Merge remote-tracking branch 'origin/master'

This commit is contained in:
sjshenjian
2024-11-14 13:32:34 +08:00
10 changed files with 218 additions and 41 deletions
@@ -623,7 +623,8 @@ public class ApiUserController {
* @param AuthorityBo
* :用户的appKey username、等资料
*/
List<OpenResource> openResourceList = openResourceService.findAll();
List<QueryParam> queryParams = Arrays.asList(new QueryParam("pubStatus", 1));
List<OpenResource> openResourceList = openResourceService.findOpenResource(queryParams);
List<AuthorityBo> authorityBoList = new ArrayList<AuthorityBo>();
ApiUserAuthority authority = apiUserAuthorityService.findByUserId(model.getUserId());
if (authority == null) {
@@ -2,10 +2,7 @@ package com.fangjia.bkoff.controllers;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.fangjia.bkoff.model.JsonModel;
import org.apache.commons.lang.StringUtils;
@@ -42,6 +39,15 @@ public class OpenResourceController {
}
public Object doAddAction(OpenResourceModel model) {
List<OpenResource> openResource = this.openResourceService.findOpenResource(null);
HashSet<Integer> apiCodeSet = new HashSet<Integer>();
for (OpenResource resource : openResource) {
apiCodeSet.add(resource.getApiCode());
}
if (model.getApiCode() != 0 && apiCodeSet.contains(model.getApiCode())){
model.setMsg("APICode已存在");
return model;
}
if (!"doAdd".equals(model.getMethod())) {
return model;
}
@@ -70,7 +76,9 @@ public class OpenResourceController {
OpenResource r = new OpenResource();
r.setUri(uri);
r.setName(name);
r.setApiCode(model.getApiCode());
r.setSaveResult(model.getSave_result());
r.setPubStatus(model.getPubStatus() ? 1 : 0);
r.setDescription(model.getDescription());
this.openResourceService.save(r);
model.setMsg("添加成功!");
@@ -80,6 +88,7 @@ public class OpenResourceController {
public Object doChangeAction(OpenResourceModel model){
Map<String, Object> data = new HashMap<String, Object>();
data.put("saveResult",model.getSave_result());
data.put("pubStatus",model.getPubStatus() ? 1 : 0);
this.openResourceService.update(data,model.getId());
model.setMsg("保存成功");
JsonModel model1 = new JsonModel();
@@ -105,6 +114,9 @@ public class OpenResourceController {
if (StringUtils.isNotBlank(model.getDescription())) {
data.put("description", model.getDescription());
}
if (0 != model.getApiCode()){
data.put("apiCode",model.getApiCode());
}
List<QueryParam> params = new ArrayList<QueryParam>();
params.add(new QueryParam("uri", uri));
params.add(new QueryParam("name", name));
@@ -141,7 +153,7 @@ public class OpenResourceController {
/**
* 格式化URI
*
*
* @param uri
* @return
*/
@@ -28,6 +28,9 @@ public class OpenResourceModel extends BaseModel {
private Boolean save_result;
private OpenResource or;
private Boolean pubStatus;
private int apiCode;
public String getExceptId() {
return exceptId;
@@ -116,4 +119,20 @@ public class OpenResourceModel extends BaseModel {
public void setSave_result(Boolean save_result) {
this.save_result = save_result;
}
public Boolean getPubStatus() {
return pubStatus;
}
public void setPubStatus(Boolean pubStatus) {
this.pubStatus = pubStatus;
}
public int getApiCode() {
return apiCode;
}
public void setApiCode(int apiCode) {
this.apiCode = apiCode;
}
}
@@ -35,6 +35,11 @@
top: 0;
background-color: #f2f2f2;
}
.resizable-td {
resize: horizontal; /* 允许水平调整大小 */
overflow: auto; /* 显示滚动条以便查看超出部分 */
min-width: 50px; /* 设置最小宽度,防止过于缩小 */
}
</style>
</head>
@@ -58,28 +63,33 @@
<thead>
<tr>
API数量:&nbsp<b>${authorityBoList?size}</b>个
<th align="center" width="15%">
<th align="center" width="50px">
APICode
</th>
<th align="center" width="100px">
uri
</th>
<th align="center" width="15%">
<th align="center" width="100px">
API名称
</th>
<th align="center" width="10%">
是否有权限<input type="checkbox" id="auth" >全选</input>
<th align="center" width="60px">
是否有权限</br>
<input type="checkbox" id="auth" >全选</input>
</th>
<th align="center" width="30%">
<th align="center" width="100px">
访问最大次数(每天)/(总数)
</th>
<th align="center" width="15%">
<th align="center" width="60px">
访问次数修改
</th>
<th align="center" width="10%">
是否按查得计费<input type="checkbox" id="isCheckCount" >全选</input>
<th align="center" width="70px">
是否按查得计费</br>
<input type="checkbox" id="isCheckCount" >全选</input>
</th>
<th align="center" width="10%">
<th align="center" width="70px">
计费次数(当天)/(历史)
</th>
<th align="center" width="15%">
<th align="center" width="150px">
操作
</th>
</tr>
@@ -88,10 +98,13 @@
<#list authorityBoList as bo>
<tr>
<td align="center">
${bo.apiCode!}
</td>
<td align="center" class="resizable-td">
<input type="hidden" id="uri_${bo_index + 1}" value="${bo.uri!}"></input>
${bo.uri!}
</td>
<td align="center">
<td align="center" class="resizable-td">
${bo.name!}
</td>
<td align="center">
@@ -99,16 +112,15 @@
</td>
<td align="center">
<#if bo.limitCountMap?? && bo.limitCountMap[bo.uri!]??>
<input type="text" value="${bo.limitCountMap[bo.uri!]}" name="limit" id="limit_${bo_index + 1}" style="width:80px;" ></input>
<input type="text" value="${bo.limitCountMap[bo.uri!]}" name="limit" id="limit_${bo_index + 1}" style="width:40px;" readonly></input>
<#else>
<input type="text" value="" name="limit" id="limit_${bo_index + 1}" style="width:80px;" ></input>
<input type="text" value="" name="limit" id="limit_${bo_index + 1}" style="width:60px;" readonly></input>
</#if>
&nbsp;&nbsp;/
/
<#if bo.totalCountMap?? && bo.totalCountMap[bo.uri!]??>
<input type="text" value="${bo.totalCountMap[bo.uri!]}" name="sum" id="sum_${bo_index + 1}" style="width:80px;" readonly ></input>
<input type="text" value="${bo.totalCountMap[bo.uri!]}" name="sum" id="sum_${bo_index + 1}" style="width:40px;" readonly ></input>
<#else>
<input type="text" value="" name="sum" id="sum_${bo_index + 1}" style="width:80px;" readonly></input>
<input type="text" value="" name="sum" id="sum_${bo_index + 1}" style="width:60px;" readonly></input>
</#if>
</td>
@@ -23,6 +23,7 @@ table{text-align: left;}
<form id="_form" action="doAdd" method="post">
<input name="method" value="doAdd" type="hidden"/>
<table style = "border:0px;">
<tr><td width="20%"><strong>APICode</strong></td><td width="30%"><input size="35" id="apiCode" name="apiCode" value="${apiCode!}"/></td><td width="50%"><font color="red" id="_apiCode_error"></font></td></tr>
<tr><td width="20%"><strong>名称</strong></td><td width="30%"><input size="35" id="name" name="name" value="${name!}"/></td><td width="50%"><font color="red" id="_name_error"></font></td></tr>
<tr><td><strong>URI</strong></td><td><input size="35" id="uri" name="uri" value="${uri!}"/></td><td><font color="red" id="_uri_error"></font></td></tr>
<tr><td><strong>说明</strong></td><td colspan="2"><input size="40" id="description" name="description" value="${description!}"/></td></tr>
@@ -32,6 +33,12 @@ table{text-align: left;}
<label><input name="save_result" type="radio" value="true" checked/>监控 </label>
</td>
</tr>
<tr><td><strong>是否对外</strong></td>
<td colspan="2">
<label><input name="pubStatus" type="radio" value="true" />不对外 </label>
<label><input name="pubStatus" type="radio" value="true" checked/>对外 </label>
</td>
</tr>
<tr><td clospan="2"><input type="button" id="_sub" value="创建"/></td></tr>
</table>
</form>
@@ -24,6 +24,11 @@ table{text-align: left;}
<input type="hidden" name="id" value="${or.id}"/>
<input name="method" value="doUpdate" type="hidden"/>
<table style = "border:0px;">
<tr><td width="20%"><strong>APICode</strong></td><td width="30%"><#if apiCode != 0>
<input size="35" id="apiCode" name="apiCode" value="${apiCode}"/>
<#else>
<input size="35" id="apiCode" name="apiCode" value="${or.apiCode}"/>
</#if></td><td width="50%"><font color="red" id="_apiCode_error"></font></td></tr>
<tr><td width="20%"><strong>名称</strong></td><td width="30%"><input size="35" id="name" name="name" value="${name!or.name}"/></td><td width="50%"><font color="red" id="_name_error"></font></td></tr>
<tr><td><strong>URI</strong></td><td><input size="35" id="uri" name="uri" value="${uri!or.uri}"/></td><td><font color="red" id="_uri_error"></font></td></tr>
<tr><td><strong>说明</strong></td><td colspan="2"><input size="40" id="description" name="description" value="${description!or.description}"/></td></tr>
@@ -47,8 +47,8 @@
<table>
<thead>
<tr>
<th align="center" width="15%">
ID
<th align="center" width="50px">
APICode
</th>
<th align="center" width="15%">
名称
@@ -56,15 +56,18 @@
<th align="center" width="15%">
URI
</th>
<th align="center" width="10%">
<th align="center" width="100px">
监控返回结果
</th>
<th align="center" width="100px">
是否对外
</th>
<th align="center" width="20%">
说明
</th>
<th align="center" width="10%">
是否有字权限
</th>
<#-- <th align="center" width="10%">-->
<#-- 是否有字权限-->
<#-- </th>-->
<th>
操作
</th>
@@ -74,7 +77,7 @@
<#list ors as or>
<tr>
<td align="center">
${or.id}
${or.apiCode!}
</td>
<td align="center">
${or.name!}
@@ -86,17 +89,20 @@
<input type="checkbox" value="false" <#if or.saveResult??&&or.saveResult==true>checked </#if> id="jk_${or.id}"
</td>
<td align="center">
${or.description!}
<input type="checkbox" value="false" <#if or.pubStatus??&&or.pubStatus==1>checked </#if> id="pub_${or.id}"
</td>
<td align="center">
<#if or.hasSubResource>
有
<#else>
无
</#if>
${or.description!}
</td>
<#-- <td align="center">-->
<#-- <#if or.hasSubResource>-->
<#-- 有-->
<#-- <#else>-->
<#-- 无-->
<#-- </#if>-->
<#-- </td>-->
<td>
<a onclick="return confirm('您确定要删除这条信息吗?');" href="../openResource/doDelete?id=${or.id}">删除</a>&nbsp;&nbsp;
<a onclick="return confirm('您确定要删除这条信息吗?');" href="../openResource/doDelete?id=${or.id}">删除</a>
<a href="../openResource/doUpdate?id=${or.id}">编辑</a>
<a href="#" onclick="saveSingle(this)" value="${or.id}">保存</a>
</td>
@@ -118,18 +124,27 @@
var a = $(e);
var id = a.attr("value");
var eck = $('#jk_'+id).attr("checked");
var eck2 = $('#pub_'+id).attr("checked");
var flag = false;
var flag2 = false;
if (eck == "checked") {
flag = true;
}
else{
flag= false;
}
if (eck2 == "checked") {
flag2 = true;
}
else{
flag2 = false;
}
$.ajax({
type: "post",
url: "../openResource/doChange",
data: "id="+id+"&save_result="+flag,
data: "id="+id+"&save_result="+flag+"&pubStatus="+flag2,
dataType: "json",
success: function (data)
{
@@ -36,6 +36,10 @@ public class OpenResource implements MongoEntity {
private Boolean saveResult;
private int pubStatus;
private int apiCode;
@Id
@GeneratedValue
@Column(name = "_id")
@@ -115,4 +119,22 @@ public class OpenResource implements MongoEntity {
public void setSaveResult(Boolean saveResult) {
this.saveResult = saveResult;
}
@Column(name = "pub_status")
public int getPubStatus() {
return pubStatus;
}
public void setPubStatus(int pubStatus) {
this.pubStatus = pubStatus;
}
@Column(name = "api_code")
public int getApiCode() {
return apiCode;
}
public void setApiCode(int apiCode) {
this.apiCode = apiCode;
}
}
@@ -0,0 +1,68 @@
package com.fangjia.script.gj.data_handle
import com.fangjia.script.commData.CommonDatautils
import com.fangjia.script.util.CosineSimilarAlgorithm
import com.fangjia.script.util.ExcelUtils
/**
* 查找重复小区
*/
class DistrictRepeatBatch {
static main(args) {
def task = new DistrictRepeatBatch()
task.run()
}
def run(){
def rets = []
rets << ["id","城市","区域", "名称", "物业类型", "地址", "备注", "id(重复)","城市(重复)","区域(重复)", "名称(重复)", "物业类型(重复)", "地址(重复)", "相似度"]
def citys = CommonDatautils.findAllCity()
def index = 0
for(def city : citys){
index++
def districts = CommonDatautils.findAllDistricts(city, "district", ["city", "region", "name", "address","estate_type2","lat", "lng"])
def rows = findRepeatByEstateType(districts)
rets.addAll(rows)
println "【${index}】 "+city +" 完成比对"
}
ExcelUtils.write("D:\\数据\\小区重复数据处理.xlsx", rets, "小区")
}
def findRepeatByEstateType(districts){
def rows = []
def ids = []
for(def d1 : districts){
if(ids.contains(d1._id.toString())){
continue
}
for(def d2 : districts){
if(d1._id.toString() == d2._id.toString()){
continue
}
if(d1.estate_type2!=d2.estate_type2){
continue
}
def d1_name = d1.name.replace("别墅", "").replace("商住楼", "").replace("商住", "").replace("小区", "")
def d2_name = d2.name.replace("别墅", "").replace("商住楼", "").replace("商住", "").replace("小区", "")
if(d1_name != d2_name){
continue
}
def key1 = d1.region+"-"+d1_name+"-"+d1.address
def key2 = d2.region+"-"+d2_name+"-"+d2.address
def score = CosineSimilarAlgorithm.getSimilarityRatio(key1, key2);
if(score>0.9){
ids << d1._id.toString()
ids << d2._id.toString()
rows << [d1._id.toString(), d1.city, d1.region, d1.name, d1.estate_type2, d1.address, "物业类型", d2._id.toString(), d2.city, d2.region, d2.name, d2.estate_type2, d2.address, score]
println d1.region +" "+d1.name +" "+d1.address +" 重复数据("+d2.region+" "+d2.name+" "+d2.address+") score:"+score
}
}
}
return rows;
}
}
@@ -32,6 +32,10 @@ public class AuthorityBo implements Serializable {
private long curVisitedCount;
private long totalVisitedCount;
private Integer isCheckCount;//是否按查得计费 1:是 ,0:否
private int pubStatus;
private int apiCode;
public Map<String, BasicDBObject> getResourceAuthorityMap() {
return resourceAuthorityMap;
@@ -158,7 +162,19 @@ public class AuthorityBo implements Serializable {
this.totalVisitedCount = totalVisitedCount;
}
public int getPubStatus() {
return pubStatus;
}
public void setPubStatus(int pubStatus) {
this.pubStatus = pubStatus;
}
public int getApiCode() {
return apiCode;
}
public void setApiCode(int apiCode) {
this.apiCode = apiCode;
}
}