Commit ad7a072a by 徐高华

群导出加门店

parent c79478e6
......@@ -78,6 +78,27 @@ public class GroupChatDTO implements Serializable {
}
return clerkRelationExcel;
}
// 群主关联门店
private String ownerStoreCode ;
private String ownerStoreName ;
public String getOwnerStoreCode() {
return ownerStoreCode;
}
public void setOwnerStoreCode(String ownerStoreCode) {
this.ownerStoreCode = ownerStoreCode;
}
public String getOwnerStoreName() {
return ownerStoreName;
}
public void setOwnerStoreName(String ownerStoreName) {
this.ownerStoreName = ownerStoreName;
}
public void setClerkRelationExcel(String clerkRelationExcel) {
this.clerkRelationExcel = clerkRelationExcel;
}
......
......@@ -43,4 +43,6 @@ public interface TabHaobanClerkMainStoreRelatedMapper {
* @return
*/
TabHaobanClerkMainStoreRelated getLastNoStatusByStaffId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("staffId") String staffId);
List<TabHaobanClerkMainStoreRelated> listByStaffIdList(@Param("list") List<String> staffIdList) ;
}
\ No newline at end of file
......@@ -8,6 +8,10 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanClerkMainStoreRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanClerkMainStoreRelated;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -61,6 +65,10 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
private StaffClerkRelationService staffClerkRelationService;
@Autowired
private WxEnterpriseService wxEnterpriseService ;
@Autowired
private TabHaobanClerkMainStoreRelatedMapper clerkMainStoreRelatedMapper ;
@Autowired
private StoreService storeService ;
@Override
public ServiceResponse<Page<GroupChatDTO>> listPage(GroupChatSearchQDTO qdto, BasePageInfo basePageInfo) {
......@@ -97,16 +105,36 @@ public class GroupChatApiServiceImpl implements GroupChatApiService {
one.setOwnerAddFlag(ownerAddFlag);
});
// 处理关联关系
boolean needClerkReltaion = (qdto.getStatus() == 0);
if (needClerkReltaion) {
List<String> staffIdList = dtoList.stream().filter(dto -> StringUtils.isNotBlank(dto.getStaffId()))
.map(dto -> dto.getStaffId()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(staffIdList)) {
List<String> relationIdList = this.staffClerkRelationService
.listRelationsStaffId(new HashSet<>(staffIdList));
dtoList.forEach(one -> {
one.setClerkRelationFlag(relationIdList.contains(one.getStaffId()) ? 1 : 0);
});
List<String> staffIdList = dtoList.stream().filter(dto -> StringUtils.isNotBlank(dto.getStaffId()))
.map(dto -> dto.getStaffId()).collect(Collectors.toList());
List<String> relationStaffIdList = null ;
if (CollectionUtils.isNotEmpty(staffIdList)) {
relationStaffIdList = this.staffClerkRelationService.listRelationsStaffId(new HashSet<>(staffIdList));
for (GroupChatDTO one : dtoList) {
one.setClerkRelationFlag(relationStaffIdList.contains(one.getStaffId()) ? 1 : 0);
}
if(CollectionUtils.isNotEmpty(relationStaffIdList)) {
List<TabHaobanClerkMainStoreRelated> storeRelationList = this.clerkMainStoreRelatedMapper.listByStaffIdList(relationStaffIdList);
if(CollectionUtils.isNotEmpty(storeRelationList)) {
List<String> storeIdList = storeRelationList.stream().map(o->o.getStoreId()).collect(Collectors.toList());
String[] arr = storeIdList.toArray(new String[storeIdList.size()]) ;
List<StoreDTO> storeList = this.storeService.getStores(arr) ;
if(CollectionUtils.isNotEmpty(storeList)) {
Map<String,String> staffMap = storeRelationList.stream().collect(Collectors.toMap(TabHaobanClerkMainStoreRelated::getStaffId,TabHaobanClerkMainStoreRelated::getStoreId,(k1,k2)->k1)) ;
Map<String,StoreDTO> storeMap = storeList.stream().collect(Collectors.toMap(StoreDTO::getStoreId,o->o,(k1,k2)->k1)) ;
for (GroupChatDTO one : dtoList) {
String staffId = one.getStaffId() ;
String storeId = staffMap.get(staffId) ;
if(StringUtils.isNotBlank(storeId)) {
StoreDTO store = storeMap.get(storeId) ;
if(null != store) {
one.setOwnerStoreCode(store.getStoreCode());
one.setOwnerStoreName(store.getStoreName());
}
}
}
}
}
}
}
// 原群主
......
......@@ -122,4 +122,15 @@
and staff_id = #{staffId}
order by create_time desc limit 1
</select>
<select id="listByStaffIdList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_clerk_main_store_related
where staff_id in
<foreach collection="list" open="(" close=")" separator="," item="item">
#{item}
</foreach>
and status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -318,8 +318,8 @@ public class GroupChatController {
ServiceResponse<Page<GroupChatDTO>> page = this.groupChatApiService.listPage(qdto, basePageInfo);
if (page.isSuccess() && CollUtil.isNotEmpty(page.getResult().getResult())){
String fileName = "客户群列表数据";
List<String> titleList = Arrays.asList("客户群ID", "客户群名称", "群人数", "群客户数", "新增总数", "流失总数","群主","群主在好办小程序关联状态","创建时间");
List<String> fileList = Arrays.asList("groupChatId", "name", "totalCount", "totalMemberCount", "addCount", "quitCount", "staffName", "clerkRelationExcel", "createTime");
List<String> titleList = Arrays.asList("客户群ID", "客户群名称", "群人数", "群客户数", "新增总数", "流失总数","群主","群主在好办小程序关联状态","门店名称","门店code","创建时间");
List<String> fileList = Arrays.asList("groupChatId", "name", "totalCount", "totalMemberCount", "addCount", "quitCount", "staffName", "clerkRelationExcel", "ownerStoreName","ownerStoreCode", "createTime");
try {
ExcelUtils.xls(response, request, fileName, page.getResult().getResult(), fileList, titleList);
} catch (Exception e) {
......
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