Merge Q-CAST-III-MR-298: 발전시뮬레이션 지붕재 아이템관련 수정

This commit is contained in:
박 꽃송이 2024-11-14 08:55:19 +00:00 committed by Space Cloud
commit c7d9400463
No known key found for this signature in database
GPG Key ID: 2F4D45726235F749
4 changed files with 49 additions and 39 deletions

View File

@ -11,7 +11,5 @@ import org.apache.ibatis.annotations.Mapper;
public interface PwrGnrSimMapper { public interface PwrGnrSimMapper {
PwrGnrSimPlanResponse selectPlanInfo(PwrGnrSimRequest pwrGnrSimRequest); PwrGnrSimPlanResponse selectPlanInfo(PwrGnrSimRequest pwrGnrSimRequest);
List<PwrGnrSimRoofResponse> selectRoofModuleList(PwrGnrSimRequest pwrGnrSimRequest); List<PwrGnrSimRoofResponse> selectRoofItemList(PwrGnrSimRequest pwrGnrSimRequest);
List<PwrGnrSimRoofResponse> selectRoofPcsList(PwrGnrSimRequest pwrGnrSimRequest);
} }

View File

@ -113,29 +113,53 @@ public class PwrGnrSimService {
} }
// 견적서의 지붕재와 아이템 정보 조회한다. // 견적서의 지붕재와 아이템 정보 조회한다.
List<PwrGnrSimRoofResponse> roofModuleList = List<PwrGnrSimRoofResponse> roofItemList = pwrGnrSimMapper.selectRoofItemList(pwrGnrSimRequest);
pwrGnrSimMapper.selectRoofModuleList(pwrGnrSimRequest);
// 지붕재 또는 지붕재에 아이템이 없음. // 지붕재 또는 지붕재에 아이템이 없음.
if (roofModuleList == null || roofModuleList.size() == 0) { if (roofItemList == null || roofItemList.size() == 0) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, "지붕재 또는 지붕재에 아이템이 없음."); throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, "지붕재 또는 지붕재에 아이템이 없음.");
} }
List<PwrGnrSimRoofResponse> pcsList = pwrGnrSimMapper.selectRoofPcsList(pwrGnrSimRequest); List<PwrGnrSimRoofResponse> moduleList =
roofItemList.stream()
.filter(item -> "MODULE_".equals(item.getItemGroup())) // itemGroup이 MODULE_인 항목만 필터링
.collect(Collectors.groupingBy(PwrGnrSimRoofResponse::getRoofNo)) // roofNo별로 그룹화
.values()
.stream()
.flatMap(List::stream) // 그룹화된 리스트를 다시 평탄화
.collect(Collectors.toList());
// 모듈 아이템이 없음.
if (moduleList == null || moduleList.size() == 0) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, "모듈 아이템이 없음.");
}
List<PwrGnrSimRoofResponse> pcsList =
roofItemList.stream()
.filter(item -> "PC_".equals(item.getItemGroup())) // itemGroup이 PC_인 항목만 필터링
.collect(
Collectors.groupingBy(
PwrGnrSimRoofResponse::getItemId,
Collectors.reducing(
(item1, item2) -> {
// item1의 amount에 item2의 amount를 더한 새로운 객체 생성
item1.setAmount(
Integer.parseInt(item1.getAmount())
+ Integer.parseInt(item2.getAmount())
+ "");
return item1;
})))
.values()
.stream()
.flatMap(Optional::stream) // Optional을 평탄화
.collect(Collectors.toList());
// pcs 아이템이 없음. // pcs 아이템이 없음.
if (pcsList == null || pcsList.size() == 0) { if (pcsList == null || pcsList.size() == 0) {
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, "pcs 아이템이 없음."); throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, "pcs 아이템이 없음.");
} }
List<String> moduleList =
roofModuleList.stream()
.map(PwrGnrSimRoofResponse::getItemId)
.distinct() // 중복 제거
.collect(Collectors.toList());
List<PwrGnrSimRoofResponse> roofList = List<PwrGnrSimRoofResponse> roofList =
roofModuleList.stream() roofItemList.stream()
.collect( .collect(
Collectors.toMap( Collectors.toMap(
PwrGnrSimRoofResponse::getRoofNo, // key는 roofNo로 PwrGnrSimRoofResponse::getRoofNo, // key는 roofNo로
@ -174,13 +198,13 @@ public class PwrGnrSimService {
} }
// module 정보 // module 정보
k = 0; k = 0;
for (String m : moduleList) { for (PwrGnrSimRoofResponse m : moduleList) {
if (k == 0) { if (k == 0) {
pwrGnrSimReq.setModule1(m); pwrGnrSimReq.setModule1(m.getItemId());
} else if (k == 1) { } else if (k == 1) {
pwrGnrSimReq.setModule2(m); pwrGnrSimReq.setModule2(m.getItemId());
} else { } else {
pwrGnrSimReq.setModule3(m); pwrGnrSimReq.setModule3(m.getItemId());
} }
k++; k++;
} }
@ -203,7 +227,7 @@ public class PwrGnrSimService {
// 지붕별 모듈정보 셋팅 // 지붕별 모듈정보 셋팅
int j = 0; int j = 0;
for (PwrGnrSimRoofResponse m : roofModuleList) { for (PwrGnrSimRoofResponse m : moduleList) {
if (data.getRoofNo().equals(m.getRoofNo())) { if (data.getRoofNo().equals(m.getRoofNo())) {
dSpecification += Double.parseDouble(m.getSpecification()); dSpecification += Double.parseDouble(m.getSpecification());
if (j == 0) { if (j == 0) {
@ -238,7 +262,7 @@ public class PwrGnrSimService {
pwrGnrSimRes.setAreaName(planInfo.getAreaName()); pwrGnrSimRes.setAreaName(planInfo.getAreaName());
pwrGnrSimRes.setSnowfall(planInfo.getSnowfall()); pwrGnrSimRes.setSnowfall(planInfo.getSnowfall());
pwrGnrSimRes.setStandardWindSpeedId(planInfo.getStandardWindSpeedId()); pwrGnrSimRes.setStandardWindSpeedId(planInfo.getStandardWindSpeedId());
pwrGnrSimRes.setRoofModuleList(roofModuleList); pwrGnrSimRes.setRoofModuleList(moduleList);
pwrGnrSimRes.setPcsList(pcsList); pwrGnrSimRes.setPcsList(pcsList);
return pwrGnrSimRes; return pwrGnrSimRes;

View File

@ -26,6 +26,9 @@ public class PwrGnrSimRoofResponse {
@Schema(description = "아이템 번호") @Schema(description = "아이템 번호")
private String itemNo; private String itemNo;
@Schema(description = "아이템 그룹")
private String itemGroup;
@Schema(description = "용량") @Schema(description = "용량")
private String specification; private String specification;

View File

@ -26,9 +26,9 @@
AND A.PLAN_NO = #{planNo} AND A.PLAN_NO = #{planNo}
</select> </select>
<select id="selectRoofModuleList" parameterType="com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRequest" <select id="selectRoofItemList" parameterType="com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRequest"
resultType="com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRoofResponse"> resultType="com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRoofResponse">
/* sqlid : com.interplug.qcast.api.pwrGnrSimulation.selectRoofModuleList (견적서 지붕재/모듈 정보 조회) */ /* sqlid : com.interplug.qcast.api.pwrGnrSimulation.selectRoofItemList (견적서 지붕재 아이템 정보 조회) */
SELECT SELECT
A.ROOF_NO A.ROOF_NO
, A.ROOF_SURFACE , A.ROOF_SURFACE
@ -39,6 +39,7 @@
, B.AMOUNT , B.AMOUNT
, C.ITEM_NO , C.ITEM_NO
, ((B.AMOUNT * C.PNOW_W) / 1000) AS SPECIFICATION /* 용량 */ , ((B.AMOUNT * C.PNOW_W) / 1000) AS SPECIFICATION /* 용량 */
, C.ITEM_GROUP
FROM T_ROOF_ESTIMATE A FROM T_ROOF_ESTIMATE A
INNER JOIN T_ROOF_ITEM_ESTIMATE B INNER JOIN T_ROOF_ITEM_ESTIMATE B
ON A.OBJECT_NO = B.OBJECT_NO ON A.OBJECT_NO = B.OBJECT_NO
@ -49,20 +50,4 @@
WHERE A.OBJECT_NO = #{objectNo} WHERE A.OBJECT_NO = #{objectNo}
AND A.PLAN_NO = #{planNo} AND A.PLAN_NO = #{planNo}
</select> </select>
<select id="selectRoofPcsList" parameterType="com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRequest"
resultType="com.interplug.qcast.biz.pwrGnrSimulation.dto.PwrGnrSimRoofResponse">
/* sqlid : com.interplug.qcast.api.pwrGnrSimulation.selectRoofPcsList (견적서 지붕재/모듈 정보 조회) */
SELECT
A.AMOUNT /* 매수X */
, A.ITEM_ID
, A.ITEM_NO
FROM T_PART_ESTIMATE A
INNER JOIN M_ITEM B
ON A.ITEM_ID = B.ITEM_ID
WHERE ITEM_GROUP ='PC_'
AND A.OBJECT_NO = #{objectNo}
AND A.PLAN_NO = #{planNo}
</select>
</mapper> </mapper>