견적서 인증용량 계산 API 추가

This commit is contained in:
LAPTOP-L3VE7KK2\USER 2024-11-13 18:03:07 +09:00
parent 77ea9441f6
commit c881f67875
5 changed files with 69 additions and 15 deletions

View File

@ -21,6 +21,9 @@ public interface EstimateMapper {
// 아이템 마스터 목록 조회
public List<ItemResponse> selectItemMasterList(EstimateRequest estimateRequest);
// 견적서 지붕재 인증용량 조회
public String selectEstimateRoofCertVolKw(EstimateRequest estimateRequest);
// 견적서 지붕재 목록 조회
public List<RoofResponse> selectEstimateRoofList(EstimateRequest estimateRequest);

View File

@ -10,9 +10,6 @@ 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 com.interplug.qcast.biz.pwrGnrSimulation.PwrGnrSimService;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimGuideResponse;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRequest;
import com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimResponse;
import com.interplug.qcast.config.Exception.ErrorCode;
import com.interplug.qcast.config.Exception.QcastException;
import com.interplug.qcast.config.message.Messages;
@ -28,6 +25,7 @@ import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import lombok.RequiredArgsConstructor;
@ -685,31 +683,33 @@ public class EstimateService {
}
// 지붕재 목록 조회
estimateRequest.setSchItemGroup("MODULE_");
RoofInfoResponse roofInfoResponse = new RoofInfoResponse();
List<RoofResponse> roofList = estimateMapper.selectEstimateRoofList(estimateRequest);
List<RoofResponse> roofPcList = estimateMapper.selectEstimateRoofPcList(estimateRequest);
estimateRequest.setSchItemGroup("MODULE_");
List<RoofResponse> roofVolList = estimateMapper.selectEstimateRoofVolList(estimateRequest);
BigDecimal moduleTotAmount = BigDecimal.ZERO;
BigDecimal moduleTotVol = BigDecimal.ZERO;
BigDecimal moduleTotVolKw = BigDecimal.ZERO;
for (RoofResponse roofVol : roofVolList) {
BigDecimal amount =
new BigDecimal(StringUtils.isEmpty(roofVol.getAmount()) ? "0" : roofVol.getAmount());
BigDecimal vol =
new BigDecimal(StringUtils.isEmpty(roofVol.getVol()) ? "0" : roofVol.getVol());
new BigDecimal(StringUtils.isEmpty(roofVol.getVolKw()) ? "0" : roofVol.getVolKw());
moduleTotAmount = moduleTotAmount.add(amount);
moduleTotVol = moduleTotVol.add(vol);
moduleTotVolKw = moduleTotVolKw.add(vol);
}
roofInfoResponse.setModuleTotAmount(String.valueOf(moduleTotAmount));
roofInfoResponse.setModuleTotVol(String.valueOf(moduleTotVol));
roofInfoResponse.setModuleTotVolKw(String.valueOf(moduleTotVolKw));
roofInfoResponse.setRoofList(roofList);
roofInfoResponse.setRoofPcList(roofPcList);
roofInfoResponse.setRoofVolList(roofVolList);
// 인증용량 구하기 (지붕면마다 모듈과 PCS의 용량을 서로 비교해 낮은쪽 용량으로 합산)
roofInfoResponse.setCertVolKw(estimateMapper.selectEstimateRoofCertVolKw(estimateRequest));
estimateResponse.setRoofInfo(roofInfoResponse);
// 아이템 목록 조회
@ -757,11 +757,13 @@ public class EstimateService {
estimateResponse.setTotPrice(
String.format("%1$,.0f", Double.parseDouble(estimateResponse.getTotPrice())));
String excelFileName = "Quation_Detail";
String excelFileName =
"Quation_Detail_" + new SimpleDateFormat("yyyyMMdd").format(new Date());
String excelTemplatePath =
excelTemplateFilePath + File.separator + "excel_download_quotation_detail_template.xlsx";
// 발전시뮬레이션 계산
/*
PwrGnrSimRequest pwrGnrSimRequest = new PwrGnrSimRequest();
pwrGnrSimRequest.setObjectNo(estimateResponse.getObjectNo());
pwrGnrSimRequest.setPlanNo(estimateResponse.getPlanNo());
@ -784,6 +786,8 @@ public class EstimateService {
estimateResponse.setPwrGnrSim(pwrGnrSimResponse);
*/
excelUtil.download(
request,
response,

View File

@ -9,11 +9,14 @@ import lombok.Setter;
@Getter
@Setter
public class RoofInfoResponse {
@Schema(description = "인증용량")
private String certVolKw;
@Schema(description = "모듈 총 수")
private String moduleTotAmount;
@Schema(description = "모듈 총 용량")
private String moduleTotVol;
private String moduleTotVolKw;
@Schema(description = "지붕면 목록")
private List<RoofResponse> roofList;

View File

@ -75,7 +75,7 @@ public class RoofResponse {
private String amount;
@Schema(description = "용량")
private String vol;
private String volKw;
@Schema(description = "Pc 모듈 매수")
private String pcModuleAmount;

View File

@ -215,6 +215,48 @@
</foreach>
</select>
<select id="selectEstimateRoofCertVolKw" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="String">
/* sqlid : com.interplug.qcast.biz.estimate.selectEstimateRoofCertVolKw */
SELECT
FORMAT(ISNULL(SUM(CASE WHEN T.MODULE_VOL_KW <![CDATA[ <= ]]> T.PC_VOL_KW THEN T.MODULE_VOL_KW ELSE T.PC_VOL_KW END), 0), '#,##0.000') AS CERT_VOL_KW
FROM
(
SELECT
P.OBJECT_NO
, P.PLAN_NO
, RE.ROOF_NO
, RE.ROOF_SURFACE
, ROUND(CAST(RE.SLOPE AS FLOAT), 2) AS SLOPE
, RIE.AMOUNT
, CAST(RIE.SPECIFICATION AS FLOAT) SPECIFICATION
, ROUND((RIE.AMOUNT * CAST(ISNULL(RIE.SPECIFICATION, 0) AS FLOAT) / 1000), 4) AS PC_VOL_KW
, I.ITEM_ID
, I.ITEM_NO
, ISNULL((
SELECT
SUM((AMOUNT * CAST(ISNULL(SPECIFICATION, 0) AS FLOAT) / 1000))
FROM T_ROOF_ITEM_ESTIMATE
WHERE ROOF_NO = RIE.ROOF_NO
AND OBJECT_NO = RIE.OBJECT_NO
AND PLAN_NO = RIE.PLAN_NO
AND PC_ITEM_ID = RIE.ITEM_ID
), 0) AS MODULE_VOL_KW
FROM T_PLAN P WITH (NOLOCK)
INNER JOIN T_ROOF_ESTIMATE RE WITH (NOLOCK)
ON P.OBJECT_NO = RE.OBJECT_NO
AND P.PLAN_NO = RE.PLAN_NO
INNER JOIN T_ROOF_ITEM_ESTIMATE RIE WITH (NOLOCK)
ON RE.ROOF_NO = RIE.ROOF_NO
AND RE.OBJECT_NO = RE.OBJECT_NO
AND RE.PLAN_NO = RE.PLAN_NO
INNER JOIN M_ITEM I WITH (NOLOCK)
ON RIE.ITEM_ID = I.ITEM_ID
WHERE P.OBJECT_NO = #{objectNo}
AND P.PLAN_NO = #{planNo}
AND I.ITEM_GROUP = 'PC_'
) T
</select>
<select id="selectEstimateRoofList" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="com.interplug.qcast.biz.estimate.dto.RoofResponse">
/* sqlid : com.interplug.qcast.biz.estimate.selectEstimateRoofList */
SELECT
@ -290,17 +332,19 @@
<select id="selectEstimateRoofVolList" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="com.interplug.qcast.biz.estimate.dto.RoofResponse">
/* sqlid : com.interplug.qcast.biz.estimate.selectEstimateRoofVolList */
SELECT
T.OBJECT_NO
T.OBJECT_NO
, T.PLAN_NO
, T.ROOF_NO
, T.ROOF_SURFACE
, T.SLOPE
, SUM(T.AMOUNT) AS AMOUNT
, ROUND(SUM(T.AMOUNT * T.SPECIFICATION / 1000), 4) AS VOL
, ROUND(SUM(T.AMOUNT * T.SPECIFICATION / 1000), 4) AS VOL_KW
FROM
(
SELECT
P.OBJECT_NO
, P.PLAN_NO
, RE.ROOF_NO
, RE.ROOF_SURFACE
, ROUND(CAST(RE.SLOPE AS FLOAT), 2) AS SLOPE
, RIE.AMOUNT
@ -323,7 +367,7 @@
AND I.ITEM_GROUP = #{schItemGroup}
</if>
) T
GROUP BY T.OBJECT_NO, T.PLAN_NO, T.ROOF_SURFACE, T.SLOPE
GROUP BY T.OBJECT_NO, T.PLAN_NO, T.ROOF_NO, T.ROOF_SURFACE, T.SLOPE
</select>
<select id="selectEstimateNoteList" parameterType="com.interplug.qcast.biz.estimate.dto.NoteRequest" resultType="com.interplug.qcast.biz.estimate.dto.NoteResponse">