| 
						
						
							
								
							
						
						
					 | 
					@ -21,13 +21,20 @@ import com.alibaba.fastjson.JSONObject; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; | 
					 | 
					 | 
					import com.epmet.commons.rocketmq.messages.OrgOrStaffMQMsg; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.annotation.LoginUser; | 
					 | 
					 | 
					import com.epmet.commons.tools.annotation.LoginUser; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.annotation.RequirePermission; | 
					 | 
					 | 
					import com.epmet.commons.tools.annotation.RequirePermission; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.constant.StrConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.enums.EnvEnum; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.enums.RequirePermissionEnum; | 
					 | 
					 | 
					import com.epmet.commons.tools.enums.RequirePermissionEnum; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetException; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.RenException; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.security.dto.TokenDto; | 
					 | 
					 | 
					import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.BarcodeUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.utils.Result; | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.validator.ValidatorUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.constant.CustomerAgencyConstant; | 
					 | 
					 | 
					import com.epmet.constant.CustomerAgencyConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.constant.OrgInfoConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.CustomerAgencyDTO; | 
					 | 
					 | 
					import com.epmet.dto.CustomerAgencyDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.dto.IcNeighborHoodDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.form.*; | 
					 | 
					 | 
					import com.epmet.dto.form.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dto.result.*; | 
					 | 
					 | 
					import com.epmet.dto.result.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.entity.CustomerAgencyEntity; | 
					 | 
					 | 
					import com.epmet.entity.CustomerAgencyEntity; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -35,6 +42,7 @@ import com.epmet.feign.EpmetMessageOpenFeignClient; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.send.SendMqMsgUtil; | 
					 | 
					 | 
					import com.epmet.send.SendMqMsgUtil; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.AgencyService; | 
					 | 
					 | 
					import com.epmet.service.AgencyService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.service.CustomerAgencyService; | 
					 | 
					 | 
					import com.epmet.service.CustomerAgencyService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.service.IcNeighborHoodService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.google.zxing.BarcodeFormat; | 
					 | 
					 | 
					import com.google.zxing.BarcodeFormat; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.google.zxing.EncodeHintType; | 
					 | 
					 | 
					import com.google.zxing.EncodeHintType; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.google.zxing.MultiFormatWriter; | 
					 | 
					 | 
					import com.google.zxing.MultiFormatWriter; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -46,9 +54,16 @@ import org.springframework.beans.BeanUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.beans.factory.annotation.Autowired; | 
					 | 
					 | 
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.web.bind.annotation.*; | 
					 | 
					 | 
					import org.springframework.web.bind.annotation.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import java.io.IOException; | 
					 | 
					 | 
					import javax.imageio.ImageIO; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import javax.imageio.stream.ImageOutputStream; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.awt.image.BufferedImage; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.io.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.net.URLEncoder; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.nio.file.FileSystems; | 
					 | 
					 | 
					import java.nio.file.FileSystems; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.nio.file.Path; | 
					 | 
					 | 
					import java.nio.file.Path; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.time.LocalDateTime; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.time.ZoneOffset; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.HashMap; | 
					 | 
					 | 
					import java.util.HashMap; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.List; | 
					 | 
					 | 
					import java.util.List; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.Map; | 
					 | 
					 | 
					import java.util.Map; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -69,6 +84,8 @@ public class AgencyController { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private CustomerAgencyService customerAgencyService; | 
					 | 
					 | 
					    private CustomerAgencyService customerAgencyService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Autowired | 
					 | 
					 | 
					    @Autowired | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; | 
					 | 
					 | 
					    private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    @Autowired | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private IcNeighborHoodService neighborHoodService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @param formDTO | 
					 | 
					 | 
					     * @param formDTO | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -370,4 +387,65 @@ public class AgencyController { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return new Result<List<SonOrgResultDTO>>().ok(agencyService.getSonAgencyId(orgId,type)); | 
					 | 
					 | 
					        return new Result<List<SonOrgResultDTO>>().ok(agencyService.getSonAgencyId(orgId,type)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * Desc: 生成某类型下的二维码 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @param formDTO | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @author zxc | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @date 2022/3/2 10:32 上午 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    @PostMapping("create-qrcode") | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    public void createQrCode(@LoginUser TokenDto tokenDto, @RequestBody CreateQrCodeFormDTO formDTO, HttpServletResponse response){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        ValidatorUtils.validateEntity(formDTO, CreateQrCodeFormDTO.CreateQrCodeForm.class); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        String id = formDTO.getId(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        String type = formDTO.getType(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        String name = ""; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        try { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (type.equals(OrgInfoConstant.COMMUNITY)){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                CustomerAgencyDTO customerAgencyDTO = customerAgencyService.get(id); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (customerAgencyDTO == null){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"组织信息不存在"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                name = customerAgencyDTO.getOrganizationName(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            }else if (type.equals(OrgInfoConstant.COMMUNITY)){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                IcNeighborHoodDTO icNeighborHoodDTO = neighborHoodService.get(id); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (icNeighborHoodDTO == null){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"小区信息不存在"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                name = icNeighborHoodDTO.getNeighborHoodName(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            //url组成:数字社区地址?小区id&用户id
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            //String url = "https://demo.tduckapp.com/s/7314b64b3a26455ab793fb8c640856b6?id="+id;
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            String url = EnvEnum.getCurrentEnv().getUrl().replace("api/", StrConstant.EPMETY_STR) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .concat("epmet-oper-gov/#/") | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .concat(id).concat(StrConstant.QUESTION_MARK_TRANSFER) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .concat("type=").concat(type).concat(StrConstant.AND_MARK) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .concat("userId=").concat(tokenDto.getUserId()) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .concat(StrConstant.AND_MARK).concat(String.valueOf(LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli())); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            BufferedImage image = BarcodeUtils.drawQRImage(name, url); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            //BufferedImage 转 InputStream
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            ImageIO.write(image, "png", imageOutput); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            long length = imageOutput.length(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            String fileName = name+".png"; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            response.setContentType("application/octet-stream"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            response.setContentLength((int)length); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            response.setHeader("Content-Disposition","attachment;filename="+ URLEncoder.encode(fileName, StrConstant.UTF_8)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            //输出流
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            byte[] bytes = new byte[1024]; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            OutputStream outputStream = response.getOutputStream(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            long count = 0; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            while(count < length){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                int len = inputStream.read(bytes, 0, 1024); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                count +=len; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                outputStream.write(bytes, 0, len); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            outputStream.flush(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } catch (Exception e) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            e.printStackTrace(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					
  |