Merge branch 'master' into docker_package
This commit is contained in:
commit
486c9b8d02
|
@ -23,7 +23,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
||||||
Integer deleteByIds(@Param("ids") List<Long> idList);
|
Integer deleteByIds(@Param("ids") List<Long> idList);
|
||||||
|
|
||||||
|
|
||||||
@Cacheable(value = "selectWithAttrs", key = "#p0")
|
@Cacheable(value = "selectWithAttrs", key = "#p0+'-'+#orderField+'-'+#orderType")
|
||||||
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);
|
||||||
|
|
|
@ -374,66 +374,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
case TSINGTAO:
|
case TSINGTAO:
|
||||||
case BAOTOU: { // 包头、青岛
|
case BAOTOU: { // 包头、青岛
|
||||||
logger.info("包头、青岛");
|
logger.info("包头、青岛");
|
||||||
if (resourceDTO.getInfoList().isEmpty()) {
|
resultPage = common(resultPage, selectDTOPageSpecilTotal, resourceDTO, orderField, orderType, pageNum, pageSize);
|
||||||
List<ResourceDTO> resourceDTOS = null;
|
|
||||||
if (orderField.equals("total")) { // 对总体评价特殊处理
|
|
||||||
List<Long> ids = new ArrayList<>();
|
|
||||||
switch (orderType) {
|
|
||||||
case "DESC": // total 倒序
|
|
||||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
|
||||||
Map index = (Map) x;
|
|
||||||
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
|
|
||||||
return Long.valueOf(string);
|
|
||||||
}
|
|
||||||
).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x ->
|
|
||||||
Long.valueOf(x.get("id").toString())
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
case "ASC": // total 升序
|
|
||||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
|
||||||
String string = (x.get("total") == null) ? "0" : x.get("total").toString();
|
|
||||||
return Long.valueOf(string);
|
|
||||||
}
|
|
||||||
)).skip((pageNum - 1) * pageSize).limit(pageSize).map(x ->
|
|
||||||
Long.valueOf(x.get("id").toString())
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
|
|
||||||
if ("DESC".equals(orderType)) {
|
|
||||||
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
|
||||||
return index.getTotal() == null ? 0L : index.getTotal();
|
|
||||||
}).reversed()).collect(Collectors.toList()));
|
|
||||||
} else {
|
|
||||||
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
|
||||||
return index.getTotal() == null ? 0L : index.getTotal();
|
|
||||||
})).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType, null);
|
|
||||||
}
|
|
||||||
resultPage.setRecords(resourceDTOS);
|
|
||||||
resultPage.setTotal(resourceDao.selectDTOPageCount(resourceDTO));
|
|
||||||
} else {
|
|
||||||
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
|
|
||||||
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
|
|
||||||
if (resourceDTOS.isEmpty()) {
|
|
||||||
resultPage.setRecords(null);
|
|
||||||
resultPage.setTotal(0);
|
|
||||||
} else {
|
|
||||||
List<ResourceDTO> recordLists = resourceDTOS.stream()
|
|
||||||
.skip((pageNum - 1) * pageSize).limit(pageSize)
|
|
||||||
.map(dto_ -> {
|
|
||||||
ResourceDTO get = this.selectWithAttrs(dto_.getId());
|
|
||||||
BeanUtils.copyProperties(get, dto_);
|
|
||||||
return dto_;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
resultPage.setRecords(recordLists);
|
|
||||||
resultPage.setTotal(resourceDTOS.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TSINGTAO_XHA: {
|
case TSINGTAO_XHA: {
|
||||||
|
@ -441,7 +382,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
logger.info("西海岸基础设施");
|
logger.info("西海岸基础设施");
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
OkHttpClient client = new OkHttpClient();
|
OkHttpClient client = new OkHttpClient();
|
||||||
String url = String.format(tsingtao_xhaProperties.getCloudcam(), org.apache.commons.lang3.StringUtils.isNotEmpty(resourceDTO.getName()) ? resourceDTO.getName() : "", pageNum, pageSize);
|
String url = String.format(tsingtao_xhaProperties.getCloudcam(), StringUtils.isNotBlank(resourceDTO.getName()) ? resourceDTO.getName() : "", pageNum, pageSize);
|
||||||
logger.info(url);
|
logger.info(url);
|
||||||
Request request = new Request.Builder().url(url).build();
|
Request request = new Request.Builder().url(url).build();
|
||||||
try (Response response = client.newCall(request).execute()) {
|
try (Response response = client.newCall(request).execute()) {
|
||||||
|
@ -479,60 +420,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
logger.error("失败", exception);
|
logger.error("失败", exception);
|
||||||
}
|
}
|
||||||
} else {
|
} else { // 西海岸普通资源
|
||||||
logger.info("西海岸基普通");
|
logger.info("西海岸基普通");
|
||||||
if (resourceDTO.getInfoList().isEmpty()) {
|
resultPage = common(resultPage, selectDTOPageSpecilTotal, resourceDTO, orderField, orderType, pageNum, pageSize);
|
||||||
List<ResourceDTO> resourceDTOS = null;
|
|
||||||
if (orderField.equals("total")) { // 对总体评价特殊处理
|
|
||||||
List<Long> ids = new ArrayList<>();
|
|
||||||
switch (orderType) {
|
|
||||||
case "DESC": // total 倒序
|
|
||||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
|
||||||
Map index = (Map) x;
|
|
||||||
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
|
|
||||||
return Long.valueOf(string);
|
|
||||||
}
|
|
||||||
).reversed()).skip((pageNum - 1) * pageSize).limit(pageSize).map(x ->
|
|
||||||
Long.valueOf(x.get("id").toString())
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
case "ASC": // total 升序
|
|
||||||
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
|
||||||
String string = (x.get("total") == null) ? "0" : x.get("total").toString();
|
|
||||||
return Long.valueOf(string);
|
|
||||||
}
|
|
||||||
)).skip((pageNum - 1) * pageSize).limit(pageSize).map(x ->
|
|
||||||
Long.valueOf(x.get("id").toString())
|
|
||||||
).collect(Collectors.toList());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
|
|
||||||
} else {
|
|
||||||
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType, null);
|
|
||||||
}
|
|
||||||
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
|
||||||
ResourceDTO index = (ResourceDTO) x;
|
|
||||||
return index.getTotal() == null ? 0L : index.getTotal();
|
|
||||||
}).reversed()).collect(Collectors.toList()));
|
|
||||||
resultPage.setTotal(resourceDao.selectDTOPageCount(resourceDTO));
|
|
||||||
} else {
|
|
||||||
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
|
|
||||||
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
|
|
||||||
if (resourceDTOS.isEmpty()) {
|
|
||||||
resultPage.setRecords(null);
|
|
||||||
resultPage.setTotal(0);
|
|
||||||
} else {
|
|
||||||
List<ResourceDTO> recordLists = resourceDTOS.stream()
|
|
||||||
.skip((pageNum - 1) * pageSize).limit(pageSize)
|
|
||||||
.map(dto_ -> {
|
|
||||||
ResourceDTO get = this.selectWithAttrs(dto_.getId());
|
|
||||||
BeanUtils.copyProperties(get, dto_);
|
|
||||||
return dto_;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
resultPage.setRecords(recordLists);
|
|
||||||
resultPage.setTotal(resourceDTOS.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -540,10 +430,84 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
return resultPage;
|
return resultPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从本库内查询
|
||||||
|
*
|
||||||
|
* @param resultPage
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Page<ResourceDTO> common(Page<ResourceDTO> resultPage, List<Map> selectDTOPageSpecilTotal, ResourceDTO resourceDTO, String orderField, String orderType, Integer pageNum, Integer pageSize) {
|
||||||
|
if (resourceDTO.getInfoList().isEmpty()) {
|
||||||
|
List<ResourceDTO> resourceDTOS;
|
||||||
|
if (orderField.equals("total")) { // 对总体评价特殊处理
|
||||||
|
List<Long> ids = new ArrayList<>();
|
||||||
|
switch (orderType) {
|
||||||
|
case "DESC": // total 倒序
|
||||||
|
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
||||||
|
Map index = (Map) x;
|
||||||
|
String string = (index.get("total") == null) ? "0" : index.get("total").toString();
|
||||||
|
return Long.valueOf(string);
|
||||||
|
}
|
||||||
|
).reversed()).skip((long) (pageNum - 1) * pageSize).limit(pageSize).map(x ->
|
||||||
|
Long.valueOf(x.get("id").toString())
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
case "ASC": // total 升序
|
||||||
|
ids = selectDTOPageSpecilTotal.parallelStream().map(Map.class::cast).sorted(Comparator.comparing(x -> {
|
||||||
|
String string = (x.get("total") == null) ? "0" : x.get("total").toString();
|
||||||
|
return Long.valueOf(string);
|
||||||
|
}
|
||||||
|
)).skip((pageNum - 1) * pageSize).limit(pageSize).map(x ->
|
||||||
|
Long.valueOf(x.get("id").toString())
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, null, null, null, null, ids);
|
||||||
|
if ("DESC".equals(orderType)) {
|
||||||
|
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||||
|
ResourceDTO index = (ResourceDTO) x;
|
||||||
|
return index.getTotal() == null ? 0L : index.getTotal();
|
||||||
|
}).reversed()).collect(Collectors.toList()));
|
||||||
|
} else {
|
||||||
|
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
|
||||||
|
ResourceDTO index = x;
|
||||||
|
return index.getTotal() == null ? 0L : index.getTotal();
|
||||||
|
})).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
} else { // 非总体评价排序时
|
||||||
|
resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1) * pageSize, pageSize, orderField, orderType, null);
|
||||||
|
}
|
||||||
|
resultPage.setRecords(resourceDTOS);
|
||||||
|
resultPage.setTotal(resourceDao.selectDTOPageCount(resourceDTO));
|
||||||
|
} else {
|
||||||
|
logger.info("orderField:{} orderType:{}", orderField, orderType);
|
||||||
|
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
|
||||||
|
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
|
||||||
|
if (resourceDTOS.isEmpty()) {
|
||||||
|
resultPage.setRecords(null);
|
||||||
|
resultPage.setTotal(0);
|
||||||
|
} else {
|
||||||
|
List<ResourceDTO> recordLists = resourceDTOS.stream()
|
||||||
|
.skip((pageNum - 1) * pageSize).limit(pageSize)
|
||||||
|
.map(dto_ -> {
|
||||||
|
ResourceDTO get = this.selectWithAttrs(dto_.getId());
|
||||||
|
BeanUtils.copyProperties(get, dto_);
|
||||||
|
return dto_;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
resultPage.setRecords(recordLists);
|
||||||
|
resultPage.setTotal(resourceDTOS.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resultPage;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AttrEntity> selectAttrsByResourceId(Long resourceId) {
|
public List<AttrEntity> selectAttrsByResourceId(Long resourceId) {
|
||||||
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
|
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("data_resource_id", resourceId).eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).orderByDesc("attr_type");
|
wrapper.eq("data_resource_id", resourceId)
|
||||||
|
.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
|
||||||
|
.orderByDesc("attr_type");
|
||||||
return attrDao.selectList(wrapper);
|
return attrDao.selectList(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,10 +123,8 @@
|
||||||
AND tdr.del_flag = 0
|
AND tdr.del_flag = 0
|
||||||
<if test="dto.type != null and dto.type != ''">
|
<if test="dto.type != null and dto.type != ''">
|
||||||
AND MATCH (tdr.type) AGAINST ( #{dto.type} IN BOOLEAN MODE)
|
AND MATCH (tdr.type) AGAINST ( #{dto.type} IN BOOLEAN MODE)
|
||||||
<!--AND tdr.type LIKE CONCAT('%',#{dto.type},'%') -->
|
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.name != null and dto.name != ''">
|
<if test="dto.name != null and dto.name != ''">
|
||||||
<!-- AND tdr.name LIKE CONCAT('%',#{dto.name},'%') -->
|
|
||||||
AND MATCH (tdr.name) AGAINST ( #{dto.name} IN BOOLEAN MODE)
|
AND MATCH (tdr.name) AGAINST ( #{dto.name} IN BOOLEAN MODE)
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.districtId != null and dto.districtId != ''">
|
<if test="dto.districtId != null and dto.districtId != ''">
|
||||||
|
@ -162,7 +160,9 @@
|
||||||
) tmp
|
) tmp
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
ORDER BY ${orderField} ${orderType}
|
<if test="orderField != null and orderField !=''">
|
||||||
|
ORDER BY ${orderField} ${orderType}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTypeCount" resultType="java.util.Map">
|
<select id="selectTypeCount" resultType="java.util.Map">
|
||||||
|
@ -428,6 +428,7 @@
|
||||||
<if test="dto.deptId != null and dto.deptId != ''">
|
<if test="dto.deptId != null and dto.deptId != ''">
|
||||||
AND tdr.dept_id = #{dto.deptId}
|
AND tdr.dept_id = #{dto.deptId}
|
||||||
</if>
|
</if>
|
||||||
|
ORDER BY create_date DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDTOPageCount" resultType="java.lang.Long">
|
<select id="selectDTOPageCount" resultType="java.lang.Long">
|
||||||
|
|
Loading…
Reference in New Issue