|
@@ -117,11 +117,7 @@ public class AnalysisSearchServiceImpl {
|
|
|
* @param organizationId
|
|
|
* @return
|
|
|
*/
|
|
|
- public OrganizationSearchVo organizationSearch(String type, String organizationId,String createTime,String endTime,List<String> personId) {
|
|
|
- //存在人员,统计人员
|
|
|
- if (!CollectionUtils.isEmpty(personId)){
|
|
|
- organizationId = null;
|
|
|
- }
|
|
|
+ public OrganizationSearchVo organizationSearch(String type, String organizationId,String createTime,String endTime) {
|
|
|
//开始时间和结束时间都不为空,按照选中时间过滤,忽略type
|
|
|
if (!StringUtils.isEmpty(createTime) && !StringUtils.isEmpty(endTime)){
|
|
|
type = null;
|
|
@@ -132,35 +128,31 @@ public class AnalysisSearchServiceImpl {
|
|
|
OrganizationSearchVo organizationSearchVo = new OrganizationSearchVo();
|
|
|
List<Map<String, Object>> item = new ArrayList<>();
|
|
|
if (("total").equals(type)) {
|
|
|
- item = analysisSearchMapper.organizationSearch(null, null, organizationId,personId);
|
|
|
+ item = analysisSearchMapper.organizationSearch(null, null, organizationId);
|
|
|
} else if (("year").equals(type)) {
|
|
|
item = analysisSearchMapper.organizationSearch(DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
- DateUtils.format(DateUtils.getLastOfYear(year)), organizationId,personId);
|
|
|
+ DateUtils.format(DateUtils.getLastOfYear(year)), organizationId);
|
|
|
} else if (("month").equals(type)) {
|
|
|
int month = calendar.get(Calendar.MONTH);
|
|
|
String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
|
|
|
String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
|
|
|
- item = analysisSearchMapper.organizationSearch(firstOfMonth, lastOfMonth, organizationId,personId);
|
|
|
+ item = analysisSearchMapper.organizationSearch(firstOfMonth, lastOfMonth, organizationId);
|
|
|
} else {
|
|
|
- item = analysisSearchMapper.organizationSearch(createTime,endTime, organizationId,personId);
|
|
|
+ item = analysisSearchMapper.organizationSearch(createTime,endTime, organizationId);
|
|
|
}
|
|
|
String deptPath = pvLogMapper.findAllDeptIdByDeptId(organizationId);
|
|
|
- if (CollectionUtils.isEmpty(personId)) {
|
|
|
- if (StringUtils.isNotEmpty(deptPath)) {
|
|
|
- deptPath = deptPath.substring(deptPath.indexOf(".") + 1);
|
|
|
- String[] split = deptPath.split("\\.");
|
|
|
- if (split.length > 6) {
|
|
|
- String first = Arrays.stream(split).limit(3).map(e -> userService.findDeptByDeptId(e).getName()).collect(Collectors.joining(">"));
|
|
|
- String end = Arrays.stream(split).skip(split.length - 3).map(e -> userService.findDeptByDeptId(e).getName()).collect(Collectors.joining(">"));
|
|
|
- organizationSearchVo.setOrganization(first + ">...>" + end);
|
|
|
- } else {
|
|
|
- String organization = Arrays.stream(split).map(e -> userService.findDeptByDeptId(e).getName()).collect(Collectors.joining(">"));
|
|
|
- organizationSearchVo.setOrganization(organization);
|
|
|
- }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(deptPath)) {
|
|
|
+ deptPath = deptPath.substring(deptPath.indexOf(".") + 1);
|
|
|
+ String[] split = deptPath.split("\\.");
|
|
|
+ if (split.length > 6) {
|
|
|
+ String first = Arrays.stream(split).limit(3).map(e -> userService.findDeptByDeptId(e).getName()).collect(Collectors.joining(">"));
|
|
|
+ String end = Arrays.stream(split).skip(split.length - 3).map(e -> userService.findDeptByDeptId(e).getName()).collect(Collectors.joining(">"));
|
|
|
+ organizationSearchVo.setOrganization(first + ">...>" + end);
|
|
|
+ } else {
|
|
|
+ String organization = Arrays.stream(split).map(e -> userService.findDeptByDeptId(e).getName()).collect(Collectors.joining(">"));
|
|
|
+ organizationSearchVo.setOrganization(organization);
|
|
|
}
|
|
|
- } else {
|
|
|
- String fullName = personId.parallelStream().map(e -> userService.queryOsUserDto(e).getFullName()).collect(Collectors.joining(","));
|
|
|
- organizationSearchVo.setOrganization(fullName);
|
|
|
}
|
|
|
Optional<BigDecimal> total = item.stream().map(e -> (BigDecimal) e.get("value")).reduce(BigDecimal::add);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -176,11 +168,66 @@ public class AnalysisSearchServiceImpl {
|
|
|
* @param personVisitDto
|
|
|
* @return
|
|
|
*/
|
|
|
- public OrganizationSearchVo personSearch(PersonVisitDto personVisitDto) {
|
|
|
- //如果组织id不为空,人员id为空情况下,显示组织访问量
|
|
|
- OrganizationSearchVo organizationSearchVo = this.organizationSearch(personVisitDto.getType(), personVisitDto.getOrganizationId(),
|
|
|
- personVisitDto.getCreateTime(), personVisitDto.getEndTime(), personVisitDto.getPersonId());
|
|
|
- return organizationSearchVo;
|
|
|
+ public List<OrganizationSearchVo> personSearch(PersonVisitDto personVisitDto) {
|
|
|
+ List<OrganizationSearchVo> searchCompanyVoList = new ArrayList<>();
|
|
|
+ //开始时间和结束时间都不为空,按照选中时间过滤,忽略type
|
|
|
+ if (!StringUtils.isEmpty(personVisitDto.getCreateTime()) && !StringUtils.isEmpty(personVisitDto.getEndTime())){
|
|
|
+ personVisitDto.setType(null);
|
|
|
+ }
|
|
|
+ //查询人员
|
|
|
+ if (!CollectionUtils.isEmpty(personVisitDto.getPersonId())){
|
|
|
+ personVisitDto.setOrganizationId(null);
|
|
|
+ searchCompanyVoList = personSearchValue(personVisitDto.getPersonId(),personVisitDto.getType(),personVisitDto.getCreateTime(),personVisitDto.getEndTime(),1);
|
|
|
+ } else {
|
|
|
+ //查询部门
|
|
|
+ String[] split = personVisitDto.getOrganizationId().split(",");
|
|
|
+ List<String> organizationIdList = Arrays.asList(split);
|
|
|
+ searchCompanyVoList = personSearchValue(organizationIdList,personVisitDto.getType(),personVisitDto.getCreateTime(),personVisitDto.getEndTime(),2);
|
|
|
+ }
|
|
|
+ return searchCompanyVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 人员创建地图赋值
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<OrganizationSearchVo> personSearchValue(List<String> list,String type,String createTime,String endTime,Integer round){
|
|
|
+
|
|
|
+ List<OrganizationSearchVo> result = list.parallelStream().map(e -> {
|
|
|
+ //获取当前年
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ OrganizationSearchVo organizationSearchVo = new OrganizationSearchVo();
|
|
|
+ List<Map<String, Object>> item = new ArrayList<>();
|
|
|
+ //查询知识分类下创建的知识数量(纬度:年 最近1个月 全部)
|
|
|
+ if (type.equals("total")) {
|
|
|
+ item = analysisSearchMapper.personSearchValue(e, null, null,round);
|
|
|
+ } else if (type.equals("year")) {
|
|
|
+ item = analysisSearchMapper.personSearchValue(e, DateUtils.format(DateUtils.getFirstOfYear(year)),
|
|
|
+ DateUtils.format(DateUtils.getLastOfYear(year)),round);
|
|
|
+ } else if (type.equals("month")) {
|
|
|
+ int month = calendar.get(Calendar.MONTH);
|
|
|
+ String firstOfMonth = DateUtils.getFirstOfMonth(year, month + 1, 15);
|
|
|
+ String lastOfMonth = DateUtils.getLastOfMonth(year, month + 1, 15);
|
|
|
+ item = analysisSearchMapper.personSearchValue(e, firstOfMonth, lastOfMonth,round);
|
|
|
+ } else {
|
|
|
+ item = analysisSearchMapper.personSearchValue(e,createTime, endTime, round);
|
|
|
+ }
|
|
|
+ Optional<BigDecimal> total = item.stream().map(h -> (BigDecimal) h.get("value")).reduce(BigDecimal::add);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("name", "访问总量");
|
|
|
+ map.put("value", total.get());
|
|
|
+ item.add(0,map);
|
|
|
+ organizationSearchVo.setItem(item);
|
|
|
+ if (round == 1){
|
|
|
+ organizationSearchVo.setOrganization(userService.queryOsUserDto(e).getFullName());
|
|
|
+ } else {
|
|
|
+ organizationSearchVo.setOrganization(userService.findDeptByDeptId(e).getName());
|
|
|
+ }
|
|
|
+ return organizationSearchVo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return result;
|
|
|
|
|
|
}
|
|
|
}
|