mirror of
https://gitee.com/freshday/radar.git
synced 2026-03-22 12:47:16 +08:00
@@ -17,8 +17,8 @@ The project code called Radar, like the code, monitor the transaction at the bac
|
||||
* 配置简单,开箱即用!
|
||||
|
||||
## 相关站点
|
||||
Gitee: https://gitee.com/freshday/radar
|
||||
Github: https://github.com/wfh45678/radar // github 为镜像网站,贡献代码请提交到 gitee
|
||||
Gitee: https://gitee.com/freshday/radar
|
||||
Github: https://github.com/wfh45678/radar // github 为镜像网站,贡献代码请提交到 gitee
|
||||
官网: https://www.riskengine.cn
|
||||
Wiki: https://gitee.com/freshday/radar/wikis/home
|
||||
|
||||
@@ -100,11 +100,10 @@ https://gitee.com/freshday/radar/wikis/manual
|
||||
## Contact to
|
||||
|
||||
如果喜欢本项目,Star支持一下, 让更多人了解本项目,谢谢!
|
||||
独乐乐不如众乐乐,微信(nicedream7758)加群一起嗨!
|
||||
提示:进群需要捐赠到gitee
|
||||
|
||||
|
||||
|
||||
## 特别说明
|
||||
前端源码仅对企业级用户开放,需付费购买。
|
||||
未经授权,禁止使用本项目源码申请软著和专利,保留追究法律责任的权力!
|
||||
Copyright © 2019-2021 WangFeiHu
|
||||
Copyright © 2019-2022 WangFeiHu
|
||||
|
||||
1
SECURITY.md
Normal file
1
SECURITY.md
Normal file
@@ -0,0 +1 @@
|
||||
mailto: wfh45678@163.com
|
||||
2
pom.xml
2
pom.xml
@@ -114,7 +114,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.66</version>
|
||||
<version>1.2.75</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 WangFeiHu
|
||||
* Copyright (c) 2019-2022 WangFeiHu
|
||||
* Radar is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
@@ -26,18 +26,12 @@ import com.pgmmers.radar.vo.model.AbstractionVO;
|
||||
import com.pgmmers.radar.vo.model.FieldVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/services/v1/abstraction")
|
||||
@Api(value = "AbstractionApi", description = "特征管理相关操作", tags = {"特征API"})
|
||||
@@ -51,6 +45,9 @@ public class AbstractionApiController {
|
||||
@Autowired
|
||||
private PreItemService preItemService;
|
||||
|
||||
@Autowired
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public CommonResult get(@PathVariable Long id) {
|
||||
CommonResult result = new CommonResult();
|
||||
@@ -90,7 +87,7 @@ public class AbstractionApiController {
|
||||
List<PreItemVO> listPreItem = preItemService.listPreItem(modelId);
|
||||
if(listPreItem != null && listPreItem.size()!= 0){
|
||||
for (PreItemVO preItem : listPreItem) {
|
||||
PluginServiceV2 pt= PluginManager.pluginServiceMap().get(preItem.getPlugin());
|
||||
PluginServiceV2 pt = pluginManager.pluginServiceMap(preItem.getPlugin());
|
||||
if (StringUtils.isNotEmpty(pt.getType()) && pt.getType().equals("JSON")) {
|
||||
//load http request data
|
||||
JsonNode json = preItem.getConfigJson();
|
||||
|
||||
@@ -20,30 +20,15 @@ import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.engine.vo.DataColumnInfo;
|
||||
import com.pgmmers.radar.service.enums.DataType;
|
||||
import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
|
||||
import com.pgmmers.radar.service.model.AbstractionService;
|
||||
import com.pgmmers.radar.service.model.ActivationService;
|
||||
import com.pgmmers.radar.service.model.FieldService;
|
||||
import com.pgmmers.radar.service.model.PreItemService;
|
||||
import com.pgmmers.radar.service.model.RuleService;
|
||||
import com.pgmmers.radar.vo.model.AbstractionVO;
|
||||
import com.pgmmers.radar.vo.model.ActivationVO;
|
||||
import com.pgmmers.radar.vo.model.FieldVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import com.pgmmers.radar.vo.model.RuleVO;
|
||||
import com.pgmmers.radar.service.model.*;
|
||||
import com.pgmmers.radar.vo.model.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/services/v1/activation")
|
||||
@Api(value = "ActivationApi", description = "策略集管理相关操作", tags = {"策略集API"})
|
||||
@@ -60,6 +45,8 @@ public class ActivationApiController {
|
||||
private PreItemService preItemService;
|
||||
@Autowired
|
||||
private RuleService ruleService;
|
||||
@Autowired
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public CommonResult get(@PathVariable Long id) {
|
||||
@@ -92,7 +79,7 @@ public class ActivationApiController {
|
||||
ds = new DataColumnInfo(DataType.PREITEMS.getDesc(), DataType.PREITEMS.getName());
|
||||
List<PreItemVO> listPreItem = preItemService.listPreItem(modelId);
|
||||
for (PreItemVO preItem : listPreItem) {
|
||||
PluginServiceV2 pt= PluginManager.pluginServiceMap().get(preItem.getPlugin());
|
||||
PluginServiceV2 pt = pluginManager.pluginServiceMap(preItem.getPlugin());
|
||||
if (StringUtils.isNotEmpty(pt.getType()) && pt.getType().equals("JSON")) {
|
||||
//load http request data
|
||||
JsonNode json = preItem.getConfigJson();
|
||||
@@ -195,4 +182,10 @@ public class ActivationApiController {
|
||||
public CommonResult enable(@PathVariable Long activationId) {
|
||||
return activationService.updateStatus(activationId, 1);
|
||||
}
|
||||
|
||||
@PostMapping("/copy")
|
||||
public CommonResult copy(@RequestBody Long id) {
|
||||
CommonResult result = activationService.copy(id);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,8 @@ import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
|
||||
import com.pgmmers.radar.util.CaptchaUtil;
|
||||
import com.pgmmers.radar.util.ZipUtils;
|
||||
import com.pgmmers.radar.vo.common.PluginVO;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -41,6 +38,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/services/v1/common")
|
||||
@@ -54,12 +52,14 @@ public class CommonApiController {
|
||||
|
||||
@Autowired
|
||||
private CacheService cacheService;
|
||||
@Autowired
|
||||
private PluginManager pluginManager;
|
||||
|
||||
|
||||
@GetMapping("/plugins")
|
||||
public CommonResult plugins() {
|
||||
CommonResult result = new CommonResult();
|
||||
List<PluginVO> plugins=PluginManager.pluginServiceMap()
|
||||
List<PluginVO> plugins = pluginManager.getPluginServiceMap()
|
||||
.values()
|
||||
.stream()
|
||||
.map(t-> new PluginVO(t.key(),t.pluginName(),t.desc()))
|
||||
|
||||
@@ -106,6 +106,7 @@ public class DataListRecordApiController {
|
||||
private ExportExcelInfo<DataListRecordVO> getImportMeta() {
|
||||
ExportExcelInfo<DataListRecordVO> info = new ExportExcelInfo<DataListRecordVO>(null);
|
||||
info.addExcelColumn("dataRecord", "dataRecord");
|
||||
info.addExcelColumn("dataRemark", "dataRemark");
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,13 @@ import com.pgmmers.radar.vo.model.FieldVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import com.pgmmers.radar.vo.model.RuleVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -39,17 +46,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 以后会独立拆分到分析子项目里面去。
|
||||
@@ -72,6 +68,8 @@ public class EventApiController {
|
||||
|
||||
@Autowired
|
||||
private RuleService ruleService;
|
||||
@Autowired
|
||||
private PluginManager pluginManager;
|
||||
|
||||
|
||||
@PostMapping("/query")
|
||||
@@ -192,7 +190,7 @@ public class EventApiController {
|
||||
if (!itemsIdMap.containsKey(item.getDestField())) {
|
||||
continue;
|
||||
}
|
||||
PluginServiceV2 plugin= PluginManager.pluginServiceMap().get(item.getPlugin());
|
||||
PluginServiceV2 plugin = pluginManager.pluginServiceMap(item.getPlugin());
|
||||
String type = plugin.getType();
|
||||
String meta = plugin.getMeta();
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>风控引擎管理平台</title> <link rel="shortcut icon" href="/images/anquan.png"> <!--[if lt IE 10]>
|
||||
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,es5-shim/4.5.7/es5-shim.min.js,es5-shim/4.5.7/es5-sham.min.js,html5shiv/3.7.2/html5shiv.min.js,media-match/2.0.2/media.match.min.js"></script>
|
||||
<![endif]--> <link href="./index.da6b2009-1.css" rel="stylesheet"><link href="./index.da6b2009-2.css" rel="stylesheet"><link href="./index.da6b2009-3.css" rel="stylesheet"></head> <body> <div id="react-content"></div> <script type="text/javascript" src="./main.da6b2009.js"></script></body> </html>
|
||||
<![endif]--> <link href="./index.ba8e3789-1.css" rel="stylesheet"><link href="./index.ba8e3789-2.css" rel="stylesheet"><link href="./index.ba8e3789-3.css" rel="stylesheet"></head> <body> <div id="react-content"></div> <script type="text/javascript" src="./main.ba8e3789.js"></script></body> </html>
|
||||
File diff suppressed because one or more lines are too long
@@ -120,13 +120,5 @@ public class DateUtils {
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>main.</p>
|
||||
*
|
||||
* @param args an array of {@link String} objects.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println(formatDate(new Date(), "yyyy-MM-ww-dd"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,13 +83,4 @@ public class MD5Utils {
|
||||
return md5StrBuff.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>main.</p>
|
||||
*
|
||||
* @param args an array of {@link String} objects.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
System.out.println(encrypt("222222","admin"));
|
||||
System.out.println(encrypt("123456","test"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ public class MobileLocationUtil {
|
||||
}
|
||||
|
||||
public static String getLocation(String mobile) {
|
||||
//TODO: 需要重新寻找手机号码段API 通道.
|
||||
String httpUrl = "http://apis.baidu.com/apistore/mobilenumber/mobilenumber";
|
||||
String httpArg = "phone=" + mobile;
|
||||
String jsonResult = get(httpUrl, httpArg);
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.pgmmers.radar.dal.bean.RuleQuery;
|
||||
import com.pgmmers.radar.vo.model.RuleHistoryVO;
|
||||
import com.pgmmers.radar.vo.model.RuleVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface RuleDal {
|
||||
|
||||
@@ -22,4 +24,5 @@ public interface RuleDal {
|
||||
|
||||
int saveHistory(RuleHistoryVO model);
|
||||
|
||||
List<RuleVO> listByActId(Long actId);
|
||||
}
|
||||
|
||||
@@ -146,4 +146,13 @@ public class RuleDalImpl implements RuleDal {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleVO> listByActId(Long actId) {
|
||||
Example example = new Example(RulePO.class);
|
||||
Example.Criteria ruleCriteria = example.createCriteria();
|
||||
ruleCriteria.andEqualTo("activationId", actId);
|
||||
List<RulePO> ruleList = ruleMapper.selectByExample(example);
|
||||
return ruleMapping.sourceToTarget(ruleList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,14 +14,15 @@ public class DataListRecordVO implements Serializable{
|
||||
|
||||
private String dataRecord;
|
||||
|
||||
private String dataRemark;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
private Long modelId;
|
||||
|
||||
|
||||
/**
|
||||
* operate
|
||||
*/
|
||||
@@ -96,6 +97,14 @@ public class DataListRecordVO implements Serializable{
|
||||
this.opt = opt;
|
||||
}
|
||||
|
||||
public String getDataRemark() {
|
||||
return dataRemark;
|
||||
}
|
||||
|
||||
public void setDataRemark(String dataRemark) {
|
||||
this.dataRemark = dataRemark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DataListRecordVO{" +
|
||||
|
||||
@@ -25,6 +25,12 @@ public class DataListRecordPO {
|
||||
@Column(name = "DATA_RECORD")
|
||||
private String dataRecord;
|
||||
|
||||
/**
|
||||
* 数据描述
|
||||
*/
|
||||
@Column(name = "DATA_REMARK")
|
||||
private String dataRemark;
|
||||
|
||||
@Column(name = "CREATE_TIME")
|
||||
private Date createTime;
|
||||
|
||||
@@ -112,4 +118,12 @@ public class DataListRecordPO {
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDataRemark() {
|
||||
return dataRemark;
|
||||
}
|
||||
|
||||
public void setDataRemark(String dataRemark) {
|
||||
this.dataRemark = dataRemark;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,10 @@
|
||||
<groupId>org.elasticsearch.client</groupId>
|
||||
<artifactId>elasticsearch-rest-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.pgmmers.radar.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "sys.conf")
|
||||
@Data
|
||||
public class SystemProperties {
|
||||
|
||||
private String mongoRestoreDays;
|
||||
|
||||
private String machineLearning;
|
||||
|
||||
private String workdir;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 WangFeiHu
|
||||
* Copyright (c) 2019-2022 WangFeiHu
|
||||
* Radar is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 WangFeiHu
|
||||
* Copyright (c) 2019-2022 WangFeiHu
|
||||
* Radar is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
@@ -54,4 +54,11 @@ public class MainController {
|
||||
CommonResult result = engineApi.uploadInfo(request.getGuid(), request.getReqId(), request.getJsonInfo());
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/syncStatus")
|
||||
@ApiOperation(value = "事件状态同步接口")
|
||||
public CommonResult syncStatus(@Valid @RequestBody StatusSyncRequest request) {
|
||||
CommonResult result = engineApi.syncStatus(request.getGuid(), request.getEventId(), request.getStatus());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 WangFeiHu
|
||||
* Radar is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
package com.pgmmers.radar.controller;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 状态同步请求。
|
||||
* @author feihu.wang
|
||||
*/
|
||||
public class StatusSyncRequest {
|
||||
@ApiModelProperty(value = "模型guid")
|
||||
@NotBlank(message = "guid 不能为空")
|
||||
private String guid;
|
||||
|
||||
@ApiModelProperty(value = "eventId")
|
||||
@NotBlank(message = "eventId 不能为空")
|
||||
private String eventId;
|
||||
|
||||
@ApiModelProperty(value = "status")
|
||||
@NotNull(message = "status 不能为空")
|
||||
private String status;
|
||||
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public String getEventId() {
|
||||
return eventId;
|
||||
}
|
||||
|
||||
public void setEventId(String eventId) {
|
||||
this.eventId = eventId;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -6,19 +6,21 @@ import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.engine.vo.Location;
|
||||
import com.pgmmers.radar.service.impl.engine.plugin.PluginManager;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
@RunWith(SpringRunner.class)
|
||||
@@ -27,14 +29,27 @@ public class PluginTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PluginTest.class);
|
||||
|
||||
@Autowired
|
||||
private PluginManager pluginManager;
|
||||
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void pluginList() {
|
||||
PluginManager.pluginServiceMap().values()
|
||||
// PluginManager.pluginServiceMap().values()
|
||||
// .stream()
|
||||
// .sorted(Comparator.comparing(PluginServiceV2::key))
|
||||
// .forEach(t -> logger.info(t.info()));
|
||||
pluginManager.getPluginServiceMap().values()
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(PluginServiceV2::key))
|
||||
.forEach(t -> logger.info(t.info()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private Map<String, Object> jsonInfo;
|
||||
|
||||
@Before
|
||||
@@ -49,7 +64,8 @@ public class PluginTest {
|
||||
jsonInfo.put("firsName", "aaa");
|
||||
jsonInfo.put("lastName", "ccc");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("ALLINONE");
|
||||
// PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("ALLINONE");
|
||||
PluginServiceV2 pluginServiceV2 = pluginManager.getPluginServiceMap().get("ALLINONE");
|
||||
String result = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(result);
|
||||
@@ -63,7 +79,8 @@ public class PluginTest {
|
||||
item.setSourceField("time");
|
||||
jsonInfo.put("time", System.currentTimeMillis());
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("DATEFORMAT");
|
||||
// PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("DATEFORMAT");
|
||||
PluginServiceV2 pluginServiceV2 = pluginManager.getPluginServiceMap().get("DATEFORMAT");
|
||||
String result = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(result);
|
||||
@@ -83,7 +100,8 @@ public class PluginTest {
|
||||
item.setSourceField("json");
|
||||
jsonInfo.put("json","");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("HTTP_UTIL");
|
||||
// PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("HTTP_UTIL");
|
||||
PluginServiceV2 pluginServiceV2 = pluginManager.getPluginServiceMap().get("HTTP_UTIL");
|
||||
JSONObject result = (JSONObject) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(result);
|
||||
@@ -96,7 +114,8 @@ public class PluginTest {
|
||||
item.setSourceField("ip");
|
||||
jsonInfo.put("ip", "1.1.1.1");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("IP2LOCATION");
|
||||
// PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("IP2LOCATION");
|
||||
PluginServiceV2 pluginServiceV2 = pluginManager.getPluginServiceMap().get("IP2LOCATION");
|
||||
Location location = (Location) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
@@ -109,7 +128,8 @@ public class PluginTest {
|
||||
item.setSourceField("phone");
|
||||
jsonInfo.put("phone", "18657150000");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("MOBILE2LOCATION");
|
||||
// PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("MOBILE2LOCATION");
|
||||
PluginServiceV2 pluginServiceV2 = pluginManager.getPluginServiceMap().get("MOBILE2LOCATION");
|
||||
Location location = (Location) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
@@ -122,7 +142,8 @@ public class PluginTest {
|
||||
item.setSourceField("time");
|
||||
jsonInfo.put("time",System.currentTimeMillis());
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("SENSITIVE_TIME");
|
||||
// PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("SENSITIVE_TIME");
|
||||
PluginServiceV2 pluginServiceV2 = pluginManager.getPluginServiceMap().get("SENSITIVE_TIME");
|
||||
String location = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
@@ -137,7 +158,8 @@ public class PluginTest {
|
||||
item.setSourceField("phone");
|
||||
jsonInfo.put("phone", "18657150000");
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("SUBSTRING");
|
||||
// PluginServiceV2 pluginServiceV2 = PluginManager.pluginServiceMap().get("SUBSTRING");
|
||||
PluginServiceV2 pluginServiceV2 = pluginManager.getPluginServiceMap().get("SUBSTRING");
|
||||
String location = (String) pluginServiceV2
|
||||
.handle(item, jsonInfo, sourceField);
|
||||
Assert.assertNotNull(location);
|
||||
|
||||
@@ -141,5 +141,18 @@ public class RiskAnalysisEngineServiceImpl implements RiskAnalysisEngineService
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult syncStatus(String modelGuid, String eventId, String status) {
|
||||
CommonResult result = new CommonResult();
|
||||
ModelVO model = modelService.getModelByGuid(modelGuid);
|
||||
if (model == null) {
|
||||
result.setMsg("模型不存在!");
|
||||
return result;
|
||||
}
|
||||
long cnt = entityService.update(model.getId(), eventId, status);
|
||||
result.setSuccess(cnt > 0 ? true : false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class MongoServiceImpl implements MongoService {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,8 +27,14 @@ public class AggregateCommandImpl implements AggregateCommand {
|
||||
@Override
|
||||
public long count(String modelId, String searchField, Object searchFieldValue, String refDateName, Date begin,
|
||||
Date end) {
|
||||
return count(modelId, searchField, searchFieldValue, refDateName,"1", begin, end);
|
||||
}
|
||||
|
||||
public long count(String modelId, String searchField, Object searchFieldValue, String refDateName, String status, Date begin,
|
||||
Date end) {
|
||||
String collectionName = "entity_" + modelId;
|
||||
Long qty = mongoService.count(collectionName, Filters.and(Filters.eq(searchField, searchFieldValue),
|
||||
Filters.eq("status", status),
|
||||
Filters.gte(refDateName, begin.getTime()), Filters.lte(refDateName, end.getTime())));
|
||||
return qty;
|
||||
}
|
||||
@@ -36,6 +42,12 @@ public class AggregateCommandImpl implements AggregateCommand {
|
||||
@Override
|
||||
public long distinctCount(String modelId, String searchField, Object searchFieldValue, String refDateName,
|
||||
Date begin, Date end, String distinctBy) {
|
||||
return distinctCount(modelId,searchField,searchFieldValue,refDateName,"1", begin, end, distinctBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long distinctCount(String modelId, String searchField, Object searchFieldValue, String refDateName,
|
||||
String status, Date begin, Date end, String distinctBy) {
|
||||
String collectionName = "entity_" + modelId;
|
||||
Long qty = mongoService.distinctCount(collectionName, Filters.and(Filters.eq(searchField, searchFieldValue),
|
||||
Filters.gte(refDateName, begin.getTime()), Filters.lte(refDateName, end.getTime())), distinctBy);
|
||||
|
||||
@@ -46,6 +46,9 @@ public class AntiFraudServiceImpl implements AntiFraudService {
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
|
||||
@Autowired
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@Override
|
||||
public CommonResult process(Long modelId, Map<String, Map<String, ?>> context) {
|
||||
AntiFraudProcessResult analysisResult = new AntiFraudProcessResult();
|
||||
@@ -110,7 +113,7 @@ public class AntiFraudServiceImpl implements AntiFraudService {
|
||||
continue;
|
||||
}
|
||||
String[] sourceField = item.getSourceField().split(",");
|
||||
Object transfer = PluginManager.pluginServiceMap().get(item.getPlugin()).handle(item,jsonInfo,sourceField);
|
||||
Object transfer = pluginManager.pluginServiceMap(item.getPlugin()).handle(item,jsonInfo,sourceField);
|
||||
result.put(item.getDestField(), transfer);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.pgmmers.radar.service.impl.engine.plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
@@ -10,6 +11,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:45 Description:
|
||||
*/
|
||||
@Component
|
||||
public class ALLINONE implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,8 +4,9 @@ import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public class DATEFORMAT implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
@@ -20,6 +21,7 @@ import java.util.Map;
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:44 Description:
|
||||
*/
|
||||
@Component
|
||||
public class GPS2LOCATION implements PluginServiceV2 {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GPS2LOCATION.class);
|
||||
|
||||
@@ -12,11 +12,13 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:47 Description:
|
||||
*/
|
||||
@Component
|
||||
public class HTTP_UTIL implements PluginServiceV2 {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HTTP_UTIL.class);
|
||||
|
||||
@@ -4,19 +4,21 @@ import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.engine.vo.Location;
|
||||
import com.pgmmers.radar.service.impl.util.BeanUtils;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import org.lionsoul.ip2region.DataBlock;
|
||||
import org.lionsoul.ip2region.DbConfig;
|
||||
import org.lionsoul.ip2region.DbSearcher;
|
||||
import org.lionsoul.ip2region.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class IP2LOCATION implements PluginServiceV2 {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(IP2LOCATION.class);
|
||||
private DbSearcher ipSearcher;
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
@@ -38,16 +40,20 @@ public class IP2LOCATION implements PluginServiceV2 {
|
||||
return "[{\"column\":\"country\", \"title\":\"国家\", \"type\":\"STRING\"},{\"column\":\"province\", \"title\":\"省份\", \"type\":\"STRING\"},{\"column\":\"city\", \"title\":\"城市\", \"type\":\"STRING\"}]";
|
||||
}
|
||||
|
||||
public IP2LOCATION() {
|
||||
static DbSearcher getDbSearcher() {
|
||||
final DbSearcher ipSearcher;
|
||||
try {
|
||||
String ipFilePath = BeanUtils.getApplicationContext().getEnvironment()
|
||||
.getProperty("ip2region.db.path");
|
||||
DbConfig conf = new DbConfig();
|
||||
|
||||
ipSearcher = new DbSearcher(conf, ipFilePath);
|
||||
logger.info("IP2LOCATION Plugin load success");
|
||||
return ipSearcher;
|
||||
} catch (Exception e) {
|
||||
logger.error("ip2region init failed", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +65,7 @@ public class IP2LOCATION implements PluginServiceV2 {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
DataBlock block = ipSearcher.memorySearch(ip);
|
||||
DataBlock block = Objects.requireNonNull(IP2LOCATION.getDbSearcher()).memorySearch(ip);
|
||||
String[] detail = block.getRegion().split("\\|");
|
||||
location = new Location();
|
||||
location.setCountry(detail[0]);
|
||||
|
||||
@@ -3,17 +3,23 @@ package com.pgmmers.radar.service.impl.engine.plugin;
|
||||
import com.pgmmers.radar.service.data.MobileInfoService;
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.service.engine.vo.Location;
|
||||
import com.pgmmers.radar.service.impl.util.BeanUtils;
|
||||
import com.pgmmers.radar.vo.data.MobileInfoVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:46 Description:
|
||||
*/
|
||||
@Component
|
||||
public class MOBILE2LOCATION implements PluginServiceV2 {
|
||||
|
||||
@Autowired
|
||||
private MobileInfoService mobileInfoService;
|
||||
|
||||
@Override
|
||||
public Integer key() {
|
||||
return 5;
|
||||
@@ -40,7 +46,9 @@ public class MOBILE2LOCATION implements PluginServiceV2 {
|
||||
if (!StringUtils.isEmpty(mobile) && mobile.length() == 11) {
|
||||
mobile = mobile.substring(0, 7);
|
||||
}
|
||||
MobileInfoVO vo = BeanUtils.getBean(MobileInfoService.class).getMobileInfoByMobile(mobile);
|
||||
// 注入bean后不需通过BeanUtils.getBean获取实列
|
||||
// MobileInfoVO vo = BeanUtils.getBean(MobileInfoService.class).getMobileInfoByMobile(mobile);
|
||||
MobileInfoVO vo = mobileInfoService.getMobileInfoByMobile(mobile);
|
||||
Location location = new Location();
|
||||
if (vo != null) {
|
||||
location.setProvince(vo.getProvince());
|
||||
|
||||
@@ -1,26 +1,49 @@
|
||||
package com.pgmmers.radar.service.impl.engine.plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import java.util.Comparator;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
public class PluginManager {
|
||||
@Service
|
||||
public class PluginManager implements ApplicationContextAware {
|
||||
|
||||
private PluginManager() {
|
||||
// private PluginManager() {
|
||||
// }
|
||||
|
||||
// public static Map<String, PluginServiceV2> pluginServiceMap() {
|
||||
// return SingletonHolder.pluginServiceMap;
|
||||
// }
|
||||
|
||||
|
||||
private final Map<String, PluginServiceV2> pluginServiceMap = new ConcurrentHashMap<>();
|
||||
|
||||
public PluginServiceV2 pluginServiceMap(String key){
|
||||
return pluginServiceMap.get(key);
|
||||
}
|
||||
|
||||
public static Map<String, PluginServiceV2> pluginServiceMap() {
|
||||
return SingletonHolder.pluginServiceMap;
|
||||
public Map<String, PluginServiceV2> getPluginServiceMap(){
|
||||
return pluginServiceMap;
|
||||
}
|
||||
private static class SingletonHolder {
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
Map<String, PluginServiceV2> beansOfType = applicationContext.getBeansOfType(PluginServiceV2.class);
|
||||
pluginServiceMap.putAll(beansOfType);
|
||||
}
|
||||
|
||||
// 工厂模式实现单例存在不能注入bean问题
|
||||
/* private static class SingletonHolder {
|
||||
private static final Map<String, PluginServiceV2> pluginServiceMap = SpringFactoriesLoader
|
||||
.loadFactories(PluginServiceV2.class, null).stream()
|
||||
.sorted(Comparator.comparing(PluginServiceV2::key))
|
||||
.collect(Collectors.toMap(PluginServiceV2::pluginName, e -> e,
|
||||
(oldValue, newValue) -> newValue));
|
||||
;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@ package com.pgmmers.radar.service.impl.engine.plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:46 Description:
|
||||
*/
|
||||
@Component
|
||||
public class SENSITIVE_TIME implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,11 +2,14 @@ package com.pgmmers.radar.service.impl.engine.plugin;
|
||||
|
||||
import com.pgmmers.radar.service.engine.PluginServiceV2;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* author: wangcheng Date: 2020/5/19 Time: 上午11:45 Description:
|
||||
*/
|
||||
@Component
|
||||
public class SUBSTRING implements PluginServiceV2 {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,13 +4,18 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.pgmmers.radar.dal.bean.ActivationQuery;
|
||||
import com.pgmmers.radar.dal.model.ActivationDal;
|
||||
import com.pgmmers.radar.dal.model.ModelDal;
|
||||
import com.pgmmers.radar.dal.model.RuleDal;
|
||||
import com.pgmmers.radar.service.cache.CacheService;
|
||||
import com.pgmmers.radar.service.cache.SubscribeHandle;
|
||||
import com.pgmmers.radar.service.common.CommonResult;
|
||||
import com.pgmmers.radar.service.model.ActivationService;
|
||||
import com.pgmmers.radar.vo.model.ActivationVO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import com.pgmmers.radar.vo.model.RuleVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -33,6 +38,9 @@ public class ActivationServiceImpl extends BaseLocalCacheService implements Acti
|
||||
@Autowired
|
||||
private ActivationDal activationDal;
|
||||
|
||||
@Autowired
|
||||
private RuleDal ruleDal;
|
||||
|
||||
@Autowired
|
||||
private CacheService cacheService;
|
||||
|
||||
@@ -108,6 +116,28 @@ public class ActivationServiceImpl extends BaseLocalCacheService implements Acti
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult copy(Long id) {
|
||||
CommonResult result = new CommonResult();
|
||||
ActivationVO origVO = activationDal.get(id);
|
||||
if (origVO == null) {
|
||||
return result;
|
||||
}
|
||||
List<RuleVO> ruleList = ruleDal.listByActId(id);
|
||||
origVO.setId(null);
|
||||
origVO.setLabel(origVO.getLabel() + "_copy");
|
||||
origVO.setCreateTime(new Date());
|
||||
activationDal.save(origVO);
|
||||
for (RuleVO ruleVO : ruleList) {
|
||||
ruleVO.setId(null);
|
||||
ruleVO.setActivationId(origVO.getId());
|
||||
ruleVO.setCreateTime(new Date());
|
||||
ruleDal.save(ruleVO);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult updateStatus(Long activationId, Integer status) {
|
||||
CommonResult result = new CommonResult();
|
||||
|
||||
@@ -12,14 +12,16 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class EntityServiceImpl implements EntityService {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(EntityServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private ModelService modelService;
|
||||
@Autowired
|
||||
@Resource
|
||||
private MongoService mongoService;
|
||||
|
||||
|
||||
@@ -47,27 +49,42 @@ public class EntityServiceImpl implements EntityService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long update(Long modelId, String eventId, String status) {
|
||||
ModelVO model = modelService.getModelById(modelId);
|
||||
Document filter = new Document();
|
||||
filter.append(model.getEntryName(), eventId);
|
||||
Document updateDoc = new Document();
|
||||
updateDoc.append("status",status);
|
||||
String collectionName = buildCollectionName(modelId);
|
||||
return mongoService.update(collectionName, filter, updateDoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(Long modelId, String jsonString, String attachJson,
|
||||
boolean isAllowDuplicate) {
|
||||
String tmpUrl = "entity_" + modelId;
|
||||
String collectionName = buildCollectionName(modelId);
|
||||
Document doc = Document.parse(jsonString);
|
||||
Document atta = Document.parse(attachJson);
|
||||
Document attach = Document.parse(attachJson);
|
||||
ModelVO model = modelService.getModelById(modelId);
|
||||
atta.put("radar_ref_datetime", new Date(doc.getLong(model.getReferenceDate())));
|
||||
doc.putAll(atta);
|
||||
attach.put("radar_ref_datetime", new Date(doc.getLong(model.getReferenceDate())));
|
||||
doc.putAll(attach);
|
||||
if (!isAllowDuplicate) {
|
||||
//设置查询条件
|
||||
Document filter = new Document();
|
||||
filter.append(model.getEntryName(), doc.get(model.getEntryName()));
|
||||
long qty = mongoService.count(tmpUrl, filter);
|
||||
long qty = mongoService.count(collectionName, filter);
|
||||
if (qty > 0) {
|
||||
logger.info("record has already exsit!");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
mongoService.insert(tmpUrl, doc);
|
||||
mongoService.insert(collectionName, doc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private String buildCollectionName(Long modelId) {
|
||||
return "entity_" + modelId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,15 +21,6 @@ import com.pgmmers.radar.util.JsonUtils;
|
||||
import com.pgmmers.radar.vo.model.FieldVO;
|
||||
import com.pgmmers.radar.vo.model.ModelVO;
|
||||
import com.pgmmers.radar.vo.model.PreItemVO;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bson.Document;
|
||||
import org.slf4j.Logger;
|
||||
@@ -38,6 +29,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class ModelServiceImpl extends BaseLocalCacheService implements ModelService,
|
||||
@@ -62,6 +59,9 @@ public class ModelServiceImpl extends BaseLocalCacheService implements ModelServ
|
||||
@Autowired
|
||||
private MongoService mongoService;
|
||||
|
||||
@Autowired
|
||||
private PluginManager pluginManager;
|
||||
|
||||
// 维护GUID到modelId的映射
|
||||
private Map<String, Long> guidMap;
|
||||
|
||||
@@ -252,8 +252,7 @@ public class ModelServiceImpl extends BaseLocalCacheService implements ModelServ
|
||||
// pre item mapping
|
||||
JSONObject preItemJson = new JSONObject();
|
||||
for (PreItemVO item : items) {
|
||||
String pluginType = item.getPlugin();
|
||||
PluginServiceV2 plugin= PluginManager.pluginServiceMap().get(pluginType);
|
||||
PluginServiceV2 plugin = pluginManager.pluginServiceMap(item.getPlugin());
|
||||
String columns = plugin.getMeta();
|
||||
if (columns == null) {
|
||||
String fieldType = plugin.getType();
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
com.pgmmers.radar.service.engine.PluginServiceV2=\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.DATEFORMAT,\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.ALLINONE,\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.GPS2LOCATION,\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.HTTP_UTIL,\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.IP2LOCATION,\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.MOBILE2LOCATION,\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.SENSITIVE_TIME,\
|
||||
com.pgmmers.radar.service.impl.engine.plugin.SUBSTRING
|
||||
# PluginManager reset
|
||||
#com.pgmmers.radar.service.engine.PluginServiceV2=\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.DATEFORMAT,\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.ALLINONE,\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.GPS2LOCATION,\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.HTTP_UTIL,\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.IP2LOCATION,\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.MOBILE2LOCATION,\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.SENSITIVE_TIME,\
|
||||
# com.pgmmers.radar.service.impl.engine.plugin.SUBSTRING
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,14 @@ public interface RiskAnalysisEngineService {
|
||||
* @author feihu.wang
|
||||
*
|
||||
*/
|
||||
|
||||
CommonResult getScore(String modelGuid, String reqId);
|
||||
|
||||
/**
|
||||
* sync event status.
|
||||
* @param modelGuid
|
||||
* @param eventId
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
CommonResult syncStatus(String modelGuid, String eventId, String status);
|
||||
}
|
||||
|
||||
@@ -55,4 +55,9 @@ public interface MongoService {
|
||||
MongoCollection<Document> collection = getCollection(collectionName);
|
||||
return collection.find(filter);
|
||||
}
|
||||
|
||||
default long update(String collectionName, Bson filter, Document updateDoc) {
|
||||
MongoCollection<Document> collection = getCollection(collectionName);
|
||||
return collection.updateOne(filter, updateDoc).getModifiedCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ public interface AggregateCommand {
|
||||
* 2016年8月4日
|
||||
*/
|
||||
public long count(String modelId, String searchField, Object searchFieldValue, String refDateName, Date begin, Date end);
|
||||
|
||||
|
||||
public long count(String modelId, String searchField, Object searchFieldValue, String refDateName, String status, Date begin, Date end);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 累计去重.
|
||||
@@ -47,6 +50,9 @@ public interface AggregateCommand {
|
||||
public long distinctCount(String modelId, String searchField, Object searchFieldValue, String refDateName, Date begin, Date end,
|
||||
String distinctBy);
|
||||
|
||||
public long distinctCount(String modelId, String searchField, Object searchFieldValue, String refDateName, String status, Date begin, Date end,
|
||||
String distinctBy);
|
||||
|
||||
/**
|
||||
*
|
||||
* 求和.
|
||||
|
||||
@@ -37,6 +37,13 @@ public class DataColumnInfo {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public DataColumnInfo(String label, String value, String type, List<DataColumnInfo> children) {
|
||||
this.label = label;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ public interface ActivationService {
|
||||
|
||||
CommonResult updateOrder(Long activationId, String ruleOrder);
|
||||
|
||||
CommonResult copy(Long id);
|
||||
|
||||
/**
|
||||
* update status of activation.
|
||||
* @param activationId
|
||||
|
||||
@@ -5,13 +5,19 @@ import java.util.List;
|
||||
|
||||
public interface EntityService {
|
||||
|
||||
public int save(Long modelId, String jsonString, boolean isAllowDuplicate);
|
||||
int save(Long modelId, String jsonString, boolean isAllowDuplicate);
|
||||
|
||||
public int save(Long modelId, String jsonString, String attachJson, boolean isAllowDuplicate);
|
||||
int save(Long modelId, String jsonString, String attachJson, boolean isAllowDuplicate);
|
||||
|
||||
public List<Object> find(Long modelId, String conds);
|
||||
|
||||
|
||||
List<Object> find(Long modelId, String conds);
|
||||
|
||||
/**
|
||||
* update status.
|
||||
* @param modelId
|
||||
* @param eventId
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
long update(Long modelId, String eventId, String status);
|
||||
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ CREATE TABLE `engine_data_list_records` (
|
||||
`ID` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`DATA_LIST_ID` bigint(20) NOT NULL COMMENT '数据列表ID',
|
||||
`DATA_RECORD` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '数据记录',
|
||||
`DATA_REMARK` varchar(32) NULL COMMENT '数据备注',
|
||||
`CREATE_TIME` datetime NOT NULL,
|
||||
`UPDATE_TIME` datetime NOT NULL,
|
||||
PRIMARY KEY (`ID`)
|
||||
|
||||
Reference in New Issue
Block a user