diff --git a/src/main/java/com/itn/admin/agent/client/cmm/service/AbstractAgentService.java b/src/main/java/com/itn/admin/agent/client/cmm/service/AbstractAgentService.java new file mode 100644 index 0000000..1e6734d --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/cmm/service/AbstractAgentService.java @@ -0,0 +1,60 @@ +package com.itn.admin.agent.client.cmm.service; + +import com.itn.admin.cmn.msg.RestResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +public abstract class AbstractAgentService implements AgentService { + + @Autowired + protected M mapper; // 매퍼를 protected로 선언하여 서브 클래스에서 접근 가능 + + private static final int BATCH_SIZE = 10000; + + @Override + public RestResponse send(T agentVO) { + List agentVOL = new ArrayList<>(); + int sendCnt = parseSendCount(agentVO); + + for (int i = 0; i < sendCnt; i++) { + T paramVO = createCopy(agentVO, i); + agentVOL.add(paramVO); + } + + int totalSize = agentVOL.size(); + long startTime = System.currentTimeMillis() / 1000; + int totalBatches = (int) Math.ceil((double) totalSize / BATCH_SIZE); + for (int i = 0; i < totalSize; i += BATCH_SIZE) { + int end = Math.min(totalSize, i + BATCH_SIZE); + List batchList = agentVOL.subList(i, end); + insertBatch(batchList); + logBatchProgress(i, totalBatches); + } + long endTime = System.currentTimeMillis() / 1000; + long totalTime = endTime - startTime; + log.info("insert 시간 : [{}]", totalTime); + return new RestResponse(HttpStatus.OK, "데이터를 정상적으로 입력했습니다.", totalTime + "초"); + } + + @Override + public RestResponse findByInsertCnt(T agentVO) { + int count = countByCondition(agentVO); + return new RestResponse(HttpStatus.OK, "", count); + } + + protected abstract int countByCondition(T agentVO); + protected abstract int parseSendCount(T agentVO); + protected abstract T createCopy(T originalVO, int index); + protected abstract void insertBatch(List batchList); + + private void logBatchProgress(int i, int totalBatches) { + int currentBatch = (i / BATCH_SIZE) + 1; + log.info("현재 처리 중인 배치: [{}]", currentBatch + "/" + totalBatches); + log.info("남은 배치 수: [{}]", (totalBatches - currentBatch)); + } +} diff --git a/src/main/java/com/itn/admin/agent/client/cmm/service/AgentService.java b/src/main/java/com/itn/admin/agent/client/cmm/service/AgentService.java new file mode 100644 index 0000000..049be149 --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/cmm/service/AgentService.java @@ -0,0 +1,8 @@ +package com.itn.admin.agent.client.cmm.service; + +import com.itn.admin.cmn.msg.RestResponse; + +public interface AgentService { + RestResponse send(T agentVO); + RestResponse findByInsertCnt(T agentVO); +} diff --git a/src/main/java/com/itn/admin/agent/client/one/mapper/AgentCOneMapper.java b/src/main/java/com/itn/admin/agent/client/one/mapper/AgentCOneMapper.java new file mode 100644 index 0000000..93f2883 --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/one/mapper/AgentCOneMapper.java @@ -0,0 +1,27 @@ +package com.itn.admin.agent.client.one.mapper; + +import com.itn.admin.agent.client.one.mapper.domain.AgentCOneVO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * packageName : com.itn.admin.agent.mapper + * fileName : AgentMapper + * author : hylee + * date : 2024-07-31 + * description : + * =========================================================== + * DATE AUTHOR NOTE + * ----------------------------------------------------------- + * 2024-07-31 hylee 최초 생성 + */ +@Mapper +public interface AgentCOneMapper { + + List findAll(AgentCOneVO agentCTwoVO); + + void insertAgents(List agentCTwoVO); + + int countBySendStatusNotAndMsgType(AgentCOneVO agentCTwoVO); +} diff --git a/src/main/java/com/itn/admin/agent/client/one/mapper/domain/AgentCOneVO.java b/src/main/java/com/itn/admin/agent/client/one/mapper/domain/AgentCOneVO.java new file mode 100644 index 0000000..928ff08 --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/one/mapper/domain/AgentCOneVO.java @@ -0,0 +1,39 @@ +package com.itn.admin.agent.client.one.mapper.domain; + +import lombok.*; + +import java.io.Serializable; + +/** + * packageName : com.itn.admin.agent.mapper.domain + * fileName : AgentVO + * author : hylee + * date : 2024-07-31 + * description : 에이젼트 테스트발송 + * =========================================================== + * DATE AUTHOR NOTE + * ----------------------------------------------------------- + * 2023-05-09 hylee 최초 생성 + */ +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Getter +@Setter +@ToString +public class AgentCOneVO implements Serializable { + + private static final long serialVersionUID = 1L; + private String msgType; + private String sendStatus; + private String requestSate; + private String recvPhone; + private String sendPhone; + private String subject; + private String message; + private String sendCnt; + + private String cnt; + + +} diff --git a/src/main/java/com/itn/admin/agent/client/one/service/AgentCOneService.java b/src/main/java/com/itn/admin/agent/client/one/service/AgentCOneService.java new file mode 100644 index 0000000..0c83a9f --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/one/service/AgentCOneService.java @@ -0,0 +1,17 @@ +package com.itn.admin.agent.client.one.service; + +import com.itn.admin.agent.client.one.mapper.domain.AgentCOneVO; +import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; +import com.itn.admin.cmn.msg.RestResponse; + + +public interface AgentCOneService { + + + + RestResponse send(AgentCOneVO agentCOneVO); + + RestResponse findByInsertCnt(AgentCOneVO agentCOneVO); + +// RestResponse findByReportCnt(AgentCTwoVO agentCTwoVO); +} diff --git a/src/main/java/com/itn/admin/agent/client/one/service/impl/AgentCOneServiceImpl.java b/src/main/java/com/itn/admin/agent/client/one/service/impl/AgentCOneServiceImpl.java new file mode 100644 index 0000000..36ab241 --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/one/service/impl/AgentCOneServiceImpl.java @@ -0,0 +1,78 @@ +package com.itn.admin.agent.client.one.service.impl; + +import com.itn.admin.agent.client.cmm.service.AbstractAgentService; +import com.itn.admin.agent.client.one.mapper.AgentCOneMapper; +import com.itn.admin.agent.client.one.mapper.domain.AgentCOneVO; +import com.itn.admin.agent.client.one.service.AgentCOneService; +import com.itn.admin.cmn.msg.RestResponse; +import jakarta.annotation.PostConstruct; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + + +@Slf4j@Service +public class AgentCOneServiceImpl extends AbstractAgentService implements AgentCOneService { + + @Autowired + private AgentCOneMapper agentCOneMapper; + + @PostConstruct + private void init() { + this.mapper = agentCOneMapper; + } + + @Override + protected int countByCondition(AgentCOneVO agentVO) { + return mapper.countBySendStatusNotAndMsgType(agentVO); + } + + @Override + protected int parseSendCount(AgentCOneVO agentVO) { + try { + return (agentVO.getSendCnt() != null && !agentVO.getSendCnt().isEmpty()) ? Integer.parseInt(agentVO.getSendCnt()) : 0; + } catch (NumberFormatException e) { + return 0; + } + } + + @Override + protected AgentCOneVO createCopy(AgentCOneVO originalVO, int index) { + AgentCOneVO paramVO = new AgentCOneVO(); + String msgType = originalVO.getMsgType(); + + paramVO.setMsgType(msgType); + paramVO.setSendStatus(originalVO.getSendStatus()); + paramVO.setRecvPhone(modifyPhoneNumber(originalVO.getRecvPhone(), index)); + paramVO.setSendPhone(modifyPhoneNumber(originalVO.getSendPhone(), index)); + paramVO.setMessage(originalVO.getMessage() + " " + (index + 1)); + if (!"S".equals(msgType)) { + paramVO.setSubject(originalVO.getSubject() + " " + (index + 1)); + } + return paramVO; + } + + @Override + protected void insertBatch(List batchList) { + mapper.insertAgents(batchList); + } + + + private String modifyPhoneNumber(String phone, int index) { + // 휴대폰 번호는 010-XXXX-YYYY 형식으로 가정 + String prefix = phone.substring(0, 4); // "010-" 부분 + String middle = phone.substring(4, 8); // "XXXX" 부분 + String suffix = phone.substring(8); // "YYYY" 부분 + + // 중간 부분 숫자 수정 + int middleNumber = Integer.parseInt(middle); + middleNumber = (middleNumber + index) % 10000; // 0000~9999 사이의 값으로 제한 + middle = String.format("%04d", middleNumber); // 네 자리 숫자로 포맷 + + return prefix + middle + suffix; + } + +} diff --git a/src/main/java/com/itn/admin/agent/client/one/web/AgentCOneController.java b/src/main/java/com/itn/admin/agent/client/one/web/AgentCOneController.java new file mode 100644 index 0000000..dece3c5 --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/one/web/AgentCOneController.java @@ -0,0 +1,32 @@ +package com.itn.admin.agent.client.one.web; + +import com.itn.admin.agent.client.one.mapper.domain.AgentCOneVO; +import com.itn.admin.agent.client.one.service.AgentCOneService; +import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; +import com.itn.admin.agent.client.two.service.AgentCTwoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; + +@Controller +public class AgentCOneController { + + private AgentCOneService agentCOneService; + + @Value("${spring.mjagent.client.one.userid}") + private String ONE_USER_ID; + + @Value("${spring.mjagent.client.two.userid}") + private String TOW_USER_ID; + + + @Autowired + public void setAgentCOneService(AgentCOneService agentCOneService) { + this.agentCOneService = agentCOneService; + } + + +} diff --git a/src/main/java/com/itn/admin/agent/client/one/web/AgentCOneRestController.java b/src/main/java/com/itn/admin/agent/client/one/web/AgentCOneRestController.java new file mode 100644 index 0000000..000cb4d --- /dev/null +++ b/src/main/java/com/itn/admin/agent/client/one/web/AgentCOneRestController.java @@ -0,0 +1,49 @@ +package com.itn.admin.agent.client.one.web; + +import com.itn.admin.agent.client.one.mapper.domain.AgentCOneVO; +import com.itn.admin.agent.client.one.service.AgentCOneService; +import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; +import com.itn.admin.agent.client.two.service.AgentCTwoService; +import com.itn.admin.cmn.msg.RestResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class AgentCOneRestController { + + private AgentCOneService agentCOneService; + + + + @Autowired + public void setAgentService(AgentCOneService agentCOneService) { + this.agentCOneService = agentCOneService; + } + + /* + * client db에 insert + * */ + @PostMapping("/agent/one/send") + public ResponseEntity send(@RequestBody AgentCOneVO agentCOneVO) throws Exception { + return ResponseEntity.ok().body(agentCOneService.send(agentCOneVO)); + } + + /* + * client db에 insert 됐는지 확인 count + * */ + @PostMapping("/agent/one/findByInsertCnt") + public ResponseEntity findByInsertCnt(@RequestBody AgentCOneVO agentCOneVO) throws Exception { + return ResponseEntity.ok().body(agentCOneService.findByInsertCnt(agentCOneVO)); + } + + /* + * client db에 insert 됐는지 확인 count + * */ +// @PostMapping("/agent/two/findByReportCnt") +// public ResponseEntity findByReportCnt(@RequestBody AgentCTwoVO agentCTwoVO) throws Exception { +// return ResponseEntity.ok().body(agentCTwoService.findByReportCnt(agentCTwoVO)); +// } +} diff --git a/src/main/java/com/itn/admin/agent/client/two/mapper/domain/AgentCTwoVO.java b/src/main/java/com/itn/admin/agent/client/two/mapper/domain/AgentCTwoVO.java index 3cc15c5..e791846 100644 --- a/src/main/java/com/itn/admin/agent/client/two/mapper/domain/AgentCTwoVO.java +++ b/src/main/java/com/itn/admin/agent/client/two/mapper/domain/AgentCTwoVO.java @@ -29,6 +29,7 @@ public class AgentCTwoVO implements Serializable { private String requestSate; private String recvPhone; private String sendPhone; + private String subject; private String message; private String sendCnt; diff --git a/src/main/java/com/itn/admin/agent/client/two/service/impl/AgentCTwoServiceImpl.java b/src/main/java/com/itn/admin/agent/client/two/service/impl/AgentCTwoServiceImpl.java index 51746a5..2005b8f 100644 --- a/src/main/java/com/itn/admin/agent/client/two/service/impl/AgentCTwoServiceImpl.java +++ b/src/main/java/com/itn/admin/agent/client/two/service/impl/AgentCTwoServiceImpl.java @@ -1,119 +1,65 @@ package com.itn.admin.agent.client.two.service.impl; +import com.itn.admin.agent.client.cmm.service.AbstractAgentService; +import com.itn.admin.agent.client.one.service.AgentCOneService; import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; -import com.itn.admin.agent.client.two.service.AgentCTwoService; import com.itn.admin.agent.client.two.mapper.AgentCTwoMapper; -import com.itn.admin.cmn.msg.RestResponse; +import com.itn.admin.agent.client.two.service.AgentCTwoService; +import jakarta.annotation.PostConstruct; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.List; @Slf4j @Service -public class AgentCTwoServiceImpl implements AgentCTwoService { +public class AgentCTwoServiceImpl extends AbstractAgentService implements AgentCTwoService { @Autowired - AgentCTwoMapper agentCTwoMapper; + private AgentCTwoMapper agentCTwoMapper; -// private SqlSession sqlSession; - private static final int BATCH_SIZE = 10000; // 배치 크기 설정 + @PostConstruct + private void init() { + this.mapper = agentCTwoMapper; + } @Override - public RestResponse send(AgentCTwoVO agentCTwoVO) { - - System.out.println("t : "+ agentCTwoVO.toString()); - List agentCTwoVOL = new ArrayList<>(); - - String sendCntStr = agentCTwoVO.getSendCnt(); - int sendCnt; + protected int countByCondition(AgentCTwoVO agentVO) { + return mapper.countBySendStatusNotAndMsgType(agentVO); + } + @Override + protected int parseSendCount(AgentCTwoVO agentVO) { try { - sendCnt = (sendCntStr != null && !sendCntStr.isEmpty()) ? Integer.parseInt(sendCntStr) : 0; + return (agentVO.getSendCnt() != null && !agentVO.getSendCnt().isEmpty()) ? Integer.parseInt(agentVO.getSendCnt()) : 0; } catch (NumberFormatException e) { - // 변환에 실패하면 기본값으로 설정 - sendCnt = 0; + return 0; } - - - for (int i = 0; i < sendCnt; i++) { - // 새 AgentVO 객체 생성 - AgentCTwoVO newAgentCTwoVO = new AgentCTwoVO(); - - // msgType, sendStatus, requestDate 등의 기존 값을 복사 - newAgentCTwoVO.setMsgType(agentCTwoVO.getMsgType()); - newAgentCTwoVO.setSendStatus(agentCTwoVO.getSendStatus()); - - // 수신번호, 발신번호, 메시지 수정 - String newRecvPhone = modifyPhoneNumber(agentCTwoVO.getRecvPhone(), i); - String newSendPhone = modifyPhoneNumber(agentCTwoVO.getSendPhone(), i); - String newMessage = agentCTwoVO.getMessage() + " " + (i + 1); - - newAgentCTwoVO.setRecvPhone(newRecvPhone); - newAgentCTwoVO.setSendPhone(newSendPhone); - newAgentCTwoVO.setMessage(newMessage); - - // 리스트에 추가 - agentCTwoVOL.add(newAgentCTwoVO); - } - - // SqlSession 초기화 -// sqlSession = MyBatisUtil.getSqlSession(); -// AgentMapper agentMapper = sqlSession.getMapper(AgentMapper.class); - - int totalSize = agentCTwoVOL.size(); - // 시작 시간 기록 (초 단위) - long startTime = System.currentTimeMillis() / 1000; - // 총 배치 수 계산 - int totalBatches = (int) Math.ceil((double) totalSize / BATCH_SIZE); - for (int i = 0; i < totalSize; i += BATCH_SIZE) { - // 배치 단위로 데이터를 나눠서 처리 - int end = Math.min(totalSize, i + BATCH_SIZE); - List batchList = agentCTwoVOL.subList(i, end); - - // 배치 삽입 - agentCTwoMapper.insertAgents(batchList); - - // 캐시 초기화 및 세션 커밋 -// sqlSession.clearCache(); -// sqlSession.commit(); - - // 현재 처리된 배치 번호 - int currentBatch = (i / BATCH_SIZE) + 1; - - // 진행 상태 출력 - log.info("현재 처리 중인 배치: [{}]", currentBatch + "/" + totalBatches); - log.info("남은 배치 수: [{}]", (totalBatches - currentBatch)); - } - - // 종료 시간 기록 (초 단위) - long endTime = System.currentTimeMillis() / 1000; - // 총 소요 시간 계산 - long totalTime = endTime - startTime; - - log.info("insert 시간 : [{}]", totalTime); - return new RestResponse(HttpStatus.OK,"데이터를 정상적으로 입력했습니다.", totalTime+"초"); } @Override - public RestResponse findByInsertCnt(AgentCTwoVO agentCTwoVO) { + protected AgentCTwoVO createCopy(AgentCTwoVO originalVO, int index) { + AgentCTwoVO paramVO = new AgentCTwoVO(); + String msgType = originalVO.getMsgType(); - int cnt = agentCTwoMapper.countBySendStatusNotAndMsgType(agentCTwoVO); - - return new RestResponse(HttpStatus.OK,"", cnt); + paramVO.setMsgType(msgType); + paramVO.setSendStatus(originalVO.getSendStatus()); + paramVO.setRecvPhone(modifyPhoneNumber(originalVO.getRecvPhone(), index)); + paramVO.setSendPhone(modifyPhoneNumber(originalVO.getSendPhone(), index)); + paramVO.setMessage(originalVO.getMessage() + " " + (index + 1)); + if (!"S".equals(msgType)) { + paramVO.setSubject(originalVO.getSubject() + " " + (index + 1)); + } + return paramVO; + } + + @Override + protected void insertBatch(List batchList) { + mapper.insertAgents(batchList); } -// -// @Override -// public RestResponse findByReportCnt(AgentCTwoVO agentCTwoVO) { -// int cnt = agentCTwoMapper.countBySendStatusNotAndMsgType(agentCTwoVO); -// -// return new RestResponse(HttpStatus.OK,"", cnt); -// } private String modifyPhoneNumber(String phone, int index) { diff --git a/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoController.java b/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoController.java index 25dac1f..26b0c23 100644 --- a/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoController.java +++ b/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoController.java @@ -22,7 +22,7 @@ public class AgentCTwoController { @Autowired - public void setCommuteService(AgentCTwoService agentCTwoService) { + public void setAgentCTwoService(AgentCTwoService agentCTwoService) { this.agentCTwoService = agentCTwoService; } diff --git a/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoRestController.java b/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoRestController.java index 89b378d..036d1ef 100644 --- a/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoRestController.java +++ b/src/main/java/com/itn/admin/agent/client/two/web/AgentCTwoRestController.java @@ -4,7 +4,6 @@ import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; import com.itn.admin.agent.client.two.service.AgentCTwoService; import com.itn.admin.cmn.msg.RestResponse; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/itn/admin/agent/server/mapper/AgentSMapper.java b/src/main/java/com/itn/admin/agent/server/mapper/AgentSMapper.java index 16bd1f3..7b7e0b9 100644 --- a/src/main/java/com/itn/admin/agent/server/mapper/AgentSMapper.java +++ b/src/main/java/com/itn/admin/agent/server/mapper/AgentSMapper.java @@ -3,8 +3,6 @@ package com.itn.admin.agent.server.mapper; import com.itn.admin.agent.server.mapper.domain.AgentSVO; import org.apache.ibatis.annotations.Mapper; -import java.util.List; - /** * packageName : com.itn.admin.agent.mapper * fileName : AgentMapper @@ -13,12 +11,12 @@ import java.util.List; * description : * =========================================================== * DATE AUTHOR NOTE - * ----------------------------------------------------------- + * -----------------------------$------------------------------ * 2024-07-31 hylee 최초 생성 */ @Mapper public interface AgentSMapper { int countByCurStateAndUserId(AgentSVO agentSVO); - int updatetwoReport(AgentSVO agentSVO); + int updateReportWhereUserId(AgentSVO agentSVO); } diff --git a/src/main/java/com/itn/admin/agent/server/service/AgentSService.java b/src/main/java/com/itn/admin/agent/server/service/AgentSService.java index cd956dc..574cccb 100644 --- a/src/main/java/com/itn/admin/agent/server/service/AgentSService.java +++ b/src/main/java/com/itn/admin/agent/server/service/AgentSService.java @@ -1,6 +1,5 @@ package com.itn.admin.agent.server.service; -import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; import com.itn.admin.agent.server.mapper.domain.AgentSVO; import com.itn.admin.cmn.msg.RestResponse; @@ -10,5 +9,5 @@ public interface AgentSService { RestResponse findByTransferCnt(AgentSVO agentSVO); - RestResponse twoReport(AgentSVO agentSVO); + RestResponse serverReport(AgentSVO agentSVO); } diff --git a/src/main/java/com/itn/admin/agent/server/service/impl/AgentSServiceImpl.java b/src/main/java/com/itn/admin/agent/server/service/impl/AgentSServiceImpl.java index fe9acd3..d435f35 100644 --- a/src/main/java/com/itn/admin/agent/server/service/impl/AgentSServiceImpl.java +++ b/src/main/java/com/itn/admin/agent/server/service/impl/AgentSServiceImpl.java @@ -1,19 +1,14 @@ package com.itn.admin.agent.server.service.impl; -import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; import com.itn.admin.agent.server.mapper.AgentSMapper; import com.itn.admin.agent.server.mapper.domain.AgentSVO; import com.itn.admin.agent.server.service.AgentSService; import com.itn.admin.cmn.msg.RestResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; - @Slf4j @Service @@ -26,16 +21,14 @@ public class AgentSServiceImpl implements AgentSService { @Override public RestResponse findByTransferCnt(AgentSVO agentSVO) { -// if("one".equals(agentSVO.getUserId())){} -// if("two".equals(agentSVO.getUserId())){} int cnt = agentSMapper.countByCurStateAndUserId(agentSVO); return new RestResponse(HttpStatus.OK,"", cnt); } @Override - public RestResponse twoReport(AgentSVO agentSVO) { - int cnt = agentSMapper.updatetwoReport(agentSVO); + public RestResponse serverReport(AgentSVO agentSVO) { + int cnt = agentSMapper.updateReportWhereUserId(agentSVO); return new RestResponse(HttpStatus.OK,"report를 시작합니다.", cnt); } } diff --git a/src/main/java/com/itn/admin/agent/server/web/AgentSRestController.java b/src/main/java/com/itn/admin/agent/server/web/AgentSRestController.java index 7af951b..ca7fa2b 100644 --- a/src/main/java/com/itn/admin/agent/server/web/AgentSRestController.java +++ b/src/main/java/com/itn/admin/agent/server/web/AgentSRestController.java @@ -1,6 +1,5 @@ package com.itn.admin.agent.server.web; -import com.itn.admin.agent.client.two.mapper.domain.AgentCTwoVO; import com.itn.admin.agent.server.mapper.domain.AgentSVO; import com.itn.admin.agent.server.service.AgentSService; import com.itn.admin.cmn.msg.RestResponse; @@ -33,9 +32,9 @@ public class AgentSRestController { * server DB에 update 함 * @@ 대량 없뎃 * */ - @PostMapping("/agent/server/two/report") - public ResponseEntity twoReport(@RequestBody AgentSVO agentSVO) throws Exception { - return ResponseEntity.ok().body(agentSService.twoReport(agentSVO)); + @PostMapping("/agent/server/report") + public ResponseEntity serverReport(@RequestBody AgentSVO agentSVO) throws Exception { + return ResponseEntity.ok().body(agentSService.serverReport(agentSVO)); } } diff --git a/src/main/java/com/itn/admin/cmn/config/MjonAgentCOneDatabaseConfig.java b/src/main/java/com/itn/admin/cmn/config/MjonAgentCOneDatabaseConfig.java new file mode 100644 index 0000000..a3f3c1b --- /dev/null +++ b/src/main/java/com/itn/admin/cmn/config/MjonAgentCOneDatabaseConfig.java @@ -0,0 +1,48 @@ +package com.itn.admin.cmn.config; + +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; + +import javax.sql.DataSource; + + +@Configuration +@MapperScan(value = "com.itn.admin.agent.client.one.mapper", sqlSessionFactoryRef = "factory5") +class MjonAgentCOneDatabaseConfig { + + private final String COMMUTE_DATA_SOURCE = "MjagentClienOneDatabase"; + + // A database DataSource + @Bean(COMMUTE_DATA_SOURCE) + @ConfigurationProperties(prefix = "spring.mjagent.client.one.datasource") + public DataSource CommuteDataSource() { + return DataSourceBuilder.create() +// .type(HikariDataSource.class) + .build(); + } + + // SqlSessionTemplate 에서 사용할 SqlSession 을 생성하는 Factory + @Bean(name = "factory5") + public SqlSessionFactory MjonAgentCOneSqlSessionFactory(@Qualifier(COMMUTE_DATA_SOURCE) DataSource dataSource) throws Exception { + SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean(); + sqlSessionFactory.setDataSource(dataSource); + sqlSessionFactory.setTypeAliasesPackage("com.itn.admin.agent.client.one.*"); + sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/agent/client/one/*Mapper.xml")); + sqlSessionFactory.setConfigLocation(new PathMatchingResourcePatternResolver().getResource("classpath:mybatis-config.xml")); + return sqlSessionFactory.getObject(); + } + + // DataSource 에서 Transaction 관리를 위한 Manager 클래스 등록 + @Bean(name = "sqlSession5") + public SqlSessionTemplate sqlSession(SqlSessionFactory sqlSessionFactory) { + return new SqlSessionTemplate(sqlSessionFactory); + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 9d7ccac..dbbb91f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -37,7 +37,7 @@ spring.commute.datasource.password=itntest! # agent client 1 spring.mjagent.client.one.userid=daltex spring.mjagent.client.one.datasource.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy -spring.mjagent.client.one.datasource.jdbc-url=jdbc:log4jdbc:mysql://192.168.0.125:3306/mjonUr_agent?serverTimezone=Asia/Seoul +spring.mjagent.client.one.datasource.jdbc-url=jdbc:log4jdbc:mysql://192.168.0.125:3306/mjon_agent?serverTimezone=Asia/Seoul spring.mjagent.client.one.datasource.username=mjonUr_agent spring.mjagent.client.one.datasource.password=mjagent123$ diff --git a/src/main/resources/mapper/agent/client/one/AgentCOneMapper.xml b/src/main/resources/mapper/agent/client/one/AgentCOneMapper.xml new file mode 100644 index 0000000..5da5dda --- /dev/null +++ b/src/main/resources/mapper/agent/client/one/AgentCOneMapper.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + /* two insertAgents */ + INSERT INTO MUNJAON_MSG + ( + MSG_TYPE + , SEND_STATUS + , REQUEST_DATE + , RECV_PHONE + , SEND_PHONE + , SUBJECT + , MESSAGE + ) + VALUES + + ( + #{item.msgType} + , #{item.sendStatus} + , now() + , #{item.recvPhone} + , #{item.sendPhone} + , #{item.subject} + , #{item.message} + ) + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/agent/client/two/AgentCTwoMapper.xml b/src/main/resources/mapper/agent/client/two/AgentCTwoMapper.xml index b4f7082..c068922 100644 --- a/src/main/resources/mapper/agent/client/two/AgentCTwoMapper.xml +++ b/src/main/resources/mapper/agent/client/two/AgentCTwoMapper.xml @@ -6,6 +6,7 @@ + /* two countBySendStatusNotAndMsgType */ SELECT count(*) as cnt FROM diff --git a/src/main/resources/mapper/agent/server/AgentSMapper.xml b/src/main/resources/mapper/agent/server/AgentSMapper.xml index e1ac1aa..ab0d457 100644 --- a/src/main/resources/mapper/agent/server/AgentSMapper.xml +++ b/src/main/resources/mapper/agent/server/AgentSMapper.xml @@ -16,7 +16,7 @@ AND USER_ID = #{userId} - + UPDATE mj_msg_data SET CUR_STATE = 3, SENT_DATE = NOW(), diff --git a/src/main/resources/mybatis-config.xml b/src/main/resources/mybatis-config.xml index fdcb435..41c4c8f 100644 --- a/src/main/resources/mybatis-config.xml +++ b/src/main/resources/mybatis-config.xml @@ -17,6 +17,7 @@ + diff --git a/src/main/resources/static/cmn/js/agent/init.js b/src/main/resources/static/cmn/js/agent/init.js index 40c0bb2..867b946 100644 --- a/src/main/resources/static/cmn/js/agent/init.js +++ b/src/main/resources/static/cmn/js/agent/init.js @@ -1,27 +1,32 @@ $(function () { - // 슬라이더 초기화 - $("#divTwoSms #slider").slider({ - range: "max", - min: 1, - max: 1000000, - value: 1, - slide: function (event, ui) { - $("#divTwoSms #sendCnt").val(ui.value); // 슬라이더 이동 시 input 값 업데이트 - } - }); + $(".slider").each(function () { + var $slider = $(this); // 현재 슬라이더 요소 + var $input = $slider.closest('.input-group').find('.sliderValue'); // 해당 슬라이더의 input 요소 - // 슬라이더의 초기 값을 input에 설정 - $("#divTwoSms #sendCnt").val($("#divTwoSms #slider").slider("value")); + // 슬라이더 초기화 + $slider.slider({ + range: "max", + min: 1, + max: 1000000, + value: 1, + slide: function (event, ui) { + $input.val(ui.value); // 슬라이더 이동 시 input 값 업데이트 + } + }); - // input 변경 시 슬라이더 값 업데이트 (실시간) - $("#divTwoSms #sendCnt").on("input", function () { - var value = $(this).val(); - // 숫자 범위 확인 후 슬라이더 값 업데이트 - if ($.isNumeric(value) && value >= 1 && value <= 1000000) { - $("#divTwoSms #slider").slider("value", value); - } + // 슬라이더의 초기 값을 input에 설정 + $input.val($slider.slider("value")); + + // input 변경 시 슬라이더 값 업데이트 (실시간) + $input.on("input", function () { + var value = $(this).val(); + // 숫자 범위 확인 후 슬라이더 값 업데이트 + if ($.isNumeric(value) && value >= 1 && value <= 1000000) { + $slider.slider("value", value); + } + }); }); $("form").on("reset", function () { @@ -34,15 +39,71 @@ $(function () { /* * 예시 버튼 * */ - $("#divTwoSms #examBtn").on("click", function () { - $('#divTwoSms #recvPhone').val('01012345678') - $('#divTwoSms #sendPhone').val('01043219876') - // 메시지 필드에 값 설정 - $('#divTwoSms #message').val('message test ' + getNowDate()); + $(".examBtn").on("click", function () { + + var tagId = getParentsId($(this)); + var $recvPhone = $(tagId + ' .recvPhone'); + var $sendPhone = $(tagId + ' .sendPhone'); + var $msgType = $(tagId + ' .msgType'); + var $message = $(tagId + ' .message'); + var $subject = $(tagId + ' .subject'); + + // 기본 전화번호 설정 + $recvPhone.val('01012345678'); + $sendPhone.val('01043219876'); + + // 메시지 타입에 따른 메시지 설정 + var msgType = $msgType.val(); + var msg = generateMessage(msgType); + + // 내용 + $message.val(msg); + + if (msgType === 'L' + ||msgType === 'M' + ||msgType === 'A' + ||msgType === 'F' + ) { + $subject.val('ITN SUBJECT'); + } + + }); + + function generateMessage(msgType) { + var messages = { + 'S': 'ITN SMS test ', + 'L': 'ITN LMS test ', + 'M': 'ITN MMS message test ', + 'A': 'ITN ', + 'F': 'ITN ' + }; + // 타입이 위 값들고 같이 않으면 null 반환 + return (messages[msgType] || '') + getNowDate(); + } + $('.msgType').on('change', function() { + + var msgType = $(this).val(); + var tagId = getParentsId($(this)); + if(msgType === 'L' + ||msgType === 'M' + ||msgType === 'A' + ||msgType === 'F' + ) { + $(tagId+' .subject').closest('.form-group').show(); + }else{ + $(tagId+' .subject').closest('.form-group').hide(); + } + + var $message = $(tagId + ' .message'); + $message.val(generateMessage(msgType)); + }); - $('#toggle-info-btn').on('click', function() { - var $hiddenInfo = $('#hidden-info'); + + $('.toggle-info-btn').on('click', function() { + var $card = $(this).closest('.card'); // 클릭한 버튼의 가장 가까운 부모 .card 요소 찾기 + var $hiddenInfo = $card.find('.hidden-info'); // 해당 카드 내에서 .hidden-info 요소 찾기 + $hiddenInfo.slideToggle(); // 애니메이션 효과를 추가하여 더 부드럽게 보이도록 함 var icon = $(this).find('i'); if ($hiddenInfo.is(':visible')) { @@ -51,4 +112,24 @@ $(function () { icon.removeClass('fa-times-circle').addClass('fa-info-circle'); } }); -}); \ No newline at end of file +}); + +function getParentsId($obj){ + + var $col = $obj.closest('.col-md-6'); // 클릭한 버튼의 가장 가까운 부모 .card 요소 찾기 + // 해당 카드 내에서 .hidden-info 요소 찾기 + return '#' + $col.attr('id'); +} + +function getNowDate(){ + + // 현재 날짜와 시간을 가져와서 포맷팅 + var now = new Date(); + var year = String(now.getFullYear()).substring(2); // 년도 마지막 두 자리 + var month = ('0' + (now.getMonth() + 1)).slice(-2); // 월 (0부터 시작하므로 +1 필요) + var day = ('0' + now.getDate()).slice(-2); // 일 + var hours = ('0' + now.getHours()).slice(-2); // 시 + var minutes = ('0' + now.getMinutes()).slice(-2); // 분 + + return year + month + day + '|' + hours + ':' + minutes; +} diff --git a/src/main/resources/static/cmn/js/agent/timerForOneC.js b/src/main/resources/static/cmn/js/agent/timerForOneC.js index 0de1537..0658b7a 100644 --- a/src/main/resources/static/cmn/js/agent/timerForOneC.js +++ b/src/main/resources/static/cmn/js/agent/timerForOneC.js @@ -1,68 +1,93 @@ -/* // 타이머 ID 저장을 위한 변수 -let insertCntIntervalId; -let transferCntIntervalId; +let oneInsertCntIntervalId; +let oneTransferCntIntervalId; +let oneReporingCntIntervalId; // insert 타이머 -let intervalId_insertSeconds; +let oneIntervalId_insertSeconds; // 이관 타이머 -let intervalId_transferSeconds; +let oneIntervalId_transferSeconds; +// 이관 타이머 +let oneIntervalId_reporingSeconds; -function startInsertTimer() { + + +function fn_oneScriptStart(){ + // 건수를 현황확인으로 이동 + $('#divOneSmsCard .sendCntTxt').text('('+$('#divOneSms .sliderValue').val()+'건)'); + oneStartInsertTimer(); // insert 타임어택 시작 + oneStartTransferTimer($('#oneUserId').val()); // 이관 카운트 +} + + +function fn_oneReportScriptStart(){ + oneStartReportTimer($('#oneUserId').val()); // report 타임어택 시작 +} + + + + +function oneStartInsertTimer() { console.log(' :: startInsertTimer :: '); let startTime = Date.now(); - startInsertCntTimer(); - intervalId_insertSeconds = setInterval(function() { + oneStartInsertCntTimer(); + oneIntervalId_insertSeconds = setInterval(function() { let currentTime = Date.now(); let elapsedTime = (currentTime - startTime) / 1000; // 밀리초를 초 단위로 변환 - document.getElementById('insertSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; + // 분과 초로 변환 + let minutes = Math.floor(elapsedTime / 60); // 분 계산 + let seconds = (elapsedTime % 60).toFixed(3); // 나머지 초 계산 + + document.querySelector('#divOneSmsCard .insertSeconds').innerText = minutes + ' 분 ' + seconds + ' 초'; }, 1); } -function startInsertCntTimer() { +function oneStartInsertCntTimer() { + console.log('oneStartInsertCntTimer ::'); // 1초마다 fn_insertCntAndTime 함수를 호출 - insertCntIntervalId = setInterval(fn_insertCntAndTime, 1000); + oneInsertCntIntervalId = setInterval(fn_oneInsertCntAndTime, 1000); } -function stopInsertTimer() { - clearInterval(intervalId_insertSeconds); - clearInterval(insertCntIntervalId); +function oneStopInsertTimer() { + clearInterval(oneIntervalId_insertSeconds); + clearInterval(oneInsertCntIntervalId); console.log("insert 타이머가 멈췄습니다."); } -function fn_insertCntAndTime(){ +function fn_oneInsertCntAndTime(){ + console.log('fn_oneInsertCntAndTime ::'); // 폼 데이터를 수집 - var formData = new FormData($("#divSmsTwo #sendForm")[0]); + var formData = new FormData($("#divOneSms .sendForm")[0]); var jsonObject = {}; formData.forEach((value, key) => { jsonObject[key] = value; }); - + console.log('url : /agent/one/findByInsertCnt'); $.ajax({ type: "POST", - url: "/agent/two/findByInsertCnt", + url: "/agent/one/findByInsertCnt", data: JSON.stringify(jsonObject), // JSON 문자열로 변환된 데이터를 전송 dataType: 'json', contentType: 'application/json', // async: true, success: function (data) { - console.log('insert data : ', data); + console.log(' one findByInsertCnt data : ', data); - if (data.status == 'OK') { + if (data.status === 'OK') { var cnt = data.data; - $('#divSmsTwoCard #insertCnt').text(cnt); - let text = $('#divSmsTwoCard #sendCntTxt').text(); + $('#divOneSmsCard .insertCnt').text(cnt); + let text = $('#divOneSmsCard .sendCntTxt').text(); let numberOnly = text.match(/\d+/)[0]; - console.log('numberOnly :', numberOnly); - console.log('cnt >= numberOnly :', cnt >= numberOnly); + console.log(' one numberOnly :', numberOnly); + console.log(' one cnt >= numberOnly :', cnt >= numberOnly); if(cnt >= numberOnly){ - stopInsertTimer(); + oneStopInsertTimer(); } } else { @@ -83,37 +108,37 @@ function fn_insertCntAndTime(){ -function startTransferTimer(userId) { - console.log(' :: startTransferTimer :: '); +function oneStartTransferTimer(userId) { + console.log(' :: one startTransferTimer :: '); let startTime = Date.now(); - startTransferCntTimer(userId) - intervalId_transferSeconds = setInterval(function() { + oneStartTransferCntTimer(userId) + oneIntervalId_transferSeconds = setInterval(function() { let currentTime = Date.now(); let elapsedTime = (currentTime - startTime) / 1000; // 밀리초를 초 단위로 변환 - document.getElementById('transferSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; + document.querySelector('#divOneSmsCard .transferSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; }, 1); } -function startTransferCntTimer(userId) { +function oneStartTransferCntTimer(userId) { // 1초마다 fn_tranferCntAndTime 함수를 호출 - transferCntIntervalId = setInterval(function() { - fn_tranferCntAndTime(userId); + oneTransferCntIntervalId = setInterval(function() { + fn_oneTranferCntAndTime(userId); }, 1000); } -function stopTransferTimer() { - clearInterval(intervalId_transferSeconds); - clearInterval(transferCntIntervalId); +function oneStopTransferTimer() { + clearInterval(oneIntervalId_transferSeconds); + clearInterval(oneTransferCntIntervalId); console.log("이관 타이머가 멈췄습니다."); } -function fn_tranferCntAndTime(userId){ +function fn_oneTranferCntAndTime(userId){ // 폼 데이터를 수집 - var formData = new FormData($("#divSmsTwo #sendForm")[0]); + var formData = new FormData($("#divOneSms .sendForm")[0]); var jsonObject = {}; formData.forEach((value, key) => { @@ -135,11 +160,11 @@ function fn_tranferCntAndTime(userId){ if (data.status == 'OK') { var cnt = data.data; - $('#divSmsTwoCard #trensferCnt').text(cnt); - let text = $('#divSmsTwoCard #insertCnt').text(); + $('#divOneSmsCard .transferCnt').text(cnt); + let text = $('#divOneSmsCard .insertCnt').text(); let numberOnly = text.match(/\d+/)[0]; if(cnt >= numberOnly){ - stopTransferTimer(); + oneStopTransferTimer(); } } else { @@ -156,4 +181,78 @@ function fn_tranferCntAndTime(userId){ //로딩창 hide } }); -}*/ +} + +// 리포트 영역 +// 리포트 영역 +// 리포트 영역 +function oneStartReportTimer(userId) { + console.log(' :: startReportTimer :: '); + let startTime = Date.now(); + oneStartReporingCntTimer(userId); + oneIntervalId_reporingSeconds = setInterval(function() { + let currentTime = Date.now(); + let elapsedTime = (currentTime - startTime) / 1000; // 밀리초를 초 단위로 변환 + document.querySelector('#divOneSmsCard .reportSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; + }, 1); +} + +function oneStartReporingCntTimer(userId) { + // 1초마다 fn_twoReportCntAndTime 함수를 호출 + oneReporingCntIntervalId = setInterval(function() { + fn_oneReportCntAndTime(userId); + }, 1000); +} + +function oneStopReporingTimer() { + clearInterval(oneIntervalId_reporingSeconds); + clearInterval(oneReporingCntIntervalId); + console.log("report 타이머가 멈췄습니다."); +} + + +function fn_oneReportCntAndTime(userId){ + + // 폼 데이터를 수집 + var formData = new FormData($("#divOneSms .sendForm")[0]); + + var jsonObject = {}; + formData.forEach((value, key) => { + jsonObject[key] = value; + }); + jsonObject['userId'] = userId; + + $.ajax({ + type: "POST", + url: "/agent/one/findByInsertCnt", + data: JSON.stringify(jsonObject), // JSON 문자열로 변환된 데이터를 전송 + dataType: 'json', + contentType: 'application/json', + // async: true, + success: function (data) { + console.log('tranfer data : ', data); + + if (data.status == 'OK') { + var cnt = data.data; + + $('#divOneSmsCard .reportSndCnt').text(cnt); + if(cnt == 0){ + oneStopReporingTimer(); + } + } + else { + alert("오류 알림 : :: "+data.msg); + } + }, + error: function (e) { + alert("report 조회에 실패하였습니다."); + console.log("ERROR : " + JSON.stringify(e)); + }, + beforeSend : function(xmlHttpRequest) { + + }, + complete : function(xhr, textStatus) { + //로딩창 hide + } + }); +} diff --git a/src/main/resources/static/cmn/js/agent/timerForTwoC.js b/src/main/resources/static/cmn/js/agent/timerForTwoC.js index 2b8b591..3d12857 100644 --- a/src/main/resources/static/cmn/js/agent/timerForTwoC.js +++ b/src/main/resources/static/cmn/js/agent/timerForTwoC.js @@ -1,8 +1,8 @@ // 타이머 ID 저장을 위한 변수 -let towInsertCntIntervalId; -let towTransferCntIntervalId; -let towReporingCntIntervalId; +let twoInsertCntIntervalId; +let twoTransferCntIntervalId; +let twoReporingCntIntervalId; // insert 타이머 let twoIntervalId_insertSeconds; // 이관 타이머 @@ -14,7 +14,7 @@ let twoIntervalId_reporingSeconds; function fn_twoScriptStart(){ // 건수를 현황확인으로 이동 - $('#divTwoSmsCard #sendCntTxt').text('('+$('#divTwoSms #sendCnt').val()+'건)'); + $('#divTwoSmsCard .sendCntTxt').text('('+$('#divTwoSms .sliderValue').val()+'건)'); twoStartInsertTimer(); // insert 타임어택 시작 twoStartTransferTimer($('#twoUserId').val()); // 이관 카운트 } @@ -34,18 +34,22 @@ function twoStartInsertTimer() { twoIntervalId_insertSeconds = setInterval(function() { let currentTime = Date.now(); let elapsedTime = (currentTime - startTime) / 1000; // 밀리초를 초 단위로 변환 - document.querySelector('#divTwoSmsCard #insertSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; + // 분과 초로 변환 + let minutes = Math.floor(elapsedTime / 60); // 분 계산 + let seconds = (elapsedTime % 60).toFixed(3); // 나머지 초 계산 + + document.querySelector('#divTwoSmsCard .insertSeconds').innerText = minutes + ' 분 ' + seconds + ' 초'; }, 1); } function twoStartInsertCntTimer() { // 1초마다 fn_insertCntAndTime 함수를 호출 - towInsertCntIntervalId = setInterval(fn_twoInsertCntAndTime, 1000); + twoInsertCntIntervalId = setInterval(fn_twoInsertCntAndTime, 1000); } function twoStopInsertTimer() { clearInterval(twoIntervalId_insertSeconds); - clearInterval(towInsertCntIntervalId); + clearInterval(twoInsertCntIntervalId); console.log("insert 타이머가 멈췄습니다."); } @@ -55,7 +59,7 @@ function twoStopInsertTimer() { function fn_twoInsertCntAndTime(){ // 폼 데이터를 수집 - var formData = new FormData($("#divTwoSms #sendForm")[0]); + var formData = new FormData($("#divTwoSms .sendForm")[0]); var jsonObject = {}; formData.forEach((value, key) => { @@ -75,8 +79,8 @@ function fn_twoInsertCntAndTime(){ if (data.status == 'OK') { var cnt = data.data; - $('#divTwoSmsCard #insertCnt').text(cnt); - let text = $('#divTwoSmsCard #sendCntTxt').text(); + $('#divTwoSmsCard .insertCnt').text(cnt); + let text = $('#divTwoSmsCard .sendCntTxt').text(); let numberOnly = text.match(/\d+/)[0]; console.log('numberOnly :', numberOnly); console.log('cnt >= numberOnly :', cnt >= numberOnly); @@ -103,19 +107,20 @@ function fn_twoInsertCntAndTime(){ function twoStartTransferTimer(userId) { - console.log(' :: startTransferTimer :: '); + console.log(' :: two startTransferTimer :: '); let startTime = Date.now(); twoStartTransferCntTimer(userId) twoIntervalId_transferSeconds = setInterval(function() { let currentTime = Date.now(); let elapsedTime = (currentTime - startTime) / 1000; // 밀리초를 초 단위로 변환 - document.getElementById('transferSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; + // console.log('elapsedTime : ', elapsedTime); + document.querySelector('#divTwoSmsCard .transferSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; }, 1); } function twoStartTransferCntTimer(userId) { // 1초마다 fn_tranferCntAndTime 함수를 호출 - towTransferCntIntervalId = setInterval(function() { + twoTransferCntIntervalId = setInterval(function() { fn_twoTranferCntAndTime(userId); }, 1000); } @@ -123,7 +128,7 @@ function twoStartTransferCntTimer(userId) { function twoStopTransferTimer() { clearInterval(twoIntervalId_transferSeconds); - clearInterval(towTransferCntIntervalId); + clearInterval(twoTransferCntIntervalId); console.log("이관 타이머가 멈췄습니다."); } @@ -132,7 +137,7 @@ function twoStopTransferTimer() { function fn_twoTranferCntAndTime(userId){ // 폼 데이터를 수집 - var formData = new FormData($("#divTwoSms #sendForm")[0]); + var formData = new FormData($("#divTwoSms .sendForm")[0]); var jsonObject = {}; formData.forEach((value, key) => { @@ -154,8 +159,8 @@ function fn_twoTranferCntAndTime(userId){ if (data.status == 'OK') { var cnt = data.data; - $('#divTwoSmsCard #transferCnt').text(cnt); - let text = $('#divTwoSmsCard #insertCnt').text(); + $('#divTwoSmsCard .transferCnt').text(cnt); + let text = $('#divTwoSmsCard .insertCnt').text(); let numberOnly = text.match(/\d+/)[0]; if(cnt >= numberOnly){ twoStopTransferTimer(); @@ -187,20 +192,20 @@ function twoStartReportTimer(userId) { twoIntervalId_reporingSeconds = setInterval(function() { let currentTime = Date.now(); let elapsedTime = (currentTime - startTime) / 1000; // 밀리초를 초 단위로 변환 - document.querySelector('#divTwoSmsCard #reportSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; + document.querySelector('#divTwoSmsCard .reportSeconds').innerText = elapsedTime.toFixed(3) + ' 초'; }, 1); } function twoStartReporingCntTimer(userId) { // 1초마다 fn_twoReportCntAndTime 함수를 호출 - towReporingCntIntervalId = setInterval(function() { + twoReporingCntIntervalId = setInterval(function() { fn_twoReportCntAndTime(userId); }, 1000); } function twoStopReporingTimer() { clearInterval(twoIntervalId_reporingSeconds); - clearInterval(towReporingCntIntervalId); + clearInterval(twoReporingCntIntervalId); console.log("report 타이머가 멈췄습니다."); } @@ -208,7 +213,7 @@ function twoStopReporingTimer() { function fn_twoReportCntAndTime(userId){ // 폼 데이터를 수집 - var formData = new FormData($("#divTwoSms #sendForm")[0]); + var formData = new FormData($("#divTwoSms .sendForm")[0]); var jsonObject = {}; formData.forEach((value, key) => { @@ -229,7 +234,7 @@ function fn_twoReportCntAndTime(userId){ if (data.status == 'OK') { var cnt = data.data; - $('#divTwoSmsCard #reportSndCnt').text(cnt); + $('#divTwoSmsCard .reportSndCnt').text(cnt); if(cnt == 0){ twoStopReporingTimer(); } diff --git a/src/main/resources/templates/agent/view.html b/src/main/resources/templates/agent/view.html index aed9775..3f729ab 100644 --- a/src/main/resources/templates/agent/view.html +++ b/src/main/resources/templates/agent/view.html @@ -51,11 +51,11 @@ color: #555; } - #toggle-info-btn i { + .toggle-info-btn i { transition: transform 0.2s ease-in-out; } - #toggle-info-btn.rotate i { + .toggle-info-btn.rotate i { transform: rotate(180deg); } @@ -95,31 +95,34 @@
-
+ + + -
-
-
-

Client 2 SMS

-
- - -
+
+
+
+

Client 1 (daltex)

+
+ +
- - + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
-
+ + + + +
+
+
+
+
+
+

Client 2 (006star)

+
+ + +
+
+ + + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ + + + + +
+ +
+ +
+ +
+ + + + + +
+
-

현황확인

- +

클라이언트1 현황확인

+
-
+
- +
클라이언트 insert
- 0 + 0 건수
- + + 0초 + +
+
+
+ +
+
+ +
+ 데이터 이관 시간 (C -> S) +
+ 0 + 건수 +
+
+
+
+ + 0초 + +
+
+
+ +
+
+ +
+ 클라이언트 report (S -> C) +
+ 0 + + 0 + 건수 +
+
+
+
+ + 0초 + +
+
+
+ + +
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+

클라이언트2 현황확인

+ + +
+
+
+
+
+
+ +
+ 클라이언트 insert +
+ 0 + 건수 +
+
+
+
+ 0초
@@ -211,38 +411,38 @@
- +
- 데이터 이관 시간 (client -> server) + 데이터 이관 시간 (C -> S)
- 0 + 0 건수
- + 0초
-
+
- +
- 클라이언트 report + 클라이언트 report (S -> C)
- 0 + 0 - 0 + 0 건수
- + 0초
@@ -254,13 +454,11 @@
- +
- -
@@ -292,23 +490,32 @@