| | |
| | | |
| | | import com.panzhihua.common.model.vos.community.ComActQuestnaireAnswerContentVO; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.FileUtils; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.xml.bind.DatatypeConverter; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.net.URL; |
| | | import java.nio.file.Files; |
| | | import java.util.ArrayList; |
| | | import java.util.Base64; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * @author lyq |
| | |
| | | //构建单个用户数据 |
| | | List<Object> userData = new ArrayList<>(); |
| | | |
| | | String noExport = "以上信息仅用于疫苗防控"; |
| | | String noExport = "以上信息仅用于"; |
| | | //遍历答案列表 |
| | | Long reserveRecordId = 0L; |
| | | Long reserveSubId = 0L; |
| | |
| | | } |
| | | continue; |
| | | } |
| | | //判断当前组件类型是否签名 |
| | | if(userAnswers.getOptionType().equals(12)){ |
| | | reserveSubId = userAnswers.getReserveSubId(); |
| | | try { |
| | | userData.add(DatatypeConverter.parseBase64Binary(userAnswers.getAnswerContent().substring(userAnswers.getAnswerContent().indexOf(",") + 1))); |
| | | }catch (Exception e){ |
| | | userData.add(" "); |
| | | log.error("导出转换图片失败!"); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | if(userAnswers.getOptionType().equals(1)){ |
| | | isOldDuo = true; |
| | |
| | | } |
| | | continue; |
| | | } |
| | | //判断当前组件类型是否签名 |
| | | if(userAnswers.getOptionType().equals(12)){ |
| | | reserveSubId = userAnswers.getReserveSubId(); |
| | | try { |
| | | //userData.add(new URL("http://image.panzhihua.nhys.cdnhxx.com//idcard/967dbdef3ef3465a9169fbea204f9aa7.jpg")); |
| | | userData.add(DatatypeConverter.parseBase64Binary(userAnswers.getAnswerContent().substring(userAnswers.getAnswerContent().indexOf(",") + 1))); |
| | | }catch (Exception e){ |
| | | userData.add(" "); |
| | | log.error("导出转换图片失败!"); |
| | | } |
| | | continue; |
| | | } |
| | | if(userAnswers.getOptionType().equals(1)){ |
| | | isOldDuo = true; |
| | | sb.append(userAnswers.getAnswerContent()==null?"无":userAnswers.getAnswerContent() + ","); |
| | |
| | | } |
| | | return resultList; |
| | | } |
| | | |
| | | public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { |
| | | File resultFile = File.createTempFile(name, '.' + ext, tmpDirFile); |
| | | resultFile.deleteOnExit(); |
| | | FileUtils.copyToFile(inputStream, resultFile); |
| | | return resultFile; |
| | | } |
| | | |
| | | public static File bytesToFile(byte[] bytes, String fileType) throws IOException { |
| | | return createTmpFile(new ByteArrayInputStream(bytes), |
| | | UUID.randomUUID().toString(), |
| | | fileType, |
| | | Files.createTempDirectory("tempFile").toFile()); |
| | | } |
| | | } |