-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM0702_MngClsfAgmtCrtrCtrl.java
208 lines (176 loc) · 7.82 KB
/
M0702_MngClsfAgmtCrtrCtrl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package kr.co.kccworld.kccg.manufacture.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import kr.co.kccworld.framework.system.KccgMap;
import kr.co.kccworld.kccg.manufacture.service.M0702_MngClsfAgmtCrtrSvc;
@RestController
@RequestMapping(value = "/manufacture/M0702")
public class M0702_MngClsfAgmtCrtrCtrl {
private final Logger logger = LoggerFactory.getLogger(M0702_MngClsfAgmtCrtrCtrl.class);
@Autowired
private M0702_MngClsfAgmtCrtrSvc service;
@RequestMapping(value = "/getItemList.do")
public ResponseEntity<Map<String, Object>> selectProductItemList(@RequestBody KccgMap paramMap) {
try {
KccgMap map = (KccgMap) paramMap.get("dsSearchMap");
int totalCnt = service.selectItemListCount(map);
List<KccgMap> itemSearchList = service.selectItemList(map);
Map<String, Object> response = new HashMap<>();
response.put("totalCnt", totalCnt);
response.put("dsClassSortList", itemSearchList);
response.put("resCode", "success");
response.put("resMsg", "");
return ResponseEntity.ok(response);
} catch (Exception e) {
logger.error("selectProductItemList : " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(createErrorResponse("처리 중 오류가 발생하였습니다."));
}
}
// 제품구분
@RequestMapping(value="/getPrdtGrpList.do")
public ModelAndView selectPrdtGrpList(@RequestBody KccgMap paramMap) {
try {
KccgMap map = (KccgMap) paramMap.get("dsSearchMap");
ModelAndView mav = service.selectPrdtGrpList(map);
addSuccessResponse(mav);
return mav;
} catch (Exception e) {
ModelAndView mav = createJsonModelAndView();
logger.error("selectPrdtGrpList : " + e.getMessage());
mav.addObject("resCode", "failure");
mav.addObject("resMsg", "처리 중 오류가 발생하였습니다.");
return mav;
}
}
// 원가유형
@RequestMapping(value="/getCostTypeList.do")
public ModelAndView selectCostTypeList(@RequestBody KccgMap paramMap) {
try {
KccgMap map = (KccgMap) paramMap.get("dsSearchMap");
ModelAndView mav = service.selectCostTypeList(map);
addSuccessResponse(mav);
return mav;
} catch (Exception e) {
logger.error("selectCostTypeList : " + e.getMessage());
ModelAndView mav = createJsonModelAndView();
mav.addObject("resCode", "failure");
mav.addObject("resMsg", "처리 중 오류가 발생하였습니다.");
return mav;
}
}
// 원가유형 팝업 조회
@RequestMapping(value = "/getCostTypePopupList.do")
public ResponseEntity<Map<String, Object>> selectCostTypePopupList(@RequestBody KccgMap paramMap) {
try {
KccgMap map = (KccgMap) paramMap.get("dsSearchMap");
int totalCnt = service.selectCostTypePopupListCount(map);
List<KccgMap> itemSearchList = service.selectCostTypePopupList(map);
Map<String, Object> response = new HashMap<>();
response.put("totalCnt", totalCnt);
response.put("dsItemSearchList", itemSearchList);
response.put("resCode", "success");
response.put("resMsg", "");
return ResponseEntity.ok(response);
} catch (Exception e) {
logger.error("selectCostTypePopupList : " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(createErrorResponse("처리 중 오류가 발생하였습니다."));
}
}
// 제품군 추출
private ModelAndView handleClassCdListRequest(KccgMap paramMap, String methodName) {
try {
KccgMap map = (KccgMap) paramMap.get("dsSearchMap");
ModelAndView mav = null;
switch (methodName) {
case "selectClassCd1List":
mav = service.selectClassCd1List(map);
break;
case "selectClassCd2List":
mav = service.selectClassCd2List(map);
break;
case "selectClassCd3List":
mav = service.selectClassCd3List(map);
break;
case "selectClassCd4List":
mav = service.selectClassCd4List(map);
break;
default:
mav = createJsonModelAndView();
mav.addObject("resCode", "failure");
mav.addObject("resMsg", "처리 중 오류가 발생하였습니다.");
break;
}
addSuccessResponse(mav);
return mav;
} catch (Exception e) {
ModelAndView mav = createJsonModelAndView();
mav.addObject("resCode", "failure");
mav.addObject("resMsg", "처리 중 오류가 발생하였습니다.");
logger.error(methodName + " : " + e.getMessage());
return mav;
}
}
// 제품군1
@RequestMapping(value = "getClassCd1List")
public ModelAndView selectClassCd1List(@RequestBody KccgMap paramMap) {
return handleClassCdListRequest(paramMap, "selectClassCd1List");
}
// 제품군2
@RequestMapping(value = "getClassCd2List")
public ModelAndView selectClassCd2List(@RequestBody KccgMap paramMap) {
return handleClassCdListRequest(paramMap, "selectClassCd2List");
}
// 제품군3
@RequestMapping(value = "getClassCd3List")
public ModelAndView selectClassCd3List(@RequestBody KccgMap paramMap) {
return handleClassCdListRequest(paramMap, "selectClassCd3List");
}
// 제품군4
@RequestMapping(value = "getClassCd4List")
public ModelAndView selectClassCd4List(@RequestBody KccgMap paramMap) {
return handleClassCdListRequest(paramMap, "selectClassCd4List");
}
@RequestMapping(value = "saveCostTypeItem.do")
public ResponseEntity<Object> saveCostTypeItem(@RequestBody KccgMap paramMap, HttpServletRequest request) {
HttpSession session = request.getSession();
KccgMap userInfo = (KccgMap) session.getAttribute("kccgErpUserMap");
if (userInfo == null) {
return ResponseEntity.badRequest().body(createErrorResponse("사용자 정보를 찾을 수 없습니다."));
}
List<KccgMap> list = (List<KccgMap>) paramMap.get("dsCostTypeList");
try {
KccgMap resultMap = service.saveCostTypeItem(list);
return ResponseEntity.ok().body(resultMap);
} catch (RuntimeException e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(createErrorResponse("처리 중 오류가 발생하였습니다."));
}
}
private ModelAndView createJsonModelAndView() {
return new ModelAndView("jsonView");
}
private void addSuccessResponse(ModelAndView mav) {
mav.addObject("resCode", "success");
mav.addObject("resMsg", "");
}
private Map<String, Object> createErrorResponse(String message) {
Map<String, Object> errorResponse = new HashMap<>();
errorResponse.put("resCode", "failure");
errorResponse.put("resMsg", message);
return errorResponse;
}
}