Commit 9ff416f8 authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents e95244d1 e017cd4e
...@@ -232,7 +232,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -232,7 +232,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
List<AppUserLogin> appUserLogins = mapper.selectbyPhones(phones); List<AppUserLogin> appUserLogins = mapper.selectbyPhones(phones);
Map<String, Integer> phoneAndUserIdMap = null; Map<String, Integer> phoneAndUserIdMap = null;
if (CollectionUtils.isNotEmpty(appUserLogins)) { if (CollectionUtils.isNotEmpty(appUserLogins)) {
phoneAndUserIdMap = appUserLogins.stream().collect(Collectors.toMap(AppUserLogin::getUsername, AppUserLogin::getId)); phoneAndUserIdMap = appUserLogins.parallelStream().collect(Collectors.toMap(AppUserLogin::getUsername, AppUserLogin::getId));
} }
return phoneAndUserIdMap; return phoneAndUserIdMap;
} }
......
...@@ -130,7 +130,7 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A ...@@ -130,7 +130,7 @@ public class AppUserPositionTempBiz extends BaseBiz<AppUserPositionTempMapper, A
BeanUtils.copyProperties(appUserPositionTemp, appUserPositionTempVo); BeanUtils.copyProperties(appUserPositionTemp, appUserPositionTempVo);
String postionName = postionMap == null ? "" : postionMap.get(appUserPositionTemp.getPositionId())==null?"":postionMap.get(appUserPositionTemp.getPositionId()).getName(); String postionName = postionMap == null ? "" : postionMap.get(appUserPositionTemp.getPositionId())==null?"":postionMap.get(appUserPositionTemp.getPositionId()).getName();
appUserPositionTempVo.setPositionName(postionName); appUserPositionTempVo.setPositionName(postionName);
appUserPositionTempVo.setStatus(appUserPositionTemp.getUserId() == null ? DataStatus.NO_USERED.code : DataStatus.USERED.code); appUserPositionTempVo.setStatus(appUserPositionTemp.getUserId() == null ? DataStatus.NO_USERED.code : appUserPositionTemp.getUserId()==0?DataStatus.NO_USERED.code:DataStatus.USERED.code);
appUserPositionTempVos.add(appUserPositionTempVo); appUserPositionTempVos.add(appUserPositionTempVo);
} }
......
...@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -24,6 +25,8 @@ import tk.mybatis.mapper.entity.Example; ...@@ -24,6 +25,8 @@ import tk.mybatis.mapper.entity.Example;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -47,6 +50,11 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper, ...@@ -47,6 +50,11 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
@Autowired @Autowired
private AppUserLoginBiz appUserLoginBiz; private AppUserLoginBiz appUserLoginBiz;
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
private final int BORDER_NUM=250;
public void saveUserMember(UserMemberSaveDTO userMemberSaveDTO, Integer userId, String name) { public void saveUserMember(UserMemberSaveDTO userMemberSaveDTO, Integer userId, String name) {
if (userMemberSaveDTO != null) { if (userMemberSaveDTO != null) {
...@@ -95,15 +103,37 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper, ...@@ -95,15 +103,37 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
List<BaseUserMemberExport> baseUserMemberExports = new ArrayList<>(); List<BaseUserMemberExport> baseUserMemberExports = new ArrayList<>();
List<BaseUserMemberLevel> levesls = userMemberLevelBiz.getLevesls(); List<BaseUserMemberLevel> levesls = userMemberLevelBiz.getLevesls();
Map<Integer, BaseUserMemberLevel> levelAndbaseUserMemberMap = levesls.stream().collect(Collectors.toMap(BaseUserMemberLevel::getLevel, Function.identity())); Map<Integer, BaseUserMemberLevel> levelAndbaseUserMemberMap = levesls.parallelStream().collect(Collectors.toMap(BaseUserMemberLevel::getLevel, Function.identity()));
Map<String,Integer> leavelNameAndLeaveMap = levelAndbaseUserMemberMap.values().stream().collect(Collectors.toMap(BaseUserMemberLevel::getName, BaseUserMemberLevel::getLevel)); Map<String,Integer> leavelNameAndLeaveMap = levelAndbaseUserMemberMap.values().parallelStream().collect(Collectors.toMap(BaseUserMemberLevel::getName, BaseUserMemberLevel::getLevel));
List<String> phones = userMemberData.stream().map(x -> x[0]).distinct().collect(Collectors.toList()); List<String> phones = userMemberData.stream().map(x -> x[0]).distinct().collect(Collectors.toList());
Map<String, Integer> phoneAndUserIdMap = appUserLoginBiz.findPhoneAndUserIdMapByPhones(phones); Map<String, Integer> phoneAndUserIdMap = appUserLoginBiz.findPhoneAndUserIdMapByPhones(phones);
Set<Map.Entry<String, Integer>> leaveNameAndLeaveEntry = leavelNameAndLeaveMap.entrySet(); Set<Map.Entry<String, Integer>> leaveNameAndLeaveEntry = leavelNameAndLeaveMap.entrySet();
Integer memberLevel =1; Integer memberLevel =1;
Integer discount = 0; Integer discount = 0;
for (String[] data : userMemberData) { AtomicInteger counter = new AtomicInteger(0);
int threadNums= userMemberData.size()/BORDER_NUM==0?1:userMemberData.size()/BORDER_NUM;
CountDownLatch latch = new CountDownLatch(threadNums);
for (int i=0;i<threadNums;i++){
int startIndex = i*BORDER_NUM;
int endIndex=i==(threadNums-1)?userMemberData.size():(i+1)*BORDER_NUM;
List<String[]> subResultDate = userMemberData.subList(startIndex,endIndex);
threadPoolTaskExecutor.execute(()->{
wrapperData(subResultDate, userId, userName, baseUserMemberExports, levelAndbaseUserMemberMap, phoneAndUserIdMap, leaveNameAndLeaveEntry, memberLevel, discount, counter);
latch.countDown();
});
}
try {
latch.await();
} catch (InterruptedException e) {
throw new BaseException("导入数据失败");
}
InsertBatch(baseUserMemberExports);
return baseUserMemberExports.size();
}
private void wrapperData(List<String[]> userMemberData, Integer userId, String userName, List<BaseUserMemberExport> baseUserMemberExports, Map<Integer, BaseUserMemberLevel> levelAndbaseUserMemberMap, Map<String, Integer> phoneAndUserIdMap, Set<Map.Entry<String, Integer>> leaveNameAndLeaveEntry, Integer memberLevel, Integer discount, AtomicInteger counter) {
for (String[] data : userMemberData) {
counter.incrementAndGet();
String phone = data[0]; String phone = data[0];
String memberLevelName = data[1]; String memberLevelName = data[1];
String memberName = data[2]; String memberName = data[2];
...@@ -131,6 +161,7 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper, ...@@ -131,6 +161,7 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
try { try {
baseUserMemberBiz.updUserMemberByUserId(userMemberDTO); baseUserMemberBiz.updUserMemberByUserId(userMemberDTO);
} catch (Exception e) { } catch (Exception e) {
log.error("当前行数:【{}】",counter.get());
log.error("会员更新错误:【{}】", e.getMessage()); log.error("会员更新错误:【{}】", e.getMessage());
throw new BaseException(e); throw new BaseException(e);
} }
...@@ -138,7 +169,7 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper, ...@@ -138,7 +169,7 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
BaseUserMemberExport memberExport = BaseUserMemberExport BaseUserMemberExport memberExport = BaseUserMemberExport
.builder() .builder()
.username(phone) .username(phone.trim())
.memberLevel(memberLevel) .memberLevel(memberLevel)
.totalNumber(Integer.valueOf(totalNumber)) .totalNumber(Integer.valueOf(totalNumber))
.rentFreeDays(Integer.valueOf(rentFreeDays)) .rentFreeDays(Integer.valueOf(rentFreeDays))
...@@ -155,9 +186,6 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper, ...@@ -155,9 +186,6 @@ public class BaseUserMemberExportBiz extends BaseBiz<BaseUserMemberExportMapper,
} }
baseUserMemberExports.add(memberExport); baseUserMemberExports.add(memberExport);
} }
InsertBatch(baseUserMemberExports);
return baseUserMemberExports.size();
} }
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
......
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
REPLACE(GROUP_CONCAT( DISTINCT t.`name`),',','|')as name1 REPLACE(GROUP_CONCAT( DISTINCT t.`name`),',','|')as name1
from tour_good g from tour_good g
LEFT JOIN (SELECT * FROM tour_good_tag WHERE is_del=0) tag ON g.id=tag.good_id LEFT JOIN (SELECT * FROM tour_good_tag WHERE is_del=0) tag ON g.id=tag.good_id
LEFT JOIN (SELECT * FROM tour_tag WHERE is_del=0) t ON tag.tag_id=t.id LEFT JOIN (SELECT * FROM tour_tag WHERE is_del=0 and name!='全部') t ON tag.tag_id=t.id
where g.recommend=1 and g.status=1 and g.is_del=0 where g.recommend=1 and g.status=1 and g.is_del=0
GROUP BY g.id GROUP BY g.id
ORDER BY g.rank DESC ,g.id DESC ORDER BY g.rank DESC ,g.id DESC
......
...@@ -9,4 +9,7 @@ public class CompanySearchDTO { ...@@ -9,4 +9,7 @@ public class CompanySearchDTO {
Integer addrCity; Integer addrCity;
String lon; String lon;
String lat; String lat;
Integer state;
Integer isShow = 1;
Integer isDel = 0;
} }
...@@ -208,7 +208,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany ...@@ -208,7 +208,7 @@ public class BranchCompanyBiz extends BaseBiz<BranchCompanyMapper, BranchCompany
public PageDataVO<BranchCompany> search(CompanySearchDTO vo) { public PageDataVO<BranchCompany> search(CompanySearchDTO vo) {
PageHelper.startPage(vo.getPage(), vo.getLimit()); PageHelper.startPage(vo.getPage(), vo.getLimit());
PageInfo<BranchCompany> branchCompanyPageInfo = new PageInfo<>(mapper.search(vo.getLon(), vo.getLat(), vo.getAddrCity())); PageInfo<BranchCompany> branchCompanyPageInfo = new PageInfo<>(mapper.search(vo.getLon(), vo.getLat(), vo.getAddrCity(), vo.getState(), vo.getIsShow(), vo.getIsDel()));
return PageDataVO.pageInfo(branchCompanyPageInfo); return PageDataVO.pageInfo(branchCompanyPageInfo);
} }
......
...@@ -12,7 +12,7 @@ import java.util.List; ...@@ -12,7 +12,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdListMapper<BranchCompany,Integer> { public interface BranchCompanyMapper extends Mapper<BranchCompany>, SelectByIdListMapper<BranchCompany,Integer> {
List<BranchCompany> search(@Param("lon") String lon, @Param("lat") String lat, @Param("addrCity") Integer addrCity); List<BranchCompany> search(@Param("lon") String lon, @Param("lat") String lat, @Param("addrCity") Integer addrCity, Integer state, Integer isShow, Integer isDel);
List<BranchCompany> selectByZoneId(Map<String, Object> param); List<BranchCompany> selectByZoneId(Map<String, Object> param);
List<Integer> findCompanyIdsByAreaId(@Param("areaId") Integer areaId); List<Integer> findCompanyIdsByAreaId(@Param("areaId") Integer areaId);
......
...@@ -36,6 +36,15 @@ ...@@ -36,6 +36,15 @@
<if test="lon != null and lat != null"> <if test="lon != null and lat != null">
and longitude is not null and latitude is not null and longitude is not null and latitude is not null
</if> </if>
<if test="state != null">
and state = #{state}
</if>
<if test="isShow != null">
and is_show = #{isShow}
</if>
<if test="isDel != null">
and is_del = #{isDel}
</if>
</where> </where>
<if test="lon != null and lat != null"> <if test="lon != null and lat != null">
order by distance asc order by distance asc
......
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