| 
					
				 | 
			
			
				@@ -5,8 +5,8 @@ import cn.hutool.core.collection.CollUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.util.StrUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.excel.EasyExcel; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.metadata.IPage; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iden.common.cache.DictCache; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -17,13 +17,11 @@ import com.iden.common.enums.CredentialsTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iden.common.enums.GenderEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iden.common.enums.PersonTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iden.common.enums.PopulationTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.iden.common.exceltool.RowWriteHandler; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iden.common.exception.BDException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.iden.common.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iden.common.vo.CrowdVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iden.common.vo.PageReqVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iden.common.vo.PersonVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.iden.common.vo.UserLoginedConvertVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.iden.common.vo.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,7 +29,10 @@ import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import javax.servlet.http.HttpServletResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.File; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.net.URL; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.net.URLEncoder; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.ArrayList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -102,6 +103,10 @@ public class CrowdService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 pageRes.getRecords().forEach(item -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     CrowdVO resVO = new CrowdVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     BeanUtils.copyProperties(item,resVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    QueryWrapper<IdenPersonCrowdRef> queryWrapper1 = new QueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    queryWrapper1.lambda().eq(IdenPersonCrowdRef::getCrowdId,resVO.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    int cnt = this.idenPersonCrowdRefService.count(queryWrapper1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    resVO.setQuantity(cnt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     list.add(resVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 results.setRecords(list); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -109,6 +114,77 @@ public class CrowdService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return results; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void exportToExcel( Long crowdId,UserLoginedConvertVO loginUser, HttpServletResponse response)  throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        QueryWrapper<IdenPerson> queryWrapper = new QueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queryWrapper.lambda() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .orderByDesc(IdenPerson::getModifyTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .orderByDesc(IdenPerson::getCreateTime); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (crowdId != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            queryWrapper.apply(" in ( select person_id from iden_person_crowd_ref ipcr where ipcr.crowd_id = "+ crowdId + ")"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<IdenPerson>  list =  this.idenPersonService.list(queryWrapper); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<PersonExcelVO> records = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollUtil.isNotEmpty(list)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            list.forEach(item->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                PersonExcelVO resVO = new PersonExcelVO(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                BeanUtils.copyProperties(item,resVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resVO.setPopulationTypeName(PopulationTypeEnum.getValueToName(item.getPopulationType())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resVO.setTypeName(PersonTypeEnum.getValueToName(item.getType())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resVO.setGenderName(GenderEnum.getValueToName(item.getGender())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resVO.setCredentialsTypeName(CredentialsTypeEnum.getValueToName(item.getCredentialsType())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resVO.setMarriageName(DictCache.getNameByValue("marriage", item.getMarriage())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resVO.setPolicitalStatusName(DictCache.getNameByValue("policital_status", item.getPolicitalStatus())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    resVO.setImageUrl(new URL(item.getImage())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } catch (Exception e){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Long communityId1 = item.getCommunityId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(communityId1 != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    IdenCommunity idenCommunity = this.idenCommunityService.getById(communityId1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(idenCommunity != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        resVO.setCommunityName(idenCommunity.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                QueryWrapper<IdenPersonCrowdRef> queryWrapper1 = new QueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                queryWrapper1.lambda().eq(IdenPersonCrowdRef::getPersonId,item.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<IdenPersonCrowdRef> listIdenPersonCrowdRef = idenPersonCrowdRefService.list(queryWrapper1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StringBuilder sb = new StringBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (CollUtil.isNotEmpty(listIdenPersonCrowdRef)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for(IdenPersonCrowdRef idenPersonCrowdRef : listIdenPersonCrowdRef){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        IdenCrowd idenCrowd = idenCrowdService.getById(idenPersonCrowdRef.getCrowdId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if(idenCrowd != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            sb.append(idenCrowd.getName()).append(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String crowdName = sb.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(crowdName != null && crowdName.endsWith(",")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    crowdName = crowdName.substring(0, crowdName.length() - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                resVO.setCrowdName(crowdName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                records.add(resVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.reset(); // 非常重要 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.addHeader("Access-Control-Allow-Origin",  "*"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.setContentType("application/vnd.ms-excel"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.setCharacterEncoding("utf-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            final String fileName = URLEncoder.encode("Person", "UTF-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response.setHeader("Content-disposition", "attachment;filename=" + fileName + "_" + System.currentTimeMillis() + ".xlsx"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            EasyExcel.write(response.getOutputStream(), PersonExcelVO.class).sheet("人员表").registerWriteHandler(new RowWriteHandler()).doWrite(records); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 删除人群 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param id 
			 |