| | |
| | | import okhttp3.MediaType; |
| | | import okhttp3.MultipartBody; |
| | | import okhttp3.RequestBody; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | String fileFinalName = ""; |
| | | for (Map.Entry<Object, Object> entry : map.entrySet()) { |
| | | fieldFse = fieldMetaEntity.getFieldMeta(fieldName); |
| | | if (fieldFse == null || !Arrays.asList(CmnConst.ATTACHMENT_TYPE, "file-image", FieldType.FILE_ATTACHMENT.getDictValue()).contains(fieldFse.getString(CmnConst.FIELD_TYPE))) { |
| | | if (fieldFse == null || !Arrays.asList(CmnConst.ATTACHMENT_TYPE, "file-image", FieldType.FILE_ATTACHMENT.getDictValue(), FieldType.SIGNATURE.getDictValue()).contains(fieldFse.getString(CmnConst.FIELD_TYPE))) { |
| | | fse.setValue(entry.getKey().toString(), null); |
| | | continue; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | boolean saveInDbFlag = FieldType.FILE_ATTACHMENT.getDictValue().equals(fieldFse.getString("field_type")); |
| | | boolean saveInDbFlag = FieldType.checkSaveInDB(fieldFse.getString("field_type")); |
| | | if (!saveInDbFlag) { |
| | | fileFinalName = FileUtils.uploadFile(tempFile, templateType, clientUuid); |
| | | } else { |
| | |
| | | return this.getFileContent(attachmentFse); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户签名 |
| | | * @return |
| | | * @throws BaseException |
| | | */ |
| | | public String getSignature(FieldSetEntity fse) throws BaseException { |
| | | String bytes = Base64.encodeBase64String(getFileContent(fse.getUUID())); |
| | | if (bytes == null) { |
| | | return null; |
| | | } |
| | | return "data:image/png;base64," + bytes; |
| | | } |
| | | |
| | | /** |
| | | * 根据附件uuid获取文件 |
| | | * 用完之后需要删除返回的 file (临时文件) |