perbaikan file path capture image saat presensi pegawai
This commit is contained in:
parent
7d0767e1d7
commit
dad28b1d68
@ -159,35 +159,17 @@ public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements Abse
|
|||||||
public String getDirPath(String dirname) {
|
public String getDirPath(String dirname) {
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
String your_os = System.getProperty("os.name").toLowerCase();
|
|
||||||
if (your_os.indexOf("win") >= 0) {
|
|
||||||
// if_windows
|
|
||||||
result = dirname + "\\";
|
|
||||||
} else if (your_os.indexOf("nix") >= 0 || your_os.indexOf("nux") >= 0 || your_os.indexOf("mac") >= 0) {
|
|
||||||
// if_unix_or_mac
|
|
||||||
result = dirname + "//";
|
|
||||||
} else {
|
|
||||||
// unknown_os?
|
|
||||||
result = dirname + "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImageAbsoluteFilePath(String filename) {
|
|
||||||
String result = "";
|
|
||||||
|
|
||||||
String workingDir = System.getProperty("user.dir");
|
String workingDir = System.getProperty("user.dir");
|
||||||
String your_os = System.getProperty("os.name").toLowerCase();
|
String your_os = System.getProperty("os.name").toLowerCase();
|
||||||
if (your_os.indexOf("win") >= 0) {
|
if (your_os.indexOf("win") >= 0) {
|
||||||
// if_windows
|
// if_windows
|
||||||
result = workingDir + "\\" + filename;
|
result = workingDir + "\\" + presensiCapturePath + "\\" + dirname + "\\";
|
||||||
} else if (your_os.indexOf("nix") >= 0 || your_os.indexOf("nux") >= 0 || your_os.indexOf("mac") >= 0) {
|
} else if (your_os.indexOf("nix") >= 0 || your_os.indexOf("nux") >= 0 || your_os.indexOf("mac") >= 0) {
|
||||||
// if_unix_or_mac
|
// if_unix_or_mac
|
||||||
result = workingDir + presensiCapturePath + filename;
|
result = workingDir + "//" + presensiCapturePath + "//" + dirname + "//";
|
||||||
} else {
|
} else {
|
||||||
// unknown_os?
|
// unknown_os?
|
||||||
result = workingDir + "/" + filename;
|
result = workingDir + "/" + presensiCapturePath + "/" + dirname + "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -209,10 +191,10 @@ public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements Abse
|
|||||||
|
|
||||||
File dire = new File(directory);
|
File dire = new File(directory);
|
||||||
if (!dire.exists()) {
|
if (!dire.exists()) {
|
||||||
dire.mkdir();
|
dire.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(getImageAbsoluteFilePath(filename));
|
File file = new File(filename);
|
||||||
ImageIO.write(bufferedImage, "jpg", file);
|
ImageIO.write(bufferedImage, "jpg", file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -286,8 +268,8 @@ public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements Abse
|
|||||||
for (Map<String, Object> map : data) {
|
for (Map<String, Object> map : data) {
|
||||||
Map<String, Object> mapRs = new HashMap<>();
|
Map<String, Object> mapRs = new HashMap<>();
|
||||||
String imageURLData = "";
|
String imageURLData = "";
|
||||||
String encodeRs = encodeFileToBase64Binary(new File(getImageAbsoluteFilePath(
|
String encodeRs = encodeFileToBase64Binary(
|
||||||
getDirPath(map.get("trdate").toString()) + map.get("filePath").toString())));
|
new File(getDirPath(map.get("trdate").toString()) + map.get("filePath").toString()));
|
||||||
if (CommonUtil.isNotNullOrEmpty(encodeRs)) {
|
if (CommonUtil.isNotNullOrEmpty(encodeRs)) {
|
||||||
imageURLData = "data:image/jpg;base64," + encodeRs;
|
imageURLData = "data:image/jpg;base64," + encodeRs;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user