fo bo 머지작업(mngr)

This commit is contained in:
jazz
2025-11-17 13:28:23 +09:00
parent 38b9a7e122
commit 16a528351b
31 changed files with 4881 additions and 1271 deletions

View File

@@ -1,23 +1,39 @@
package com.wb.domainserver.domain.mngr.puri.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.wb.domainserver.common.msg.GconeMessageSource;
import com.wb.domainserver.common.mvc.tags.ui.pagination.PaginationInfo;
import com.wb.domainserver.common.prop.PaginationProperties;
import com.wb.domainserver.domain.gcone.puri.service.BOPuriService;
import com.wb.domainserver.domain.gcone.puri.vo.BOPuriSrchVO;
import com.wb.domainserver.domain.mngr.puri.vo.PuriSrchVO;
import com.wb.domainserver.response.WnbtResponse;
import com.wb.domainserver.response.WnbtResponseBody;
import com.wb.domainserver.response.WnbtWebClientResponseHandler;
import com.wb.domainserver.security.authentication.AnonymousUser;
import com.wb.domainserver.security.authentication.MemberJwtContextHolder;
import com.wb.domainserver.security.authorization.annotation.AuthPolicy;
import com.wb.domainserver.security.authorization.annotation.Policy;
import com.wb.domainserver.util.communicate.RESRC;
import com.wb.domainserver.util.communicate.ReplyFromResrc;
import com.wb.domainserver.util.communicate.SendToResrc;
import com.wb.domainserver.util.dataaccess.DataMap;
import lombok.extern.slf4j.Slf4j;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
@Slf4j
@@ -36,6 +52,15 @@ public class PuriController {
@Autowired
private GconeMessageSource gconeMessageSource;
@Autowired
private BOPuriService service;
@Autowired
private PaginationProperties paginationProperties;
@Value("${secret.key}")
private String secretKey;
/**
* 정수기 판매 및 설치내역
* @param vo 게시판 등록 파라미터 VO
@@ -43,13 +68,44 @@ public class PuriController {
*/
@Policy(AuthPolicy.RESTRICTED)
@RequestMapping(value="/selectPuriOrderListR")
public String selectPuriOrderListR(PuriSrchVO vo, ModelMap model, @CookieValue(value = "authSopmalCd") String authSopmalCd){
public String selectPuriOrderListR(BOPuriSrchVO vo, ModelMap model, @CookieValue(value = "authSopmalCd") String authSopmalCd){
vo.setSopmalCd(authSopmalCd);
responseHandler.handleResponse(
sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/selectPuriOrderListR", vo),
model,
"resultMap"
);
// 작성자 정보 할당
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
if("01".equals(user.getSysDvCd())){
vo.setSopmalCd(user.getSopmalCd());
}
log.debug(" 검색 파라미터 확인 리스트 검색조건 : {}", vo);
DataMap content = new DataMap();
PaginationInfo paginationInfo = new PaginationInfo();
paginationInfo.setCurrentPageNo(vo.getPageIndex());
paginationInfo.setRecordCountPerPage(vo.getPageUnit());
paginationInfo.setPageSize(paginationProperties.getPageSize());
vo.setPaginationInfo(paginationInfo);
vo.setFirstIndex(paginationInfo.getFirstRecordIndex());
vo.setLastIndex(paginationInfo.getLastRecordIndex());
vo.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());
vo.setSecretKey(secretKey);
List<DataMap> list = new ArrayList<>();
list = service.selectBOPuriOrderList(vo);
log.debug("asdsadasdsa" + vo.getPaginationInfo().getTotalRecordCount());
content.put("list", list);
content.put("BOPuriSrchVO", vo);
content.put("paginationInfo", vo.getPaginationInfo());
model.addAttribute("resultMap", content);
// responseHandler.handleResponse(
// sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/selectPuriOrderListR", vo),
// model,
// "resultMap"
// );
return "mngr/puri/PuriOrderListR";
}
@@ -60,13 +116,23 @@ public class PuriController {
*/
@Policy(AuthPolicy.RESTRICTED)
@RequestMapping(value="/selectPuriOrderListForm")
public String selectPuriOrderListForm(PuriSrchVO vo, ModelMap model, @CookieValue(value = "authSopmalCd") String authSopmalCd){
public String selectPuriOrderListForm(BOPuriSrchVO vo, ModelMap model, @CookieValue(value = "authSopmalCd") String authSopmalCd){
vo.setSopmalCd(authSopmalCd);
responseHandler.handleResponse(
sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/selectPuriOrderListForm", vo),
model,
"resultMap"
);
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
if("01".equals(user.getSysDvCd())){
vo.setSopmalCd(user.getSopmalCd());
}
DataMap content = new DataMap();
content.put("BOPuriSrchVO", vo);
model.addAttribute("resultMap", content);
// responseHandler.handleResponse(
// sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/selectPuriOrderListForm", vo),
// model,
// "resultMap"
// );
return "mngr/puri/PuriOrderList";
}
@@ -85,7 +151,7 @@ public class PuriController {
/**
* 정수기 필터 교체 문자 발송 내역
* @param vo 게시판 등록 파라미터 VO
* @param puriAllimSeq 게시판 등록 파라미터 VO
* @return String JSP 경로
*/
@Policy(AuthPolicy.RESTRICTED)
@@ -93,49 +159,104 @@ public class PuriController {
@ResponseBody
public Map<String,Object> selectPuriAllimList(@RequestParam Integer puriAllimSeq){
PuriSrchVO vo = new PuriSrchVO();
BOPuriSrchVO vo = new BOPuriSrchVO();
vo.setPuriAllimSeq(puriAllimSeq);
log.debug(" 검색 파라미터 확인 231: {}", vo);
Map<String,Object> resultMap = responseHandler.handleResponseAsMap(
sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/selectPuriAllimList", vo)
);
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
if("01".equals(user.getSysDvCd())){
vo.setSopmalCd(user.getSopmalCd());
}
vo.setSecretKey(secretKey);
log.debug(" 검색 파라미터 확인 231: {}", vo);
Map<String,Object> resultMap = new HashMap<>();
List<DataMap> list = new ArrayList<>();
list = service.selectPuriAllimList(vo);
resultMap.put("list", list);
// Map<String,Object> resultMap = responseHandler.handleResponseAsMap(
// sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/selectPuriAllimList", vo)
// );
return resultMap;
}
/**
* 정수기 필터 상세 페이지 puri_order 내역 업데이트
* @param vo 게시판 등록 파라미터 VO
* @param formData 게시판 등록 파라미터 VO
*/
@Policy(AuthPolicy.RESTRICTED)
@RequestMapping(value="/updatePuriOrder" , method= RequestMethod.POST)
@RequestMapping(value="/updatePuriOrder" , method= RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<WnbtResponse> updatePuriOrder(@RequestParam Map<String, Object> formData){
log.debug(" 검색 파라미터 확인 231: {}", formData);
return responseHandler.handleResponse(
sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/updatePuriOrder", formData),
ReplyFromResrc::getReply
AnonymousUser user = MemberJwtContextHolder.getMemberInfo();
DataMap content = new DataMap();
service.updatePuriOrder(formData);
content.put("status", "success");
content.put("message", "정수기 필터 주문 내역이 성공적으로 업데이트되었습니다.");
content.put("updatedData", formData);
ObjectMapper objectMapper = new ObjectMapper();
return ResponseEntity.ok(
WnbtResponse.builder()
.resBody(new WnbtResponseBody(content))
.build()
);
// return responseHandler.handleResponse(
// sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/updatePuriOrder", formData),
// ReplyFromResrc::getReply
// );
}
/**
* 정수기 필터 상세 페이지 puri_allim 내역 업데이트
* @param vo 게시판 등록 파라미터 VO
* @param formData 게시판 등록 파라미터 VO
*/
@Policy(AuthPolicy.RESTRICTED)
@RequestMapping(value="/updatePuriAllim" , method= RequestMethod.POST)
@RequestMapping(value="/updatePuriAllim" , method= RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<WnbtResponse> updatePuriAllim(@RequestParam Map<String, Object> formData){
log.debug(" 검색 파라미터 확인 231: {}", formData);
return responseHandler.handleResponse(
sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/updatePuriAllim", formData),
ReplyFromResrc::getReply
DataMap content = new DataMap();
String puriAllimSeq = formData.get("puriAllimSeq").toString();
if("".equals(formData.get("installDe").toString())){
formData.put("installDe", null);
}
String telnb = formData.get("telnbOne").toString() + formData.get("telnbTwo").toString() + formData.get("telnbThree").toString();
formData.put("telnb", telnb);
formData.put("secretKey",secretKey);
if(puriAllimSeq == "" || puriAllimSeq == null){
service.insertPuriAllim(formData);
} else{
service.updatePuriAllim(formData);
}
content.put("status", "success");
content.put("message", "정수기 필터 알림 내역이 성공적으로 업데이트되었습니다.");
content.put("updatedData", formData);
return ResponseEntity.ok(
WnbtResponse.builder()
.resBody(new WnbtResponseBody(content))
.build()
);
// return responseHandler.handleResponse(
// sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/updatePuriAllim", formData),
// ReplyFromResrc::getReply
// );
}
/**
@@ -153,20 +274,242 @@ public class PuriController {
/**
* 정수기 기사 설치 방문일 갱신
* @param vo 게시판 등록 파라미터 VO
* @param formData 게시판 등록 파라미터 VO
*/
@Policy(AuthPolicy.RESTRICTED)
@RequestMapping(value="/updateVisitDate" , method= RequestMethod.POST)
@RequestMapping(value="/updateVisitDate" , method= RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<WnbtResponse> updateVisitDate(@RequestParam Map<String, Object> formData){
log.debug(" 검색 파라미터 확인 231: {}", formData);
return responseHandler.handleResponse(
sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/updateVisitDate", formData),
ReplyFromResrc::getReply
DataMap content = new DataMap();
String dataList = formData.get("textData").toString().replace(" ", "");
String mode = formData.get("mode").toString();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String jsonResult = "";
LocalDate baseDate = LocalDate.of(2020,01,01);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
List<String> splitArr = new ArrayList<>();
List<String> ordrCdArr = new ArrayList<>();
List<String> visitDateArr = new ArrayList<>();
List<String> realUpateOrdrCdArr = new ArrayList<>();
List<String> realUpdateVisitDateArr = new ArrayList<>();
List<Integer> puriOrderSeqArr = new ArrayList<>();
List<DataMap> tsPuriAllimDupLogList = new ArrayList<>();
List<DataMap> updateStopPuriAllimList = new ArrayList<>();
List<DataMap> allimlist = new ArrayList<>();
Map<String,Object> paramMap = new HashMap<>();
Map<String,Object> updateParamMap = new HashMap<>();
int failCnt = 0;
// ,로 1차분류 |로 2차분류함 첫번쨰 인덱스 주문번호 두번쨰 방문일
if(!"".equals(dataList)){
String[] splitData = dataList.split("\n");
splitArr = Arrays.asList(splitData);
for (String data : splitArr){
String[] splitTwo = data.split("\t");
if (splitTwo.length > 0) {
ordrCdArr.add(splitTwo[0].trim());
}
if (splitTwo.length > 1) {
visitDateArr.add(splitTwo[1].trim());
}
}
for (int i=0; i<visitDateArr.size(); i++){
if (vaildateVisitDate(visitDateArr.get(i)) ){
realUpdateVisitDateArr.add(visitDateArr.get(i));
realUpateOrdrCdArr.add(ordrCdArr.get(i));
}
}
// 오더코드로 업데이트할 puri_order_seq 조회후 업데이트 처리
if (!ordrCdArr.isEmpty() && !realUpateOrdrCdArr.isEmpty()) {
for (int i=0; i<realUpateOrdrCdArr.size(); i++) {
paramMap.put("ordrCd", realUpateOrdrCdArr.get(i));
paramMap.put("secretKey", secretKey);
List<DataMap> ordrList = service.selectPuriVisitUpdate(paramMap);
if(!ordrList.isEmpty()) {
if(ordrList.size() > 1) {
failCnt++;
} else {
Long puriOrderSeq = (Long) ordrList.get(0).get("puriOrderSeq");
puriOrderSeqArr.add(puriOrderSeq.intValue());
DataMap allim = new DataMap();
allim.put("puriOrderSeq",puriOrderSeq.intValue());
allim.put("status","wait");
allim.put("cttpc",(String) ordrList.get(0).get("cttpc"));
allim.put("cstmrNm",(String) ordrList.get(0).get("purchsrNm"));
allim.put("installDe",realUpdateVisitDateArr.get(i));
allim.put("nextSndngResveDe",getNextDate(LocalDate.parse(realUpdateVisitDateArr.get(i),formatter),baseDate));
allim.put("telnb",(String) ordrList.get(0).get("dlivyCttpc"));
allim.put("chngLog",getChangeLog("regist"));
allim.put("secretKey", secretKey);
allimlist.add(allim);
}
} else {
failCnt++;
}
}
}
if(!puriOrderSeqArr.isEmpty() && !realUpdateVisitDateArr.isEmpty()) {
// gc_puri_allim 테이블 insert 및 gc_puri_order 테이블 seq 업데이트
for(Integer puriOrderSeq : puriOrderSeqArr){
List<DataMap> dupList = service.selectDupPuriOrderAllimList(puriOrderSeq);
updateParamMap.put("puriOrderSeqArr",puriOrderSeqArr);
updateParamMap.put("realUpdateVisitDateArr",realUpdateVisitDateArr);
// 중복데이터 리턴처리
if(!dupList.isEmpty()) {
if ("clear".equals(mode)) {
service.updatePuriVisitCancelDate(updateParamMap);
service.deletePuriAllim(dupList);
content.put("status", "success");
content.put("message", "방문일 등록 취소가 완료되었습니다.");
return ResponseEntity.ok(
WnbtResponse.builder()
.resBody(new WnbtResponseBody(content))
.build()
);
}
service.updatePuriVisitDate(updateParamMap);
content.put("status", "error");
content.put("message", "해당 판매에 대한 알림이 이미 등록되어있습니다.");
return ResponseEntity.ok(
WnbtResponse.builder()
.resBody(new WnbtResponseBody(content))
.build()
);
}
}
service.insertPuriAllimList(allimlist);
//전화번호 중복 처리
if(!allimlist.isEmpty()) {
List<DataMap> allimSameList = service.selectSameNumber(allimlist);
if(allimSameList != null && !allimSameList.isEmpty()) {
for (DataMap puriAllimSeq : allimSameList ) {
DataMap tsPuriAllimDupLog = new DataMap();
DataMap updateStopAllim = new DataMap();
updateStopAllim.put("secretKey",secretKey);
updateStopAllim.put("puriAllimSeq",puriAllimSeq);
updateStopAllim.put("chngLog",getChangeLog("stop"));
updateStopPuriAllimList.add(updateStopAllim);
tsPuriAllimDupLog.put("puriAllimSeq",puriAllimSeq);
tsPuriAllimDupLog.put("act","stop");
tsPuriAllimDupLog.put("secretKey",secretKey);
tsPuriAllimDupLog.put("sndngCn","발송번호 중복으로 이전 알림 자동 중지(" + puriAllimSeq + ")");
tsPuriAllimDupLogList.add(tsPuriAllimDupLog);
}
service.insertPuriAllimLogFirst(tsPuriAllimDupLogList);
service.updateStopAllim(updateStopPuriAllimList);
}
}
content.put("status", "success");
content.put("message", "전체 " + splitArr.size() + "건 중" + allimlist.size() + "건 성공 " + failCnt +"건 실패)");
content.put("updatedData", formData);
} else {
content.put("status", "error");
content.put("message", "데이터없음");
}
} else {
content.put("status", "error");
content.put("message", "데이터없음");
}
return ResponseEntity.ok(
WnbtResponse.builder()
.resBody(new WnbtResponseBody(content))
.build()
);
// return responseHandler.handleResponse(
// sendToResrc.ofPost(RESRC.GCONEBO, "/gcone/puri/updateVisitDate", formData),
// ReplyFromResrc::getReply
// );
}
public static boolean vaildateVisitDate (String visitDate) {
if("".equals(visitDate)) {
return false;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
dateFormat.setLenient(false);
LocalDate baseDate = LocalDate.of(2020,01,01);
try {
Date pareDate = dateFormat.parse(visitDate);
LocalDate parseDates = LocalDate.parse(visitDate,formatter);
if (parseDates.isBefore(baseDate) || parseDates.isEqual(baseDate)) {
return false;
}
String formattedDate = dateFormat.format(pareDate);
if(!visitDate.equals(formattedDate)) {
return false;
}
} catch (Exception e) {
return false;
}
return true;
}
public static String getChangeLog(String status) {
// 현재 시간 포맷팅
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentTime = formatter.format(new Date());
JSONObject changeList = new JSONObject();
changeList.put("status", status);
return new String("[" + currentTime + ", C ]" + changeList.toString());
}
public static LocalDate getNextDate(LocalDate dlivyDe, LocalDate baseDate) {
if(dlivyDe.isBefore(baseDate)) {
return null;
}
LocalDate nextDate = dlivyDe.plusMonths(6).minusDays(7);
LocalDate today = LocalDate.now();
while (nextDate.isBefore(today)) {
nextDate = nextDate.plusMonths(6);
}
return nextDate;
}
}