Commit b5a47723 authored by licc's avatar licc

新增向下层级接口

parent d53cf35f
......@@ -4,6 +4,8 @@ import cn.wisenergy.model.app.UserData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author 86187
*/
......@@ -16,4 +18,6 @@ public interface UserDataMapper extends BaseMapper<UserData> {
UserData getByUserId(@Param("userId") Long userId);
Long getMaxId();
List<UserData> getBottom(@Param("startNo") Integer startNumber, @Param("endNo") Integer endNo);
}
package cn.wisenergy.mapper;
import cn.wisenergy.model.app.UserData;
import cn.wisenergy.model.app.Users;
import cn.wisenergy.model.dto.UserDto;
import cn.wisenergy.model.dto.UserSimpleInfoDto;
......
......@@ -105,7 +105,14 @@
</select>
<select id="getMaxId" resultType="java.lang.Long">
select user_id from user_data order by user_id desc limit 1
select user_id from user_data where bottom is null order by user_id limit 1
</select>
<select id="getBottom" resultMap="userMap">
select *
from
<include refid="table"/>
limit #{startNo},#{endNo}
</select>
</mapper>
......@@ -174,7 +174,7 @@
<select id="getLevelAndTotal" resultType="cn.wisenergy.model.dto.UsersInfoDto">
SELECT u1.rank,u2.count
SELECT u1.rank as bottom,u2.count as totalPeople
FROM
users u1,(select count(*) 'count',max(LENGTH(path)) 'maxrank'
from users
......@@ -258,4 +258,5 @@ GROUP BY user_id
order by u.id
</select>
</mapper>
......@@ -29,4 +29,18 @@ public class UserDataManger {
}
return true;
}
@Transactional(rollbackFor = Exception.class)
public boolean updateBatchUserData(List<UserData> list) {
if (!CollectionUtils.isEmpty(list)) {
for (UserData userData : list) {
int count = userDataMapper.edit(userData);
if (count == 0) {
return false;
}
}
}
return true;
}
}
......@@ -15,4 +15,12 @@ public interface UserDataService {
*/
R<Boolean> addBatch(UserQueryVo queryVo);
/**
* 获取向下层级
*
* @param queryVo 条数
* @return true or false
*/
R<Boolean> getBottom(UserQueryVo queryVo);
}
......@@ -119,4 +119,34 @@ public class UserDataServiceImpl implements UserDataService {
}
return R.ok(0, true);
}
@Override
public R<Boolean> getBottom(UserQueryVo queryVo) {
Long usersId = userDataMapper.getMaxId();
if (null == usersId) {
usersId = 0L;
}
Integer startNo = Math.toIntExact(usersId)-1;
Integer endNo = queryVo.getNumber();
//获取所有用户数据
List<UserData> list = userDataMapper.getBottom(startNo, endNo);
if (!CollectionUtils.isEmpty(list)) {
for (UserData userData : list) {
//3、向下最深层级层级数、伞下人员总和
UsersInfoDto userInfoDto = usersMapper.getLevelAndTotal(userData.getUserId());
if (null != userInfoDto) {
if (null != userInfoDto.getBottom()) {
userData.setBottom(userInfoDto.getBottom() - userData.getRank());
}
userData.setTotalPeople(userInfoDto.getTotalPeople());
}
}
boolean bool = userDataManger.updateBatchUserData(list);
if (!bool) {
return R.ok(1, false);
}
}
return R.ok(0, true);
}
}
......@@ -169,6 +169,9 @@
<orderEntry type="library" name="Maven: org.glassfish.jaxb:txw2:2.3.3" level="project" />
<orderEntry type="library" name="Maven: com.sun.istack:istack-commons-runtime:3.0.11" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.activation:jakarta.activation:1.2.2" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.13.2" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.2" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.2" level="project" />
<orderEntry type="library" name="Maven: com.hikvision.ga:artemis-http-client:1.1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.11" level="project" />
......
......@@ -30,4 +30,11 @@ public class UserDataController {
public R<Boolean> saveBatchUserData(@RequestBody UserQueryVo queryVo) {
return userDataService.addBatch(queryVo);
}
@ApiOperation(value = "向下最深层级层级数、伞下人员总和", notes = "向下最深层级层级数、伞下人员总和", httpMethod = "POST")
@ApiImplicitParam(name = "queryVo", value = "每次统计条数", dataType = "UserQueryVo")
@PostMapping(value = "/user/updateBatchUserData")
public R<Boolean> updateBatchUserData(@RequestBody UserQueryVo queryVo) {
return userDataService.getBottom(queryVo);
}
}
......@@ -17,7 +17,7 @@ spring:
allow-bean-definition-overriding: true
# 环境 dev|test|prod
profiles:
active: dev
active: prod
# jackson时间格式化
jackson:
time-zone: GMT+8
......
......@@ -146,6 +146,9 @@
<orderEntry type="library" name="Maven: org.glassfish.jaxb:txw2:2.3.3" level="project" />
<orderEntry type="library" name="Maven: com.sun.istack:istack-commons-runtime:3.0.11" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.sun.activation:jakarta.activation:1.2.2" level="project" />
<orderEntry type="library" name="Maven: junit:junit:4.13.2" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:2.2" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest:2.2" level="project" />
<orderEntry type="library" name="Maven: com.hikvision.ga:artemis-http-client:1.1.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment