Commit 4b627354 authored by zuoadmin's avatar zuoadmin

Merge branch 'dev' into 'master'

Dev

See merge request !19
parents f8548932 80c048fe
......@@ -122,7 +122,7 @@ public class PushCallBackServiceImpl extends ServiceImpl<PushCallBackDao, PushCa
List<PushCallBackEntity> list = new ArrayList<>();
while (matcher.find()) {
String group = matcher.group(1);
log.error("回调信息:{}", group);
log.info("回调信息:{}", group);
PushCallBackEntity callBackInfo = JSONObject.parseObject(group, PushCallBackEntity.class);
String desc = JSONObject.parseObject(group).getString("desc");
callBackInfo.setDescStr(desc);
......
......@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weface.code.CommonResult;
import com.weface.common.utils.CommonUtil;
import com.weface.common.utils.SnowIdUtil;
import com.weface.dao.UserMenusDao;
import com.weface.dto.UserMenuFrom;
......@@ -33,34 +34,30 @@ public class UserMenusServiceImpl extends ServiceImpl<UserMenusDao, UserMenusEnt
*/
@Override
public void batchInsert(List<UserMenusEntity> userMenusList) {
if (CollUtil.isNotEmpty(userMenusList)) {
List<String> deleteUid = getDeleteUid(userMenusList);
//批量插入前全删
List<Long> ids = this.baseMapper.findIdByUserId(deleteUid);
this.removeByIds(ids);
//获取集合长度
int count = userMenusList.size();
//每次批量插入个数
int limit = 10000;
int sum = 0;
//计算页数
int totalPage = (count % limit == 0) ? (count / limit) : (count / limit + 1);
for (int i = 0; i < totalPage; i++) {
List<UserMenusEntity> userMenusEntities = new ArrayList<>(10000);
//如果是最后一页,则截取到最后
if (i == totalPage - 1) {
userMenusEntities = userMenusList.subList(i * limit, count);
try {
if (CollUtil.isNotEmpty(userMenusList)) {
List<String> deleteUid = getDeleteUid(userMenusList);
List<List<String>> lists = CommonUtil.fixedGrouping(deleteUid, 10000);
for (List<String> list : lists) {
//批量插入前全删
List<Long> ids = this.baseMapper.findIdByUserId(list);
this.removeByIds(ids);
}
int sum = 0;
List<List<UserMenusEntity>> tagLists = CommonUtil.fixedGrouping(userMenusList, 10000);
for (List<UserMenusEntity> tagList : tagLists) {
//批量插入每次一万条
sum += this.baseMapper.batchInsert(tagList);
}
if (sum > 0) {
log.warn("新增成功记录=={}==条", sum);
} else {
userMenusEntities = userMenusList.subList(i * limit, (i + 1) * limit);
log.error("新增失败");
}
//批量插入每次一万条
sum += this.baseMapper.batchInsert(userMenusEntities);
}
if (sum > 0) {
log.warn("新增成功记录=={}==条", sum);
} else {
log.error("新增失败");
}
} catch (Exception e) {
e.printStackTrace();
log.error("新增用户标签失败{}", e.getMessage());
}
}
......
......@@ -22,10 +22,17 @@
<!-- 根据uid查询标签id-->
<select id="findIdByUserId" resultType="long">
SELECT id FROM tb_user_menus WHERE is_valid = 1 AND user_id IN
SELECT
um.id
FROM
( SELECT id, tags_id FROM tb_user_menus WHERE is_valid = 1 AND user_id IN
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
) um
LEFT JOIN tb_menu_tags mt ON um.tags_id = mt.id
WHERE
mt.is_custom = 0
</select>
</mapper>
\ No newline at end of file
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