발전시뮬레이션 지붕재 아이템관련 수정
This commit is contained in:
parent
1702e44a12
commit
d6ae1b9748
@ -11,7 +11,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface PwrGnrSimMapper {
|
||||
PwrGnrSimPlanResponse selectPlanInfo(PwrGnrSimRequest pwrGnrSimRequest);
|
||||
|
||||
List<PwrGnrSimRoofResponse> selectRoofModuleList(PwrGnrSimRequest pwrGnrSimRequest);
|
||||
|
||||
List<PwrGnrSimRoofResponse> selectRoofPcsList(PwrGnrSimRequest pwrGnrSimRequest);
|
||||
List<PwrGnrSimRoofResponse> selectRoofItemList(PwrGnrSimRequest pwrGnrSimRequest);
|
||||
}
|
||||
|
||||
@ -113,29 +113,53 @@ public class PwrGnrSimService {
|
||||
}
|
||||
|
||||
// 견적서의 지붕재와 아이템 정보 조회한다.
|
||||
List<PwrGnrSimRoofResponse> roofModuleList =
|
||||
pwrGnrSimMapper.selectRoofModuleList(pwrGnrSimRequest);
|
||||
|
||||
List<PwrGnrSimRoofResponse> roofItemList = pwrGnrSimMapper.selectRoofItemList(pwrGnrSimRequest);
|
||||
// 지붕재 또는 지붕재에 아이템이 없음.
|
||||
if (roofModuleList == null || roofModuleList.size() == 0) {
|
||||
if (roofItemList == null || roofItemList.size() == 0) {
|
||||
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 아이템이 없음.
|
||||
if (pcsList == null || pcsList.size() == 0) {
|
||||
throw new QcastException(ErrorCode.INTERNAL_SERVER_ERROR, "pcs 아이템이 없음.");
|
||||
}
|
||||
|
||||
List<String> moduleList =
|
||||
roofModuleList.stream()
|
||||
.map(PwrGnrSimRoofResponse::getItemId)
|
||||
.distinct() // 중복 제거
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<PwrGnrSimRoofResponse> roofList =
|
||||
roofModuleList.stream()
|
||||
roofItemList.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
PwrGnrSimRoofResponse::getRoofNo, // key는 roofNo로
|
||||
@ -174,13 +198,13 @@ public class PwrGnrSimService {
|
||||
}
|
||||
// module 정보
|
||||
k = 0;
|
||||
for (String m : moduleList) {
|
||||
for (PwrGnrSimRoofResponse m : moduleList) {
|
||||
if (k == 0) {
|
||||
pwrGnrSimReq.setModule1(m);
|
||||
pwrGnrSimReq.setModule1(m.getItemId());
|
||||
} else if (k == 1) {
|
||||
pwrGnrSimReq.setModule2(m);
|
||||
pwrGnrSimReq.setModule2(m.getItemId());
|
||||
} else {
|
||||
pwrGnrSimReq.setModule3(m);
|
||||
pwrGnrSimReq.setModule3(m.getItemId());
|
||||
}
|
||||
k++;
|
||||
}
|
||||
@ -203,7 +227,7 @@ public class PwrGnrSimService {
|
||||
|
||||
// 지붕별 모듈정보 셋팅
|
||||
int j = 0;
|
||||
for (PwrGnrSimRoofResponse m : roofModuleList) {
|
||||
for (PwrGnrSimRoofResponse m : moduleList) {
|
||||
if (data.getRoofNo().equals(m.getRoofNo())) {
|
||||
dSpecification += Double.parseDouble(m.getSpecification());
|
||||
if (j == 0) {
|
||||
@ -238,7 +262,7 @@ public class PwrGnrSimService {
|
||||
pwrGnrSimRes.setAreaName(planInfo.getAreaName());
|
||||
pwrGnrSimRes.setSnowfall(planInfo.getSnowfall());
|
||||
pwrGnrSimRes.setStandardWindSpeedId(planInfo.getStandardWindSpeedId());
|
||||
pwrGnrSimRes.setRoofModuleList(roofModuleList);
|
||||
pwrGnrSimRes.setRoofModuleList(moduleList);
|
||||
pwrGnrSimRes.setPcsList(pcsList);
|
||||
|
||||
return pwrGnrSimRes;
|
||||
|
||||
@ -26,6 +26,9 @@ public class PwrGnrSimRoofResponse {
|
||||
@Schema(description = "아이템 번호")
|
||||
private String itemNo;
|
||||
|
||||
@Schema(description = "아이템 그룹")
|
||||
private String itemGroup;
|
||||
|
||||
@Schema(description = "용량")
|
||||
private String specification;
|
||||
|
||||
|
||||
@ -26,9 +26,9 @@
|
||||
AND A.PLAN_NO = #{planNo}
|
||||
</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">
|
||||
/* sqlid : com.interplug.qcast.api.pwrGnrSimulation.selectRoofModuleList (견적서 지붕재/모듈 정보 조회) */
|
||||
/* sqlid : com.interplug.qcast.api.pwrGnrSimulation.selectRoofItemList (견적서 지붕재 아이템 정보 조회) */
|
||||
SELECT
|
||||
A.ROOF_NO
|
||||
, A.ROOF_SURFACE
|
||||
@ -39,6 +39,7 @@
|
||||
, B.AMOUNT
|
||||
, C.ITEM_NO
|
||||
, ((B.AMOUNT * C.PNOW_W) / 1000) AS SPECIFICATION /* 용량 */
|
||||
, C.ITEM_GROUP
|
||||
FROM T_ROOF_ESTIMATE A
|
||||
INNER JOIN T_ROOF_ITEM_ESTIMATE B
|
||||
ON A.OBJECT_NO = B.OBJECT_NO
|
||||
@ -49,20 +50,4 @@
|
||||
WHERE A.OBJECT_NO = #{objectNo}
|
||||
AND A.PLAN_NO = #{planNo}
|
||||
</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>
|
||||
Loading…
x
Reference in New Issue
Block a user