물건정보 API 파일 기능 제거 및 변경

This commit is contained in:
LAPTOP-L3VE7KK2\USER 2024-10-07 09:45:16 +09:00
parent 302a936bab
commit 542721abc5
4 changed files with 104 additions and 309 deletions

View File

@ -2,17 +2,12 @@ package com.interplug.qcast.biz.object;
import com.interplug.qcast.biz.object.dto.*; import com.interplug.qcast.biz.object.dto.*;
import io.micrometer.common.util.StringUtils; import io.micrometer.common.util.StringUtils;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.ini4j.Wini;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -57,16 +52,10 @@ public class ObjectService {
} }
public ObjectResponse selectObjectDetail(String objectNo) throws Exception { public ObjectResponse selectObjectDetail(String objectNo) throws Exception {
// object 상세 정보 조회2 // object 상세 정보 조회
ObjectResponse objectResponse = objectMapper.selectObjectDetail(objectNo); ObjectResponse objectResponse = objectMapper.selectObjectDetail(objectNo);
if (objectResponse != null) { if (objectResponse != null) {
// 기본 플랜번호 셋팅
objectResponse.setPlanNo("1");
// ini 파일 읽어 Response 객체 담기
this.objectFileInfo(objectResponse);
// Plan 목록 조회 // Plan 목록 조회
PlanRequest planRequest = new PlanRequest(); PlanRequest planRequest = new PlanRequest();
planRequest.setObjectNo(objectNo); planRequest.setObjectNo(objectNo);
@ -132,10 +121,6 @@ public class ObjectService {
planRequest.setUserId(objectRequest.getUserId()); planRequest.setUserId(objectRequest.getUserId());
result += objectMapper.insertPlan(planRequest); result += objectMapper.insertPlan(planRequest);
// ini 파일 생성
objectRequest.setPlanNo(planRequest.getPlanNo());
this.objectFileSave(objectRequest);
// 결과 데이터 리턴 // 결과 데이터 리턴
ObjectResponse objectResponse = new ObjectResponse(); ObjectResponse objectResponse = new ObjectResponse();
objectResponse.setObjectNo(objectNo); objectResponse.setObjectNo(objectNo);
@ -175,28 +160,10 @@ public class ObjectService {
+ (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo())); + (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo()));
result += objectMapper.updateObject(objectRequest); result += objectMapper.updateObject(objectRequest);
// Plan 목록 조회
PlanRequest planRequest = new PlanRequest();
planRequest.setObjectNo(objectRequest.getObjectNo());
List<PlanResponse> planList = objectMapper.selectPlanList(planRequest);
for (PlanResponse planResponse : planList) {
objectRequest.setPlanNo(planResponse.getPlanNo());
// ini 파일 수정
this.objectFileSave(objectRequest);
}
// 임시저장에서 저장상태로 돌리기 // 임시저장에서 저장상태로 돌리기
if (tempChgFlg) { if (tempChgFlg) {
objectMapper.updateObjectNoChange(objectRequest); objectMapper.updateObjectNoChange(objectRequest);
objectMapper.updatePlanObjectNoChange(objectRequest); objectMapper.updatePlanObjectNoChange(objectRequest);
// 임시저장 폴더명 생성 물건번호명으로 교체
File file = new File(baseDirPath + File.separator + objectRequest.getObjectNo());
if (file.exists()) {
file.renameTo(new File(baseDirPath + File.separator + objectRequest.getNewObjectNo()));
}
} }
} }
@ -218,178 +185,6 @@ public class ObjectService {
return result; return result;
} }
public void objectFileSave(ObjectRequest objectRequest) throws Exception {
try {
// Dir 파일 체크하여 없으면 생성해 준다. (물건번호/플랜번호/파일명)
String dirPath =
baseDirPath
+ File.separator
+ objectRequest.getObjectNo()
+ File.separator
+ objectRequest.getPlanNo();
File file = new File(dirPath);
if (!file.exists()) {
file.mkdirs();
}
file = new File(dirPath + File.separator + baseFileName);
if (!file.exists()) {
FileWriter fw = new FileWriter(file);
fw.close();
}
// ini4j 라이브러리 이용하여 파일 읽기
FileInputStream input = new FileInputStream(file);
Wini iniFile = new Wini(new InputStreamReader(input, "MS932"));
// [物件情報] 영역 코드명
String groupKey = "物件情報";
// 판매점명
objectFileSetting(iniFile, groupKey, "作成者", objectRequest.getSaleStoreName());
// 경칭
objectFileSetting(iniFile, groupKey, "敬称", objectRequest.getObjectNameOmit());
// 후라가나
objectFileSetting(iniFile, groupKey, "フリガナ", objectRequest.getObjectNameKana());
// 안건명
objectFileSetting(iniFile, groupKey, "邸名", objectRequest.getObjectName());
// 담당자
objectFileSetting(iniFile, groupKey, "担当者", objectRequest.getReceiveUser());
// 우편번호
if (StringUtils.isEmpty(objectRequest.getZipNo())) {
objectRequest.setZipNo("0");
}
objectFileSetting(iniFile, groupKey, "郵便番号", objectRequest.getZipNo());
// 도도부현
objectFileSetting(iniFile, groupKey, "都道府県", objectRequest.getPrefName());
// 주소
objectFileSetting(iniFile, groupKey, "住所", objectRequest.getAddress());
// 발전시뮬레이션 지역
objectFileSetting(iniFile, groupKey, "地域", objectRequest.getPowerSimArea());
// 판매오더 예상코드명
objectFileSetting(iniFile, groupKey, "受注見込", objectRequest.getWorkName());
// 부동산 분류 코드명 (0/1)
objectFileSetting(iniFile, groupKey, "物件区分", objectRequest.getObjectStatusName());
// 메모
objectFileSetting(iniFile, groupKey, "メモ", objectRequest.getRemarks());
// 설치높이
objectFileSetting(iniFile, groupKey, "高さ", objectRequest.getInstallHeight());
// 기준풍속
objectFileSetting(iniFile, groupKey, "基準風速", objectRequest.getWindSpeed());
// 수직적설량
objectFileSetting(iniFile, groupKey, "積雪", objectRequest.getSnowCover());
// 면조도구분 (III ㆍIV/II)
objectFileSetting(iniFile, groupKey, "面粗度", objectRequest.getSurfaceType());
// 전력계약 (0/1)
objectFileSetting(iniFile, groupKey, "電力契約", objectRequest.getPowerConTerms());
// 염해지역 아이템 사용여부 (0/1)
objectFileSetting(iniFile, groupKey, "塩害地域", objectRequest.getSaltAreaChk());
// 한랭지 대책여부 (0/1)
objectFileSetting(iniFile, groupKey, "寒冷地域", objectRequest.getColdAreaChk());
// 판매오더 예상코드
objectFileSetting(iniFile, groupKey, "受注見込コード", objectRequest.getWorkNo());
// 부동산 분류 코드
objectFileSetting(iniFile, groupKey, "物件区分コード", objectRequest.getObjectStatusId());
// 도도부현 코드
objectFileSetting(iniFile, groupKey, "都道府県コード", objectRequest.getPrefId());
// 물건번호
objectFileSetting(
iniFile,
groupKey,
"物件コード",
!StringUtils.isEmpty(objectRequest.getNewObjectNo())
? objectRequest.getNewObjectNo()
: objectRequest.getObjectNo());
// 최종 일본어 형식으로 저장
OutputStreamWriter output =
new OutputStreamWriter(
new FileOutputStream(dirPath + File.separator + baseFileName), "MS932");
iniFile.store(output);
output.close();
input.close();
} catch (Exception e) {
log.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
public void objectFileInfo(ObjectResponse objectResponse) throws Exception {
try {
String filePath =
baseDirPath
+ File.separator
+ objectResponse.getObjectNo()
+ File.separator
+ objectResponse.getPlanNo()
+ File.separator
+ baseFileName;
System.out.println(filePath);
File file = new File(filePath);
if (file.exists()) {
FileInputStream input = new FileInputStream(file);
Wini iniFile = new Wini(new InputStreamReader(input, "MS932"));
// [物件情報] 영역 코드명
String groupKey = "物件情報";
// 발전시뮬레이션 지역
if (!StringUtils.isEmpty(iniFile.get(groupKey, "地域"))) {
objectResponse.setPowerSimArea(iniFile.get(groupKey, "地域"));
}
// 주소
if (!StringUtils.isEmpty(iniFile.get(groupKey, "住所"))) {
objectResponse.setAddress(iniFile.get(groupKey, "住所"));
}
// 설치높이
if (!StringUtils.isEmpty(iniFile.get(groupKey, "高さ"))) {
objectResponse.setInstallHeight(iniFile.get(groupKey, "高さ"));
}
// 기준풍속
if (!StringUtils.isEmpty(iniFile.get(groupKey, "基準風速"))) {
objectResponse.setWindSpeed(iniFile.get(groupKey, "基準風速"));
}
// 수직적설량
if (!StringUtils.isEmpty(iniFile.get(groupKey, "積雪"))) {
objectResponse.setSnowCover(iniFile.get(groupKey, "積雪"));
}
// 면조도구분 (III ㆍIV/II)
if (!StringUtils.isEmpty(iniFile.get(groupKey, "面粗度"))) {
objectResponse.setSurfaceType(iniFile.get(groupKey, "面粗度"));
}
// 전력계약 (0/1)
if (!StringUtils.isEmpty(iniFile.get(groupKey, "電力契約"))) {
objectResponse.setPowerConTerms(iniFile.get(groupKey, "電力契約"));
}
// 염해지역 아이템 사용여부 (0/1)
if (!StringUtils.isEmpty(iniFile.get(groupKey, "塩害地域"))) {
objectResponse.setSaltAreaChk(iniFile.get(groupKey, "塩害地域"));
}
// 한랭지 대책여부 (0/1)
if (!StringUtils.isEmpty(iniFile.get(groupKey, "寒冷地域"))) {
objectResponse.setColdAreaChk(iniFile.get(groupKey, "寒冷地域"));
}
input.close();
}
} catch (Exception e) {
log.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
public void objectFileSetting(Wini wini, String groupOptName, String optName, String val)
throws Exception {
if (wini.get(groupOptName, optName) != null) {
wini.remove(groupOptName, optName);
}
if (!StringUtils.isEmpty(val)) {
wini.put(groupOptName, optName, val);
}
}
public String insertPlan(PlanRequest planRequest) throws Exception { public String insertPlan(PlanRequest planRequest) throws Exception {
// 추가 Plan 등록 // 추가 Plan 등록
planRequest.setRoofKindId("0"); planRequest.setRoofKindId("0");
@ -401,46 +196,11 @@ public class ObjectService {
objectMapper.insertPlan(planRequest); objectMapper.insertPlan(planRequest);
try {
String dirPath = baseDirPath + File.separator + planRequest.getObjectNo();
File file = new File(dirPath + File.separator + planRequest.getPlanNo());
if (!file.exists()) {
file.mkdirs();
}
// ini 파일 복사
File orgFile = new File(dirPath + File.separator + "1" + File.separator + baseFileName);
File copyFile =
new File(
dirPath + File.separator + planRequest.getPlanNo() + File.separator + baseFileName);
Files.copy(orgFile.toPath(), copyFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
log.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
return planRequest.getPlanNo(); return planRequest.getPlanNo();
} }
public void deletePlan(PlanRequest planRequest) throws Exception { public void deletePlan(PlanRequest planRequest) throws Exception {
// Plan 삭제 // Plan 삭제
objectMapper.deletePlan(planRequest); objectMapper.deletePlan(planRequest);
try {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date time = new Date();
String delTime = dateFormat.format(time);
String dirPath = baseDirPath + File.separator + planRequest.getObjectNo();
File file = new File(dirPath + File.separator + planRequest.getPlanNo());
if (file.exists()) {
file.renameTo(new File(dirPath + File.separator + planRequest.getPlanNo() + "_" + delTime));
}
} catch (Exception e) {
log.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
} }
} }

View File

@ -5,9 +5,23 @@ import lombok.Data;
@Data @Data
public class ObjectRequest { public class ObjectRequest {
// 물건정보 ini 파일 설정 순서에 맞쳐 셋팅 @Schema(description = "물건번호")
@Schema(description = "판매점명") private String objectNo;
private String saleStoreName;
@Schema(description = "생성 물건번호")
private String newObjectNo;
@Schema(description = "판매오더코드")
private String workNo;
@Schema(description = "담당자")
private String receiveUser;
@Schema(description = "부동산 분류코드")
private String objectStatusId;
@Schema(description = "안건명")
private String objectName;
@Schema(description = "경칭") @Schema(description = "경칭")
private String objectNameOmit; private String objectNameOmit;
@ -15,73 +29,52 @@ public class ObjectRequest {
@Schema(description = "안건명 후리가나") @Schema(description = "안건명 후리가나")
private String objectNameKana; private String objectNameKana;
@Schema(description = "안건명")
private String objectName;
@Schema(description = "담당자")
private String receiveUser;
@Schema(description = "우편번호") @Schema(description = "우편번호")
private String zipNo; private String zipNo;
@Schema(description = "도도부현코드")
private String prefId;
@Schema(description = "도도부현명") @Schema(description = "도도부현명")
private String prefName; private String prefName;
@Schema(description = "주소") @Schema(description = "주소")
private String address; private String address;
@Schema(description = "발전시뮬레이션 지역") @Schema(description = "발전시뮬레이션 지역코드")
private String powerSimArea; private String areaId;
@Schema(description = "판매오더명")
private String workName;
@Schema(description = "부동산 분류코드명")
private String objectStatusName;
@Schema(description = "메모")
private String remarks;
@Schema(description = "설치높이")
private String installHeight;
@Schema(description = "기준풍속") @Schema(description = "기준풍속")
private String windSpeed; private String windSpeed;
@Schema(description = "수직적설량") @Schema(description = "수직적설량")
private String snowCover; private String verticalSnowCover;
@Schema(description = "면조도구분") @Schema(description = "면조도구분")
private String surfaceType; private String surfaceType;
@Schema(description = "전력계약구분") @Schema(description = "설치높이")
private String powerConTerms; private String installHeight;
@Schema(description = "염해지역 아이템사용 여부") @Schema(description = "계약조건")
private String saltAreaChk; private String conType;
@Schema(description = "한랭지 대책여부") @Schema(description = "한랭지 대책여부")
private String coldAreaChk; private String coldRegionFlg;
@Schema(description = "판매오더코드") @Schema(description = "염해지역 아이템사용 여부")
private String workNo; private String saltAreaFlg;
@Schema(description = "부동산 분류코드") @Schema(description = "메모")
private String objectStatusId; private String remarks;
@Schema(description = "도도부현코드")
private String prefId;
@Schema(description = "물건번호")
private String objectNo;
@Schema(description = "생성 물건번호")
private String newObjectNo;
// 그외 물건정보 // 그외 물건정보
@Schema(description = "판매점ID") @Schema(description = "판매점ID")
private String saleStoreId; private String saleStoreId;
@Schema(description = "판매점명")
private String saleStoreName;
@Schema(description = "배송회사명") @Schema(description = "배송회사명")
private String addresseeCompanyName; private String addresseeCompanyName;

View File

@ -13,7 +13,7 @@ public class ObjectResponse {
@Schema(description = "물건번호") @Schema(description = "물건번호")
private String objectNo; private String objectNo;
@Schema(description = "판매점ID") @Schema(description = "판매점 ID")
private String saleStoreId; private String saleStoreId;
@Schema(description = "판매점명") @Schema(description = "판매점명")
@ -43,6 +43,33 @@ public class ObjectResponse {
@Schema(description = "주소") @Schema(description = "주소")
private String address; private String address;
@Schema(description = "발전시뮬레이션 지역코드")
private String areaId;
@Schema(description = "발전시뮬레이션 지역명")
private String areaName;
@Schema(description = "기준풍속")
private String windSpeed;
@Schema(description = "수직적설량")
private String verticalSnowCover;
@Schema(description = "면조도구분")
private String surfaceType;
@Schema(description = "설치높이")
private String installHeight;
@Schema(description = "계약조건")
private String conType;
@Schema(description = "한랭지 대책여부")
private String coldRegionFlg;
@Schema(description = "염해지역 아이템사용 여부")
private String saltAreaFlg;
@Schema(description = "메모") @Schema(description = "메모")
private String remarks; private String remarks;
@ -79,31 +106,6 @@ public class ObjectResponse {
@Schema(description = "갱신자") @Schema(description = "갱신자")
private String lastEditUserName; private String lastEditUserName;
// ini 설정정보
@Schema(description = "발전시뮬레이션 지역")
private String powerSimArea;
@Schema(description = "기준풍속")
private String windSpeed;
@Schema(description = "수직적설량")
private String snowCover;
@Schema(description = "면조도구분")
private String surfaceType;
@Schema(description = "설치높이")
private String installHeight;
@Schema(description = "전력계약구분")
private String powerConTerms;
@Schema(description = "한랭지 대책여부")
private String coldAreaChk;
@Schema(description = "염해지역 아이템사용 여부")
private String saltAreaChk;
// 플랜정보 // 플랜정보
@Schema(description = "플랜번호") @Schema(description = "플랜번호")
private String planNo; private String planNo;

View File

@ -157,6 +157,14 @@
, O.SPECIFICATION_CONFIRM_DATE , O.SPECIFICATION_CONFIRM_DATE
, O.CREATE_DATETIME , O.CREATE_DATETIME
, O.LAST_EDIT_DATETIME , O.LAST_EDIT_DATETIME
, O.AREA_ID
, O.WIND_SPEED
, O.VERTICAL_SNOW_COVER
, O.SURFACE_TYPE
, O.INSTALL_HEIGHT
, O.CON_TYPE
, O.COLD_REGION_FLG
, O.SALT_AREA_FLG
, S.SALE_STORE_NAME , S.SALE_STORE_NAME
, S.DISP_COMPANY_NAME , S.DISP_COMPANY_NAME
, (SELECT NAME FROM M_USER WHERE USER_ID = O.CREATE_USER) AS CREATE_USER_NAME , (SELECT NAME FROM M_USER WHERE USER_ID = O.CREATE_USER) AS CREATE_USER_NAME
@ -236,6 +244,14 @@
, O.RECEIVE_USER , O.RECEIVE_USER
, O.SPECIFICATION_CONFIRM_DATE , O.SPECIFICATION_CONFIRM_DATE
, O.CONTENTS_PATH , O.CONTENTS_PATH
, O.AREA_ID
, O.WIND_SPEED
, O.VERTICAL_SNOW_COVER
, O.SURFACE_TYPE
, O.INSTALL_HEIGHT
, O.CON_TYPE
, O.COLD_REGION_FLG
, O.SALT_AREA_FLG
, O.TEMP_FLG , O.TEMP_FLG
FROM T_OBJECT O WITH (NOLOCK) FROM T_OBJECT O WITH (NOLOCK)
WHERE O.OBJECT_NO = #{objectNo} WHERE O.OBJECT_NO = #{objectNo}
@ -355,6 +371,14 @@
, LAST_EDIT_USER , LAST_EDIT_USER
, EDIT_AGENCY , EDIT_AGENCY
, NORTH_ARRANGEMENT , NORTH_ARRANGEMENT
, AREA_ID
, WIND_SPEED
, VERTICAL_SNOW_COVER
, SURFACE_TYPE
, INSTALL_HEIGHT
, CON_TYPE
, COLD_REGION_FLG
, SALT_AREA_FLG
, TEMP_FLG , TEMP_FLG
, TEMP_DEL_FLG , TEMP_DEL_FLG
) VALUES ( ) VALUES (
@ -390,6 +414,14 @@
, #{userId} , #{userId}
, '0' , '0'
, '0' , '0'
, #{areaId}
, #{windSpeed}
, #{verticalSnowCover}
, #{surfaceType}
, #{installHeight}
, #{conType}
, #{coldRegionFlg}
, #{saltAreaFlg}
, #{tempFlg} , #{tempFlg}
, #{tempDelFlg} , #{tempDelFlg}
) )
@ -411,6 +443,14 @@
, REMARKS = #{remarks} , REMARKS = #{remarks}
, RECEIVE_USER = #{receiveUser} , RECEIVE_USER = #{receiveUser}
, CONTENTS_PATH = #{contentsPath} , CONTENTS_PATH = #{contentsPath}
, AREA_ID = #{areaId}
, WIND_SPEED = #{windSpeed}
, VERTICAL_SNOW_COVER = #{verticalSnowCover}
, SURFACE_TYPE = #{surfaceType}
, INSTALL_HEIGHT = #{installHeight}
, CON_TYPE = #{conType}
, COLD_REGION_FLG = #{coldRegionFlg}
, SALT_AREA_FLG = #{saltAreaFlg}
, LAST_EDIT_DATETIME = GETDATE() , LAST_EDIT_DATETIME = GETDATE()
, LAST_EDIT_USER = #{userId} , LAST_EDIT_USER = #{userId}
WHERE OBJECT_NO = #{objectNo} WHERE OBJECT_NO = #{objectNo}