feat: Enhance user management and reporting features

- Added `end_date` field to user management for better tracking of user status.
- Updated SQL queries in `adminController` to include `end_date` during user save operations.
- Improved purchase report data handling by refining the logic for received quantities.
- Enhanced file preview functionality to streamline file path handling.
- Updated outbound and receiving controllers to ensure accurate updates to shipment and purchase order details.

These changes aim to improve the overall functionality and user experience in managing user data and reporting processes.
This commit is contained in:
kjs
2026-04-08 15:33:09 +09:00
parent 3421d95e4e
commit 2a23cadb41
124 changed files with 5541 additions and 5662 deletions

View File

@@ -843,45 +843,45 @@ export const previewFile = async (
return;
}
// 파일 경로에서 회사코드와 날짜 폴더 추출
const filePathParts = fileRecord.file_path!.split("/");
let fileCompanyCode = filePathParts[2] || "DEFAULT";
// company_* 처리 (실제 회사 코드로 변환)
if (fileCompanyCode === "company_*") {
fileCompanyCode = "company_*"; // 실제 디렉토리명 유지
}
// file_path의 /uploads/ 이후를 baseUploadDir과 직접 결합
const fileName = fileRecord.saved_file_name!;
// 파일 경로에 날짜 구조가 있는지 확인 (YYYY/MM/DD)
let dateFolder = "";
if (filePathParts.length >= 6) {
dateFolder = `${filePathParts[3]}/${filePathParts[4]}/${filePathParts[5]}`;
const dbFilePath = fileRecord.file_path || "";
const uploadsIdx = dbFilePath.indexOf("/uploads/");
let finalPath: string;
if (uploadsIdx !== -1) {
const relativePath = dbFilePath.substring(uploadsIdx + "/uploads/".length);
finalPath = path.join(baseUploadDir, relativePath);
} else {
// fallback: 기존 방식
const filePathParts = dbFilePath.split("/");
let fileCompanyCode = filePathParts[2] || "DEFAULT";
if (fileCompanyCode === "company_*") {
fileCompanyCode = "company_*";
}
let dateFolder = "";
if (filePathParts.length >= 6) {
dateFolder = `${filePathParts[3]}/${filePathParts[4]}/${filePathParts[5]}`;
}
const companyUploadDir = getCompanyUploadDir(
fileCompanyCode,
dateFolder || undefined
);
finalPath = path.join(companyUploadDir, fileName);
}
const companyUploadDir = getCompanyUploadDir(
fileCompanyCode,
dateFolder || undefined
);
const filePath = path.join(companyUploadDir, fileName);
console.log("🔍 파일 미리보기 경로 확인:", {
objid: objid,
filePathFromDB: fileRecord.file_path,
companyCode: companyCode,
dateFolder: dateFolder,
fileName: fileName,
companyUploadDir: companyUploadDir,
finalFilePath: filePath,
fileExists: fs.existsSync(filePath),
finalFilePath: finalPath,
fileExists: fs.existsSync(finalPath),
});
if (!fs.existsSync(filePath)) {
console.error("❌ 파일 없음:", filePath);
if (!fs.existsSync(finalPath)) {
console.error("❌ 파일 없음:", finalPath);
res.status(404).json({
success: false,
message: `실제 파일을 찾을 수 없습니다: ${filePath}`,
message: `실제 파일을 찾을 수 없습니다: ${finalPath}`,
});
return;
}
@@ -929,7 +929,7 @@ export const previewFile = async (
res.setHeader("Content-Type", mimeType);
// 파일 스트림으로 전송
const fileStream = fs.createReadStream(filePath);
const fileStream = fs.createReadStream(finalPath);
fileStream.pipe(res);
} catch (error) {
console.error("파일 미리보기 오류:", error);