Compare commits

..

5 Commits

Author SHA1 Message Date
wangliwen a63f63bb66 加入flyway管理数据库版本;后端有字段变动或数据迁移时请使用flyway!! 2022-06-14 16:05:27 +08:00
dinggang 3f88a03a8f sql語句錯誤 2022-06-14 09:32:40 +08:00
dinggang c009850d30 一些無用的改動 2022-06-13 17:11:58 +08:00
wangliwen 8af8d1282f ... 2022-06-13 15:26:34 +08:00
wangliwen cc21e26ab6 知识库同步定时任务化 2022-06-13 15:11:18 +08:00
23 changed files with 2224 additions and 295 deletions

View File

@ -39,6 +39,7 @@
<system.linux-x86_64>linux-x86_64</system.linux-x86_64> <system.linux-x86_64>linux-x86_64</system.linux-x86_64>
<ffmpeg.version>5.0</ffmpeg.version> <ffmpeg.version>5.0</ffmpeg.version>
<okhttp.version>3.14.9</okhttp.version> <okhttp.version>3.14.9</okhttp.version>
<flyway-core.version>8.5.12</flyway-core.version>
<java.version>1.8</java.version> <java.version>1.8</java.version>
</properties> </properties>
@ -262,6 +263,17 @@
<version>${okhttp.version}</version> <version>${okhttp.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-core -->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<!-- javacv+javacpp核心库--> <!-- javacv+javacpp核心库-->
<dependency> <dependency>

View File

@ -47,7 +47,7 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
public class ActHistoryService { public class ActHistoryService {
private static Logger logger = LoggerFactory.getLogger(ActHistoryService.class); private static final Logger logger = LoggerFactory.getLogger(ActHistoryService.class);
@Autowired @Autowired
protected RepositoryService repositoryService; protected RepositoryService repositoryService;

View File

@ -1,10 +1,4 @@
/** package io.renren.modules.notice.enums;
* Copyright (c) 2016-2020 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/package io.renren.modules.notice.enums;
/** /**
* 通知阅读状态枚举 * 通知阅读状态枚举

View File

@ -1,10 +1,4 @@
/** package io.renren.modules.notice.enums;
* Copyright (c) 2016-2020 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/package io.renren.modules.notice.enums;
/** /**
* 通知状态枚举 * 通知状态枚举

View File

@ -1,10 +1,4 @@
/** package io.renren.modules.notice.enums;
* Copyright (c) 2016-2020 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/package io.renren.modules.notice.enums;
/** /**
* 接受者类型枚举 * 接受者类型枚举

View File

@ -1,7 +1,6 @@
package io.renren.modules.resource.controller; package io.renren.modules.resource.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import io.renren.common.annotation.LogOperation; import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant; import io.renren.common.constant.Constant;
@ -11,13 +10,11 @@ import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.DefaultGroup;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import okhttp3.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -27,19 +24,12 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.time.LocalDateTime; import java.util.HashMap;
import java.time.ZoneOffset; import java.util.Map;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/** /**
* 资源表 * 资源表
@ -51,6 +41,7 @@ import java.util.stream.Collectors;
@RequestMapping("/resource") @RequestMapping("/resource")
@Api(tags = "资源表") @Api(tags = "资源表")
public class ResourceController { public class ResourceController {
@Value("${qdyjj.ipAndPort}") @Value("${qdyjj.ipAndPort}")
private String ipAndPort; private String ipAndPort;
@ -87,7 +78,7 @@ public class ResourceController {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
private static Logger logger = LoggerFactory.getLogger(ResourceController.class); private static final Logger logger = LoggerFactory.getLogger(ResourceController.class);
@GetMapping("/page") @GetMapping("/page")
@ApiOperation("分页查询资源信息") @ApiOperation("分页查询资源信息")
@ -103,9 +94,7 @@ public class ResourceController {
}) })
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) { public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<ResourceDTO> page = resourceService.page(params); PageData<ResourceDTO> page = resourceService.page(params);
page.getList().forEach(item -> { page.getList().forEach(item -> item.setInfoList(resourceService.selectAttrsByResourceId(item.getId())));
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
});
return new Result<PageData<ResourceDTO>>().ok(page); return new Result<PageData<ResourceDTO>>().ok(page);
} }
@ -202,7 +191,7 @@ public class ResourceController {
@LogOperation("修改") @LogOperation("修改")
//@RequiresPermissions("resource:resource:update") //@RequiresPermissions("resource:resource:update")
public Result update(@RequestBody ResourceDTO dto) { public Result update(@RequestBody ResourceDTO dto) {
////效验数据 //效验数据
//ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); //ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
resourceService.updateWithAttrs(dto); resourceService.updateWithAttrs(dto);
@ -279,141 +268,7 @@ public class ResourceController {
@GetMapping("knowledgeBase") @GetMapping("knowledgeBase")
@ApiOperation("对接知识库数据") @ApiOperation("对接知识库数据")
public Result<String> knowledgeBase() { public Result<String> knowledgeBase() {
final int pageSize = 100; resourceService.KnowledgeBase();
final long timestamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
final OkHttpClient client = new OkHttpClient();
Arrays.stream(catalogIds).map(index -> {
logger.info("处理:" + index);
CopyOnWriteArrayList<CompletableFuture> task = new CopyOnWriteArrayList<>();
AtomicBoolean end = new AtomicBoolean(true);
AtomicInteger pageIndex = new AtomicInteger(1);
AtomicInteger maxPage = new AtomicInteger(100); // 防止死循环
do {
int page = pageIndex.getAndIncrement();
logger.info("处理:" + index + " 分页{}", page);
task.add(CompletableFuture.supplyAsync(() -> {
try {
logger.info("分页任务处理:" + index + " 分页{} 时间 -->" + timestamp, page);
JSONObject bizContentParam = new JSONObject();
bizContentParam.put("appkey", appKey);
bizContentParam.put("catalogId", index);
bizContentParam.put("pageIndex", page);
bizContentParam.put("pageSize", pageSize);
String bizContent_ = bizContentParam.toJSONString();
logger.info("biz_content参数{}", bizContent_);
// 通过FormBody对象构建Builder来添加表单参数
FormBody.Builder signFormBody = new FormBody.Builder()
.add("app_id", appId)
.add("interface_id", methodId)
.add("version", version)
.add("timestamp", String.valueOf(timestamp))
.add("origin", origin)
.add("charset", charset)
.add("biz_content", bizContent_);
logger.info(index + "分页{}对接知识库数据请求参数:" + signFormBody.build().contentType().toString(), page);
Request signRequest = new Request.Builder().url(sign).post(signFormBody.build()).build();
Response signResponse =
client.newCall(signRequest).execute();
String signResult = signResponse.body().string();
logger.info("{}分页signResult数据" + signResult, page);
JSONObject signJsonObject = JSON.parseObject(signResult);
if (!signJsonObject.containsKey("data")) {
logger.info("获取sign异常" + signResult);
end.set(false);
throw new RuntimeException("获取sign异常");
}
if (signJsonObject.get("data") == null) {
logger.info("获取sign异常" + signResult);
end.set(false);
throw new RuntimeException("获取sign异常");
}
Map<String, Object> signData = (Map<String, Object>) signJsonObject.get("data");
String signString = signData.get("sign").toString();
signFormBody.add("sign", signString);
Request gatewayRequest = new Request.Builder().url(gateway).post(signFormBody.build()).build();
Response gatewayResponse = client.newCall(gatewayRequest).execute();
String gatewayResult = gatewayResponse.body().string();
logger.info("{}分页数据:" + gatewayResult, page);
JSONObject gatewayJsonObject = JSON.parseObject(gatewayResult);
JSONObject gatewayData = JSON.parseObject(gatewayJsonObject.get("data").toString());
JSONArray infos = gatewayData.getJSONObject("data").getJSONArray("infos");
int total = gatewayData.getJSONObject("data").getIntValue("total");
if (maxPage.get() != (total / pageSize)) {
maxPage.set(total / pageSize);
}
if (!infos.isEmpty()) { // 不为空则数据分页还没传输结束
logger.info("--继续分页--");
end.set(true); // TODO
} else {
end.set(false);
}
return infos;
} catch (Exception e) {
logger.info("获取异常:", e);
end.set(false);
return new JSONArray();
}
}).thenAcceptAsync(list -> {
logger.info("知识库数据量:{}", list.size());
if (list.size() < 1) {
end.set(false);
}
list.parallelStream().forEach(resource -> {
Map<String, Object> map = (Map<String, Object>) resource;
ResourceDTO dto = new ResourceDTO();
dto.setName(map.get("title").toString());
dto.setType("知识库");
dto.setVisits(0L);
//所属部门暂时设为青岛市政府办公厅
dto.setDeptId(1517116100113850370L);
dto.setNote1(map.get("uuid").toString());
dto.setDelFlag(0);
ArrayList<AttrEntity> infoList = new ArrayList<>();
map.forEach((key, value) -> {
switch (key) {
case "title":
dto.setName(value.toString());
break;
case "url":
dto.setLink(value.toString());
break;
case "createtime":
Date createDate = new Date(Long.parseLong(value.toString()));
dto.setCreateDate(createDate);
break;
default:
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType(key);
attrEntity.setAttrValue(value.toString());
infoList.add(attrEntity);
break;
}
});
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType("文件类型");
if ("f49561afc7204f008c4bb3cd821eb6ba".equals(index)) {
attrEntity.setAttrValue("政府公报");
} else {
attrEntity.setAttrValue("政策解读");
}
infoList.add(attrEntity);
dto.setInfoList(infoList);
resourceService.insertWithAttrs(dto);
logger.info("插入:" + dto.getName());
});
}));
try {
Thread.sleep(500L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
} while (end.get() || pageIndex.get() < maxPage.get());
return task;
}).collect(Collectors.toList());
return new Result().ok("任务开启成功!"); return new Result().ok("任务开启成功!");
} }

View File

@ -23,10 +23,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO, List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO,
@Param("orderField") String orderField, @Param("orderField") String orderField,
@Param("orderType") String orderType, @Param("orderType") String orderType);
@Param("pageNum") Integer pageNum,
@Param("pageSize") Integer pageSize
);
List<Map> selectTypeCount(); List<Map> selectTypeCount();

View File

@ -74,4 +74,9 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectResourceListByType(String type); Object selectResourceListByType(String type);
Object selectResourceListByAppArea(String appArea); Object selectResourceListByAppArea(String appArea);
/**
* 同步知识库
*/
void KnowledgeBase();
} }

View File

@ -24,12 +24,27 @@ import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
import io.renren.modules.resourceScore.dao.ResourceScoreDao; import io.renren.modules.resourceScore.dao.ResourceScoreDao;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.dao.SysDeptDao; import io.renren.modules.sys.dao.SysDeptDao;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -40,6 +55,33 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService { public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
@Value("${zsk.appid}")
private String appId;
@Value("${zsk.appkey}")
private String appKey;
@Value("${zsk.url.sign}")
private String sign;
@Value("${zsk.url.gateway}")
private String gateway;
@Value("${zsk.methodId}")
private String methodId;
@Value("${zsk.param.charset}")
private String charset;
@Value("${zsk.param.origin}")
private String origin;
@Value("${zsk.param.version}")
private String version;
@Value("${zsk.catalogIds}")
private String[] catalogIds;
@Autowired @Autowired
private ResourceDao resourceDao; private ResourceDao resourceDao;
@ -62,6 +104,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Autowired @Autowired
private SysDeptDao sysDeptDao; private SysDeptDao sysDeptDao;
@Lazy
@Autowired
private JdbcTemplate jdbcTemplate;
@Override @Override
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) { public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
@ -99,6 +145,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
BeanUtils.copyProperties(dto, resourceEntity); BeanUtils.copyProperties(dto, resourceEntity);
Long resourceID = IdWorker.getId(resourceEntity); Long resourceID = IdWorker.getId(resourceEntity);
resourceEntity.setId(resourceID); resourceEntity.setId(resourceID);
resourceEntity.setVisits(0L);
if (dto.getDelFlag() == null) { if (dto.getDelFlag() == null) {
resourceEntity.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag()); resourceEntity.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
} }
@ -171,13 +218,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize); Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize);
if (resourceDTO.getInfoList().isEmpty()) { if (resourceDTO.getInfoList().isEmpty()) {
List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType); List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType);
//resourceDTOS.forEach(item -> {
// item.setInfoList(this.selectAttrsByResourceId(item.getId()));
//});
resultPage.setRecords(resourceDTOS); resultPage.setRecords(resourceDTOS);
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size()); resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size());
} else { } else {
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType, (pageNum - 1) * pageSize, pageSize); List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
int j = Math.min(pageNum * pageSize, resourceDTOS.size()); int j = Math.min(pageNum * pageSize, resourceDTOS.size());
if (resourceDTOS.isEmpty()) { if (resourceDTOS.isEmpty()) {
resultPage.setRecords(null); resultPage.setRecords(null);
@ -258,7 +302,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override @Override
public Object selectRecommend() { public Object selectRecommend() {
Long userId = SecurityUser.getUser().getId(); Long userId = SecurityUser.getUser().getId();
//根据用户收藏和申请数据查出应用领域排名根据应用领域查询热门能力推荐给用户 //根据用户收藏和申请数据查出应用领域排名根据应用领域查询热门能力推荐给用户
List<Map> applyAreaList = resourceDao.selectApplyArea(userId); List<Map> applyAreaList = resourceDao.selectApplyArea(userId);
//没有收藏和申请过按最热能力选取,否则根据应用领域最多类型推荐 //没有收藏和申请过按最热能力选取,否则根据应用领域最多类型推荐
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
@ -280,19 +324,19 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
jsonObject.put("pageSize", 9); jsonObject.put("pageSize", 9);
jsonObject.put("orderField", "total"); jsonObject.put("orderField", "total");
jsonObject.put("orderType", "DESC"); jsonObject.put("orderType", "DESC");
Page<ResourceDTO> Page = (Page<ResourceDTO>) this.pageWithAttrs(jsonObject); Page<ResourceDTO> page = (Page<ResourceDTO>) this.pageWithAttrs(jsonObject);
//若查出数据不足9条则在热门能力补充缺少的数量 //若查出数据不足9条则在热门能力补充缺少的数量
if (Page.getRecords().size() < 9) { if (page.getRecords().size() < 9) {
for (int i = 0; Page.getRecords().size() < 9; i++) { for (int i = 0; page.getRecords().size() < 9; i++) {
for (int j = 0; j < Page.getRecords().size(); j++) { for (int j = 0; j < page.getRecords().size(); j++) {
if (!Page.getRecords().get(j).getId().equals(resultPage.getRecords().get(i).getId())) { if (!page.getRecords().get(j).getId().equals(resultPage.getRecords().get(i).getId())) {
Page.getRecords().add(resultPage.getRecords().get(i)); page.getRecords().add(resultPage.getRecords().get(i));
break; break;
} }
} }
} }
} }
return Page; return page;
} else { } else {
return resultPage; return resultPage;
} }
@ -300,8 +344,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override @Override
public List<Map<String, Object>> getAmountGroupByType() { public List<Map<String, Object>> getAmountGroupByType() {
List<Map<String, Object>> amountInfo = resourceDao.getAmountGroupByType(); return resourceDao.getAmountGroupByType();
return amountInfo;
} }
@Override @Override
@ -330,9 +373,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey()); map.put("type", item.getKey());
map.put("total", resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"))); map.put("total", resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")));
item.getValue().forEach(item1 -> { item.getValue().forEach(item1 -> item1.remove("type"));
item1.remove("type");
});
map.put("dataList", item.getValue()); map.put("dataList", item.getValue());
resultList.add(map); resultList.add(map);
}); });
@ -343,14 +384,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
areaMap.put("type", "区级"); areaMap.put("type", "区级");
areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type"))); areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type")));
ArrayList<Map> areaListTemp = new ArrayList<>(); ArrayList<Map> areaListTemp = new ArrayList<>();
areaTypeList.orElse(new HashMap<>()).entrySet().stream().forEach(item -> { areaTypeList.orElse(new HashMap<>()).forEach((key, value) -> {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("type", item.getKey()); map.put("type", key);
map.put("total", resourceDao.selectTypeCountByDist(item.getKey(), jsonObject.getString("type"))); map.put("total", resourceDao.selectTypeCountByDist(key, jsonObject.getString("type")));
item.getValue().forEach(item1 -> { value.forEach(item1 -> item1.remove("type"));
item1.remove("type"); map.put("dataList", value);
});
map.put("dataList", item.getValue());
areaListTemp.add(map); areaListTemp.add(map);
}); });
areaMap.put("dataList", areaListTemp); areaMap.put("dataList", areaListTemp);
@ -384,13 +423,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
} }
}; };
List<Map> deptTypeCount = resourceDao.selectDeptTypeCount(); List<Map> deptTypeCount = resourceDao.selectDeptTypeCount();
map.entrySet().forEach(item -> { map.entrySet().forEach(item -> deptTypeCount.forEach(index -> {
deptTypeCount.forEach(index -> { if (index.get("type").equals(item.getKey())) {
if (index.get("type").equals(item.getKey())) { item.setValue(index.get("count"));
item.setValue(index.get("count")); }
} }));
});
});
resultMap.put("deptTypeCount", map); resultMap.put("deptTypeCount", map);
List<Map> deptTotalCount = resourceDao.selectDeptTotalCount(); List<Map> deptTotalCount = resourceDao.selectDeptTotalCount();
HashMap<String, Object> map1 = new HashMap() { HashMap<String, Object> map1 = new HashMap() {
@ -402,13 +439,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
put("20", 0); put("20", 0);
} }
}; };
map1.entrySet().forEach(item -> { map1.entrySet().forEach(item -> deptTotalCount.forEach(index -> {
deptTotalCount.forEach(index -> { if (index.get("type").equals(item.getKey())) {
if (index.get("type").equals(item.getKey())) { item.setValue(index.get("total"));
item.setValue(index.get("total")); }
} }));
});
});
resultMap.put("deptTotalCount", map1); resultMap.put("deptTotalCount", map1);
return resultMap; return resultMap;
} }
@ -471,9 +506,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
typeCountListMap.forEach((k, v) -> { typeCountListMap.forEach((k, v) -> {
HashMap<Object, Object> map = new HashMap<>(); HashMap<Object, Object> map = new HashMap<>();
map.put("name", k); map.put("name", k);
v.forEach(item -> { v.forEach(item -> map.put(item.get("type").toString(), item.get("count")));
map.put(item.get("type").toString(), item.get("count"));
});
resultList.add(map); resultList.add(map);
}); });
return resultList; return resultList;
@ -487,9 +520,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
typeCountListMap.forEach((k, v) -> { typeCountListMap.forEach((k, v) -> {
HashMap<Object, Object> map = new HashMap<>(); HashMap<Object, Object> map = new HashMap<>();
map.put("name", k); map.put("name", k);
v.forEach(item -> { v.forEach(item -> map.put(item.get("type").toString(), item.get("count")));
map.put(item.get("type").toString(), item.get("count"));
});
resultList.add(map); resultList.add(map);
}); });
return resultList; return resultList;
@ -533,4 +564,152 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
return resourceDao.selectByAppArea(appArea); return resourceDao.selectByAppArea(appArea);
} }
/**
* 同步知识库
*/
@Override
public void KnowledgeBase() {
final List<String> knowledgeUUID =
jdbcTemplate.queryForList("SELECT note1 FROM tb_data_resource WHERE type ='知识库';", String.class)
.stream().distinct().collect(Collectors.toList());
final int pageSize = 100;
final OkHttpClient client = new OkHttpClient();
Arrays.stream(catalogIds).map(index -> {
logger.info("处理:" + index);
CopyOnWriteArrayList<CompletableFuture> task = new CopyOnWriteArrayList<>();
AtomicBoolean end = new AtomicBoolean(true);
AtomicInteger pageIndex = new AtomicInteger(1);
AtomicInteger maxPage = new AtomicInteger(100); // 防止死循环
do {
final long timestamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
int page = pageIndex.getAndIncrement();
logger.info("处理:" + index + " 分页{}", page);
task.add(CompletableFuture.supplyAsync(() -> {
try {
logger.info("分页任务处理:" + index + " 分页{} 时间 -->" + timestamp, page);
JSONObject bizContentParam = new JSONObject();
bizContentParam.put("appkey", appKey);
bizContentParam.put("catalogId", index);
bizContentParam.put("pageIndex", page);
bizContentParam.put("pageSize", pageSize);
String bizContent_ = bizContentParam.toJSONString();
logger.info("biz_content参数{}", bizContent_);
// 通过FormBody对象构建Builder来添加表单参数
FormBody.Builder signFormBody = new FormBody.Builder()
.add("app_id", appId)
.add("interface_id", methodId)
.add("version", version)
.add("timestamp", String.valueOf(timestamp))
.add("origin", origin)
.add("charset", charset)
.add("biz_content", bizContent_);
logger.info(index + "分页{}对接知识库数据请求参数:" + signFormBody.build().contentType().toString(), page);
Request signRequest = new Request.Builder().url(sign).post(signFormBody.build()).build();
Response signResponse =
client.newCall(signRequest).execute();
String signResult = signResponse.body().string();
logger.info("{}分页signResult数据" + signResult, page);
JSONObject signJsonObject = JSON.parseObject(signResult);
if (!signJsonObject.containsKey("data")) {
logger.info("获取sign异常" + signResult);
end.set(false);
throw new RuntimeException("获取sign异常");
}
if (signJsonObject.get("data") == null) {
logger.info("获取sign异常" + signResult);
end.set(false);
throw new RuntimeException("获取sign异常");
}
Map<String, Object> signData = (Map<String, Object>) signJsonObject.get("data");
String signString = signData.get("sign").toString();
signFormBody.add("sign", signString);
Request gatewayRequest = new Request.Builder().url(gateway).post(signFormBody.build()).build();
Response gatewayResponse = client.newCall(gatewayRequest).execute();
String gatewayResult = gatewayResponse.body().string();
logger.info("{}分页数据:" + gatewayResult, page);
JSONObject gatewayJsonObject = JSON.parseObject(gatewayResult);
JSONObject gatewayData = JSON.parseObject(gatewayJsonObject.get("data").toString());
JSONArray infos = gatewayData.getJSONObject("data").getJSONArray("infos");
int total = gatewayData.getJSONObject("data").getIntValue("total");
if (maxPage.get() != (total / pageSize)) {
maxPage.set(total / pageSize);
}
if (!infos.isEmpty()) { // 不为空则数据分页还没传输结束
logger.info("--继续分页--");
end.set(true);
} else {
end.set(false);
}
return infos;
} catch (Exception e) {
logger.info("获取异常:", e);
end.set(false);
return new JSONArray();
}
}).thenAcceptAsync(list -> {
logger.info("知识库数据量:{}", list.size());
if (list.size() < 1) {
end.set(false);
}
list.parallelStream().filter(resource -> {
Map<String, Object> map = (Map<String, Object>) resource;
return !knowledgeUUID.contains(map.get("uuid").toString());
}).forEach(resource -> {
Map<String, Object> map = (Map<String, Object>) resource;
ResourceDTO dto = new ResourceDTO();
dto.setName(map.get("title").toString());
dto.setType("知识库");
dto.setVisits(0L);
//所属部门暂时设为青岛市政府办公厅
dto.setDeptId(1517116100113850370L);
dto.setNote1(map.get("uuid").toString());
dto.setDelFlag(0);
ArrayList<AttrEntity> infoList = new ArrayList<>();
map.forEach((key, value) -> {
switch (key) {
case "title":
dto.setName(value.toString());
break;
case "url":
dto.setLink(value.toString());
break;
case "createtime":
Date createDate = new Date(Long.parseLong(value.toString()));
dto.setCreateDate(createDate);
break;
default:
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType(key);
attrEntity.setAttrValue(value.toString());
infoList.add(attrEntity);
break;
}
});
AttrEntity attrEntity = new AttrEntity();
attrEntity.setDelFlag(0);
attrEntity.setAttrType("文件类型");
if ("f49561afc7204f008c4bb3cd821eb6ba".equals(index)) {
attrEntity.setAttrValue("政府公报");
} else {
attrEntity.setAttrValue("政策解读");
}
infoList.add(attrEntity);
dto.setInfoList(infoList);
this.insertWithAttrs(dto);
logger.info("插入:" + dto.getName());
});
}));
try {
Thread.sleep(300L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
} while (end.get() || pageIndex.get() < maxPage.get());
return task;
}).collect(Collectors.toList());
}
} }

View File

@ -0,0 +1,29 @@
package io.renren.modules.resource.task;
import io.renren.modules.job.task.ITask;
import io.renren.modules.resource.service.ResourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 知识库定时任务
*/
@Component("knowledgeBaseTask")
public class KnowledgeBaseTask implements ITask {
private static final Logger logger = LoggerFactory.getLogger(KnowledgeBaseTask.class);
@Autowired
private ResourceService resourceService;
/**
* 执行定时任务接口
*
* @param params 参数多参数使用JSON数据
*/
@Override
public void run(String params) {
logger.info("执行同步知识库任务");
resourceService.KnowledgeBase();
}
}

View File

@ -2,14 +2,12 @@ package io.renren.modules.resourceBrowse.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.common.utils.DateUtils; import io.renren.common.utils.DateUtils;
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao; import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO; import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity; import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService; import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -64,12 +62,12 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao
startDay = DateUtils.addDateDays(startDay, 1); startDay = DateUtils.addDateDays(startDay, 1);
} }
ArrayList<Map<String, Object>> resultMap = new ArrayList<>(); ArrayList<Map<String, Object>> resultMap = new ArrayList<>();
for (int i = 0; i < dayList.size(); i++) { for (String s : dayList) {
HashMap<String, Object> dayMap = new HashMap<>(); HashMap<String, Object> dayMap = new HashMap<>();
dayMap.put(dayList.get(i), 0); dayMap.put(s, 0);
for (Map map : maps) { for (Map map : maps) {
if (dayList.get(i).equals(map.get("date"))) { if (s.equals(map.get("date"))) {
dayMap.put(dayList.get(i), map.get("count")); dayMap.put(s, map.get("count"));
} }
} }
resultMap.add(dayMap); resultMap.add(dayMap);

View File

@ -4,20 +4,16 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceCar.dto.ResourceCarDTO;
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao; import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO; import io.renren.modules.resourceCollection.dto.ResourceCollectionDTO;
import io.renren.modules.resourceCollection.entity.ResourceCollectionEntity; import io.renren.modules.resourceCollection.entity.ResourceCollectionEntity;
import io.renren.modules.resourceCollection.service.ResourceCollectionService; import io.renren.modules.resourceCollection.service.ResourceCollectionService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail; import io.renren.modules.security.user.UserDetail;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -52,9 +48,7 @@ public class ResourceCollectionServiceImpl extends CrudServiceImpl<ResourceColle
Page<ResourceCollectionDTO> page = new Page(pageNum, pageSize); Page<ResourceCollectionDTO> page = new Page(pageNum, pageSize);
params.put("userId", user.getId()); params.put("userId", user.getId());
List<ResourceCollectionDTO> resourceCollectionDTOS = resourceCollectionDao.selectPageWithResource(params, (pageNum - 1) * pageSize, pageSize); List<ResourceCollectionDTO> resourceCollectionDTOS = resourceCollectionDao.selectPageWithResource(params, (pageNum - 1) * pageSize, pageSize);
resourceCollectionDTOS.forEach(item -> { resourceCollectionDTOS.forEach(item -> item.setResourceDTO(resourceService.selectWithAttrs(item.getResourceId())));
item.setResourceDTO(resourceService.selectWithAttrs(item.getResourceId()));
});
List<ResourceCollectionDTO> resourceCollectionDTOSs = resourceCollectionDao.selectPageWithResource(params, 0, 100000); List<ResourceCollectionDTO> resourceCollectionDTOSs = resourceCollectionDao.selectPageWithResource(params, 0, 100000);
page.setRecords(resourceCollectionDTOS); page.setRecords(resourceCollectionDTOS);
page.setTotal(resourceCollectionDTOSs.size()); page.setTotal(resourceCollectionDTOSs.size());

View File

@ -3,14 +3,10 @@ package io.renren.modules.workDynamics.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.modules.workDynamics.dao.WorkDynamicsDao; import io.renren.modules.workDynamics.dao.WorkDynamicsDao;
import io.renren.modules.workDynamics.dto.WorkDynamicsDTO; import io.renren.modules.workDynamics.dto.WorkDynamicsDTO;
import io.renren.modules.workDynamics.entity.WorkDynamicsEntity; import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
import io.renren.modules.workDynamics.service.WorkDynamicsService; import io.renren.modules.workDynamics.service.WorkDynamicsService;
import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@ -1,10 +1,3 @@
/**
* Copyright (c) 2016-2020 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package io.renren.websocket; package io.renren.websocket;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -31,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Component @Component
@ServerEndpoint(value = "/websocket", configurator = WebSocketConfig.class) @ServerEndpoint(value = "/websocket", configurator = WebSocketConfig.class)
public class WebSocketServer { public class WebSocketServer {
private static Logger logger = LoggerFactory.getLogger(WebSocketServer.class); private static final Logger logger = LoggerFactory.getLogger(WebSocketServer.class);
public WebSocketServer() { public WebSocketServer() {
logger.info("-------------websocket----------------"); logger.info("-------------websocket----------------");

View File

@ -1,10 +1,4 @@
/** package io.renren.websocket.config;
* Copyright (c) 2016-2020 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/package io.renren.websocket.config;
import io.renren.common.constant.Constant; import io.renren.common.constant.Constant;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;

View File

@ -1,10 +1,4 @@
/** package io.renren.websocket.data;
* Copyright (c) 2016-2020 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/package io.renren.websocket.data;
import lombok.Data; import lombok.Data;

View File

@ -1,10 +1,4 @@
/** package io.renren.websocket.data;
* Copyright (c) 2016-2020 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/package io.renren.websocket.data;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;

View File

@ -51,6 +51,10 @@ spring:
check-process-definitions: false check-process-definitions: false
resources: resources:
static-locations: classpath:/static,classpath:/public,file:${resource.path} static-locations: classpath:/static,classpath:/public,file:${resource.path}
flyway:
locations: classpath:db
baseline-on-migrate: true
baseline-version: 0
fdfs: fdfs:
@ -87,6 +91,7 @@ system:
yawei: yawei:
enable: true enable: true
#知识库 #知识库
zsk: zsk:
url: url:

View File

@ -50,6 +50,7 @@
<include>*.yml</include> <include>*.yml</include>
<include>*.properties</include> <include>*.properties</include>
<include>*.json</include> <include>*.json</include>
<include>db/*.sql</include>
</includes> </includes>
<filtered>true</filtered> <filtered>true</filtered>
<outputDirectory>${file.separator}config</outputDirectory> <outputDirectory>${file.separator}config</outputDirectory>

View File

@ -1,5 +1,11 @@
==================================================================================================================== .----------------. .----------------. .----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
欢迎使用 renren-security 人人权限专业版 - Powered By https://www.renren.io | | ____ ____ | || | _________ | || | ____ ____ | || | ________ | || | ________ | |
| | |_ _||_ _| | || | | _ _ | | || | |_ || _| | || | |_ ___ `. | || | | __ _| | |
==================================================================================================================== | | \ \ / / | || | |_/ | | \_| | || | | |__| | | || | | | `. \ | || | |_/ / / | |
| | \ \/ / | || | | | | || | | __ | | || | | | | | | || | .'.' _ | |
| | _| |_ | || | _| |_ | || | _| | | |_ | || | _| |___.' / | || | _/ /__/ | | |
| | |______| | || | |_____| | || | |____||____| | || | |________.' | || | |________| | |
| | | || | | || | | || | | || | | |
| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------' '----------------' '----------------'

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
/*
Navicat Premium Data Transfer
Source Server : 15.2.21.238
Source Server Type : MySQL
Source Server Version : 50732
Source Host : 15.2.21.238:3310
Source Schema : share_platform
Target Server Type : MySQL
Target Server Version : 50732
File Encoding : 65001
Date: 14/06/2022 15:48:36
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Records of act_re_model
-- ----------------------------
INSERT INTO `act_re_model` VALUES ('1', 51, '能力申请', 'abilityprocess', NULL, '2022-04-13 18:36:31.681', '2022-05-30 10:58:37.536', 1, '{\"name\":\"能力申请\",\"description\":\"能力申请表单\",\"revision\":1}', NULL, '2', '3', '');
INSERT INTO `act_re_model` VALUES ('252725', 32, '能力资源上架', 'resourcemountapply', NULL, '2022-04-24 14:08:13.296', '2022-05-30 10:50:31.746', 1, '{\"name\":\"能力资源上架\",\"description\":\"能力资源上架审批流程\",\"revision\":1}', NULL, '252726', '252727', '');
INSERT INTO `act_re_model` VALUES ('277501', 20, '能力需求申请', 'abilitydemandapply', NULL, '2022-04-25 10:49:42.466', '2022-06-02 10:53:36.595', 1, '{\"name\":\"能力需求申请\",\"description\":\"能力需求申请\",\"revision\":1}', NULL, '277502', '277503', '');
INSERT INTO `act_re_model` VALUES ('485001', 18, '能力资源下架', 'resourcundercarriageapply', NULL, '2022-05-10 10:23:05.802', '2022-05-30 10:48:13.801', 1, '{\"name\":\"能力资源下架\",\"description\":\"能力资源下架\",\"revision\":1}', NULL, '485002', '485003', '');
INSERT INTO `act_re_model` VALUES ('5019', 8, '转正申请', 'correctionprocess', NULL, '2022-04-14 17:44:34.122', '2022-04-14 20:27:14.548', 1, '{\"name\":\"转正申请\",\"description\":\"\",\"revision\":1}', NULL, '5020', '5021', '');

View File

@ -121,10 +121,11 @@
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" LEFT JOIN ( SELECT resource_id, user_id, ( IF(COUNT( id ) = 1, 'true', 'false') ) AS "isCollect"
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} GROUP BY resource_id FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} GROUP BY resource_id
) trc2 ON tdr.id = trc2.resource_id ) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} LEFT JOIN ( SELECT resource_id, user_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0
AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1 WHERE 1 = 1
@ -251,14 +252,17 @@
( taa2.approve_status &lt; 1, '未申请', "已申请" ) AS "applyState" ( taa2.approve_status &lt; 1, '未申请', "已申请" ) AS "applyState"
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND
del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
resource_id, resource_id,
user_id, user_id,
( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" ( IF(COUNT( id ) = 1, 'true', 'false') ) AS "isCollect"
FROM FROM
tb_resource_collection tb_resource_collection
WHERE WHERE
@ -268,7 +272,8 @@
GROUP BY GROUP BY
resource_id resource_id
) trc2 ON tdr.id = trc2.resource_id ) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND user_id = #{userId} GROUP BY resource_id ) taa2 ON tdr.id = taa2.resource_id LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
AND del_flag = 0 AND user_id = #{userId} GROUP BY resource_id ) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE WHERE
1 = 1 1 = 1
@ -293,10 +298,11 @@
0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" LEFT JOIN ( SELECT resource_id, user_id, ( IF(COUNT( id ) = 1, 'true', 'false') ) AS "isCollect"
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT DISTINCT resource_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} LEFT JOIN ( SELECT DISTINCT resource_id, approve_status FROM t_ability_application WHERE 1 = 1 AND del_flag = 0
AND user_id = #{dto.creator}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1 WHERE 1 = 1
@ -412,12 +418,12 @@
FROM FROM
( (
SELECT SELECT
* type,
deptCount
FROM FROM
( (
SELECT SELECT
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type", ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0 ) AS "deptCount" IFNULL( tdr.deptCount, 0 ) AS "deptCount"
FROM FROM
sys_dept sd sys_dept sd
@ -451,15 +457,13 @@
FROM FROM
( (
SELECT SELECT
* type, deptCount, districtName
FROM FROM
( (
SELECT SELECT
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type", ( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0) AS "deptCount", IFNULL( tdr.deptCount, 0) AS "deptCount",
IFNULL(sr.name, '暂无该地区') AS "districtName", IFNULL(sr.name, '暂无该地区') AS "districtName"
sr.id AS "districtId"
FROM FROM
sys_dept sd sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource
@ -609,8 +613,7 @@
FROM FROM
( (
SELECT SELECT
COUNT( id ) AS "count", COUNT( id ) AS "count"
dept_id
FROM FROM
tb_data_resource tb_data_resource
WHERE WHERE
@ -673,8 +676,7 @@
FROM FROM
( (
SELECT SELECT
COUNT( taa.id ) AS "count", COUNT( taa.id ) AS "count"
su.dept_id
FROM FROM
t_ability_application taa, t_ability_application taa,
sys_user su sys_user su
@ -787,7 +789,7 @@
SELECT SELECT
MAX( count ) AS "total" MAX( count ) AS "total"
FROM FROM
( SELECT COUNT( id ) AS "count", type FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp2 ( SELECT COUNT( id ) AS "count" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp2
) )
</select> </select>