Commit 64eb8aac by 田超

Merge branch 'fixbug/1003971' into 'master'

fixbug:[1003971]  finish fillTypeCode

See merge request rays/pcloud-book!1180
parents 285377ba 36fc129d
...@@ -118,4 +118,9 @@ public interface ServeCollectBiz { ...@@ -118,4 +118,9 @@ public interface ServeCollectBiz {
*/ */
void processingData(); void processingData();
/**
* 填充收藏TypeCode和TypeName
*/
void processingData2TypeCode();
} }
\ No newline at end of file
package com.pcloud.book.applet.biz.impl; package com.pcloud.book.applet.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.pcloud.appcenter.app.dto.AppDto; import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.dto.AppTypeDto; import com.pcloud.appcenter.app.dto.AppTypeDto;
...@@ -486,6 +487,90 @@ public class ServeCollectBizImpl implements ServeCollectBiz { ...@@ -486,6 +487,90 @@ public class ServeCollectBizImpl implements ServeCollectBiz {
return serveCollectDao.getDistinctTypeCode(); return serveCollectDao.getDistinctTypeCode();
} }
/**
* 填充数据:typeCode,typeName
*/
public void processingData2TypeCode(){
int currentPage = 0;
while(true){
PageBeanNew<ServeCollect> pageBeanNew = serveCollectDao.listPageNew(new PageParam(currentPage, 1000), null, "List2ProcessedData");
if (CollUtil.isEmpty(pageBeanNew.getRecordList())){
return;
}
fillTypeCodeAndTypeName(pageBeanNew.getRecordList());
currentPage++;
serveCollectDao.batchUpdate(pageBeanNew.getRecordList());
}
}
private void fillTypeCodeAndTypeName(List<ServeCollect> recordList){
List<Long> productsIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.PRODUCT.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList());
List<Long> appIdList = recordList.stream().filter(serveCollect -> AppletRecordTypeEnum.APP.value.equals(serveCollect.getServeType())).
map(serveCollect -> serveCollect.getServeId()).collect(Collectors.toList());
Map<Long,ProductDto> productDtoMap = new HashMap<>();
Future<Map<Long,ProductDto>> productDtoMapFuture = null;
Map<Long,AppDto> appDtoMap = new HashMap<>();
Future<Map<Long,AppDto>> appDtoMapFuture = null;
if (!CollUtil.isEmpty(productsIdList)){
productDtoMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> productConsr.getProBasesByIds(productsIdList));
}
if (!CollUtil.isEmpty(appIdList)){
appDtoMapFuture = ThreadPoolUtils.FILL_APPLET_RECORD.submit(() -> appConsr.mapByIds4AuditPass(appIdList));
}
Iterator<ServeCollect> iterator = recordList.iterator();
while(iterator.hasNext()){
ServeCollect serveCollect = iterator.next();
if (Objects.equals(AppletRecordTypeEnum.PRODUCT.value,serveCollect.getServeType())){
fillProTypeNameAndTypeCode(productDtoMap,productDtoMapFuture,serveCollect);
}
if (Objects.equals(AppletRecordTypeEnum.APP.value,serveCollect.getServeType())){
fillAppTypeNameAndTypeCode(appDtoMap,appDtoMapFuture,serveCollect);
}
}
}
/**
* 填充product收藏的TypeName与TypeCode
* @param productDtoMap
* @param productDtoMapFuture
* @param serveCollect
*/
private void fillProTypeNameAndTypeCode(Map<Long,ProductDto> productDtoMap,Future<Map<Long,ProductDto>> productDtoMapFuture,ServeCollect serveCollect){
try{
productDtoMap = productDtoMapFuture.get();
}catch (InterruptedException | ExecutionException e){
LOGGER.error("获取商品详情错误: {}==", e);
}
if (CollUtil.isEmpty(productDtoMap)){
return;
}
if ( null != productDtoMap.get(serveCollect.getServeId())){
serveCollect.setServeTypeCode(productDtoMap.get(serveCollect.getServeId()).getProductTypeCode());
serveCollect.setServeTypeName(productDtoMap.get(serveCollect.getServeId()).getProductTypeName());
}
}
private void fillAppTypeNameAndTypeCode(Map<Long,AppDto> appDtoMap,Future<Map<Long,AppDto>> appDtoMapFuture,ServeCollect serveCollect){
try {
appDtoMap = appDtoMapFuture.get();
}catch (InterruptedException | ExecutionException e){
LOGGER.error("获取App详情错误:{}==",e);
}
if (CollUtil.isEmpty(appDtoMap)){
return;
}
if (null != appDtoMap.get(serveCollect.getServeId())){
serveCollect.setServeTypeCode(appDtoMap.get(serveCollect.getServeId()).getTypeCode());
serveCollect.setServeTypeName(appDtoMap.get(serveCollect.getServeId()).getTypeName());
}
}
@Override @Override
public List<Long> getAllCollect(Long wechatUserId,String typeCode) { public List<Long> getAllCollect(Long wechatUserId,String typeCode) {
return serveCollectDao.getAllCollect(wechatUserId,typeCode); return serveCollectDao.getAllCollect(wechatUserId,typeCode);
......
...@@ -36,4 +36,8 @@ public interface ServeCollectDao extends BaseDao<ServeCollect> { ...@@ -36,4 +36,8 @@ public interface ServeCollectDao extends BaseDao<ServeCollect> {
List<CollectionTypeNameCodeClassifyVO> getDistinctTypeCode(); List<CollectionTypeNameCodeClassifyVO> getDistinctTypeCode();
void updateTypeName(Map<String,String> paramMap); void updateTypeName(Map<String,String> paramMap);
List<ServeCollect> List2ProcessedData();
void batchUpdate(List<ServeCollect> serveCollectList);
} }
\ No newline at end of file
...@@ -66,6 +66,16 @@ public class ServeCollectDaoImpl extends BaseDaoImpl<ServeCollect> implements Se ...@@ -66,6 +66,16 @@ public class ServeCollectDaoImpl extends BaseDaoImpl<ServeCollect> implements Se
} }
@Override @Override
public List<ServeCollect> List2ProcessedData() {
return null;
}
@Override
public void batchUpdate(List<ServeCollect> serveCollectList) {
getSessionTemplate().update(getStatement("batchUpdate"),serveCollectList);
}
@Override
public List<Long> getAllCollect(Long wechatUserId,String typeCode) { public List<Long> getAllCollect(Long wechatUserId,String typeCode) {
Map<String, Object> paramMap = new HashMap<>(); Map<String, Object> paramMap = new HashMap<>();
paramMap.put("wechatUserId",wechatUserId); paramMap.put("wechatUserId",wechatUserId);
......
...@@ -147,4 +147,12 @@ public class ServeCollectFacade { ...@@ -147,4 +147,12 @@ public class ServeCollectFacade {
serveCollectBiz.processingData(); serveCollectBiz.processingData();
return new ResponseDto<>(); return new ResponseDto<>();
} }
@ApiOperation("填充收藏TypeCode与TypeName")
@GetMapping("processingData2TypeCode")
public ResponseDto<?> processingData2TypeCode(@RequestHeader("token") String token){
SessionUtil.getToken4Redis(token);
serveCollectBiz.processingData2TypeCode();
return new ResponseDto<>();
}
} }
\ No newline at end of file
...@@ -317,4 +317,29 @@ ...@@ -317,4 +317,29 @@
where where
serve_type_code =#{serveTypeCode} serve_type_code =#{serveTypeCode}
</update> </update>
<select id="List2ProcessedData" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
serve_collect
where
serve_type_code is null
</select>
<update id="batchUpdate" parameterType="list">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update serve_collect
<set>
update_time = NOW(),
<if test="item.serveTypeCode != null">
serve_type_code = #{item.serveTypeCode},
</if>
<if test="item.serveTypeName != null">
serve_type_name = #{item.serveTypeName}
</if>
</set>
where id = #{item.id}
</foreach>
</update>
</mapper> </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