아파트단지 상세 파일업로드 추가
This commit is contained in:
@@ -6,7 +6,6 @@ use App\Controllers\BaseController;
|
||||
use App\Libraries\MyUpload;
|
||||
use App\Models\article\AptModel;
|
||||
use App\Models\common\CodeModel;
|
||||
use MY_Upload;
|
||||
|
||||
class Apt extends BaseController
|
||||
{
|
||||
@@ -673,6 +672,34 @@ class Apt extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 단지정보 작성완료
|
||||
public function saveWriteComplete()
|
||||
{
|
||||
try {
|
||||
|
||||
$rcpt_no = $this->request->getPost('rcpt_no');
|
||||
if (empty($rcpt_no)) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => '정보누락'
|
||||
]);
|
||||
}
|
||||
|
||||
$this->aptModel->saveWriteComplete($rcpt_no);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 검수완료 저장
|
||||
public function confirmAptInfo()
|
||||
{
|
||||
@@ -868,11 +895,7 @@ class Apt extends BaseController
|
||||
$rcpt_no = $this->request->getPost('rcpt_no');
|
||||
$uploadType = $this->request->getPost('upload_type');
|
||||
$files = $this->request->getFiles();
|
||||
$imgPath = "/upload/apt_file/" . $rcpt_no . "/";
|
||||
|
||||
$imgPath = NCLOUD_OBJECT_STORAGE_URL . $imgPath;
|
||||
$moviePath = $imgPath;
|
||||
$photo360Path = $imgPath;
|
||||
$uploadPath = "/upload/apt_file/" . $rcpt_no . "/";
|
||||
|
||||
if (!isset($files['files'])) {
|
||||
return $this->response->setJSON([
|
||||
@@ -881,36 +904,267 @@ class Apt extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if ($uploadType === "photo") {
|
||||
|
||||
$arrUploadfile = [];
|
||||
foreach ($files['files'] as $file) {
|
||||
|
||||
// foreach ($files['files'] as $file) {
|
||||
// if ($file->isValid()) {
|
||||
// $file->move(WRITEPATH . 'uploads');
|
||||
$uploadData = $lib->do_upload2($file, $uploadPath);
|
||||
|
||||
// INSERT apt_photo
|
||||
if ($uploadData !== false) {
|
||||
$arrUploadfile[] = $uploadData;
|
||||
}
|
||||
|
||||
print_r($_FILES);
|
||||
// }
|
||||
}
|
||||
|
||||
$gps_lat = null;
|
||||
$gps_lon = null;
|
||||
$camDate = null;
|
||||
if (!empty($arrUploadfile)) {
|
||||
foreach ($arrUploadfile as $key => $uploadFile) {
|
||||
$object_storage_url = $uploadFile['object_storage_url'];
|
||||
$arrExifData = @exif_read_data($object_storage_url);
|
||||
if (!empty($arrExifData)) {
|
||||
$notFound = "Unavailable";
|
||||
if (@array_key_exists('DateTime', $arrExifData)) {
|
||||
$camDate = $arrExifData['DateTime'];
|
||||
} else {
|
||||
$camDate = $notFound;
|
||||
}
|
||||
|
||||
$imageMetaData = $camDate;
|
||||
$camDate = substr(str_replace(':', '-', $camDate), 0, 10);
|
||||
|
||||
|
||||
|
||||
// $imageDataBlob = file_get_contents($object_storage_url);
|
||||
// $im = new Imagick();
|
||||
// $im->readImageBlob($imageDataBlob);
|
||||
// $im->thumbnailImage(105, 80, false);
|
||||
// $thumb_im = $im->getImageBlob();
|
||||
// $lib->upload_object_storage_imagick();
|
||||
$arrGPS = $arrExifData['GPS'] ?? null;
|
||||
|
||||
// }
|
||||
if (empty($arrGPS)) { // GPS 섹션이 없으면, 개별 키로도 체크
|
||||
if (!empty($arrExifData['GPSLongitude']) && !empty($arrExifData['GPSLatitude'])) {
|
||||
$arrGPS = [
|
||||
'GPSLongitude' => $arrExifData['GPSLongitude'],
|
||||
'GPSLatitude' => $arrExifData['GPSLatitude'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!empty($arrGPS)
|
||||
&& !empty($arrGPS['GPSLongitude'])
|
||||
&& !empty($arrGPS['GPSLatitude'])
|
||||
&& is_array($arrGPS['GPSLongitude'])
|
||||
&& is_array($arrGPS['GPSLatitude'])
|
||||
) { //GPS 정보가 있다면
|
||||
if (@array_key_exists('GPSLongitude', $arrGPS) && (@array_key_exists('GPSLatitude', $arrGPS))) {
|
||||
list($temp_d1, $temp_d2) = sscanf($arrGPS["GPSLatitude"][0], "%d/%d"); //문자->숫자로 계산
|
||||
$gps_lat_d = $temp_d1 / $temp_d2;
|
||||
list($temp_d1, $temp_d2) = sscanf($arrGPS["GPSLatitude"][1], "%d/%d");
|
||||
$gps_lat_m = $temp_d1 / $temp_d2;
|
||||
list($temp_d1, $temp_d2) = sscanf($arrGPS["GPSLatitude"][2], "%d/%d");
|
||||
$gps_lat_s = $temp_d1 / $temp_d2;
|
||||
|
||||
list($temp_d1, $temp_d2) = sscanf($arrGPS["GPSLongitude"][0], "%d/%d"); //문자->숫자로 계산
|
||||
$gps_lon_d = $temp_d1 / $temp_d2;
|
||||
list($temp_d1, $temp_d2) = sscanf($arrGPS["GPSLongitude"][1], "%d/%d");
|
||||
$gps_lon_m = $temp_d1 / $temp_d2;
|
||||
list($temp_d1, $temp_d2) = sscanf($arrGPS["GPSLongitude"][2], "%d/%d");
|
||||
$gps_lon_s = $temp_d1 / $temp_d2;
|
||||
|
||||
$gps_lat = $gps_lat_d + $gps_lat_m / 60 + $gps_lat_s / 3600; //도분초를 도로 변환
|
||||
$gps_lon = $gps_lon_d + $gps_lon_m / 60 + $gps_lon_s / 3600;
|
||||
}
|
||||
} else {
|
||||
$xy = $this->aptModel->getDetail($rcpt_no);
|
||||
|
||||
$gps_lat = $xy['rcpt_y'];
|
||||
$gps_lon = $xy['rcpt_x'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
$base = $uploadFile['base_name']; // xxxx
|
||||
$dir = rtrim(dirname($uploadFile['object_key']), '/'); // upload/apt_file/2
|
||||
$thumbKey = $dir . '/' . $base . '_thumb.jpg';
|
||||
|
||||
$imageDataBlob = file_get_contents($object_storage_url);
|
||||
$im = new \Imagick();
|
||||
$im->readImageBlob($imageDataBlob);
|
||||
$im->thumbnailImage(105, 80, false);
|
||||
$thumb_im = $im->getImageBlob();
|
||||
// 썸네일 s3 전송
|
||||
$lib->upload_object_storage_imagick2($thumbKey, $thumb_im);
|
||||
|
||||
|
||||
/**
|
||||
* 파일업로드 내용 저장
|
||||
* rcpt_no, pho_lati, pho_long, filenm, filenm_up, file_path, thumb_path, thumb_nm, cloud_upload_yn
|
||||
*
|
||||
*/
|
||||
$uploadParam = [
|
||||
'rcpt_no' => $rcpt_no, // 접수번호
|
||||
'gps_lat' => $gps_lat, // latitude
|
||||
'gps_lon' => $gps_lon, // longitude
|
||||
'origin_name' => $uploadFile['origin_name'], // 원본파일명
|
||||
'file_name' => $uploadFile['file_name'], // 저장파일명
|
||||
'upload_path' => $uploadPath, // 저장경로
|
||||
'thumb_name' => $base . '_thumb.jpg',
|
||||
'cam_date' => $camDate, // 촬영일
|
||||
];
|
||||
|
||||
$res = $this->aptModel->saveImg($uploadParam);
|
||||
log_message('debug', 'apt_file :: rcpt_no : ' . $rcpt_no . ', fileName : ' . $uploadFile['file_name']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($uploadType === "video") {
|
||||
|
||||
|
||||
$arrUploadfile = [];
|
||||
foreach ($files['files'] as $file) {
|
||||
|
||||
$uploadData = $lib->do_upload2($file, $uploadPath);
|
||||
|
||||
if ($uploadData !== false) {
|
||||
$arrUploadfile[] = $uploadData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// print_r($arrUploadfile);
|
||||
// exit;
|
||||
|
||||
if (!empty($arrUploadfile)) {
|
||||
foreach ($arrUploadfile as $key => $uploadFile) {
|
||||
$uploadParam = [
|
||||
'rcpt_no' => $rcpt_no, // 접수번호
|
||||
'origin_name' => $uploadFile['origin_name'], // 원본파일명
|
||||
'file_name' => $uploadFile['file_name'], // 저장파일명
|
||||
'upload_path' => $uploadPath, // 저장경로
|
||||
// 'thumb_name' => $base . '_thumb.jpg',
|
||||
// 'cam_date' => $camDate, // 촬영일
|
||||
];
|
||||
|
||||
|
||||
// 동영상 정보 저장
|
||||
$this->aptModel->saveVideo($uploadParam);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 업로드파일삭제
|
||||
public function reqRemovePho()
|
||||
{
|
||||
try {
|
||||
|
||||
$type = $this->request->getPost('type');
|
||||
|
||||
|
||||
if ($type === "all") {
|
||||
$rcpt_no = $this->request->getPost('rcpt_no');
|
||||
|
||||
// 사진 일괄 삭제
|
||||
$this->aptModel->removeAllPho($rcpt_no);
|
||||
|
||||
|
||||
} else if ($type === "select") {
|
||||
$phoNo = $this->request->getPost('phoNo'); // ✅ 배열로 들어옴
|
||||
|
||||
if (!is_array($phoNo))
|
||||
$phoNo = [$phoNo];
|
||||
|
||||
if (empty($phoNo)) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => '데이터 누락'
|
||||
]);
|
||||
}
|
||||
|
||||
// 선택 사진 삭제
|
||||
$this->aptModel->removePho($phoNo);
|
||||
|
||||
|
||||
} else {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => '잘못된 접근'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 업로드 파일 카테고리 지정
|
||||
public function savePhoCate()
|
||||
{
|
||||
try {
|
||||
|
||||
$rcpt_no = $this->request->getPost('rcpt_no');
|
||||
$code1 = $this->request->getPost('code1');
|
||||
$code2 = $this->request->getPost('code2');
|
||||
$phoNo = $this->request->getPost('phoNo');
|
||||
|
||||
if (!is_array($phoNo))
|
||||
$phoNo = [$phoNo];
|
||||
|
||||
if (empty($phoNo)) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => '데이터 누락'
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($phoNo as $pho) {
|
||||
|
||||
$data = [
|
||||
'rcpt_no' => $rcpt_no,
|
||||
'pho_no' => $pho,
|
||||
'code1' => $code1,
|
||||
'code2' => $code2,
|
||||
];
|
||||
|
||||
// 카테고리 지정
|
||||
$this->aptModel->updatePhoCate($data);
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
|
||||
Reference in New Issue
Block a user