|
@@ -1,6 +1,5 @@
|
|
|
package com.github.jfcloud.gene.lis.controller;
|
|
package com.github.jfcloud.gene.lis.controller;
|
|
|
|
|
|
|
|
-import cn.hutool.core.util.DesensitizedUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.db.Entity;
|
|
import cn.hutool.db.Entity;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -21,10 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
-import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -65,7 +61,7 @@ public class SampleLisController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//计数
|
|
//计数
|
|
|
- Entity countEntity = lisDb.queryOne("select count(*)as num from (" + sql + ") tmp");
|
|
|
|
|
|
|
+ Entity countEntity = lisDb.queryOne("select count(*) as num from (" + sql + ") tmp");
|
|
|
Long num = countEntity.getLong("num");
|
|
Long num = countEntity.getLong("num");
|
|
|
if (num < 1) {
|
|
if (num < 1) {
|
|
|
return R.ok(new PageDTO<>());
|
|
return R.ok(new PageDTO<>());
|
|
@@ -91,31 +87,25 @@ public class SampleLisController {
|
|
|
"from HT_BAS_DEP_USER hbpu " +
|
|
"from HT_BAS_DEP_USER hbpu " +
|
|
|
"left join HT_INFO_DEP hid on hbpu.DEP_ID = hid.ID " +
|
|
"left join HT_INFO_DEP hid on hbpu.DEP_ID = hid.ID " +
|
|
|
"left join HT_INFO_USER_EXTEND hiue on hbpu.USER_ID = hiue.USER_ID " +
|
|
"left join HT_INFO_USER_EXTEND hiue on hbpu.USER_ID = hiue.USER_ID " +
|
|
|
- "where hbpu.STATUS=1 and hbpu.HSP_ID=%d ";
|
|
|
|
|
- sql = String.format(sql, depId);
|
|
|
|
|
|
|
+ "where hbpu.STATUS=1 and hid.HSP_ID=" + depId;
|
|
|
if (StrUtil.isNotBlank(name)) {
|
|
if (StrUtil.isNotBlank(name)) {
|
|
|
- sql += "and hiue.name like N'%" + name + "%'";
|
|
|
|
|
|
|
+ sql += " and hiue.name like N'%" + name + "%'";
|
|
|
}
|
|
}
|
|
|
- sql += String.format(" order by hiue.user_id desc offset %d rows fetch next %d rows only", page.offset(), page.getSize());
|
|
|
|
|
- List<Entity> entities = lisDb.query(sql);
|
|
|
|
|
- //lis数据库有重复数据,去重,后面的覆盖前面的
|
|
|
|
|
- Map<String, Entity> nameMap = entities.stream().collect(Collectors.toMap(entity -> entity.getStr("name"), Function.identity(), (a, b) -> b));
|
|
|
|
|
- if (nameMap.isEmpty()) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //计数
|
|
|
|
|
+ Entity countEntity = lisDb.queryOne("select count(*) as num from (" + sql + ") tmp");
|
|
|
|
|
+ Long num = countEntity.getLong("num");
|
|
|
|
|
+ if (num < 1) {
|
|
|
return R.ok(new PageDTO<>());
|
|
return R.ok(new PageDTO<>());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- List<DeptUserItem> items = nameMap.values().stream()
|
|
|
|
|
- .map(entity -> {
|
|
|
|
|
- DeptUserItem userItem = entity.toBeanWithCamelCase(new DeptUserItem());
|
|
|
|
|
- //手机号脱敏
|
|
|
|
|
- userItem.setPhone(DesensitizedUtil.mobilePhone(userItem.getPhone()));
|
|
|
|
|
- return userItem;
|
|
|
|
|
- })
|
|
|
|
|
- .sorted(Comparator.comparingLong(DeptUserItem::getUserId))
|
|
|
|
|
- .skip(page.offset())
|
|
|
|
|
- .limit(page.getSize())
|
|
|
|
|
|
|
+ //分页
|
|
|
|
|
+ sql += String.format(" order by hiue.user_id desc offset %d rows fetch next %d rows only", page.offset(), page.getSize());
|
|
|
|
|
+ List<Entity> entities = lisDb.query(sql);
|
|
|
|
|
+ List<DeptUserItem> items = entities.stream()
|
|
|
|
|
+ .map(entity -> entity.toBeanWithCamelCase(new DeptUserItem()))
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
- Page<DeptUserItem> pageResult = PageDTO.of(page.getCurrent(), page.getSize(), nameMap.size());
|
|
|
|
|
|
|
+ Page<DeptUserItem> pageResult = PageDTO.of(page.getCurrent(), page.getSize(), num);
|
|
|
pageResult.setRecords(items);
|
|
pageResult.setRecords(items);
|
|
|
return R.ok(pageResult);
|
|
return R.ok(pageResult);
|
|
|
}
|
|
}
|