Merge branch 'dev' of https://git.jetbrains.space/nalpari/q-cast-iii/qcast-api into feature/qcast-api-002

This commit is contained in:
changkyu choi 2024-09-10 11:24:32 +09:00
commit 3a080f4ca7
13 changed files with 1062 additions and 2 deletions

View File

@ -111,6 +111,12 @@
<artifactId>jackson-databind</artifactId>
<version>2.16.1</version>
</dependency>
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency>
</dependencies>
<build>

View File

@ -1,7 +1,7 @@
package com.interplug.qcast.biz.commCode;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
@ -22,7 +22,7 @@ public class CommCodeController {
private final CommCodeService commCodeService;
@Operation(description = "공통코드 COMM_H, COMM_L 정보를 등록/수정 한다.(동기화)")
@PostMapping("/qc-comm-yn-update")
@PutMapping("/qc-comm-yn-update")
@ResponseStatus(HttpStatus.OK)
public CommCodeResponse setQcCommCdYn(@RequestBody CommCodeRequest codeReq) {
CommCodeResponse codeResponse = new CommCodeResponse();

View File

@ -0,0 +1,76 @@
package com.interplug.qcast.biz.object;
import com.interplug.qcast.biz.object.dto.ObjectRequest;
import com.interplug.qcast.biz.object.dto.ObjectResponse;
import com.interplug.qcast.biz.object.dto.PlanRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/api/object")
@RequiredArgsConstructor
@Tag(name = "ObjectController", description = "물건정보 관련 API")
public class ObjectController {
// @Autowired private ObjectService objectService;
private final ObjectService objectService;
@Operation(description = "물건정보 목록을 조회한다.")
@GetMapping("/v1.0/object")
@ResponseStatus(HttpStatus.OK)
public List<ObjectResponse> selectObjectList(ObjectRequest objectRequest) throws Exception {
return objectService.selectObjectList(objectRequest);
}
@Operation(description = "물건정보 상세를 조회한다.")
@GetMapping("/v1.0/object/{objectNo}")
@ResponseStatus(HttpStatus.OK)
public ObjectResponse selectObjectDetail(@PathVariable String objectNo) throws Exception {
return objectService.selectObjectDetail(objectNo);
}
@Operation(description = "물건정보을 저장한다.")
@PostMapping("/v1.0/object")
@ResponseStatus(HttpStatus.CREATED)
public ObjectResponse insertObject(@RequestBody ObjectRequest objectRequest) throws Exception {
return objectService.insertObject(objectRequest);
}
@Operation(description = "물건정보을 수정한다.")
@PutMapping("/v1.0/object")
@ResponseStatus(HttpStatus.CREATED)
public void updateObject(@RequestBody ObjectRequest objectRequest) throws Exception {
int reust = objectService.updateObject(objectRequest);
}
@Operation(description = "물건정보을 삭제한다.")
@DeleteMapping("/v1.0/object/{objectNo}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteObject(@PathVariable String objectNo) throws Exception {
objectService.deleteObject(objectNo);
}
@Operation(description = "물건정보의 플랜정보를 추가한다.")
@PostMapping("/v1.0/object/plan")
@ResponseStatus(HttpStatus.CREATED)
public void insertPlan(@RequestBody PlanRequest planRequest) throws Exception {
objectService.insertPlan(planRequest);
}
@Operation(description = "물건정보의 플랜정보를 삭제한다.")
@DeleteMapping("/v1.0/object/plan/{objectNo}/{planNo}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deletePlan(@PathVariable String objectNo, @PathVariable String planNo) throws Exception {
PlanRequest planRequest = new PlanRequest();
planRequest.setObjectNo(objectNo);
planRequest.setPlanNo(planNo);
objectService.deletePlan(planRequest);
}
}

View File

@ -0,0 +1,46 @@
package com.interplug.qcast.biz.object;
import com.interplug.qcast.biz.object.dto.ObjectRequest;
import com.interplug.qcast.biz.object.dto.ObjectResponse;
import com.interplug.qcast.biz.object.dto.PlanRequest;
import com.interplug.qcast.biz.object.dto.PlanResponse;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
interface ObjectMapper {
// 물건정보 목록 조회
public List<ObjectResponse> selectObjectList(ObjectRequest objectRequest);
// 물건정보 상세 확인
public ObjectResponse selectObjectDetail(String objectNo);
// 물건번호 조회
public String selectObjectNo(ObjectRequest objectRequest);
// 물건정보 PLAN 목록 조회
public List<PlanResponse> selectPlanList(PlanRequest planRequest);
// 물건번호 등록
public int insertObjectNo(ObjectRequest objectRequest);
// 물건정보 등록
public int insertObject(ObjectRequest objectRequest);
// 물건정보 수정
public int updateObject(ObjectRequest objectRequest);
// 물건정보 삭제
public int deleteObject(ObjectRequest objectRequest);
// 물건정보 > 배송정보 수정
public int updateObjectDelivery(ObjectRequest objectRequest);
// 플랜정보 등록
public int insertPlan(PlanRequest planRequest);
// 플랜정보 삭제(물리 삭제)
public int deletePlan(PlanRequest planRequest);
}

View File

@ -0,0 +1,326 @@
package com.interplug.qcast.biz.object;
import com.interplug.qcast.QCastApplication;
import com.interplug.qcast.biz.object.dto.ObjectRequest;
import com.interplug.qcast.biz.object.dto.ObjectResponse;
import com.interplug.qcast.biz.object.dto.PlanRequest;
import com.interplug.qcast.biz.object.dto.PlanResponse;
import io.micrometer.common.util.StringUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.ini4j.Wini;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor
public class ObjectService {
private final ObjectMapper objectMapper;
private final QCastApplication qCastApplication;
@Value("${file.ini.root.path}")
private String baseDirPath;
@Value("${file.ini.base.filename}")
private String baseFileName;
public List<ObjectResponse> selectObjectList(ObjectRequest objectRequest) throws Exception {
return objectMapper.selectObjectList(objectRequest);
}
public ObjectResponse selectObjectDetail(String objectNo) throws Exception {
ObjectResponse objectResponse = new ObjectResponse();
// object 상세 정보 조회
objectResponse = objectMapper.selectObjectDetail(objectNo);
// 기본 플랜번호 셋팅
objectResponse.setPlanNo("1");
if (objectResponse != null) {
// ini 파일 읽어 Response 객체 담기
this.objectFileInfo(objectResponse);
}
return objectResponse;
}
public ObjectResponse insertObject(ObjectRequest objectRequest) throws Exception {
int result = 0;
// 물건번호 등록/조회
result += objectMapper.insertObjectNo(objectRequest);
String objectNo = objectMapper.selectObjectNo(objectRequest);
objectRequest.setObjectNo(objectNo);
// 물건정보 등록
objectRequest.setAddress(objectRequest.getPrefName() + ((!StringUtils.isEmpty(objectRequest.getAddress())) ? objectRequest.getAddress() : ""));
objectRequest.setAddresseeCompanyName(objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit());
objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit());
objectRequest.setContentsPath(baseDirPath + "\\\\" + objectRequest.getObjectNo());
result += objectMapper.insertObject(objectRequest);
result += objectMapper.updateObjectDelivery(objectRequest);
// 디폴트 Plan 등록
PlanRequest planRequest = new PlanRequest();
planRequest.setObjectNo(objectNo);
planRequest.setRoofKindId("0");
planRequest.setCharger(objectRequest.getReceiveUser());
planRequest.setStatus("1");
planRequest.setDelFlg("0");
planRequest.setNorthArrangement("0");
planRequest.setDiffRoofEnabled("0");
planRequest.setUserId(objectRequest.getUserId());
result += objectMapper.insertPlan(planRequest);
// ini 파일 생성
objectRequest.setPlanNo(planRequest.getPlanNo());
this.objectFileSave(objectRequest);
// 결과 데이터 리턴
ObjectResponse objectResponse = new ObjectResponse();
objectResponse.setObjectNo(objectNo);
objectResponse.setPlanNo(planRequest.getPlanNo());
return objectResponse;
}
public int updateObject(ObjectRequest objectRequest) throws Exception {
int result = 0;
// 물건정보 수정
objectRequest.setAddress(objectRequest.getPrefName() + ((!StringUtils.isEmpty(objectRequest.getAddress())) ? objectRequest.getAddress() : ""));
objectRequest.setAddresseeCompanyName(objectRequest.getObjectName() + ' ' + objectRequest.getObjectNameOmit());
objectRequest.setAddresseeCompanyNameOmit(objectRequest.getObjectNameOmit());
objectRequest.setContentsPath(baseDirPath + "\\\\" + objectRequest.getObjectNo());
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);
}
return result;
}
public int deleteObject(String objectNo) throws Exception {
int result = 0;
// 물건정보 삭제
ObjectRequest objectRequest = new ObjectRequest();
objectRequest.setObjectNo(objectNo);
result = objectMapper.deleteObject(objectRequest);
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, "物件コード", objectRequest.getObjectNo());
// 최종 일본어 형식으로 저장
iniFile.store(new OutputStreamWriter(new FileOutputStream(dirPath + File.separator + baseFileName), "MS932"));
} 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, "寒冷地域"));
}
}
} 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");
planRequest.setStatus("1");
planRequest.setDelFlg("0");
planRequest.setNorthArrangement("0");
planRequest.setDiffRoofEnabled("0");
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());
}
}
}

View File

@ -0,0 +1,60 @@
package com.interplug.qcast.biz.object.dto;
import lombok.Data;
@Data
public class ObjectRequest {
// 물건정보 ini 파일 설정 순서에 맞쳐 셋팅
private String saleStoreName;
private String objectNameOmit;
private String objectNameKana;
private String objectName;
private String receiveUser;
private String zipNo;
private String prefName;
private String address;
private String powerSimArea;
private String workName;
private String objectStatusName;
private String remarks;
private String installHeight;
private String windSpeed;
private String snowCover;
private String surfaceType;
private String powerConTerms;
private String saltAreaChk;
private String coldAreaChk;
private String workNo;
private String objectStatusId;
private String prefId;
private String objectNo;
// 그외 물건정보
private String saleStoreId;
private String addresseeCompanyName;
private String addresseeCompanyNameOmit;
private String contentsPath;
private String delFlg;
private String userId;
// 플랜정보
private String planNo;
// 검색정보
private String schObjectNo;
private String schSaleStoreId;
private String schAddress;
private String schObjectName;
private String schSaleStoreName;
private String schSpecDateYn;
private String schReceiveUser;
private String schDispCompanyName;
private String schDateType;
private String schFromDt;
private String schToDt;
// 페이징정보
private String startRow;
private String endRow;
}

View File

@ -0,0 +1,52 @@
package com.interplug.qcast.biz.object.dto;
import lombok.Getter;
import lombok.Setter;
//@Data
@Getter
@Setter
public class ObjectResponse {
// 물건정보
private String objectNo;
private String saleStoreId;
private String saleStoreName;
private String workNo;
private String objectStatusId;
private String objectName;
private String objectNameOmit;
private String objectNameKana;
private String zipNo;
private String prefId;
private String address;
private String remarks;
private String sameObjectInfo;
private String receiveCompanyName;
private String receiveUser;
private String contentsPath;
private String specDate;
private String dispCompanyName;
private String createDatetime;
private String createUserName;
private String lastEditDatetime;
private String lastEditUserName;
// ini 설정정보
private String powerSimArea;
private String windSpeed;
private String snowCover;
private String surfaceType;
private String installHeight;
private String powerConTerms;
private String coldAreaChk;
private String saltAreaChk;
// 플랜정보
private String planNo;
private String planTotCnt;
// 페이징 정보
private Integer rowNumber;
private Integer totCnt;
}

View File

@ -0,0 +1,40 @@
package com.interplug.qcast.biz.object.dto;
import lombok.Data;
@Data
public class PlanRequest {
private String objectNo;
private String planNo;
private String constructSpecification;
private String setupHeight;
private String weatherPoint;
private String roofKindId;
private String slope;
private String roofMaterialClassId;
private String roofMaterialId;
private String supportMethodId;
private String moduleModel;
private String charger;
private String estimateValidityTerm;
private String decisionPlan;
private String number;
private String capacity;
private String snowfall;
private String standardWindSpeedCheck;
private String optionCover;
private String hanwfaFlg;
private String standKindId;
private String standardWindSpeedId;
private String supportMeaker;
private String consumptionTaxId;
private String status;
private String userId;
private String delFlg;
private String pcTypeNo;
private String northArrangement;
private String roofMaterialIdMulti;
private String supportMethodIdMulti;
private String supportMeakerMulti;
private String diffRoofEnabled;
}

View File

@ -0,0 +1,40 @@
package com.interplug.qcast.biz.object.dto;
import lombok.Data;
@Data
public class PlanResponse {
private String objectNo;
private String planNo;
private String constructSpecification;
private String setupHeight;
private String weatherPoint;
private String roofKindId;
private String slope;
private String roofMaterialClassId;
private String roofMaterialId;
private String supportMethodId;
private String moduleModel;
private String charger;
private String estimateValidityTerm;
private String decisionPlan;
private String number;
private String capacity;
private String snowfall;
private String standardWindSpeedCheck;
private String optionCover;
private String hanwfaFlg;
private String standKindId;
private String standardWindSpeedId;
private String supportMeaker;
private String consumptionTaxId;
private String status;
private String userId;
private String delFlg;
private String pcTypeNo;
private String northArrangement;
private String roofMaterialIdMulti;
private String supportMethodIdMulti;
private String supportMeakerMulti;
private String diffRoofEnabled;
}

View File

@ -26,3 +26,9 @@ spring:
#QSP
qsp:
url: http://172.23.4.129:8120
#File
file:
root.path: C:\\
ini.root.path: C:\\NewEstimate
ini.base.filename: 料金シミュレーション.ini

View File

@ -26,3 +26,9 @@ spring:
#QSP
qsp:
url: http://localhost:8120
#File
file:
root.path: C:\\
ini.root.path: C:\\NewEstimate
ini.base.filename: 料金シミュレーション.ini

View File

@ -26,3 +26,9 @@ spring:
#QSP
qsp:
url: http://jp.qsalesplatform.com
#File
file:
root.path: C:\\
ini.root.path: \\10.31.0.21\NewEstimate
ini.base.filename: 料金シミュレーション.ini

View File

@ -0,0 +1,396 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.interplug.qcast.biz.object.ObjectMapper">
<select id="selectObjectList" parameterType="com.interplug.qcast.biz.object.dto.ObjectRequest" resultType="com.interplug.qcast.biz.object.dto.ObjectResponse">
/* 계층형 구조에 맞는 SALE_STORE_ID 축출 - 재귀함수 */
WITH SALES_STORE_CTE AS (
SELECT
SALE_STORE_LEVEL
, SALE_STORE_ID
, PARENT_SALE_AGENT_ID
FROM M_SALES_STORE WITH(NOLOCK)
WHERE SALE_STORE_ID = #{saleStoreId}
UNION ALL
SELECT
A.SALE_STORE_LEVEL
, A.SALE_STORE_ID
, A.PARENT_SALE_AGENT_ID
FROM M_SALES_STORE A WITH(NOLOCK)
INNER JOIN SALES_STORE_CTE B
ON A.PARENT_SALE_AGENT_ID = B.SALE_STORE_ID
WHERE A.DEL_FLG = '0'
)
SELECT
TT.*
FROM
(
SELECT
COUNT(1) OVER() AS TOT_CNT
, ROW_NUMBER() OVER(ORDER BY O.CREATE_DATETIME DESC) AS ROW_NUMBER
, O.OBJECT_NO
, O.OBJECT_NAME
, O.SALE_STORE_ID
, O.ZIP_NO
, O.ADDRESS
, O.RECEIVE_USER
, O.SPEC_DATE
, O.CREATE_DATETIME
, O.LAST_EDIT_DATETIME
, S.SALE_STORE_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.LAST_EDIT_USER) AS LAST_EDIT_USER_NAME
, (SELECT COUNT(1) FROM T_PLAN WHERE OBJECT_NO = O.OBJECT_NO AND DEL_FLG = '0') AS PLAN_TOT_CNT
FROM T_OBJECT O WITH (NOLOCK)
INNER JOIN M_SALES_STORE S WITH (NOLOCK)
ON O.SALE_STORE_ID = S.SALE_STORE_ID
INNER JOIN SALES_STORE_CTE T
ON S.SALE_STORE_ID = T.SALE_STORE_ID
WHERE O.DEL_FLG = '0'
<if test='schObjectNo != null and schObjectNo != ""'>
AND O.OBJECT_NO LIKE '%' + #{schObjectNo} + '%'
</if>
<if test='schSaleStoreId != null and schSaleStoreId != ""'>
AND O.SALE_STORE_ID LIKE '%' + #{schSaleStoreId} + '%'
</if>
<if test='schAddress != null and schAddress != ""'>
AND O.ADDRESS LIKE '%' + #{schAddress} + '%'
</if>
<if test='schObjectName != null and schObjectName != ""'>
AND O.OBJECT_NAME LIKE '%' + #{schObjectName} + '%'
</if>
<if test='schSaleStoreName != null and schSaleStoreName != ""'>
AND S.SALE_STORE_NAME LIKE '%' + #{schSaleStoreName} + '%'
</if>
<choose>
<when test='schSpecDateYn != null and schSpecDateYn == "Y"'>
AND O.SPEC_DATE IS NOT NULL
</when>
<when test='schSpecDateYn != null and schSpecDateYn == "N"'>
AND O.SPEC_DATE IS NULL
</when>
</choose>
<if test='schReceiveUser != null and schReceiveUser != ""'>
AND O.RECEIVE_USER LIKE '%' + #{schReceiveUser} + '%'
</if>
<if test='schDispCompanyName != null and schDispCompanyName != ""'>
AND S.DISP_COMPANY_NAME LIKE '%' + #{schDispCompanyName} + '%'
</if>
<choose>
<when test='schDateType != null and schDateType == "U" and (schFromDt != null and schFromDt != "") and (schToDt != null and schToDt != "")'>
/* 갱신일 시작일,종료일 검색조건 */
AND O.LAST_EDIT_DATETIME BETWEEN CONVERT(DATETIME, CONVERT(VARCHAR(10), PARSE(#{schFromDt} AS DATE USING 'en-US')) + ' 00:00:00') AND CONVERT(DATETIME, CONVERT(VARCHAR(10), PARSE(#{schToDt} AS DATE USING 'en-US')) + ' 23:59:59')
</when>
<when test='schDateType != null and schDateType == "R" and (schFromDt != null and schFromDt != "") and (schToDt != null and schToDt != "")'>
/* 등록일 시작일,종료일 검색조건 */
AND O.CREATE_DATETIME BETWEEN CONVERT(DATETIME, CONVERT(VARCHAR(10), PARSE(#{schFromDt} AS DATE USING 'en-US')) + ' 00:00:00') AND CONVERT(DATETIME, CONVERT(VARCHAR(10), PARSE(#{schToDt} AS DATE USING 'en-US')) + ' 23:59:59')
</when>
</choose>
) TT
<if test='startRow != null and startRow != "" and endRow != null and endRow != ""'>
WHERE TT.ROW_NUMBER BETWEEN #{startRow} AND #{endRow}
</if>
ORDER BY TT.ROW_NUMBER
</select>
<select id="selectObjectDetail" parameterType="String" resultType="com.interplug.qcast.biz.object.dto.ObjectResponse">
/* sqlid : com.interplug.qcast.biz.object.selectObjectDetail */
SELECT
O.OBJECT_NO
, O.SALE_STORE_ID
, O.WORK_NO
, O.OBJECT_STATUS_ID
, O.OBJECT_NAME
, O.OBJECT_NAME_OMIT
, O.OBJECT_NAME_KANA
, O.ZIP_NO
, O.PREF_ID
, O.ADDRESS
, O.REMARKS
, O.SAME_OBJECT_INFO
, O.RECEIVE_COMPANY_NAME
, O.RECEIVE_USER
, O.CONTENTS_PATH
FROM T_OBJECT O WITH (NOLOCK)
WHERE O.OBJECT_NO = #{objectNo}
AND O.DEL_FLG = '0'
</select>
<select id="selectObjectNo" parameterType="com.interplug.qcast.biz.object.dto.ObjectRequest" resultType="String">
/* sqlid : com.interplug.qcast.biz.object.selectObjectNo */
SELECT
'R' + #{saleStoreId} + RIGHT(CAST(YEAR(GETDATE()) AS VARCHAR), 2) + RIGHT('0' + CAST(MONTH(GETDATE()) AS VARCHAR), 2) + RIGHT('0' + CAST(DAY(GETDATE()) AS VARCHAR), 2) +
RIGHT (
'00' +
CAST (
(
SELECT
ISNULL(MAX(NO), 1)
FROM T_OBJECT_NO
WHERE SALE_STORE_ID = #{saleStoreId}
AND YEAR = RIGHT(CAST(YEAR(GETDATE()) AS VARCHAR), 2)
AND MONTH = RIGHT ('0' + CAST (MONTH (GETDATE()) AS VARCHAR), 2)
AND DAY = RIGHT ('0' + CAST (DAY (GETDATE()) AS VARCHAR), 2)
) AS VARCHAR
), 3)
</select>
<select id="selectPlanList" parameterType="com.interplug.qcast.biz.object.dto.PlanRequest" resultType="com.interplug.qcast.biz.object.dto.PlanResponse">
/* sqlid : com.interplug.qcast.biz.object.selectPlanList */
SELECT
T.OBJECT_NO
, T.PLAN_NO
, T.CONSTRUCT_SPECIFICATION
, T.SETUP_HEIGHT
, T.WEATHER_POINT
, T.ROOF_KIND_ID
, T.SLOPE
, T.ROOF_MATERIAL_CLASS_ID
, T.ROOF_MATERIAL_ID
, T.SUPPORT_METHOD_ID
, T.MODULE_MODEL
, T.CHARGER
, T.ESTIMATE_VALIDITY_TERM
, T.DECISION_PLAN
, T.NUMBER
, T.CAPACITY
, T.SNOWFALL
, T.STANDARD_WIND_SPEED_CHECK
, T.OPTION_COVER
, T.HANWFA_FLG
, T.STAND_KIND_ID
, T.STANDARD_WIND_SPEED_ID
, T.SUPPORT_MEAKER
, T.CONSUMPTION_TAX_ID
, T.STATUS
, T.PC_TYPE_NO
, T.NORTH_ARRANGEMENT
, T.ROOF_MATERIAL_ID_MULTI
, T.SUPPORT_METHOD_ID_MULTI
, T.SUPPORT_MEAKER_MULTI
, T.DIFF_ROOF_ENABLED
FROM T_PLAN T WITH (NOLOCK)
WHERE T.OBJECT_NO = #{objectNo}
AND T.DEL_FLG = '0'
</select>
<insert id="insertObjectNo" parameterType="com.interplug.qcast.biz.object.dto.ObjectRequest">
/* sqlid : com.interplug.qcast.biz.object.insertObjectNo */
INSERT INTO T_OBJECT_NO
(
SALE_STORE_ID
, YEAR
, MONTH
, DAY
, NO
)
SELECT
#{saleStoreId}
, RIGHT(CAST(YEAR(GETDATE()) AS VARCHAR), 2)
, RIGHT('0' + CAST(MONTH(GETDATE()) AS VARCHAR), 2)
, RIGHT('0' + CAST(DAY(GETDATE()) AS VARCHAR), 2)
, ISNULL(MAX(NO), 0) + 1 FROM T_OBJECT_NO WHERE SALE_STORE_ID = #{saleStoreId} AND YEAR = RIGHT(CAST(YEAR(GETDATE()) AS VARCHAR), 2) AND MONTH = RIGHT('0' + CAST(MONTH(GETDATE()) AS VARCHAR), 2) AND DAY = RIGHT('0' + CAST(DAY(GETDATE()) AS VARCHAR), 2)
</insert>
<insert id="insertObject" parameterType="com.interplug.qcast.biz.object.dto.ObjectRequest">
/* sqlid : com.interplug.qcast.biz.object.insertObject */
INSERT INTO T_OBJECT
(
OBJECT_NO
, SALE_STORE_ID
, OBJECT_STATUS_ID
, OBJECT_NAME
, OBJECT_NAME_OMIT
, OBJECT_NAME_KANA
, ZIP_NO
, PREF_ID
, ADDRESS
, ADDRESSEE_COMPANY_NAME
, ADDRESSEE_COMPANY_NAME_OMIT
, REMARKS
, SAME_OBJECT_INFO
, RECEIVE_USER
, DELIVERY_HOPE_DATE
, CONSTRUCT_SCHEDULED_DATE
, CAR_KIND_CD
, TRACK_KAIND
, TRACK_10T_DELIVERY
, TRACK_WEIGHT
, TRACK_TIME_SPECIFY
, FORKLIFT
, HOUSE_CLASS_CD
, FIRST_STORE_CHARGER
, CONTENTS_PATH
, DEL_FLG
, LAST_EDIT_DATETIME
, LAST_EDIT_USER
, EDIT_AGENCY
, NORTH_ARRANGEMENT
) VALUES (
#{objectNo}
, #{saleStoreId}
, #{objectStatusId}
, #{objectName}
, #{objectNameOmit}
, #{objectNameKana}
, #{zipNo}
, #{prefId}
, #{address}
, #{addresseeCompanyName}
, #{addresseeCompanyNameOmit}
, #{remarks}
, '1'
, #{receiveUser}
, GETDATE()
, GETDATE()
, '0'
, '4'
, '1'
, '10'
, '0'
, '1'
, '0'
, #{receiveUser}
, #{contentsPath}
, '0'
, GETDATE()
, #{userId}
, '0'
, '0'
)
</insert>
<update id="updateObject" parameterType="com.interplug.qcast.biz.object.dto.ObjectRequest">
/* sqlid : com.interplug.qcast.biz.object.updateObject */
UPDATE T_OBJECT
SET
OBJECT_STATUS_ID = #{objectStatusId}
, OBJECT_NAME = #{objectName}
, OBJECT_NAME_OMIT = #{objectNameOmit}
, OBJECT_NAME_KANA = #{objectNameKana}
, ZIP_NO = #{zipNo}
, PREF_ID = #{prefId}
, ADDRESS = #{address}
, ADDRESSEE_COMPANY_NAME = #{addresseeCompanyName}
, ADDRESSEE_COMPANY_NAME_OMIT = #{addresseeCompanyNameOmit}
, REMARKS = #{remarks}
, RECEIVE_USER = #{receiveUser}
, LAST_EDIT_DATETIME = GETDATE()
, LAST_EDIT_USER = #{userId}
WHERE OBJECT_NO = #{objectNo}
</update>
<update id="updateObjectDelivery" parameterType="com.interplug.qcast.biz.object.dto.ObjectRequest">
/* sqlid : com.interplug.qcast.biz.object.updateObjectDelivery */
UPDATE A SET
A.RECEIVE_COMPANY_NAME = B.DISP_COMPANY_NAME
, A.DELIVERY_ZIP_NO = B.DISP_ZIP_NO
, A.DELIVERY_TARGET = B.DISP_ADDRESS
, A.DELIVERY_TEL = B.DISP_TEL
FROM T_OBJECT AS A
INNER JOIN M_SALES_STORE AS B
ON A.SALE_STORE_ID = B.SALE_STORE_ID
WHERE A.OBJECT_NO = #{objectNo}
</update>
<update id="deleteObject" parameterType="com.interplug.qcast.biz.object.dto.ObjectRequest">
/* sqlid : com.interplug.qcast.biz.object.deleteObject */
UPDATE T_OBJECT
SET
DEL_FLG = '1'
, LAST_EDIT_DATETIME = GETDATE()
, LAST_EDIT_USER = #{userId}
WHERE OBJECT_NO = #{objectNo}
</update>
<insert id="insertPlan" parameterType="com.interplug.qcast.biz.object.dto.PlanRequest">
/* sqlid : com.interplug.qcast.biz.object.insertPlan*/
<selectKey resultType="String" keyProperty="planNo" order="BEFORE">
SELECT CAST(ISNULL(MAX(PLAN_NO), 0) + 1 AS NVARCHAR) FROM T_PLAN WHERE OBJECT_NO = #{objectNo}
</selectKey>
INSERT INTO T_PLAN
(
OBJECT_NO
, PLAN_NO
, CONSTRUCT_SPECIFICATION
, SETUP_HEIGHT
, WEATHER_POINT
, ROOF_KIND_ID
, SLOPE
, ROOF_MATERIAL_CLASS_ID
, ROOF_MATERIAL_ID
, SUPPORT_METHOD_ID
, MODULE_MODEL
, CHARGER
, ESTIMATE_VALIDITY_TERM
, DECISION_PLAN
, NUMBER
, CAPACITY
, SNOWFALL
, STANDARD_WIND_SPEED_CHECK
, OPTION_COVER
, HANWFA_FLG
, STAND_KIND_ID
, STANDARD_WIND_SPEED_ID
, SUPPORT_MEAKER
, CONSUMPTION_TAX_ID
, STATUS
, LAST_EDIT_DATETIME
, LAST_EDIT_USER
, DEL_FLG
, PC_TYPE_NO
, NORTH_ARRANGEMENT
, ROOF_MATERIAL_ID_MULTI
, SUPPORT_METHOD_ID_MULTI
, SUPPORT_MEAKER_MULTI
, DIFF_ROOF_ENABLED
) VALUES (
#{objectNo}
, #{planNo}
, #{constructSpecification}
, #{setupHeight}
, #{weatherPoint}
, #{roofKindId}
, #{slope}
, #{roofMaterialClassId}
, #{roofMaterialId}
, #{supportMethodId}
, #{moduleModel}
, (SELECT RECEIVE_USER FROM T_OBJECT WHERE OBJECT_NO = #{objectNo})
, #{estimateValidityTerm}
, CASE WHEN #{planNo} = '1' THEN '1' ELSE '0' END
, #{number}
, #{capacity}
, #{snowfall}
, #{standardWindSpeedCheck}
, #{optionCover}
, #{hanwfaFlg}
, #{standKindId}
, #{standardWindSpeedId}
, #{supportMeaker}
, #{consumptionTaxId}
, #{status}
, GETDATE()
, #{userId}
, #{delFlg}
, #{pcTypeNo}
, #{northArrangement}
, #{roofMaterialIdMulti}
, #{supportMethodIdMulti}
, #{supportMeakerMulti}
, #{diffRoofEnabled}
)
</insert>
<delete id="deletePlan" parameterType="com.interplug.qcast.biz.object.dto.PlanRequest">
/* sqlid : com.interplug.qcast.biz.object.deletePlan */
DELETE FROM T_PLAN
WHERE OBJECT_NO = #{objectNo}
AND PLAN_NO = #{planNo}
</delete>
</mapper>