Merge remote-tracking branch 'origin/master'

# Conflicts:
#	renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java
This commit is contained in:
yitonglei 2022-06-25 09:01:31 +08:00
commit 510c2806cb
8 changed files with 139 additions and 75 deletions

View File

@ -292,7 +292,7 @@ public class CensusControllerV2 {
});
});
CompletableFuture<Void> allKnowledgeVisitsAmount = CompletableFuture.supplyAsync(() -> { // 获取平台知识库浏览量
return jdbcTemplate.queryForObject("SELECT SUM(visits) visits FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class);
return jdbcTemplate.queryForObject("SELECT IFNULL(SUM(visits),0) visits FROM tb_data_resource WHERE type ='知识库' AND del_flag = 0;", Long.class);
}).thenAccept(sum -> {
result.add(new HashMap<String, Object>() {
{
@ -383,12 +383,12 @@ public class CensusControllerV2 {
result.add(new HashMap<String, Object>() {
{
put("amount", 0L);
put("type", "总数据");
put("type", "总数据");
}
});
result.add(new HashMap<String, Object>() {
{
put("amount", 0l);
put("amount", 0L);
put("type", "总申请次数");
}
});
@ -409,11 +409,10 @@ public class CensusControllerV2 {
TsingtaoDataResourceService tsingtaoDataResourceService = new TsingtaoDataResourceService();
GetDataResourceListDto getDataResourceListDto = new GetDataResourceListDto().setPageNum(1).setPageSize(5);
HashMap dataResource = (HashMap) tsingtaoDataResourceService.getDataResource(getDataResourceListDto);
JSONObject data = JSON.parseObject(JSON.toJSONString(dataResource.get("data")));
result.add(new HashMap<String, Object>() {
{
put("amount", data.get("rows"));
put("type", "总数据");
put("amount", dataResource.get("rows"));
put("type", "总数据");
}
});
result.add(new HashMap<String, Object>() {
@ -430,11 +429,10 @@ public class CensusControllerV2 {
});
result.add(new HashMap<String, Object>() {
{
String ja = data.getString("data");
List<Map> lists = JSON.parseArray(ja, Map.class);
List<Map> lists = (List<Map>) dataResource.get("data");
ArrayList<Map> list = new ArrayList<>();
lists.forEach(item -> {
list.add(new HashMap<String, Object>(){{
list.add(new HashMap<String, Object>() {{
put("服务名称", item.get("zyname"));
put("申请次数", item.get("syqk"));
}});
@ -457,7 +455,7 @@ public class CensusControllerV2 {
result.add(new HashMap<String, Object>() {
{
put("amount", finalTotal);
put("type", "总数据");
put("type", "总数据");
}
});
}
@ -468,7 +466,6 @@ public class CensusControllerV2 {
logger.error("青岛西海岸失败", exception);
}
OkHttpClient client1 = new OkHttpClient();
Request request1 = new Request.Builder().url(tsingtao_xhaProperties.getResourceapplyinfo()).build();
try (Response response = client1.newCall(request1).execute()) {

View File

@ -15,6 +15,8 @@ import io.renren.common.domain.Tsingtao_xhaProperties;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.resource.dao.AttrDao;
import io.renren.modules.resource.dao.ResourceDao;
import io.renren.modules.resource.dataResource.domain.TsingtaoDataResourceService;
import io.renren.modules.resource.dto.GetDataResourceListDto;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity;
@ -377,7 +379,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
logger.error("青岛西海岸失败", exception);
}
});
CompletableFuture.allOf(cloud, local);
CompletableFuture all = CompletableFuture.allOf(cloud, local);
all.join();
return result_.stream().filter(index -> index != null).findAny().orElse(0l);
}).thenAccept(sum -> {
re.add(new HashMap<String, Object>() {
@ -387,8 +390,44 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
});
});
OkHttpClient client = new OkHttpClient();
Long total = 0L;
Request request = new Request.Builder().url(tsingtao_xhaProperties.getResourcecount()).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
if (jsonObject.containsKey("data")) {
total = jsonObject.getJSONObject("data").getLongValue("total");
Long finalTotal = total;
re.add(new HashMap<String, Object>() {
{
put("count", finalTotal);
put("type", "数据资源");
}
});
}
} else {
logger.error("青岛西海岸获取失败");
}
} catch (Exception exception) {
logger.error("青岛西海岸失败", exception);
}
allAmount.join();
}
break;
case TSINGTAO: {
//青岛市局数据资源
TsingtaoDataResourceService tsingtaoDataResourceService = new TsingtaoDataResourceService();
GetDataResourceListDto getDataResourceListDto = new GetDataResourceListDto().setPageNum(1).setPageSize(5);
HashMap dataResource = (HashMap) tsingtaoDataResourceService.getDataResource(getDataResourceListDto);
re.add(new HashMap<String, Object>() {
{
put("count", null == dataResource ? "0" : dataResource.get("rows") + "");
put("type", "数据资源");
}
});
}
break;
}
resultMap.put("total", re);
return resultMap;
@ -694,10 +733,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
return resultMap;
}
@Override
public List<Map<String,Object>> applicationAreaCapabilitySet(Map params){
return resourceDao.applicationAreaCapabilitySet(params);
}
@Override
public Object selectResourceListByType(String type) {
return resourceDao.selectByType(type);
@ -864,8 +899,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceBusinessDetails(Map<String,Object> params){
List<Map<String,Object>> result = new CopyOnWriteArrayList<>();
public List<Map<String, Object>> resourceBusinessDetails(Map<String, Object> params) {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
List<Map> deptList = new ArrayList<>();//保存部门 发布总数 访问量
params.put("pageNum", (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()));
@ -875,23 +910,23 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Object[] pas = {params.get("id"),params.get("id"),page,pageSize};
Object[] pas = {params.get("id"), params.get("id"), page, pageSize};
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName,\n" +
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName,\n" +
"SUM(a.visits) AS resourceVisits \n" +
"FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" +
"WHERE a.type = '组件服务' AND a.del_flag = 0\n" +
"AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" +
"AND (b.ID = ? OR b.pids LIKE CONCAT(CONCAT('%',?),'%'))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n" +
"LIMIT ?,?",pas);
"LIMIT ?,?", pas);
result.addAll(result2);
ConcurrentHashMap hashMap = new ConcurrentHashMap();
hashMap.putAll(params);
CompletableFuture<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> { // 获取被申请数量
CompletableFuture<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> { // 获取被申请数量
result.forEach(dept -> {
String id = dept.get("deptId").toString();//部门id
hashMap.put("id", id);
@ -941,27 +976,27 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
});
//还缺少被调用总数
CompletableFuture<Void> all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02, voidCompletableFuture03,voidCompletableFuture04,voidCompletableFuture05);
CompletableFuture<Void> all = CompletableFuture.allOf(voidCompletableFuture01, voidCompletableFuture02, voidCompletableFuture03, voidCompletableFuture04, voidCompletableFuture05);
all.join();
return result;
}
@Override
public List<Map<String, Object>> resourceApplicationDetails(Map<String,Object> params){
public List<Map<String, Object>> resourceApplicationDetails(Map<String, Object> params) {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Object[] pas = {params.get("id"),params.get("id"),page,pageSize};
Object[] pas = {params.get("id"), params.get("id"), page, pageSize};
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
"FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" +
"WHERE a.type = '应用资源' AND a.del_flag = 0\n" +
"AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" +
"AND (b.ID = ? OR b.pids LIKE CONCAT(CONCAT('%',?),'%'))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n" +
"LIMIT ?,?",pas);
"LIMIT ?,?", pas);
result.addAll(result2);
CompletableFuture<Void> voidCompletableFuture01 = CompletableFuture.runAsync(() -> { //应用浏览数量
result.forEach(r -> {
@ -986,20 +1021,20 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceInfrastructureDetails(Map<String,Object> params){
public List<Map<String, Object>> resourceInfrastructureDetails(Map<String, Object> params) {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Object[] pas = {params.get("id"),params.get("id"),page,pageSize};
Object[] pas = {params.get("id"), params.get("id"), page, pageSize};
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
"FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" +
"WHERE a.type = '基础设施' AND a.del_flag = 0\n" +
"AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" +
"AND (b.ID = ? OR b.pids LIKE CONCAT(CONCAT('%',?),'%'))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n" +
"LIMIT ?,?",pas);
"LIMIT ?,?", pas);
result.addAll(result2);
CompletableFuture<Void> resourceCollectionNum01 = CompletableFuture.runAsync(() -> {//被申请数量 resourceCarNum
@ -1030,20 +1065,20 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceDatasDetails(Map<String,Object> params){
public List<Map<String, Object>> resourceDatasDetails(Map<String, Object> params) {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Object[] pas = {params.get("id"),params.get("id"),page,pageSize};
Object[] pas = {params.get("id"), params.get("id"), page, pageSize};
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
"FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" +
"WHERE a.type = '数据资源' AND a.del_flag = 0\n" +
"AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" +
"AND (b.ID = ? OR b.pids LIKE CONCAT(CONCAT('%',?),'%'))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n" +
"LIMIT ?,?",pas);
"LIMIT ?,?", pas);
result.addAll(result2);
CompletableFuture<Void> resourceCarNum = CompletableFuture.runAsync(() -> { //被申请数量
@ -1074,26 +1109,26 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceKnowledgeDetails(Map<String,Object> params){
public List<Map<String, Object>> resourceKnowledgeDetails(Map<String, Object> params) {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Object[] pas = {params.get("id"),params.get("id"),page,pageSize};
Object[] pas = {params.get("id"), params.get("id"), page, pageSize};
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) as resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
List<Map<String, Object>> result2 = jdbcTemplate.queryForList("SELECT COUNT(a.id) AS resourceNum,a.dept_id AS deptId,b.name AS deptName\n" +
"FROM tb_data_resource a INNER JOIN sys_dept b ON a.dept_id = b.id\n" +
"WHERE a.type = '知识库' AND a.del_flag = 0\n" +
"AND (b.ID = ? OR b.pids like CONCAT(CONCAT('%',?),'%'))\n" +
"AND (b.ID = ? OR b.pids LIKE CONCAT(CONCAT('%',?),'%'))\n" +
"GROUP BY a.dept_id,b.name\n" +
"ORDER BY a.dept_id,b.name\n" +
"LIMIT ?,?",pas);
"LIMIT ?,?", pas);
result.addAll(result2);
return result;
}
// @Override
// @Override
// public List<Map<String,Object>> selectDeptList(Map<String,Object> params){
// List<Map<String,Object>> list = new ArrayList<>();
// Map map = new HashMap();
@ -1116,8 +1151,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
// return list;
// }
@Override
public List<Map<String,Object>> resourceBusinessUseDetails(Map<String,Object> params){
List<Map<String,Object>> result = new CopyOnWriteArrayList<>();
public List<Map<String, Object>> resourceBusinessUseDetails(Map<String, Object> params) {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
params.put("pageNum", (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()));
params.put("pageSize", params.get("limit"));
result = baseDao.selectResurceCarDetails(params);
@ -1129,8 +1164,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> resourceDatasUseDetails(Map<String,Object> params){
List<Map<String,Object>> result = new CopyOnWriteArrayList<>();
public List<Map<String, Object>> resourceDatasUseDetails(Map<String, Object> params) {
List<Map<String, Object>> result = new CopyOnWriteArrayList<>();
params.put("pageNum", (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()));
params.put("pageSize", params.get("limit"));
result = baseDao.selectResurceCarDetails(params);
@ -1138,15 +1173,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<Map<String,Object>> assemblerCarDetail(Map<String,Object> params){
List<Map<String,Object>> result = new ArrayList<>();
Object[] ps = {params.get("id"),params.get("resourceType"),(Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()),Integer.parseInt(params.get("limit").toString())};
public List<Map<String, Object>> assemblerCarDetail(Map<String, Object> params) {
List<Map<String, Object>> result = new ArrayList<>();
Object[] ps = {params.get("id"), params.get("resourceType"), (Integer.parseInt(params.get("page").toString()) - 1) * Integer.parseInt(params.get("limit").toString()), Integer.parseInt(params.get("limit").toString())};
result = jdbcTemplate.queryForList("\n" +
"SELECT a.*,b.username,c.name as resourcename from tb_resource_car a inner join sys_user b on a.user_id = b.id \n" +
"inner join tb_data_resource c on a.resource_id = c.id \n" +
"where a.del_flg = 0 AND b.dept_id = ? and c.type = ?\n" +
"order by a.create_date desc \n" +
"limit ?,?\n",ps);
"SELECT a.*,b.username,c.name AS resourcename FROM tb_resource_car a INNER JOIN sys_user b ON a.user_id = b.id \n" +
"INNER JOIN tb_data_resource c ON a.resource_id = c.id \n" +
"WHERE b.dept_id = ? AND c.type = ?\n" +
"ORDER BY a.create_date DESC \n" +
"LIMIT ?,?\n", ps);
return result;
}

View File

@ -33,10 +33,14 @@ public class BaoTouVideoPreviewService extends AbstractVideoPreviewService {
@Override
public String getHls(String key) {
String hls = null;
Request request = new Request.Builder().url(String.format(baoTouProperties.getHlsurl(), key)).build();
String url = String.format(baoTouProperties.getHlsurl(), key);
logger.info("包头预览:" + url);
Request request = new Request.Builder().url(url).build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
JSONObject jsonObject = JSON.parseObject(response.body().string());
String body = response.body().string();
logger.error("包头预览返回:" + body);
JSONObject jsonObject = JSON.parseObject(body);
if (jsonObject.containsKey("data")) {
hls = jsonObject.getString("data");
}

View File

@ -87,7 +87,8 @@ public class LoginController {
LoginDTO login = new LoginDTO();
login.setUsername(String.valueOf(params.get("username")));
login.setPassword(String.valueOf(params.get("password")));
String password = PasswordUtils.desEncrypt(String.valueOf(params.get("password")));
login.setPassword(password);
// login.setCaptcha(String.valueOf(params.get("captcha")));
login.setUuid(String.valueOf(params.get("uuid")));
//效验数据

View File

@ -1,12 +1,21 @@
package io.renren.modules.security.password;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
/**
* 密码工具类
*
* @since 1.0.0
*/
public class PasswordUtils {
private static PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
private static final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
// 密码传输密钥
private static final String pwdKey = "YwwqhsxBkywjgm01";
private static final String pwdIv = "SSXXZYZYBABA30TM";
/**
* 加密
@ -28,4 +37,20 @@ public class PasswordUtils {
return passwordEncoder.matches(str, password);
}
// 解密前端传输过来的密码加密串
public static String desEncrypt(String data) {
try {
byte[] encrypted1 = Base64.getDecoder().decode(data);
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
SecretKeySpec keyspec = new SecretKeySpec(pwdKey.getBytes(), "AES");
IvParameterSpec ivspec = new IvParameterSpec(pwdIv.getBytes());
cipher.init(Cipher.DECRYPT_MODE, keyspec, ivspec);
byte[] original = cipher.doFinal(encrypted1);
return new String(original).trim();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -7,7 +7,6 @@ import io.renren.common.page.PageData;
import io.renren.common.utils.ConvertUtils;
import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
@ -25,7 +24,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
@ -103,12 +101,15 @@ public class SysUserController {
UserDetail user = SecurityUser.getUser();
String password = PasswordUtils.desEncrypt(dto.getPassword());
String newPassword = PasswordUtils.desEncrypt(dto.getNewPassword());
//原密码不正确
if(!PasswordUtils.matches(dto.getPassword(), user.getPassword())){
if(!PasswordUtils.matches(password, user.getPassword())){
return new Result().error(ErrorCode.PASSWORD_ERROR);
}
sysUserService.updatePassword(user.getId(), dto.getNewPassword());
sysUserService.updatePassword(user.getId(), newPassword);
return new Result();
}

View File

@ -108,9 +108,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
public void save(SysUserDTO dto) {
SysUserEntity entity = ConvertUtils.sourceToTarget(dto, SysUserEntity.class);
String password = PasswordUtils.desEncrypt(dto.getPassword());
//密码加密
String password = PasswordUtils.encode(entity.getPassword());
entity.setPassword(password);
entity.setPassword(PasswordUtils.encode(password));
//保存用户
entity.setSuperAdmin(SuperAdminEnum.NO.value());
@ -128,13 +129,13 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
public void update(SysUserDTO dto) {
SysUserEntity entity = ConvertUtils.sourceToTarget(dto, SysUserEntity.class);
//密码加密
if (StringUtils.isBlank(dto.getPassword())) {
entity.setPassword(null);
} else {
String password = PasswordUtils.encode(entity.getPassword());
entity.setPassword(password);
}
////密码加密
//if (StringUtils.isBlank(dto.getPassword())) {
// entity.setPassword(null);
//} else {
// String password = PasswordUtils.encode(entity.getPassword());
// entity.setPassword(password);
//}
//更新用户
updateById(entity);

View File

@ -1 +1 @@
baotou.hlsurl=http://10.110.205.1:18088/server/device/hisdeviceapplylist/url/%s
baotou.hlsurl=http://172.16.10.11:8088/server/device/hisdeviceapplylist/url/%s