|
|
|
|
@ -16,6 +16,7 @@ import org.springblade.system.user.entity.User; |
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
|
import java.util.*; |
|
|
|
|
@ -164,61 +165,23 @@ public class ExamineResultServiceImpl extends BaseServiceImpl<ExamineResultMappe |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String resultPicture(String picturePath) { |
|
|
|
|
public String resultPicture(MultipartFile file) { |
|
|
|
|
String fileName = ""; |
|
|
|
|
if (!"".equals(picturePath) && picturePath != null) { |
|
|
|
|
if (file != null) { |
|
|
|
|
Random random = new Random(); |
|
|
|
|
fileName = random.nextLong() + ".png"; |
|
|
|
|
String path = sysClient.getParamValue("electronic_signature_real_path").getData() + fileName; |
|
|
|
|
// byte[] bytes = Base64Utils.decodeFromString(user.getElectronicSignature());
|
|
|
|
|
// byte[] decode = Base64.getMimeDecoder().decode(user.getElectronicSignature());
|
|
|
|
|
|
|
|
|
|
// String tempStr = user.getElectronicSignature();
|
|
|
|
|
|
|
|
|
|
if (picturePath.contains("data:")) { |
|
|
|
|
int start = picturePath.indexOf(","); |
|
|
|
|
picturePath = picturePath.substring(start + 1); |
|
|
|
|
} |
|
|
|
|
final Base64.Decoder decoder = Base64.getDecoder(); |
|
|
|
|
picturePath = picturePath.replaceAll("\r|\n", ""); |
|
|
|
|
picturePath = picturePath.trim(); |
|
|
|
|
byte[] decode = decoder.decode(picturePath); |
|
|
|
|
|
|
|
|
|
byteArrayToFile(decode, path); |
|
|
|
|
// String s = sysClient.getParamValue("electronic_signature").getData();
|
|
|
|
|
// user.setElectronicSignature(fileName);
|
|
|
|
|
} |
|
|
|
|
return fileName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void byteArrayToFile(byte[] src, String filePath) { |
|
|
|
|
//1.创建源
|
|
|
|
|
File file = new File(filePath); |
|
|
|
|
//选择流
|
|
|
|
|
InputStream writing = null; |
|
|
|
|
OutputStream os = null; |
|
|
|
|
try { |
|
|
|
|
writing = new ByteArrayInputStream(src); |
|
|
|
|
os = new FileOutputStream(file); |
|
|
|
|
byte[] frush = new byte[5];//3表示0个字节为一段
|
|
|
|
|
int len = -1; |
|
|
|
|
while ((len = writing.read(frush)) != -1) { |
|
|
|
|
os.write(frush, 0, len); |
|
|
|
|
} |
|
|
|
|
os.flush(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} finally { |
|
|
|
|
if (os != null) { |
|
|
|
|
FileOutputStream fout; |
|
|
|
|
try { |
|
|
|
|
os.close(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
fout = new FileOutputStream(path); |
|
|
|
|
fout.write(file.getBytes()); |
|
|
|
|
fout.close(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return fileName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -305,10 +268,38 @@ public class ExamineResultServiceImpl extends BaseServiceImpl<ExamineResultMappe |
|
|
|
|
// TODO 当有多个检测结果的时候,getOne报错
|
|
|
|
|
ExamineResult examineResult = this.getOne(wrapper); |
|
|
|
|
entry.setId(examineResult.getId()); |
|
|
|
|
// 上传图片文件名
|
|
|
|
|
List<String> path = entry.getPath(); |
|
|
|
|
if (path != null && path.size() > 0) { |
|
|
|
|
String picturePath = ""; |
|
|
|
|
if (path.size() > 1) { |
|
|
|
|
for (String s : path) { |
|
|
|
|
String s1 = s + ","; |
|
|
|
|
picturePath += s1; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
picturePath = path.get(0); |
|
|
|
|
} |
|
|
|
|
entry.setPicturePath(picturePath); |
|
|
|
|
} |
|
|
|
|
return this.updateById(entry); |
|
|
|
|
} |
|
|
|
|
// 提交修改实验结果
|
|
|
|
|
else { |
|
|
|
|
// 上传图片文件名
|
|
|
|
|
List<String> path = entry.getPath(); |
|
|
|
|
if (path != null && path.size() > 0) { |
|
|
|
|
String picturePath = ""; |
|
|
|
|
if (path.size() > 1) { |
|
|
|
|
for (String s : path) { |
|
|
|
|
String s1 = s + ","; |
|
|
|
|
picturePath += s1; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
picturePath = path.get(0); |
|
|
|
|
} |
|
|
|
|
entry.setPicturePath(picturePath); |
|
|
|
|
} |
|
|
|
|
return this.updateById(entry); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|