Browse Source

오류 수정
- Backlog 년말 data 입력후 조회 안됨

dev001 9 months ago
parent
commit
85dbdbf7c0

+ 5 - 0
src/main/java/sgc/portal/ei/ei0102/persistence/EI01020001UMapper.java

@@ -22,6 +22,9 @@ public interface EI01020001UMapper {
     
     List<EasyHashMap<String, Object>> getListCnt(EI01020001U eI01020001U);
     
+    List<EasyHashMap<String, Object>> getSpecCd(EI01020001USearch search);
+    
+    int getBacklogCnt(EI01020001USearch search);
     
     /*
      * UPDATE
@@ -43,4 +46,6 @@ public interface EI01020001UMapper {
      * INSERT
      */
     int insert1(EI01020001U eI01020001U);
+    
+    int insertBacklogFcst(EI01020001U eI01020001U);
 }

+ 26 - 2
src/main/java/sgc/portal/ei/ei0102/service/EI01020001UService.java

@@ -40,6 +40,15 @@ public class EI01020001UService {
         return mapper.getList3(search);
     }
     
+    public List<EasyHashMap<String, Object>> getSpecCd(EI01020001USearch search) {
+        return mapper.getSpecCd(search);
+    }
+    
+    public int getBacklogCnt(EI01020001USearch search) {
+        return mapper.getBacklogCnt(search);
+    }
+    
+    
     /*
      * SAVE LIST
      */
@@ -65,8 +74,6 @@ public class EI01020001UService {
     
     @Transactional
     public Map<String, String> update3(List<EI01020001U> eI01020001U) {
-    	log.info("EI01020001UService - update3()");
-    	
     	Map<String,String> result = new HashMap<>();
     	for (EI01020001U vo : eI01020001U) {
     		update3(vo);
@@ -75,6 +82,19 @@ public class EI01020001UService {
     	return result;
     }
     
+    @Transactional
+    public Map<String, String> update4(List<EI01020001U> eI01020001U) {
+    	log.info("EI01020001UService - update4()");
+    	
+    	Map<String,String> result = new HashMap<>();
+    	for (EI01020001U vo : eI01020001U) {
+    		update4(vo);
+        }
+    	
+    	return result;
+    }
+    
+    
     /*
      * UPDATE
      */
@@ -96,4 +116,8 @@ public class EI01020001UService {
     	mapper.insertOrUpdate3(eI01020001U);
     }
     
+    private void update4(EI01020001U eI01020001U) {
+    	mapper.insertBacklogFcst(eI01020001U);
+    }
+    
 }

+ 28 - 0
src/main/java/sgc/portal/ei/ei0102/web/EI01020001UController.java

@@ -1,5 +1,6 @@
 package sgc.portal.ei.ei0102.web;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -37,6 +38,33 @@ public class EI01020001UController {
     
     @PostMapping("/EI01020001U/list2")
     public List<EasyHashMap<String, Object>> getList2(@RequestBody EI01020001USearch search) {
+    	// EIS_MI_BACKLOG (경영정보 - Backlog) 데이터 유무 확인 
+    	log.info("=== EIS_MI_BACKLOG (경영정보 - Backlog) 데이터 유무 확인 ===");
+    	
+    	int backlogCnt  = service.getBacklogCnt(search);
+    	log.info("backlogCnt : " + backlogCnt);
+    	
+    	if(backlogCnt < 1) {
+    		// 사업본부 구분코드 조회
+    		log.info("=== 사업본부 구분코드 조회 ===");
+    		List<EasyHashMap<String, Object>> list = service.getSpecCd(search);  // 사업본부 구분코드
+    		
+    		List<EI01020001U> eI01020001U = new ArrayList<>();
+    		
+    		for(int i = 0; i < list.size(); i++) {
+    			EI01020001U ei = new EI01020001U();
+    			ei.setCmpnCd(search.getCmpnCd());
+    			ei.setPyear(search.getPyear());
+    			ei.setPmonth(search.getPmonth());
+    			ei.setCcgrpGbCd(list.get(i).get("specCd").toString());
+    			ei.setBacklogFcst("0");
+    			
+    			eI01020001U.add(ei);
+    		}
+    		
+    		service.update4(eI01020001U);
+    	}
+    	
         return service.getList2(search);
     }
     

+ 40 - 4
src/main/resources/sqlmap/mappers/ei/ei0102/EI01020001UMapper.xml

@@ -246,7 +246,7 @@ SELECT AA.CMPN_CD
 	 , AA.CCGRP_GB_CD                                                                   /* 사업본부 구분코드[EI002] */
 	 , AA.SORT_NUM                                                                      /* 정렬 순번                        */
 	 
-	 , NVL(BB.BACKLOG_PFMC_00, 0)   AS BACKLOG_PFMC_00                                                               /* 연말 실적                        */
+	 , NVL(BB.BACKLOG_PFMC_00, 0)   AS BACKLOG_PFMC_00                                  /* 연말 실적                        */
 	 
 	 , NVL(BB.BACKLOG_PFMC_00, 0) + NVL(AA.CNTRT_AMT_01, 0) - NVL(CC.SLAMT_SUM_01, 0)  AS BACKLOG_PFMC_01     /* 월별 Backlog 실적(1월) */  /*  당월(당월이전) = 전월Backlog + 수주실적 – 매출실적 */
 	 , NVL(BB.BACKLOG_FCST_01, 0)   AS BACKLOG_FCST_01                                                        /* 월별 Backlog 전망(1월) */
@@ -868,6 +868,26 @@ SELECT AA.CMPN_CD
                 , A.CCGRP_GB_CD             /* 사업본부 구분코드  */
 	</select>
 	
+	<select id="getSpecCd" resultType="easyHashMap">
+	SELECT SPEC_CD   /* 사업본부 구분코드   */
+      FROM SM_COM_COMMCD_D   /* 공통)공통코드상세 */
+     WHERE COMM_CD_ID = '1111'
+       AND ESBS_CD1 = 'Y'
+	</select>
+	
+	<select id="getBacklogCnt" resultType="int">
+	SELECT COUNT(1)  AS CNT
+      FROM EIS_MI_BACKLOG /* EIS) 경영정보 - Backlog */ 
+     WHERE CMPN_CD = #{cmpnCd}  /* 회사 코드 */
+       AND PYEAR = #{pyear}     /* 기준 연도 */
+       AND PMONTH = #{pmonth}   /* 기준 월   */
+       AND CCGRP_GB_CD IN (
+             	            SELECT SPEC_CD   /* 사업본부 구분코드   */
+                              FROM SM_COM_COMMCD_D   /* 공통)공통코드상세 */
+                             WHERE COMM_CD_ID = '1111'
+                               AND ESBS_CD1 = 'Y'
+                           )
+	</select>
 		
 	<update id="update1">
 		UPDATE EIS_MI_RCORD
@@ -888,15 +908,12 @@ SELECT AA.CMPN_CD
      USING dual
         ON (A.CMPN_CD = #{cmpnCd} AND A.PYEAR = #{pyear} AND A.PMONTH = #{pmonth} AND CCSCTR_GB_CD = #{ccsctrGbCd} AND CCGRP_GB_CD = #{ccgrpGbCd})
       WHEN MATCHED THEN
-	  
 		UPDATE 
 		   SET A.RCORD_PLAN = #{rcordPlan}
 		     , A.RCORD_FCST = #{rcordFcst}
 		     , A.MDFT_DT = #{mdftDt}
 		     , A.MDFT_PR = #{mdftPr}
-		 		
       WHEN NOT MATCHED THEN
-	  
            INSERT (A.CMPN_CD, A.PYEAR, A.PMONTH, A.CCSCTR_GB_CD, A.CCGRP_GB_CD, A.RCORD_PLAN, A.RCORD_FCST, A.WRTE_DT, A.WRTE_PR)
            VALUES (#{cmpnCd} , #{pyear} , #{pmonth} , #{ccsctrGbCd} , #{ccgrpGbCd} , #{rcordPlan} , #{rcordFcst} , #{wrteDt}, #{wrtePr})
     </update>
@@ -946,6 +963,25 @@ SELECT AA.CMPN_CD
 	    )
     </insert>
     
+    <insert id="insertBacklogFcst">
+		INSERT INTO EIS_MI_BACKLOG(
+	            CMPN_CD
+	          , PYEAR
+	          , PMONTH
+	          , CCGRP_GB_CD
+	          , BACKLOG_FCST
+	          , WRTE_DT
+	          , WRTE_PR
+	    )VALUES(
+	            #{cmpnCd}
+	          , #{pyear}
+	          , #{pmonth}
+	          , #{ccgrpGbCd}
+	          , #{backlogFcst}
+	          , #{wrteDt}
+	          , #{wrtePr}
+	    )
+    </insert>
     
     <update id="update2">
 		UPDATE EIS_MI_BACKLOG