Explorar o código

구매발주 생성 저장 기능 임시 작업

dwkim %!s(int64=2) %!d(string=hai) anos
pai
achega
45e2a0ff88

+ 3 - 1
src/main/java/com/oqpo/api/mapper/pomng/PchOrdMapper.java

@@ -16,9 +16,11 @@ public interface PchOrdMapper {
16 16
     List<PchOdrBaseInfoEntity> selectRecPchInitInfo(@Param("brandId") String brandId, List<PchOdrDtlPtclEntity> gridUpdateData)throws Exception;
17 17
     List<PchOdrDtlPtclEntity> selectRecPchDtlInitInfo(@Param("brandId") String brandId, List<PchOdrDtlPtclEntity> gridUpdateData)throws Exception;
18 18
     PchOdrBaseInfoEntity selectPoInitInfo(@Param("brandId") String brandId)throws Exception;
19
+    PchOdrDtlPtclEntity selectPoPchDtlSaveInfo(@Param("pchReqUnqNo") String pchReqUnqNo, @Param("pchReqDtlNo") String pchReqDtlNo)throws Exception;
20
+    PchOdrDtlPtclEntity selectPoItemDtlSaveInfo(@Param("brandId") String brandId, @Param("itemId") String itemId)throws Exception;
19 21
 
20 22
     int insertPchOdrBaseInfo(@Param("userId") String userId, PchOdrBaseInfoEntity entity)throws Exception;
21
-    int insertPchOdrDtlPtcl(@Param("userId") String userId, List<PchOdrBaseInfoEntity> gridInsertData)throws Exception;
23
+    int insertPchOdrDtlPtcl(@Param("userId") String userId, List<PchOdrDtlPtclEntity> gridInsertData)throws Exception;
22 24
 
23 25
 /*
24 26
     List<PchReqBaseInfoEntity> selectPchReqGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("fromDt") String fromDt, @Param("toDt") String toDt, @Param("sWhsId") String sWhsId, @Param("sPchReqStCd") String sPchReqStCd, @Param("sItemNm") String sItemNm, GridRequest gridRequest)throws Exception;

+ 73 - 19
src/main/java/com/oqpo/api/service/pomng/PchOrdService.java

@@ -210,13 +210,7 @@ public class PchOrdService extends CommonService {
210 210
     @Transactional
211 211
     public void savePchOrdInfo(String userId, SavePchOrdRequest savePchOrdRequest) throws Exception {
212 212
         try {
213
-
214
-            if ("C".equals(savePchOrdRequest.getViewCd())) {
215
-                // 구매발주 아이디 부여
216
-                //entity.setPchReqUnqNo(fnGetDealNo(14,""));  // 구매발주번호 생성
217
-            }
218
-
219
-
213
+/*
220 214
             List<PchOdrBaseInfoEntity> headList = null;
221 215
             List<PchOdrDtlPtclEntity> itemList = null;
222 216
             if ("R".equals(savePchOrdRequest.getJobCd())) {   // 구매요청건
@@ -238,12 +232,6 @@ public class PchOrdService extends CommonService {
238 232
                     if ("".equals(headData.getStoreId())) {
239 233
                         throw new GlobalException(SystemMessageCode.ERR_NONSTORE);
240 234
                     }
241
-
242
-                    //구매요청 납품매장과 발주 납품매장이 서로 틀립니다.
243
-                    if (!headData.getStoreId().equals(savePchOrdRequest.getStoreId())) {
244
-                        throw new GlobalException(SystemMessageCode.ERR_NOEQSTORE);
245
-                    }
246
-
247 235
                 } else if ("DL02".equals(savePchOrdRequest.getDlvDvsn())) {
248 236
                     // 공급사 배송 - 본사로 배송,  매장배송송
249 237
                     String spplyId = "";
@@ -264,24 +252,90 @@ public class PchOrdService extends CommonService {
264 252
                     if (!spplyId.equals(savePchOrdRequest.getSpplyId())) {
265 253
                         throw new GlobalException(SystemMessageCode.ERR_NOEQSPPLY);
266 254
                     }
255
+                }
267 256
 
268
-                    //납품창고 와 신청한 납품창고 상이 여부 체크
269
-                    if (!headData.getWhsId().equals(savePchOrdRequest.getWhsId())) {
270
-                        throw new GlobalException(SystemMessageCode.ERR_NOEQSTORE);
271
-                    }
257
+                //납품창고 와 신청한 납품창고 상이 여부 체크
258
+                if (!headData.getWhsId().equals(savePchOrdRequest.getWhsId()) || !headData.getLocation().equals(savePchOrdRequest.getLocation())) {
259
+                    throw new GlobalException(SystemMessageCode.ERR_NOEQSTORE);
272 260
                 }
273 261
 
274 262
 
275
-                // 전달받은 데이타와 전송발 데이타 세팅 후 저장
263
+            } else if ("P".equals(savePchOrdRequest.getJobCd())) {  //신규발주건
264
+
265
+            }
276 266
 
267
+*/
268
+            // 로그인 정보 가져오기
269
+            UserMngEntity uEntity = userMngMapper.selectGroupUserInfo(userId);
270
+
271
+            // 전달받은 데이타와 전송발 데이타 세팅 후 저장
272
+            String pchPodrUnqNo = fnGetDealNo(14,"");
273
+            PchOdrBaseInfoEntity pchOrdEntity = new PchOdrBaseInfoEntity();
274
+            pchOrdEntity.setPchPodrUnqNo(pchPodrUnqNo) ;
275
+            pchOrdEntity.setBrandId(savePchOrdRequest.getBrandId());
276
+            pchOrdEntity.setDlvDvsn(savePchOrdRequest.getDlvDvsn());
277
+            pchOrdEntity.setDlvReqDt(savePchOrdRequest.getDlvReqDt());
278
+            pchOrdEntity.setPodrMgrNm(uEntity.getUserNm());
279
+            pchOrdEntity.setPodrDvsn("OD01");
280
+            pchOrdEntity.setPchOdrStCd("PO001");
281
+            pchOrdEntity.setSpplyId(savePchOrdRequest.getSpplyId());
282
+            pchOrdEntity.setPodrMgrId(uEntity.getUserId());
283
+            pchOrdEntity.setPodrMgrTelNo(uEntity.getTelNo());
284
+            //
285
+            if ("".equals(savePchOrdRequest.getStoreId())) {  // 본사납품장소
286
+                pchOrdEntity.setWhsDvsn("W01");
287
+            } else {  // 매장납품장소
288
+                pchOrdEntity.setWhsDvsn("W02");
289
+            }
290
+            pchOrdEntity.setWhsId(savePchOrdRequest.getWhsId());
291
+            pchOrdEntity.setLocation(savePchOrdRequest.getLocation());
292
+            pchOrdEntity.setShmtWhsId(savePchOrdRequest.getShmtWhsId());
293
+            pchOrdEntity.setShmtLocation(savePchOrdRequest.getShmtLocation());
294
+            pchOrdEntity.setStoreId(savePchOrdRequest.getStoreId());
295
+
296
+            Integer dtlRow = 0 ;
297
+            List<PchOdrDtlPtclEntity> pchOrdDtlList = new ArrayList<PchOdrDtlPtclEntity>();
298
+            List<PchOdrDtlPtclEntity> gridUpdateData = savePchOrdRequest.toCodeEntities(savePchOrdRequest.getGridInsertData());
299
+            if (gridUpdateData.size() > 0) {
300
+                int poTotAmt = 0 ;
301
+                int poItemCnt = 0 ;
302
+                for (int i = 0 ; i < gridUpdateData.size() ;i++ ) {
303
+                    PchOdrDtlPtclEntity poDtlEntity = gridUpdateData.get(i);
304
+                    PchOdrDtlPtclEntity poSaveDtlEntity = new PchOdrDtlPtclEntity();
305
+                    // 구매요청건에 대한 데이타 가져옴
306
+                    if ("R".equals(savePchOrdRequest.getJobCd())) {   // 구매요청건
307
+                        // 구매요청번호와 항번으로 데이타 가져놈
308
+                        poSaveDtlEntity = pchOrdMapper.selectPoPchDtlSaveInfo(poDtlEntity.getPchReqUnqNo(), poDtlEntity.getPchPodrDtlNo()) ;
309
+
310
+                    } else if ("P".equals(savePchOrdRequest.getJobCd())) {  // 신규발주건
311
+                        // item id 로 데이타 가져옴  == 단가는 브랜드 단가로 처리함
312
+                        poSaveDtlEntity = pchOrdMapper.selectPoItemDtlSaveInfo(savePchOrdRequest.getBrandId(), poDtlEntity.getItemId());
313
+                    }
314
+                    dtlRow = dtlRow + 10;
315
+                    poSaveDtlEntity.setPchPodrUnqNo(pchPodrUnqNo);
316
+                    poSaveDtlEntity.setPchPodrDtlNo(Integer.toString(dtlRow));
317
+                    poSaveDtlEntity.setPchReqUnqNo(poDtlEntity.getPchReqUnqNo());
318
+                    poSaveDtlEntity.setPchReqDtlNo(poDtlEntity.getPchPodrDtlNo());
319
+                    poSaveDtlEntity.setPodrQty(poDtlEntity.getPodrQty());
320
+                    poSaveDtlEntity.setPodrAmt(poDtlEntity.getPodrQty() * poSaveDtlEntity.getUnitAmt() );
321
+                    poSaveDtlEntity.setCurr("KRW");
322
+                    poTotAmt = poTotAmt +  poSaveDtlEntity.getPodrAmt();
323
+                    poItemCnt = poItemCnt + 1;
324
+
325
+                    pchOrdDtlList.add(poSaveDtlEntity);
326
+                }
277 327
 
278 328
 
329
+                pchOrdEntity.setPodrTotalAmt(poTotAmt);
330
+                pchOrdEntity.setPodrItemQty(poItemCnt);
279 331
 
280
-            } else if ("P".equals(savePchOrdRequest.getJobCd())) {  //신규발주건
332
+                pchOrdMapper.insertPchOdrBaseInfo(userId, pchOrdEntity);
333
+                pchOrdMapper.insertPchOdrDtlPtcl(userId, pchOrdDtlList);
281 334
 
282 335
             }
283 336
 
284 337
 
338
+
285 339
         } catch (GlobalException e) {
286 340
             e.getStackTrace();
287 341
             throw new GlobalException(e.getSystemMessageCode());

+ 20 - 38
src/main/resources/mybatis/sqlmaps/pomng/PchOrd.xml

@@ -71,55 +71,37 @@
71 71
         INSERT INTO pch_odr_dtl_ptcl
72 72
             (pch_podr_unq_no, pch_podr_dtl_no, pch_req_unq_no, pch_req_dtl_no, item_id
73 73
             , item_nm, podr_qty, podr_amt, curr, unit
74
-            , price_unit, dlv_req_dt, unit_amt, dlv_sch_dt, shmt_pssbl_qty
74
+            , unit_amt, dlv_sch_dt
75 75
             , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id)
76 76
         VALUES
77 77
         <foreach collection="gridInsertData" item="item" separator=",">
78 78
             (#{entity.pchPodrUnqNo}, #{entity.pchPodrDtlNo}, #{entity.pchReqUnqNo}, #{entity.pchReqDtlNo}, #{entity.itemId}
79 79
             , #{entity.itemNm}, #{entity.podrQty}, #{entity.podrAmt}, #{entity.curr}, #{entity.unit}
80
-            , #{entity.priceUnit}, #{entity.dlvReqDt}, #{entity.unitAmt}, #{entity.dlvSchDt}, #{entity.shmtPssblQty}
80
+            , #{entity.unitAmt}, #{entity.dlvSchDt}
81 81
             , NOW(), #{userId}, NOW(), #{userId})
82 82
         </foreach>
83 83
     </insert>
84 84
 
85 85
 
86
-
87
-    <select id="selectPoPchSaveInfo" resultType="com.oqpo.api.entity.pomng.PchOdrBaseInfoEntity">
88
-        SELECT distinct base.BRAND_ID, FN_BRAND_NM(base.brand_id) AS brand_nm
89
-            , date_format(now() ,'%Y.%m.%d') as podr_dt
90
-            , base.whs_id, base.location
91
-            , concat(FN_WHS_NM(base.brand_id, base.whs_id) ,'-',FN_WHS_LOCATION_NM(base.brand_id, base.whs_id, base.location)) as dlv_place
92
-            , case when base.store_id is null or base.store_id = '' then 'DL02' else 'DL01' end as dlv_dvsn
93
-            , fn_code_nm('DLV_DVSN',case when base.store_id is null or base.store_id = '' then 'DL02' else 'DL01' end)  as dlv_dvsn_nm
94
-            , base.store_id
95
-        FROM pch_req_base_info base
96
-        , pch_req_dtl_ptcl ptcl
97
-        WHERE 1 = 1
98
-        and base.brand_id = #{brandId}
99
-        AND base.PCH_REQ_UNQ_NO = ptcl.PCH_REQ_UNQ_NO
100
-        AND base.PCH_REQ_ST_CD = 'PR20'
101
-        AND concat(base.PCH_REQ_UNQ_NO, ptcl.PCH_REQ_DTL_NO) IN
102
-        <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
103
-            concat(#{item.pchReqUnqNo},#{{item.pchReqDtlNo})
104
-        </foreach>
86
+    <select id="selectPoPchDtlSaveInfo" resultType="com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity">
87
+        select ptcl.item_id, ptcl.item_nm,  ptcl.unit, ptcl.unit_amt
88
+        from  pch_req_dtl_ptcl ptcl
89
+          join pch_req_base_info base on ptcl.pch_req_unq_no = base.pch_req_unq_no
90
+        where 1=1
91
+        and   base.pch_req_unq_no = #{pchReqUnqNo}
92
+        and   ptcl.pch_req_dtl_no = #{pchReqDtlNo}
105 93
     </select>
106 94
 
107
-    <select id="selectPoPchDtlSaveInfo" resultType="com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity">
108
-        select base.pch_req_unq_no , ptcl.pch_req_dtl_no
109
-        , ptcl.item_id , ptcl.item_nm , ptcl.unit_amt , ptcl.unit
110
-        , ptcl.pch_req_qty, ptcl.pch_req_qty as podr_qty, ptcl.pch_req_amt , base.dlv_req_dt
111
-        , 0 as whs_pass_qty, bunit.spply_id, fn_spply_nm(bunit.spply_id) as spply_nm
112
-        from pch_req_base_info base
113
-        , pch_req_dtl_ptcl ptcl
114
-        , brand_item_unit_info bunit
115
-        where 1 = 1
116
-        and base.brand_id = #{brandId}
117
-        and base.pch_req_unq_no = ptcl.pch_req_unq_no
118
-        and ptcl.brand_unit_unq_no = bunit.brand_unit_unq_no
119
-        and base.pch_req_st_cd = 'PR20'
120
-        and concat(base.pch_req_unq_no, ptcl.pch_req_dtl_no) in
121
-        <foreach collection="gridUpdateData" item="item" separator="," open="(" close=")">
122
-            concat(#{item.pchReqUnqNo},#{{item.pchReqDtlNo})
123
-        </foreach>
95
+
96
+    <select id="selectPoItemDtlSaveInfo" resultType="com.oqpo.api.entity.pomng.PchOdrDtlPtclEntity">
97
+        select item_id, item_nm, unit, unit_amt
98
+        from brand_item_unit_info
99
+        where 1=1
100
+        and   brand_id = #{brandId}
101
+        and   item_id = #{itemId}
102
+        and   date_format(now(), '%Y%m%d') between cont_stt_dt and cont_end_dt
124 103
     </select>
104
+
105
+
106
+
125 107
 </mapper>