This commit is contained in:
curry772
2026-05-07 15:39:27 +09:00
12 changed files with 715 additions and 37 deletions
@@ -10,6 +10,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
@Service
@Transactional(transactionManager = "transactionManagerForEMS")
public class PortalNoticeService extends AbstractEMSDataSerivce<PortalNotice, String, PortalNoticeRepository> {
@@ -19,6 +22,10 @@ public class PortalNoticeService extends AbstractEMSDataSerivce<PortalNotice, St
BooleanBuilder predicate = new BooleanBuilder();
if (StringUtils.isNotBlank(portalNoticeUISearch.getSearchNoticeType())) {
predicate.and(qPortalNotice.noticeType.eq(portalNoticeUISearch.getSearchNoticeType()));
}
if (StringUtils.isNotBlank(portalNoticeUISearch.getSearchUseYn())) {
predicate.and(qPortalNotice.useYn.eq(portalNoticeUISearch.getSearchUseYn()));
}
@@ -28,7 +35,12 @@ public class PortalNoticeService extends AbstractEMSDataSerivce<PortalNotice, St
.or(qPortalNotice.noticeDetail.containsIgnoreCase(portalNoticeUISearch.getSearchSubjectDetail())));
}
return repository.findAll(predicate, pageable);
//return repository.findAll(predicate, pageable);
Sort fixYnFirst = Sort.by(Sort.Direction.DESC, "fixYn");
Sort combinedSort = fixYnFirst.and(pageable.getSort());
Pageable fixedPageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), combinedSort);
return repository.findAll(predicate, fixedPageable);
}
}
@@ -5,6 +5,7 @@ import lombok.Data;
@Data
public class PortalNoticeUISearch {
private String searchNoticeType;
private String searchUseYn;
private String searchSubjectDetail;
@@ -1,6 +1,9 @@
package com.eactive.eai.rms.data.entity.onl.inflow;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
@@ -13,6 +16,7 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.eactive.apim.portal.app.entity.QCredential;
import com.eactive.eai.data.entity.onl.adapter.QAdapterGroup;
import com.eactive.eai.data.entity.onl.inflow.InflowControl;
import com.eactive.eai.data.entity.onl.inflow.InflowControlId;
@@ -33,10 +37,15 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
public class InflowControlService extends AbstractDataService<InflowControl, InflowControlId, InflowControlRepository> {
private static final String ADAPTER_TYPE_INFLOW = "01";
private static final String INTERFACE_TYPE_INFLOW = "02";
private static final String CLIENT_TYPE_INFLOW = "03";
@PersistenceContext
EntityManager entityManager;
@PersistenceContext(unitName = "entityManagerFactoryForEMS")
EntityManager entityManagerForEMS;
@Autowired
InflowControlManMapper mapper;
@@ -124,7 +133,7 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
.select(qInflowControl, qEAIMessageEntity.eaisvcname, qEAIMessageEntity.eaisvcdesc)
.from(qEAIMessageEntity)
.leftJoin(qInflowControl)
.on(qInflowControl.id.type.eq("02").and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.on(qInflowControl.id.type.eq(INTERFACE_TYPE_INFLOW).and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.where(qEAIMessageEntity.eaisvcname.contains(searchName))
.orderBy(qEAIMessageEntity.eaisvcname.asc())
.offset(pageable.getOffset())
@@ -143,6 +152,8 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
.fetchOne();
return new PageImpl<>(dtoList, pageable, totalCount);
}
private InflowControlServiceDto toDto(QEAIMessageEntity qEAIMessageEntity, QInflowControl qInflowControl,
Tuple tuple) {
@@ -167,13 +178,109 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
.select(qInflowControl, qEAIMessageEntity.eaisvcname, qEAIMessageEntity.eaisvcdesc)
.from(qEAIMessageEntity)
.leftJoin(qInflowControl)
.on(qInflowControl.id.type.eq("02").and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.on(qInflowControl.id.type.eq(INTERFACE_TYPE_INFLOW).and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.where(qEAIMessageEntity.eaisvcname.eq(eaisvcname))
.fetchOne();
return toDto(qEAIMessageEntity, qInflowControl, tuple);
}
public InflowControlServiceDto findByIdForClient(String clientId) {
QCredential qCredential = QCredential.credential;
QInflowControl qInflowControl = QInflowControl.inflowControl;
// EMSADM: Credential 조회
Tuple credTuple = new JPAQueryFactory(entityManagerForEMS)
.select(qCredential.clientid, qCredential.clientname)
.from(qCredential)
.where(qCredential.clientid.eq(clientId))
.fetchOne();
// AGWADM: InflowControl 조회
InflowControl inflowControl = new JPAQueryFactory(entityManager)
.selectFrom(qInflowControl)
.where(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
.and(qInflowControl.id.name.eq(clientId)))
.fetchOne();
InflowControlServiceDto dto;
if (inflowControl != null) {
dto = mapper.toDto(inflowControl);
} else {
dto = new InflowControlServiceDto();
dto.setName(clientId);
dto.setType(CLIENT_TYPE_INFLOW);
}
if (credTuple != null) {
dto.setDesc(credTuple.get(qCredential.clientname));
}
return dto;
}
public Page<InflowControlServiceDto> findAllForClient(Pageable pageable, String searchName) {
QCredential qCredential = QCredential.credential;
QInflowControl qInflowControl = QInflowControl.inflowControl;
// EMSADM: Credential 목록 및 건수 조회
JPAQueryFactory emsFactory = new JPAQueryFactory(entityManagerForEMS);
BooleanBuilder credPredicate = new BooleanBuilder();
if (!StringUtils.isEmpty(searchName)) {
credPredicate.and(qCredential.clientname.contains(searchName));
}
long totalCount = emsFactory
.select(qCredential.clientid.count())
.from(qCredential)
.where(credPredicate)
.fetchOne();
List<Tuple> credList = emsFactory
.select(qCredential.clientid, qCredential.clientname)
.from(qCredential)
.where(credPredicate)
.orderBy(qCredential.clientname.asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
if (credList.isEmpty()) {
return new PageImpl<>(Collections.emptyList(), pageable, totalCount);
}
// AGWADM: 해당 clientId의 InflowControl 일괄 조회
List<String> clientIds = credList.stream()
.map(t -> t.get(qCredential.clientid))
.collect(Collectors.toList());
Map<String, InflowControl> inflowMap = new JPAQueryFactory(entityManager)
.selectFrom(qInflowControl)
.where(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
.and(qInflowControl.id.name.in(clientIds)))
.fetch()
.stream()
.collect(Collectors.toMap(ic -> ic.getId().getName(), ic -> ic));
// Java에서 병합
List<InflowControlServiceDto> dtoList = credList.stream()
.map(tuple -> {
String clientId = tuple.get(qCredential.clientid);
InflowControl inflowControl = inflowMap.get(clientId);
InflowControlServiceDto dto;
if (inflowControl != null) {
dto = mapper.toDto(inflowControl);
} else {
dto = new InflowControlServiceDto();
dto.setName(clientId);
dto.setType(CLIENT_TYPE_INFLOW);
}
dto.setDesc(tuple.get(qCredential.clientname));
return dto;
})
.collect(Collectors.toList());
return new PageImpl<>(dtoList, pageable, totalCount);
}
public Page<Tuple> selectLogList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) {
QInflowControlLog qlog = QInflowControlLog.inflowControlLog;
QInflowControlGroup qgroup = QInflowControlGroup.inflowControlGroup;
@@ -1,6 +1,8 @@
package com.eactive.eai.rms.onl.apim.portalnotice;
import com.eactive.eai.rms.common.base.BaseAnnotationController;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.login.SessionManager;
import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeUISearch;
@@ -16,12 +18,16 @@ import org.springframework.web.bind.annotation.PostMapping;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequiredArgsConstructor
public class PortalNoticeManController extends BaseAnnotationController {
private final PortalNoticeManService portalNoticeManService;
private final ComboService comboService;
@GetMapping(value = "/onl/apim/portalnotice/portalNoticeMan.view")
public void view() {
@@ -40,6 +46,14 @@ public class PortalNoticeManController extends BaseAnnotationController {
Page<PortalNoticeUI> page = portalNoticeManService.selectList(pageable, portalNoticeUISearch);
return ResponseEntity.ok(new GridResponse<>(page));
}
@PostMapping(value = "/onl/apim/portalnotice/portalNoticeMan.json", params = "cmd=LIST_INIT_COMBO")
public ResponseEntity<Map<String, Object>> initCombo() {
List<ComboVo> noticeTypeList = comboService.getMonitoringCodeSortedBySeq("NOTICE_TYPE");
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("noticeTypeList", noticeTypeList);
return ResponseEntity.ok(resultMap);
}
@PostMapping(value = "/onl/apim/portalnotice/portalNoticeMan.json", params = "cmd=DETAIL")
public ResponseEntity<PortalNoticeUI> selectDetail(String id) {
@@ -93,8 +93,9 @@ public class PortalNoticeManService extends BaseService {
}
public void insert(PortalNoticeUI portalNoticeUI) throws IOException {
portalNoticeUI.setNoticeSubject(decodeString(portalNoticeUI.getNoticeSubject()));
portalNoticeUI.setNoticeDetail(decodeString(StringEscapeUtils.unescapeHtml(portalNoticeUI.getNoticeDetail())));
//portalNoticeUI.setNoticeSubject(decodeString(portalNoticeUI.getNoticeSubject()));
//portalNoticeUI.setNoticeDetail(decodeString(StringEscapeUtils.unescapeHtml(portalNoticeUI.getNoticeDetail())));
portalNoticeUI.setNoticeDetail(StringEscapeUtils.unescapeHtml(portalNoticeUI.getNoticeDetail()));
PortalNotice portalNotice = portalNoticeUIMapper.toEntity(portalNoticeUI);
portalNotice.setId(null);
@@ -123,8 +124,9 @@ public class PortalNoticeManService extends BaseService {
}
public void update(PortalNoticeUI portalNoticeUI) throws IOException {
portalNoticeUI.setNoticeSubject(decodeString(portalNoticeUI.getNoticeSubject()));
portalNoticeUI.setNoticeDetail(decodeString(StringEscapeUtils.unescapeHtml(portalNoticeUI.getNoticeDetail())));
//portalNoticeUI.setNoticeSubject(decodeString(portalNoticeUI.getNoticeSubject()));
//portalNoticeUI.setNoticeDetail(decodeString(StringEscapeUtils.unescapeHtml(portalNoticeUI.getNoticeDetail())));
portalNoticeUI.setNoticeDetail(StringEscapeUtils.unescapeHtml(portalNoticeUI.getNoticeDetail()));
PortalNotice portalNotice = portalNoticeService.getById(portalNoticeUI.getId());
@@ -32,6 +32,11 @@ public class PortalNoticeUI {
private String useYn;
private String inquirerName;
private String fixYn;
private String noticeType;
private String createdBy;
@@ -0,0 +1,86 @@
package com.eactive.eai.rms.onl.manage.inflow.inflow;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.agent.command.CommonCommand;
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.vo.GridResponse;
@Controller
public class InflowClientControlManController extends OnlBaseAnnotationController {
@Autowired
private InflowControlManService service;
@Autowired
private ComboService comboService;
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.view")
public String viewList() {
return "/onl/admin/inflow/inflowClientControlMan";
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.view", params = "cmd=DETAIL")
public String viewDetail() {
return "/onl/admin/inflow/inflowClientControlManDetail";
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<InflowControlManUI>> selectList(HttpServletRequest request, Pageable pageVo,
String searchName) {
Page<InflowControlManUI> uiPage = service.selectClientList(pageVo, searchName);
return ResponseEntity.ok(new GridResponse<>(uiPage));
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=DETAIL")
public ResponseEntity<InflowControlManUI> selectDetail(HttpServletRequest request, HttpServletResponse response,
String name) {
InflowControlManUI ui = service.selectClientDetail(name);
return ResponseEntity.ok(ui);
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=UPDATE")
public String save(HttpServletRequest request, HttpServletResponse response, InflowControlManUI ui)
throws Exception {
service.mergeClient(ui);
CommonCommand command = new CommonCommand("com.eactive.eai.agent.inflow.ReloadInflowClientControlCommand",
ui.getName());
agentUtilService.broadcast(command);
return null;
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=DELETE")
public String delete(HttpServletRequest request, HttpServletResponse response, String name) throws Exception {
service.deleteClient(name);
CommonCommand command = new CommonCommand("com.eactive.eai.agent.inflow.RemoveInflowClientControlCommand",
name);
agentUtilService.broadcast(command);
return null;
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) {
List<ComboVo> useYnRows = comboService.getFromCode("USE_YN");
List<ComboVo> timeUnitRows = comboService.getFromCode("INFLOW_CTRL_TIME_UNIT");
Map<String, List<ComboVo>> resultMap = new HashMap<>();
resultMap.put("useYnRows", useYnRows);
resultMap.put("timeUnitRows", timeUnitRows);
return new ModelAndView("jsonView", resultMap);
}
}
@@ -20,6 +20,7 @@ public class InflowControlManService extends BaseService {
private static final String ADAPTER_TYPE_INFLOW = "01";
private static final String INTERFACE_TYPE_INFLOW = "02";
private static final String CLIENT_TYPE_INFLOW = "03";
@Autowired
@Qualifier("comboService")
@@ -92,6 +93,38 @@ public class InflowControlManService extends BaseService {
service.deleteById(id);
}
// 클라이언트 유량제어
public Page<InflowControlManUI> selectClientList(Pageable pageable, String searchName) {
Page<InflowControlServiceDto> dtoList = service.findAllForClient(pageable, searchName);
return dtoList.map(mapper::toVo);
}
public InflowControlManUI selectClientDetail(String name) {
return mapper.toVo(service.findByIdForClient(name));
}
public void mergeClient(InflowControlManUI ui) {
ui.setType(CLIENT_TYPE_INFLOW);
InflowControlId id = toId(ui);
Optional<InflowControl> inflowControlOptional = service.findById(id);
InflowControl entity = null;
if (inflowControlOptional.isPresent()) {
entity = inflowControlOptional.get();
mapper.updateToEntity(ui, entity);
} else {
entity = mapper.toEntity(ui);
}
service.save(entity);
}
public void deleteClient(String name) {
InflowControlId id = toId(CLIENT_TYPE_INFLOW, name);
service.findById(id).ifPresent(service::delete);
}
private InflowControlId toId(InflowControlManUI ui) {
return toId(ui.getType(), ui.getName());
}