From 542721abc5e7343ccad55c020916290f90a0196e Mon Sep 17 00:00:00 2001 From: "LAPTOP-L3VE7KK2\\USER" Date: Mon, 7 Oct 2024 09:45:16 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=BC=EA=B1=B4=EC=A0=95=EB=B3=B4=20API=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EA=B8=B0=EB=8A=A5=20=EC=A0=9C=EA=B1=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qcast/biz/object/ObjectService.java | 242 +----------------- .../qcast/biz/object/dto/ObjectRequest.java | 77 +++--- .../qcast/biz/object/dto/ObjectResponse.java | 54 ++-- .../resources/mappers/object/objectMapper.xml | 40 +++ 4 files changed, 104 insertions(+), 309 deletions(-) diff --git a/src/main/java/com/interplug/qcast/biz/object/ObjectService.java b/src/main/java/com/interplug/qcast/biz/object/ObjectService.java index c54ee7d1..7e071b16 100644 --- a/src/main/java/com/interplug/qcast/biz/object/ObjectService.java +++ b/src/main/java/com/interplug/qcast/biz/object/ObjectService.java @@ -2,17 +2,12 @@ package com.interplug.qcast.biz.object; import com.interplug.qcast.biz.object.dto.*; 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.util.Calendar; -import java.util.Date; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomStringUtils; -import org.ini4j.Wini; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -57,16 +52,10 @@ public class ObjectService { } public ObjectResponse selectObjectDetail(String objectNo) throws Exception { - // object 상세 정보 조회2 + // object 상세 정보 조회 ObjectResponse objectResponse = objectMapper.selectObjectDetail(objectNo); if (objectResponse != null) { - // 기본 플랜번호 셋팅 - objectResponse.setPlanNo("1"); - - // ini 파일 읽어 Response 객체 담기 - this.objectFileInfo(objectResponse); - // Plan 목록 조회 PlanRequest planRequest = new PlanRequest(); planRequest.setObjectNo(objectNo); @@ -132,10 +121,6 @@ public class ObjectService { planRequest.setUserId(objectRequest.getUserId()); result += objectMapper.insertPlan(planRequest); - // ini 파일 생성 - objectRequest.setPlanNo(planRequest.getPlanNo()); - this.objectFileSave(objectRequest); - // 결과 데이터 리턴 ObjectResponse objectResponse = new ObjectResponse(); objectResponse.setObjectNo(objectNo); @@ -175,28 +160,10 @@ public class ObjectService { + (tempChgFlg ? objectRequest.getNewObjectNo() : objectRequest.getObjectNo())); result += objectMapper.updateObject(objectRequest); - // Plan 목록 조회 - PlanRequest planRequest = new PlanRequest(); - planRequest.setObjectNo(objectRequest.getObjectNo()); - List planList = objectMapper.selectPlanList(planRequest); - - for (PlanResponse planResponse : planList) { - objectRequest.setPlanNo(planResponse.getPlanNo()); - - // ini 파일 수정 - this.objectFileSave(objectRequest); - } - // 임시저장에서 저장상태로 돌리기 if (tempChgFlg) { objectMapper.updateObjectNoChange(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; } - 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 { // 추가 Plan 등록 planRequest.setRoofKindId("0"); @@ -401,46 +196,11 @@ public class ObjectService { 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(); } public void deletePlan(PlanRequest planRequest) throws Exception { // Plan 삭제 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()); - } } } diff --git a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java index 1e1d32d2..46c276ef 100644 --- a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java +++ b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectRequest.java @@ -5,9 +5,23 @@ import lombok.Data; @Data public class ObjectRequest { - // 물건정보 ini 파일 설정 순서에 맞쳐 셋팅 - @Schema(description = "판매점명") - private String saleStoreName; + @Schema(description = "물건번호") + private String objectNo; + + @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 = "경칭") private String objectNameOmit; @@ -15,73 +29,52 @@ public class ObjectRequest { @Schema(description = "안건명 후리가나") private String objectNameKana; - @Schema(description = "안건명") - private String objectName; - - @Schema(description = "담당자") - private String receiveUser; - @Schema(description = "우편번호") private String zipNo; + @Schema(description = "도도부현코드") + private String prefId; + @Schema(description = "도도부현명") private String prefName; @Schema(description = "주소") private String address; - @Schema(description = "발전시뮬레이션 지역") - private String powerSimArea; - - @Schema(description = "판매오더명") - private String workName; - - @Schema(description = "부동산 분류코드명") - private String objectStatusName; - - @Schema(description = "메모") - private String remarks; - - @Schema(description = "설치높이") - private String installHeight; + @Schema(description = "발전시뮬레이션 지역코드") + private String areaId; @Schema(description = "기준풍속") private String windSpeed; @Schema(description = "수직적설량") - private String snowCover; + private String verticalSnowCover; @Schema(description = "면조도구분") private String surfaceType; - @Schema(description = "전력계약구분") - private String powerConTerms; + @Schema(description = "설치높이") + private String installHeight; - @Schema(description = "염해지역 아이템사용 여부") - private String saltAreaChk; + @Schema(description = "계약조건") + private String conType; @Schema(description = "한랭지 대책여부") - private String coldAreaChk; + private String coldRegionFlg; - @Schema(description = "판매오더코드") - private String workNo; + @Schema(description = "염해지역 아이템사용 여부") + private String saltAreaFlg; - @Schema(description = "부동산 분류코드") - private String objectStatusId; - - @Schema(description = "도도부현코드") - private String prefId; - - @Schema(description = "물건번호") - private String objectNo; - - @Schema(description = "생성 물건번호") - private String newObjectNo; + @Schema(description = "메모") + private String remarks; // 그외 물건정보 @Schema(description = "판매점ID") private String saleStoreId; + @Schema(description = "판매점명") + private String saleStoreName; + @Schema(description = "배송회사명") private String addresseeCompanyName; diff --git a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java index dde71e36..88435b10 100644 --- a/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java +++ b/src/main/java/com/interplug/qcast/biz/object/dto/ObjectResponse.java @@ -13,7 +13,7 @@ public class ObjectResponse { @Schema(description = "물건번호") private String objectNo; - @Schema(description = "판매점ID") + @Schema(description = "판매점 ID") private String saleStoreId; @Schema(description = "판매점명") @@ -43,6 +43,33 @@ public class ObjectResponse { @Schema(description = "주소") 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 = "메모") private String remarks; @@ -79,31 +106,6 @@ public class ObjectResponse { @Schema(description = "갱신자") 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 = "플랜번호") private String planNo; diff --git a/src/main/resources/mappers/object/objectMapper.xml b/src/main/resources/mappers/object/objectMapper.xml index 1ec46287..cf6e27e8 100644 --- a/src/main/resources/mappers/object/objectMapper.xml +++ b/src/main/resources/mappers/object/objectMapper.xml @@ -157,6 +157,14 @@ , O.SPECIFICATION_CONFIRM_DATE , O.CREATE_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.DISP_COMPANY_NAME , (SELECT NAME FROM M_USER WHERE USER_ID = O.CREATE_USER) AS CREATE_USER_NAME @@ -236,6 +244,14 @@ , O.RECEIVE_USER , O.SPECIFICATION_CONFIRM_DATE , 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 FROM T_OBJECT O WITH (NOLOCK) WHERE O.OBJECT_NO = #{objectNo} @@ -355,6 +371,14 @@ , LAST_EDIT_USER , EDIT_AGENCY , NORTH_ARRANGEMENT + , AREA_ID + , WIND_SPEED + , VERTICAL_SNOW_COVER + , SURFACE_TYPE + , INSTALL_HEIGHT + , CON_TYPE + , COLD_REGION_FLG + , SALT_AREA_FLG , TEMP_FLG , TEMP_DEL_FLG ) VALUES ( @@ -390,6 +414,14 @@ , #{userId} , '0' , '0' + , #{areaId} + , #{windSpeed} + , #{verticalSnowCover} + , #{surfaceType} + , #{installHeight} + , #{conType} + , #{coldRegionFlg} + , #{saltAreaFlg} , #{tempFlg} , #{tempDelFlg} ) @@ -411,6 +443,14 @@ , REMARKS = #{remarks} , RECEIVE_USER = #{receiveUser} , 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_USER = #{userId} WHERE OBJECT_NO = #{objectNo}