diff --git a/src/main/java/com/xit/biz/ctgy/auth/MinPasswordEncoder.java b/src/main/java/com/xit/biz/ctgy/auth/MinPasswordEncoder.java index f796bab..a0b001e 100644 --- a/src/main/java/com/xit/biz/ctgy/auth/MinPasswordEncoder.java +++ b/src/main/java/com/xit/biz/ctgy/auth/MinPasswordEncoder.java @@ -1,7 +1,6 @@ package com.xit.biz.ctgy.auth; -import com.xit.biz.ctgy.repository.IMinUserRepository; -import com.xit.biz.ctgy.v2.dao.MinUserinfoDao; +import com.xit.biz.ctgy.v2.repository.MinUserinfoDao; import lombok.RequiredArgsConstructor; import lombok.Setter; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/xit/biz/ctgy/auth/service/impl/AuthMinService.java b/src/main/java/com/xit/biz/ctgy/auth/service/impl/AuthMinService.java index d2618ac..e2eed69 100644 --- a/src/main/java/com/xit/biz/ctgy/auth/service/impl/AuthMinService.java +++ b/src/main/java/com/xit/biz/ctgy/auth/service/impl/AuthMinService.java @@ -5,8 +5,7 @@ import com.xit.biz.ctgy.auth.service.IAuthMinService; import com.xit.biz.ctgy.dto.LoginMinRequestDto; import com.xit.biz.ctgy.dto.MinUserinfoDto; import com.xit.biz.ctgy.entity.MinUserinfo; -import com.xit.biz.ctgy.repository.IMinUserRepository; -import com.xit.biz.ctgy.v2.dao.MinUserinfoDao; +import com.xit.biz.ctgy.v2.repository.MinUserinfoDao; import com.xit.core.constant.ErrorCode; import com.xit.core.constant.XitConstants; import com.xit.core.exception.TokenAuthException; @@ -14,7 +13,6 @@ import com.xit.core.oauth2.api.dao.RefreshTokenDao; import com.xit.core.oauth2.api.dto.TokenDto; import com.xit.core.oauth2.api.dto.TokenRequestDto; import com.xit.core.oauth2.api.entity.RefreshToken; -import com.xit.core.oauth2.api.repository.RefreshTokenRepository; import com.xit.core.oauth2.config.properties.AppProperties; import com.xit.core.oauth2.oauth.JwtTokenProvider; import com.xit.core.oauth2.utils.CookieUtil; diff --git a/src/main/java/com/xit/biz/ctgy/auth/service/impl/CustomMinUserDetailsService.java b/src/main/java/com/xit/biz/ctgy/auth/service/impl/CustomMinUserDetailsService.java index c2721fb..f117214 100644 --- a/src/main/java/com/xit/biz/ctgy/auth/service/impl/CustomMinUserDetailsService.java +++ b/src/main/java/com/xit/biz/ctgy/auth/service/impl/CustomMinUserDetailsService.java @@ -3,8 +3,7 @@ package com.xit.biz.ctgy.auth.service.impl; import com.xit.biz.ctgy.auth.UserMinPrincipal; import com.xit.biz.ctgy.dto.MinUserinfoDto; import com.xit.biz.ctgy.entity.MinUserinfo; -import com.xit.biz.ctgy.repository.IMinUserRepository; -import com.xit.biz.ctgy.v2.dao.MinUserinfoDao; +import com.xit.biz.ctgy.v2.repository.MinUserinfoDao; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.CustomBaseException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java index 6a198b8..48bc9ba 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java @@ -52,31 +52,31 @@ public class BoardController { return RestResponse.of(service.findAll(dto, pageable)); } -// @Secured(policy = SecurityPolicy.TOKEN) -// @Operation(summary = "게시글 조회수 증가" , description = "게시글 조회수 증가") -// @Parameters({ -// @Parameter(in = ParameterIn.PATH, name = "ciCode", description = "게시글번호", required = true, example = "18"), -// }) -// @PutMapping(value = "/hit/{ciCode}", produces = MediaType.APPLICATION_JSON_VALUE) -// public ResponseEntity modifyByCiCode(@PathVariable final Long ciCode) { -// return RestResponse.of(service.modifyByCiCode(ciCode)); -// } -// -// @Secured(policy = SecurityPolicy.TOKEN) -// @Operation(summary = "게시글 등록" , description = "게시글 등록") -// @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) -// public ResponseEntity saveBoard(BoardDto dto) { -// service.saveBoard(dto); -// return RestResponse.of(HttpStatus.OK); -// } -// -// @Secured(policy = SecurityPolicy.TOKEN) -// @Operation(summary = "게시글 삭제", description = "게시글 삭제") -// @PostMapping(value = "/{ciCode}") -// public ResponseEntity removeBoard(@PathVariable @Nonnull final Long ciCode) { -// AssertUtils.isTrue(!Checks.isEmpty(ciCode), "게시글이 선택되지 않았습니다."); -// service.removeBoard(ciCode); -// -// return RestResponse.of(HttpStatus.OK); -// } + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "게시글 조회수 증가" , description = "게시글 조회수 증가") + @Parameters({ + @Parameter(in = ParameterIn.PATH, name = "ciCode", description = "게시글번호", required = true, example = "18"), + }) + @PutMapping(value = "/hit/{ciCode}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity modifyByCiCode(@PathVariable final Long ciCode) { + return RestResponse.of(service.modifyByCiCode(ciCode)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "게시글 등록" , description = "게시글 등록") + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity saveBoard(BoardDto dto) { + service.saveBoard(dto); + return RestResponse.of(HttpStatus.OK); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "게시글 삭제", description = "게시글 삭제") + @PostMapping(value = "/{ciCode}") + public ResponseEntity removeBoard(@PathVariable @Nonnull final Long ciCode) { + AssertUtils.isTrue(!Checks.isEmpty(ciCode), "게시글이 선택되지 않았습니다."); + service.removeBoard(ciCode); + + return RestResponse.of(HttpStatus.OK); + } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/BoardDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/BoardDao.java new file mode 100644 index 0000000..1b3bc70 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/BoardDao.java @@ -0,0 +1,65 @@ +package com.xit.biz.ctgy.v2.repository; + +import com.xit.biz.ctgy.dto.BoardDto; +import com.xit.biz.ctgy.entity.MinCivBoard680; +import com.xit.core.support.sql.parser.QueryGenerator; +import com.xit.core.util.mpower.MpowerUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Repository +@Slf4j +public class BoardDao { + + public Map findAll(final BoardDto dto, Pageable pageable) { + String cntSql = getSql("selectBoardListCnt", dto, pageable); + String listSql = getSql("selectBoardList", dto, pageable); + + MpowerUtils listQuery = new MpowerUtils(); + listQuery.setFeilds("ciCode, ciName, ciContentno, ciTitle, ciContents, ciNalja, ciStep, ciRevel, ciRef, ciHit, ciPass, ciId"); + listQuery.setQuery(listSql); + + return listQuery.getPagingMap(BoardDto.class, cntSql); + } + + private String getSql(String sqlId, BoardDto dto, Pageable pageable){ + return QueryGenerator.createNamedQuery("board", sqlId) + .setParameter("ciTitle", dto.getCiTitle()) + .setParameter("ciName", dto.getCiName()) + .setParameter("ciContents", dto.getCiContents()) + .setParameter("page", pageable.getPageNumber()) + .setParameter("size", pageable.getPageSize()) + .getQueryString(); + } + + + //@Query("UPDATE MinCivBoard680 m SET m.ciHit = m.ciHit + 1 WHERE m.ciCode = :ciCode") + public int updateInHitForMinCivBoard680(Long ciCode) { + return 0; + } + + public Optional findById(Long ciCode) { + return Optional.empty(); + } + + //@Query(value = "SELECT max(e.ci_code) + 1 FROM min_civ_board680 e", nativeQuery = true) + public Long getCiCode() { + return null; + } + + public void save(MinCivBoard680 entity) { + } + + public List findByCiRef(Long ciCode) { + return null; + } + + public void deleteById(Long ciCode) { + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/dao/MinUserinfoDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/MinUserinfoDao.java similarity index 96% rename from src/main/java/com/xit/biz/ctgy/v2/dao/MinUserinfoDao.java rename to src/main/java/com/xit/biz/ctgy/v2/repository/MinUserinfoDao.java index 9a5e849..c17fa84 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/dao/MinUserinfoDao.java +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/MinUserinfoDao.java @@ -1,4 +1,4 @@ -package com.xit.biz.ctgy.v2.dao; +package com.xit.biz.ctgy.v2.repository; import com.xit.biz.ctgy.dto.MinUserinfoDto; import com.xit.biz.ctgy.entity.MinUserinfo; @@ -57,4 +57,7 @@ public class MinUserinfoDao { public List findAllByTeamAndIsenableAndAccesstype(String msuTeam, String isenabled, String accesstype){ return null; } + + public void save(MinUserinfoDto dto) { + } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java new file mode 100644 index 0000000..ebc4275 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java @@ -0,0 +1,4 @@ +package com.xit.biz.ctgy.v2.repository; + +public class ParkingDao { +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/PublicBoardDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/PublicBoardDao.java new file mode 100644 index 0000000..1de0596 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/PublicBoardDao.java @@ -0,0 +1,59 @@ +package com.xit.biz.ctgy.v2.repository; + +import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; +import com.xit.biz.ctgy.dto.MinUserinfoDto; +import com.xit.biz.ctgy.entity.MinUserinfo; +import com.xit.core.support.sql.parser.QueryGenerator; +import com.xit.core.util.mpower.MpowerUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.time.LocalDate; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +@Repository +@Slf4j +public class PublicBoardDao { + + public Map findAll(MinInfoBoard680Dto dto, Pageable pageable) { + return null; + } + + public MinInfoBoard680Dto findByInCode(Long inCode) { + return null; + } + + public int updateInHitForMinInfoBoard680(Long inCode) { + return 1; + } + + //public Optional findById(Long inCode) { + //} + + //@Query(value = "SELECT e.msMaincode FROM #{#entityName} e WHERE e.msChasu = :msChasu AND e.msSdate = :msSdate AND e.msEdate = :msEdate") + public List findAllMsMaincode(Long msChasu, LocalDate msSdate, LocalDate msEdate){ + return null; + }; + + //@Modifying + //@Query(value = "UPDATE #{#entityName} m SET m.msResult = :msResult WHERE m.msMaincode = :msMaincode AND m.msSeq = :msSeq") + public int updateMsResult(final Long msMaincode, final String msSeq, final String msResult){ + return 1; + }; + + public Long getInCodeByInBgubun() { + return 1L; + } + + public void save(MinInfoBoard680Dto savedDto) { + } + + public void delete(MinInfoBoard680Dto savedEntity) { + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java new file mode 100644 index 0000000..7a92066 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java @@ -0,0 +1,4 @@ +package com.xit.biz.ctgy.v2.repository; + +public class ResidentAndDisabledDao { +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java index 2ec4e23..0de9473 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java @@ -12,11 +12,9 @@ public interface IBoardService { Page findAll(final BoardDto dto, Pageable pageable); -// Page findAll2(final MinCivBoard680 entity, Pageable pageable); -// -// int modifyByCiCode(Long ciCode); -// -// void saveBoard(BoardDto dto); -// -// void removeBoard(Long ciCode); + int modifyByCiCode(Long ciCode); + + void saveBoard(BoardDto dto); + + void removeBoard(Long ciCode); } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/ICtgyFileService.java b/src/main/java/com/xit/biz/ctgy/v2/service/ICtgyFileService.java index d58b5f1..980fb4e 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/ICtgyFileService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/ICtgyFileService.java @@ -11,9 +11,9 @@ import java.util.List; * @since 2021-07-16 */ public interface ICtgyFileService { - MinInfoBoard680 findFiles(Long inCode); + MinInfoBoard680Dto findFiles(Long inCode); -// List saveFiles(@Nonnull MinInfoBoard680Dto dto); -// -// void removePublicBoardFile(Long inCode); + List saveFiles(@Nonnull MinInfoBoard680Dto dto); + + void removePublicBoardFile(Long inCode); } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IMinUserService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IMinUserService.java index 09915f5..0e8083e 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IMinUserService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IMinUserService.java @@ -9,11 +9,11 @@ public interface IMinUserService { Page findMinUsers(final MinUserinfo minUserinfo, Pageable pageable); -// MinUserinfo findMinUser(); -// -// MinUserinfo findMinUserByUserid(final String userId); -// -// void saveMinUser(MinUserinfoDto dto); -// -// void removeMinUser(MinUserinfoDto dto); + MinUserinfo findMinUser(); + + MinUserinfo findMinUserByUserid(final String userId); + + void saveMinUser(MinUserinfoDto dto); + + void removeMinUser(MinUserinfoDto dto); } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java index 3643cff..3b7f5f9 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java @@ -12,26 +12,26 @@ public interface IParkingService { Page findParkings(final JudgeListDto dto, Pageable pageable); -// /** -// * 주정차 의견진술 심의 결과 목록 -// * @param dto JudgeListDto -// * @return Map -// */ -// Map findParkingResults(final JudgeListDto dto); -// -// List findParkingJudgeTargets(final ParkingTargetDto dto) ; -// -// // Page findAll(final MinSimsa680 minSimsa680, Pageable pageable); -// -// void saveParkingJudgeTargets(ParkingTargetDto dto); -// -// void removeParkingJudge(final ParkingTargetDto dto); -// -// //--------------------------------------------------------------------------------- -// // 심사자 -// //--------------------------------------------------------------------------------- -// List findByUserJudges(); -// -// void saveJudgeResult(JudgeListDto dto); + /** + * 주정차 의견진술 심의 결과 목록 + * @param dto JudgeListDto + * @return Map + */ + Map findParkingResults(final JudgeListDto dto); + + List findParkingJudgeTargets(final ParkingTargetDto dto) ; + + // Page findAll(final MinSimsa680 minSimsa680, Pageable pageable); + + void saveParkingJudgeTargets(ParkingTargetDto dto); + + void removeParkingJudge(final ParkingTargetDto dto); + + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- + List findByUserJudges(); + + void saveJudgeResult(JudgeListDto dto); } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IPublicBoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IPublicBoardService.java index 1def95f..23d92d2 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IPublicBoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IPublicBoardService.java @@ -1,13 +1,14 @@ package com.xit.biz.ctgy.v2.service; +import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; import com.xit.biz.ctgy.entity.MinInfoBoard680; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; public interface IPublicBoardService { - Page findAll(final MinInfoBoard680 entity, Pageable pageable); -// MinInfoBoard680 findByInCode(final Long inCode); -// -// int modifyByInCode(Long inCode); + Page findAll(final MinInfoBoard680Dto dto, Pageable pageable); + MinInfoBoard680Dto findByInCode(final Long inCode); + + int modifyByInCode(Long inCode); } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IResidentAndDisabledService.java index a73618b..4301615 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IResidentAndDisabledService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IResidentAndDisabledService.java @@ -27,66 +27,66 @@ public interface IResidentAndDisabledService { * @return Page */ Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable); -// -// /** -// * 거주자 / 장애인 심의자료 정보 조회 -// * @param scCode Long -// * @return GnRecallScDto -// */ -// GnRecallScDto findJudgeData(final Long scCode); -// -// //Page findAll(final GnRecallSc entity, Pageable pageable); -// -// // 심의자료 저장 -// -// /** -// * 거주자 / 장애인 심의자료 저장 -// * @param entity GnRecallScDto -// */ -// void saveJudgeData(GnRecallScDto entity); -// -// void removeJudgeData(Long scCode); -// -// /** -// * 거주자 / 장애인 의견진술 심의 목록 조회 -// * @param dto JudgeListDto -// * @param pageable Pageable -// * @return Page -// */ -// Page findJudges(JudgeListDto dto, Pageable pageable); -// -// /** -// * 거주자 / 장애인 의견진술 심의 결과 목록 -// * @param dto JudgeListDto -// * @return Map -// */ -// Map findJudgeResults(final JudgeListDto dto); -// Map findJudgeResults2(final JudgeListDto dto); -// -// /** -// * 거주자 / 장애인 심의대상 목록 조회 -// * @param dto JufgeTargetDto -// * @return List -// */ -// List findJudgeTargets(final JudgeTargetDto dto) ; -// -// /** -// * 거주자 / 장애인 심의대상 목록 저장 -// * @param dto JudgeTargetDto -// */ -// void saveJudgeTargets(JudgeTargetDto dto); -// -// void removeJudge(final JudgeListDto dto); -// -// void saveJudgeStds(final JudgeStdDto dto); -// -// Map findDashboard(); -// -// //--------------------------------------------------------------------------------- -// // 심사자 -// //--------------------------------------------------------------------------------- -// List findByUserJudges(JudgeListDto dto); -// -// void saveJudgeResult(JudgeListDto dto); + + /** + * 거주자 / 장애인 심의자료 정보 조회 + * @param scCode Long + * @return GnRecallScDto + */ + GnRecallScDto findJudgeData(final Long scCode); + + //Page findAll(final GnRecallSc entity, Pageable pageable); + + // 심의자료 저장 + + /** + * 거주자 / 장애인 심의자료 저장 + * @param entity GnRecallScDto + */ + void saveJudgeData(GnRecallScDto entity); + + void removeJudgeData(Long scCode); + + /** + * 거주자 / 장애인 의견진술 심의 목록 조회 + * @param dto JudgeListDto + * @param pageable Pageable + * @return Page + */ + Page findJudges(JudgeListDto dto, Pageable pageable); + + /** + * 거주자 / 장애인 의견진술 심의 결과 목록 + * @param dto JudgeListDto + * @return Map + */ + Map findJudgeResults(final JudgeListDto dto); + Map findJudgeResults2(final JudgeListDto dto); + + /** + * 거주자 / 장애인 심의대상 목록 조회 + * @param dto JufgeTargetDto + * @return List + */ + List findJudgeTargets(final JudgeTargetDto dto) ; + + /** + * 거주자 / 장애인 심의대상 목록 저장 + * @param dto JudgeTargetDto + */ + void saveJudgeTargets(JudgeTargetDto dto); + + void removeJudge(final JudgeListDto dto); + + void saveJudgeStds(final JudgeStdDto dto); + + Map findDashboard(); + + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- + List findByUserJudges(JudgeListDto dto); + + void saveJudgeResult(JudgeListDto dto); } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java index c88c173..5a1477d 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java @@ -2,131 +2,86 @@ package com.xit.biz.ctgy.v2.service.impl; import com.google.common.base.Objects; import com.xit.biz.ctgy.dto.BoardDto; -import com.xit.biz.ctgy.dto.JudgeListDto; -import com.xit.biz.ctgy.dto.struct.MinCivBoard680Mapstruct; import com.xit.biz.ctgy.entity.MinCivBoard680; -import com.xit.biz.ctgy.repository.IBoardRepository; +import com.xit.biz.ctgy.v2.repository.BoardDao; import com.xit.biz.ctgy.v2.service.IBoardService; -import com.xit.core.config.database.BaseMybatisDaoSupport; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.CustomBaseException; import com.xit.core.oauth2.utils.HeaderUtil; -import com.xit.core.support.jpa.JpaUtil; -import com.xit.core.support.sql.parser.QueryGenerator; import com.xit.core.util.Checks; import com.xit.core.util.CommUtil; -import com.xit.core.util.DBUtils; -import com.xit.core.util.mpower.MpowerUtil; -import com.xit.core.util.mpower.MpowerUtils; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.mapping.BoundSql; -import org.apache.ibatis.mapping.MappedStatement; -import org.apache.ibatis.session.Configuration; -import org.apache.ibatis.session.SqlSession; -import org.apache.ibatis.session.SqlSessionFactory; -import org.dom4j.DocumentException; -import org.mapstruct.factory.Mappers; -import org.mybatis.spring.SqlSessionTemplate; import org.springframework.data.domain.*; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; import java.util.Map; -import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; - @Service @AllArgsConstructor @Slf4j public class BoardService implements IBoardService { private final PasswordEncoder passwordEncoder; + private final BoardDao boardDao; @Transactional(readOnly = true) public Page findAll(final BoardDto dto, Pageable pageable) { - String cntSql = getSql("selectBoardListCnt", dto, pageable); - String listSql = getSql("selectBoardList", dto, pageable); - - MpowerUtils listQuery = new MpowerUtils(); - listQuery.setFeilds("ciCode, ciName, ciContentno, ciTitle, ciContents, ciNalja, ciStep, ciRevel, ciRef, ciHit, ciPass, ciId"); - listQuery.setQuery(listSql); - - Map map = listQuery.getPagingMap(BoardDto.class, cntSql); + Map map = boardDao.findAll(dto, pageable); if(Long.parseLong(map.get("totalCount").toString()) <= 0) return new PageImpl<>(new ArrayList<>(), pageable, 0); else return new PageImpl<>((List)map.get("list"), pageable, Long.parseLong(map.get("totalCount").toString())); } - private String getSql(String sqlId, BoardDto dto, Pageable pageable){ - return QueryGenerator.createNamedQuery("board", sqlId) - .setParameter("ciTitle", dto.getCiTitle()) - .setParameter("ciName", dto.getCiName()) - .setParameter("ciContents", dto.getCiContents()) - .setParameter("page", pageable.getPageNumber()) - .setParameter("size", pageable.getPageSize()) - .getQueryString(); + @Override + @Transactional + public int modifyByCiCode(Long ciCode) { + return boardDao.updateInHitForMinCivBoard680(ciCode); + } + + @Override + @Transactional + public void saveBoard(BoardDto dto) { + MinCivBoard680 entity = null; + + // update 인 경우 + if(Checks.isNotEmpty(dto.getCiCode())) { + entity = boardDao.findById(dto.getCiCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); + if(!entity.getCiPass().equals(passwordEncoder.encode(dto.getCiPass()))){ + throw new CustomBaseException(ErrorCode.MISMATCH_PASSWORD); + } + entity.setCiTitle(dto.getCiTitle()); + entity.setCiContents(dto.getCiContents()); + }else { + dto.setCiCode(boardDao.getCiCode()); + dto.setCiContentno(dto.getCiCode()); + if (Checks.isEmpty(dto.getCiRef()) || dto.getCiRef() == 0L) { + dto.setCiRef(dto.getCiCode()); + dto.setCiStep(0L); + dto.setCiRevel(0L); + } + dto.setCiPass(passwordEncoder.encode(dto.getCiPass())); + dto.setCiIp(CommUtil.getDeviceInfo().getIp()); + } + boardDao.save(entity); + } + + @Override + @Transactional + public void removeBoard(Long ciCode) { + + MinCivBoard680 savedEntity = boardDao.findById(ciCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); + if(!Objects.equal(HeaderUtil.getUserId(), savedEntity.getCiId())) throw new CustomBaseException("삭제 권한(게시글 소유자)이 없는 사용자 입니다"); + + // 댓글 존재 여부 조회 + List list = boardDao.findByCiRef(ciCode); + if(list.size() > 1) throw new CustomBaseException("삭제 할 수 없는 게시글 입니다[댓글 존재]"); + boardDao.deleteById(ciCode); } -// @Transactional(readOnly = true) -// public Page findAll2(final MinCivBoard680 entity, Pageable pageable) { -// pageable = JpaUtil.getPagingInfo(pageable); -// ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll() -// .withMatcher("ciTitle", contains()) -// .withMatcher("ciName", contains()); -// Example example = Example.of(entity, exampleMatcher); -// return repository.findAll(example, pageable); -// } -// -// @Override -// @Transactional -// public int modifyByCiCode(Long ciCode) { -// return repository.updateInHitForMinCivBoard680(ciCode); -// } -// -// @Override -// @Transactional -// public void saveBoard(BoardDto dto) { -// MinCivBoard680 entity = null; -// -// // update 인 경우 -// if(Checks.isNotEmpty(dto.getCiCode())) { -// entity = repository.findById(dto.getCiCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); -// if(!entity.getCiPass().equals(passwordEncoder.encode(dto.getCiPass()))){ -// throw new CustomBaseException(ErrorCode.MISMATCH_PASSWORD); -// } -// entity.setCiTitle(dto.getCiTitle()); -// entity.setCiContents(dto.getCiContents()); -// }else { -// dto.setCiCode(repository.getCiCode()); -// dto.setCiContentno(dto.getCiCode()); -// if (Checks.isEmpty(dto.getCiRef()) || dto.getCiRef() == 0L) { -// dto.setCiRef(dto.getCiCode()); -// dto.setCiStep(0L); -// dto.setCiRevel(0L); -// } -// dto.setCiPass(passwordEncoder.encode(dto.getCiPass())); -// dto.setCiIp(CommUtil.getDeviceInfo().getIp()); -// entity = mapstruct.toEntity(dto); -// } -// repository.save(entity); -// } -// -// @Override -// @Transactional -// public void removeBoard(Long ciCode) { -// -// MinCivBoard680 savedEntity = repository.findById(ciCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); -// if(!Objects.equal(HeaderUtil.getUserId(), savedEntity.getCiId())) throw new CustomBaseException("삭제 권한(게시글 소유자)이 없는 사용자 입니다"); -// -// // 댓글 존재 여부 조회 -// List list = repository.findByCiRef(ciCode); -// if(list.size() > 1) throw new CustomBaseException("삭제 할 수 없는 게시글 입니다[댓글 존재]"); -// repository.deleteById(ciCode); -// } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/CtgyFileService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/CtgyFileService.java index 4471b69..ef999c1 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/CtgyFileService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/CtgyFileService.java @@ -1,7 +1,10 @@ package com.xit.biz.ctgy.v2.service.impl; import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; +import com.xit.biz.ctgy.dto.struct.MinInfoBoard680Mapstruct; import com.xit.biz.ctgy.entity.MinInfoBoard680; +import com.xit.biz.ctgy.repository.IPublicBoardRepository; +import com.xit.biz.ctgy.v2.repository.PublicBoardDao; import com.xit.biz.ctgy.v2.service.ICtgyFileService; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.CustomBaseException; @@ -44,134 +47,119 @@ public class CtgyFileService implements ICtgyFileService { @Value("${file.cmm.upload.max.size:1024}") private long maxSize; + private final PublicBoardDao publicBoardDao; + @Override - public MinInfoBoard680 findFiles(Long inCode) { + public MinInfoBoard680Dto findFiles(Long inCode) { Assert.notNull(inCode, "대상 게시글[inCode]을 선택해 주세요."); - return null; -// return repository.findById(inCode).orElse(null); + + return publicBoardDao.findByInCode(inCode); } -// -// /** -// * 파일 등록 -// * 신규등록시는 CmmFileMst.fileMstId가 null, 변경시 not null -// * 변경시 동일한 파일 이름이 존재하면 DB 및 해당 파일 삭제후 신규로 생성 -// * -// * @param dto MinInfoBoard680Dto -// * @return CmmFileMst -// */ -// @Override -// @Transactional -// public List saveFiles(@Nonnull MinInfoBoard680Dto dto) { -// List entityList = new ArrayList<>(); -// MultipartFile[] files = dto.getFiles(); -// String makePath = ""; -// -// if(files != null && files.length > 0){ -// //makePath = File.separator + DateUtil.getToday(""); -// -// // 파일 경로 : upload root 제외 -// String urlPath = this.uploadPath + makePath; -// // 물리적인 파일 저장 위치 -// String fileUploadPath = this.rootPath + urlPath; -// File file = new File(fileUploadPath); -// if(!file.exists()) file.mkdirs(); -// -// for(MultipartFile mf : files) { -// if (!mf.isEmpty()) { -// String orgFileName = ""; -// try { -// orgFileName = StringUtils.cleanPath(Objects.requireNonNull(mf.getOriginalFilename())); -// MinInfoBoard680 savedEntity = null; -// -// // 파일 저장 && 전송 -// if(Checks.isEmpty(dto.getInCode())) { -// dto.setInCode(repository.getInCodeByInBgubun()); -// dto.setInContentno(dto.getInCode()); -// dto.setInFilename(orgFileName); -// dto.setInFilesize(mf.getSize()); -// dto.setInFileurl(serviceUrl + urlPath); -// savedEntity = mapstruct.toEntity(dto); //MinInfoBoard680.builder().build(); -// }else { -// savedEntity = repository.findById(dto.getInCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); -// savedEntity.setInFilename(orgFileName); -// savedEntity.setInFilesize(mf.getSize()); -// savedEntity.setInFileurl(serviceUrl + urlPath); -// setEntity(savedEntity, dto); -// } -// repository.save(savedEntity); -// -// entityList.add(savedEntity); -// mf.transferTo(new File(fileUploadPath + File.separator + orgFileName)); -// -// // inputStream을 가져와 -// // copyOfLocation (저장위치)로 파일을 쓴다. -// // copy의 옵션은 기존에 존재하면 REPLACE(대체한다), 오버라이딩 한다 -// //Files.copy(multipartFile.getInputStream(), copyOfLocation, StandardCopyOption.REPLACE_EXISTING); -// -// } catch (IOException e) { -// String errMsg = String.format("File Upload Error :: %s", orgFileName); -// //TODO : 에러처리 -// //return RestError.of(String.format("File Upload Error :: %s", orgFileName)); -// AssertUtils.isTrue(false, String.format("File Upload Error :: %s", orgFileName)); -// } -// } -// } -// }else{ -// MinInfoBoard680 savedEntity = null; -// if(Checks.isEmpty(dto.getInCode())) { -// dto.setInCode(repository.getInCodeByInBgubun()); -// dto.setInContentno(dto.getInCode()); -// savedEntity = mapstruct.toEntity(dto); -// }else { -// savedEntity = repository.findById(dto.getInCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); -// setEntity(savedEntity, dto); -// } -// repository.save(savedEntity); -// //JpaUtil.saveIfNullId(dto.getInCode(), repository, savedEntity); -// } -// return entityList; -// } -// -// @Override -// @Transactional -// public void removePublicBoardFile(Long inCode) { -// -// MinInfoBoard680 savedEntity = repository.findById(inCode).orElseThrow(() -> new CustomBaseException(ErrorCode.NOT_FOUND)); -// repository.delete(savedEntity); -// -// // 정보 삭제후 파일 삭제 : 에러 발생시 skip -// if(Checks.isNotEmpty(savedEntity.getInFilename())){ -// String absFile = rootPath + savedEntity.getInFileurl().split(serviceUrl)[1]+File.separator + savedEntity.getInFilename(); -// try { -// File file = new File(absFile); -// if (Checks.isNotEmpty(file) && file.exists()) file.delete(); -// }catch(Exception e){ -// // -// } -// } -// -// } -// -// private void setEntity(MinInfoBoard680 savedEntity, MinInfoBoard680Dto dto){ -// savedEntity.setInDept(dto.getInDept()); -// savedEntity.setInTitle(dto.getInTitle()); -// savedEntity.setInContents(dto.getInContents()); -// } -} + /** + * 파일 등록 + * 신규등록시는 CmmFileMst.fileMstId가 null, 변경시 not null + * 변경시 동일한 파일 이름이 존재하면 DB 및 해당 파일 삭제후 신규로 생성 + * + * @param dto MinInfoBoard680Dto + * @return CmmFileMst + */ + @Override + @Transactional + public List saveFiles(@Nonnull MinInfoBoard680Dto dto) { + List entityList = new ArrayList<>(); + MultipartFile[] files = dto.getFiles(); + String makePath = ""; + + if(files != null && files.length > 0){ + //makePath = File.separator + DateUtil.getToday(""); + + // 파일 경로 : upload root 제외 + String urlPath = this.uploadPath + makePath; + // 물리적인 파일 저장 위치 + String fileUploadPath = this.rootPath + urlPath; + File file = new File(fileUploadPath); + if(!file.exists()) file.mkdirs(); + + for(MultipartFile mf : files) { + if (!mf.isEmpty()) { + String orgFileName = ""; + try { + orgFileName = StringUtils.cleanPath(Objects.requireNonNull(mf.getOriginalFilename())); + MinInfoBoard680Dto savedDto = null; + + // 파일 저장 && 전송 + if(Checks.isEmpty(dto.getInCode())) { + dto.setInCode(publicBoardDao.getInCodeByInBgubun()); + dto.setInContentno(dto.getInCode()); + dto.setInFilename(orgFileName); + dto.setInFilesize(mf.getSize()); + dto.setInFileurl(serviceUrl + urlPath); + publicBoardDao.save(dto); + entityList.add(dto); + }else { + savedDto = publicBoardDao.findByInCode(dto.getInCode()); + savedDto.setInFilename(orgFileName); + savedDto.setInFilesize(mf.getSize()); + savedDto.setInFileurl(serviceUrl + urlPath); + publicBoardDao.save(savedDto); + entityList.add(savedDto); + } + + mf.transferTo(new File(fileUploadPath + File.separator + orgFileName)); + + // inputStream을 가져와 + // copyOfLocation (저장위치)로 파일을 쓴다. + // copy의 옵션은 기존에 존재하면 REPLACE(대체한다), 오버라이딩 한다 + //Files.copy(multipartFile.getInputStream(), copyOfLocation, StandardCopyOption.REPLACE_EXISTING); + } catch (IOException e) { + String errMsg = String.format("File Upload Error :: %s", orgFileName); + //TODO : 에러처리 + //return RestError.of(String.format("File Upload Error :: %s", orgFileName)); + AssertUtils.isTrue(false, String.format("File Upload Error :: %s", orgFileName)); + } + } + } + }else{ + MinInfoBoard680Dto savedEntity = null; + if(Checks.isEmpty(dto.getInCode())) { + dto.setInCode(publicBoardDao.getInCodeByInBgubun()); + dto.setInContentno(dto.getInCode()); + publicBoardDao.save(dto); + }else { + savedEntity = publicBoardDao.findByInCode(dto.getInCode()); + publicBoardDao.save(savedEntity); + } + publicBoardDao.save(savedEntity); + //JpaUtil.saveIfNullId(dto.getInCode(), repository, savedEntity); + } + return entityList; + } + + @Override + @Transactional + public void removePublicBoardFile(Long inCode) { + + MinInfoBoard680Dto savedEntity = publicBoardDao.findByInCode(inCode); + publicBoardDao.delete(savedEntity); -/* - // File.seperator 는 OS종속적이다. - // Spring에서 제공하는 cleanPath()를 통해서 ../ 내부 점들에 대해서 사용을 억제한다 - Path copyOfLocation = Paths.get(uploadDir + File.separator + StringUtils.cleanPath(multipartFile.getOriginalFilename())); - try { - // inputStream을 가져와서 - // copyOfLocation (저장위치)로 파일을 쓴다. - // copy의 옵션은 기존에 존재하면 REPLACE(대체한다), 오버라이딩 한다 - Files.copy(multipartFile.getInputStream(), copyOfLocation, StandardCopyOption.REPLACE_EXISTING); - } catch (IOException e) { - e.printStackTrace(); - throw new FileStorageException("Could not store file : " + multipartFile.getOriginalFilename()); + // 정보 삭제후 파일 삭제 : 에러 발생시 skip + if(Checks.isNotEmpty(savedEntity.getInFilename())){ + String absFile = rootPath + savedEntity.getInFileurl().split(serviceUrl)[1]+File.separator + savedEntity.getInFilename(); + try { + File file = new File(absFile); + if (Checks.isNotEmpty(file) && file.exists()) file.delete(); + }catch(Exception e){ + // + } } -*/ + + } + + private void setEntity(MinInfoBoard680 savedEntity, MinInfoBoard680Dto dto){ + savedEntity.setInDept(dto.getInDept()); + savedEntity.setInTitle(dto.getInTitle()); + savedEntity.setInContents(dto.getInContents()); + } +} diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/MinUserService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/MinUserService.java index 2d65213..b44450c 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/MinUserService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/MinUserService.java @@ -2,6 +2,7 @@ package com.xit.biz.ctgy.v2.service.impl; import com.xit.biz.ctgy.dto.MinUserinfoDto; import com.xit.biz.ctgy.entity.MinUserinfo; +import com.xit.biz.ctgy.v2.repository.MinUserinfoDao; import com.xit.biz.ctgy.v2.service.IMinUserService; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.CustomBaseException; @@ -20,6 +21,7 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc public class MinUserService implements IMinUserService { private final PasswordEncoder passwordEncoder; + private final MinUserinfoDao minUserinfoDao; @Transactional//(readOnly = true) public Page findMinUsers(final MinUserinfo minUserinfo, Pageable pageable) { @@ -35,33 +37,33 @@ public class MinUserService implements IMinUserService { // return page; } -// @Override -// @Transactional(readOnly = true) -// public MinUserinfo findMinUser() { -// //cmmUserRepos -// //return Optional.empty(); //cmmUserRepository.findOneWithAuthorities(SecurityUtil.getCurrentMemberId()); -// return repository.findMinUserinfoByUserid(HeaderUtil.getUserId()); -// } -// -// @Override -// @Transactional(readOnly = true) -// public MinUserinfo findMinUserByUserid(final String userid) { -// return repository.findMinUserinfoByUserid(userid); -// } -// -// @Override -// @Transactional -// public void saveMinUser(MinUserinfoDto dto) { -// if("Y".equals(dto.getNewYn()) && repository.findByUserid(dto.getUserid()).isPresent()) throw new CustomBaseException(ErrorCode.MEMBER_EXISTS); -// dto.setPasswd(passwordEncoder.encode(dto.getPasswd())); -// repository.save(mapstruct.toEntity(dto)); -// } -// -// @Override -// @Transactional -// public void removeMinUser(MinUserinfoDto dto) { -// MinUserinfo entity = repository.findByUserid(dto.getUserid()).orElseThrow(()-> new CustomBaseException(ErrorCode.USER_NOT_FOUND)); -// entity.setIsenable("0"); -// repository.save(entity); -// } + @Override + @Transactional(readOnly = true) + public MinUserinfo findMinUser() { + //cmmUserRepos + //return Optional.empty(); //cmmUserRepository.findOneWithAuthorities(SecurityUtil.getCurrentMemberId()); + return minUserinfoDao.findMinUserinfoByUserid(HeaderUtil.getUserId()); + } + + @Override + @Transactional(readOnly = true) + public MinUserinfo findMinUserByUserid(final String userid) { + return minUserinfoDao.findMinUserinfoByUserid(userid); + } + + @Override + @Transactional + public void saveMinUser(MinUserinfoDto dto) { + if("Y".equals(dto.getNewYn()) && minUserinfoDao.findByUserid(dto.getUserid()).isPresent()) throw new CustomBaseException(ErrorCode.MEMBER_EXISTS); + dto.setPasswd(passwordEncoder.encode(dto.getPasswd())); + minUserinfoDao.save(dto); + } + + @Override + @Transactional + public void removeMinUser(MinUserinfoDto dto) { + MinUserinfoDto savedDto = minUserinfoDao.findByUserid(dto.getUserid()).orElseThrow(()-> new CustomBaseException(ErrorCode.USER_NOT_FOUND)); + savedDto.setIsenable("0"); + minUserinfoDao.save(savedDto); + } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java index a4068ee..a8bd99d 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java @@ -6,6 +6,11 @@ import com.xit.biz.ctgy.dto.ParkingTargetDto; import com.xit.biz.ctgy.entity.MinSimsaUser680; import com.xit.biz.ctgy.entity.MinUserinfo; import com.xit.biz.ctgy.entity.Tf680Recall; +import com.xit.biz.ctgy.mapper.IParkingMapper; +import com.xit.biz.ctgy.repository.IMinUserRepository; +import com.xit.biz.ctgy.repository.IParkingJudgeUserRepository; +import com.xit.biz.ctgy.repository.IParkingRepository; +import com.xit.biz.ctgy.repository.IRecallRepository; import com.xit.biz.ctgy.v2.service.IParkingService; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.CustomBaseException; @@ -29,155 +34,160 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class ParkingService implements IParkingService { + private final IParkingRepository repository; + private final IRecallRepository recallRepository; + private final IMinUserRepository userRepository; + private final IParkingJudgeUserRepository parkingJudgeUserRepository; + private final IParkingMapper mapper; + @Override @Transactional(readOnly = true) public Page findParkings(final JudgeListDto dto, Pageable pageable) { - return null; -// return repository.findParkings(dto, pageable); + return repository.findParkings(dto, pageable); } -// @Override -// public Map findParkingResults(JudgeListDto dto) { -// Map resultMap = new HashMap<>(); -// -// // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 -//// Map teamMap = mapper.selectTotParkingJudgeResultGroupByTeamAndChasu(dto); -//// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); -//// List> totJudgeUserList = mapper.selectTotParkingJudgeResultGroupByUser(dto); -//// totJudgeUserList.add(teamMap); -// -// List> teamList = mapper.selectParkingJudgeTeamGroupByChasuAndTeamList(dto); -// if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); -// -// // 차수별 심사자별 심사결과 합산 -// dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); + @Override + public Map findParkingResults(JudgeListDto dto) { + Map resultMap = new HashMap<>(); + + // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 +// Map teamMap = mapper.selectTotParkingJudgeResultGroupByTeamAndChasu(dto); +// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); // List> totJudgeUserList = mapper.selectTotParkingJudgeResultGroupByUser(dto); -// totJudgeUserList.add(teamList.get(0)); -// -// // 심사대상 차량 목록 -// List> judgeCarList = mapper.selectParkingJurgeResultGroupByCarnum(dto); -// -// // 차량별 심사자 심사결과 목록 -// Map paramMap = new HashMap<>(); -// paramMap.put("msDatagb", dto.getMsDatagb()); -// paramMap.put("msChasu", dto.getMsChasu()); -// paramMap.put("msSdate", dto.getMsSdate()); -// paramMap.put("msEdate", dto.getMsEdate()); -// paramMap.put("msuTeam", dto.getMsuTeam()); -// paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); -// paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); -// -// List> jurgeUserList = mapper.selectParkingJudgeResultList(paramMap); -//// List> resultList = judgeCarList.stream().peek((m) -> { -//// paramMap.put("msSeq", m.get("msSeq")); -//// paramMap.put("msCarnum", m.get("msCarnum")); -//// m.put("simsa", mapper.selectParkingJudgeResultList(paramMap)); -//// }).collect(Collectors.toList()); -// -// resultMap.put("teamList", teamList); -// // 차수별 심사자별 심사결과 합산 -// resultMap.put("totJudgeUserData", totJudgeUserList); -// // 심사대상 차량 목록 -// resultMap.put("judgeCarData", judgeCarList); -// // 차량별 심사자 심사결과 목록 -// resultMap.put("judgeUserData", jurgeUserList); -// -// return resultMap; -// } -// -// @Override -// @Transactional(readOnly = true) -// public List findParkingJudgeTargets(ParkingTargetDto dto) { -// return repository.findParkingJudgeTargets(dto); -// } -// -// @Override -// @Transactional -// public void saveParkingJudgeTargets(ParkingTargetDto dto) { -// boolean isFirst = true; -// -// for(Long rcCode : dto.getRcCodes()) { -// -// //--------------------------------------------------------- -// // 심사대상 등록 -// //--------------------------------------------------------- -// dto.setRcCode(rcCode); -// -// if (isFirst) { -// dto.setMsYear(dto.getMsSdate().toString().substring(0, 4)); -// dto.setMsResult("0"); -// isFirst = false; -// } -// if(mapper.insertParkingJudgeTargetIntoSelect(dto) == 0) throw new CustomBaseException(String.format("처리된 데이타가 있습니다[ %s ]", dto.getMmOcarno())); -// -// //--------------------------------------------------------- -// // 등록한 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수 -// //--------------------------------------------------------- -// Tf680Recall recallEntity = recallRepository.findById(dto.getRcCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); -// recallEntity.setRcIrTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode()); -// JpaUtil.saveIfNullId(recallEntity.getRcCode(), recallRepository, recallEntity); -// -// //--------------------------------------------------------- -// // 심사자 등록 -// //--------------------------------------------------------- -// List userinfoList = userRepository.findAllByTeamAndIsenableAndAccesstype( -// dto.getMsuTeam(), -// CtgyConstants.UserInfo.ISENABLED_USE.getCode(), -// CtgyConstants.UserInfo.ACCESSTYPE_SIMSA.getCode()); -// -// List simsaUserList = userinfoList.stream().map(u -> -// MinSimsaUser680.builder() -// .msuMaincode(rcCode) -// .msuUserid(u.getUserid()) -// .msuResult(CtgyConstants.SimsaUserInfo.MSU_RESULT_NONE.getCode()) -// //.msuReaso -// // n() -// .msuTeam(dto.getMsuTeam()) -// //.msuIndate() -// .build() -// ).collect(Collectors.toList()); -// parkingJudgeUserRepository.saveAll(simsaUserList); -// } -// } -// -// -// /** -// * 심사자료 삭제 -// * 1. 삭제 대상 조회 : min_simsa680 테이블 : ms_chasu, ms_sdate, ms_edate 조건으로 ms_maincode 삭제 대상 조회 -// * 2. 심사자 삭제 : min_simsa_user680 테이블 : msu_maincode = ms_maincode -// * 3. 단속데이타 정보 변경 : tf680_recall 테이블 : rc_ir_transfer = '1', rc_code = ms_maincode -// * 4. 심사자료 삭제 : min_simsa680 테이블 ms_maincode = ms_maincode -// * @param dto ParkingTargetDto -// */ -// @Override -// @Transactional -// public void removeParkingJudge(final ParkingTargetDto dto) { -// -// List msMaincodes = repository.findAllMsMaincode(dto.getMsChasu(), dto.getMsSdate(), dto.getMsEdate()); -// -// msMaincodes.forEach(msMaincode -> { -// parkingJudgeUserRepository.deleteByMsuMaincode(msMaincode); -// // 전송상태 -> 미접수(1), 심의결과 -> 심의전(0) -// recallRepository.updateRcIrTransferAndRcState(msMaincode); -// repository.deleteById(msMaincode); -// }); -// } -// -// //--------------------------------------------------------------------------------- -// // 심사자 -// //--------------------------------------------------------------------------------- -// @Override -// @Transactional(readOnly = true) -// public List findByUserJudges() { -// return repository.findByUserJudges(); -// } -// -// @Override -// @Transactional -// public void saveJudgeResult(JudgeListDto dto){ -// parkingJudgeUserRepository.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), -// dto.getMsuResult(), -// dto.getMsuReason(), -// LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); -// } +// totJudgeUserList.add(teamMap); + + List> teamList = mapper.selectParkingJudgeTeamGroupByChasuAndTeamList(dto); + if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); + + // 차수별 심사자별 심사결과 합산 + dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); + List> totJudgeUserList = mapper.selectTotParkingJudgeResultGroupByUser(dto); + totJudgeUserList.add(teamList.get(0)); + + // 심사대상 차량 목록 + List> judgeCarList = mapper.selectParkingJurgeResultGroupByCarnum(dto); + + // 차량별 심사자 심사결과 목록 + Map paramMap = new HashMap<>(); + paramMap.put("msDatagb", dto.getMsDatagb()); + paramMap.put("msChasu", dto.getMsChasu()); + paramMap.put("msSdate", dto.getMsSdate()); + paramMap.put("msEdate", dto.getMsEdate()); + paramMap.put("msuTeam", dto.getMsuTeam()); + paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); + paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); + + List> jurgeUserList = mapper.selectParkingJudgeResultList(paramMap); +// List> resultList = judgeCarList.stream().peek((m) -> { +// paramMap.put("msSeq", m.get("msSeq")); +// paramMap.put("msCarnum", m.get("msCarnum")); +// m.put("simsa", mapper.selectParkingJudgeResultList(paramMap)); +// }).collect(Collectors.toList()); + + resultMap.put("teamList", teamList); + // 차수별 심사자별 심사결과 합산 + resultMap.put("totJudgeUserData", totJudgeUserList); + // 심사대상 차량 목록 + resultMap.put("judgeCarData", judgeCarList); + // 차량별 심사자 심사결과 목록 + resultMap.put("judgeUserData", jurgeUserList); + + return resultMap; + } + + @Override + @Transactional(readOnly = true) + public List findParkingJudgeTargets(ParkingTargetDto dto) { + return repository.findParkingJudgeTargets(dto); + } + + @Override + @Transactional + public void saveParkingJudgeTargets(ParkingTargetDto dto) { + boolean isFirst = true; + + for(Long rcCode : dto.getRcCodes()) { + + //--------------------------------------------------------- + // 심사대상 등록 + //--------------------------------------------------------- + dto.setRcCode(rcCode); + + if (isFirst) { + dto.setMsYear(dto.getMsSdate().toString().substring(0, 4)); + dto.setMsResult("0"); + isFirst = false; + } + if(mapper.insertParkingJudgeTargetIntoSelect(dto) == 0) throw new CustomBaseException(String.format("처리된 데이타가 있습니다[ %s ]", dto.getMmOcarno())); + + //--------------------------------------------------------- + // 등록한 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수 + //--------------------------------------------------------- + Tf680Recall recallEntity = recallRepository.findById(dto.getRcCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); + recallEntity.setRcIrTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode()); + JpaUtil.saveIfNullId(recallEntity.getRcCode(), recallRepository, recallEntity); + + //--------------------------------------------------------- + // 심사자 등록 + //--------------------------------------------------------- + List userinfoList = userRepository.findAllByTeamAndIsenableAndAccesstype( + dto.getMsuTeam(), + CtgyConstants.UserInfo.ISENABLED_USE.getCode(), + CtgyConstants.UserInfo.ACCESSTYPE_SIMSA.getCode()); + + List simsaUserList = userinfoList.stream().map(u -> + MinSimsaUser680.builder() + .msuMaincode(rcCode) + .msuUserid(u.getUserid()) + .msuResult(CtgyConstants.SimsaUserInfo.MSU_RESULT_NONE.getCode()) + //.msuReaso + // n() + .msuTeam(dto.getMsuTeam()) + //.msuIndate() + .build() + ).collect(Collectors.toList()); + parkingJudgeUserRepository.saveAll(simsaUserList); + } + } + + + /** + * 심사자료 삭제 + * 1. 삭제 대상 조회 : min_simsa680 테이블 : ms_chasu, ms_sdate, ms_edate 조건으로 ms_maincode 삭제 대상 조회 + * 2. 심사자 삭제 : min_simsa_user680 테이블 : msu_maincode = ms_maincode + * 3. 단속데이타 정보 변경 : tf680_recall 테이블 : rc_ir_transfer = '1', rc_code = ms_maincode + * 4. 심사자료 삭제 : min_simsa680 테이블 ms_maincode = ms_maincode + * @param dto ParkingTargetDto + */ + @Override + @Transactional + public void removeParkingJudge(final ParkingTargetDto dto) { + + List msMaincodes = repository.findAllMsMaincode(dto.getMsChasu(), dto.getMsSdate(), dto.getMsEdate()); + + msMaincodes.forEach(msMaincode -> { + parkingJudgeUserRepository.deleteByMsuMaincode(msMaincode); + // 전송상태 -> 미접수(1), 심의결과 -> 심의전(0) + recallRepository.updateRcIrTransferAndRcState(msMaincode); + repository.deleteById(msMaincode); + }); + } + + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- + @Override + @Transactional(readOnly = true) + public List findByUserJudges() { + return repository.findByUserJudges(); + } + + @Override + @Transactional + public void saveJudgeResult(JudgeListDto dto){ + parkingJudgeUserRepository.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), + dto.getMsuResult(), + dto.getMsuReason(), + LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); + } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/PublicBoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/PublicBoardService.java index 35402fb..f8b1fa6 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/PublicBoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/PublicBoardService.java @@ -1,6 +1,9 @@ package com.xit.biz.ctgy.v2.service.impl; +import com.xit.biz.ctgy.dto.BoardDto; +import com.xit.biz.ctgy.dto.MinInfoBoard680Dto; import com.xit.biz.ctgy.entity.MinInfoBoard680; +import com.xit.biz.ctgy.v2.repository.PublicBoardDao; import com.xit.biz.ctgy.v2.service.IPublicBoardService; import com.xit.core.support.jpa.JpaUtil; import lombok.AllArgsConstructor; @@ -8,38 +11,37 @@ import org.springframework.data.domain.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; @Service @AllArgsConstructor public class PublicBoardService implements IPublicBoardService { + private final PublicBoardDao publicBoardDao; + + @Override + @Transactional(readOnly = true) + public Page findAll(final MinInfoBoard680Dto dto, Pageable pageable) { + Map map = publicBoardDao.findAll(dto, pageable); + if(Long.parseLong(map.get("totalCount").toString()) <= 0) + return new PageImpl<>(new ArrayList<>(), pageable, 0); + else + return new PageImpl<>((List)map.get("list"), pageable, Long.parseLong(map.get("totalCount").toString())); + } + @Override @Transactional(readOnly = true) - public Page findAll(final MinInfoBoard680 entity, Pageable pageable) { - // Sort sort = Sort.by(Sort.Direction.DESC, "inCode"); - pageable = JpaUtil.getPagingInfo(pageable); - // pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending()) - ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll() - .withMatcher("inTitle", contains()) - .withMatcher("inName", contains()); - Example example = Example.of(entity, exampleMatcher); - return null; -// Page page = repository.findAll( -// example, -// PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("inCode").descending())); -// return page; + public MinInfoBoard680Dto findByInCode(final Long inCode) { + return publicBoardDao.findByInCode(inCode); } -// @Override -// @Transactional(readOnly = true) -// public MinInfoBoard680 findByInCode(final Long inCode) { -// return repository.findByInCode(inCode); -// } -// -// @Override -// @Transactional -// public int modifyByInCode(Long inCode) { -// return repository.updateInHitForMinInfoBoard680(inCode); -// } + @Override + @Transactional + public int modifyByInCode(Long inCode) { + return publicBoardDao.updateInHitForMinInfoBoard680(inCode); + } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java index 721db0c..ec0b03f 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java @@ -6,11 +6,14 @@ import com.xit.biz.ctgy.dto.GnRecallScDto; import com.xit.biz.ctgy.dto.JudgeListDto; import com.xit.biz.ctgy.dto.JudgeStdDto; import com.xit.biz.ctgy.dto.JudgeTargetDto; +import com.xit.biz.ctgy.dto.struct.GnRecallScMapstruct; import com.xit.biz.ctgy.entity.GnRecallSc; import com.xit.biz.ctgy.entity.MinInfoBoard680; import com.xit.biz.ctgy.entity.MinSimsaUser680Sc; import com.xit.biz.ctgy.entity.MinUserinfo; import com.xit.biz.ctgy.mapper.IParkingMapper; +import com.xit.biz.ctgy.mapper.IResidentAndDisabledMapper; +import com.xit.biz.ctgy.repository.*; import com.xit.biz.ctgy.service.IPublicBoardService; import com.xit.biz.ctgy.v2.service.IResidentAndDisabledService; import com.xit.core.constant.ErrorCode; @@ -54,6 +57,16 @@ public class ResidentAndDisabledService implements IResidentAndDisabledService { @Value("${file.cmm.upload.simsaPath:[simUpFile_sc1]}") private String[] uploadPath; + private final GnRecallScMapstruct mapstruct = Mappers.getMapper(GnRecallScMapstruct.class); + private final IResidentAndDisabledRepository gnReacallRepository; + private final IMinUserRepository userRepository; + private final IJudgeUserRepository judgeUserRepository; + + private final IJudgeRepository judgeRepository; + private final IResidentAndDisabledMapper residentAndDisabledMapper; + + private final IParkingRepository parkingRepository; + private final ICmmFileService fileService; private final IPublicBoardService pBoardService; private final IParkingMapper parkingMapper; @@ -68,323 +81,323 @@ public class ResidentAndDisabledService implements IResidentAndDisabledService { public Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable) { // Sort sort = Sort.by(Sort.Direction.DESC, "inCode"); pageable = JpaUtil.getPagingInfo(pageable); - return null; -// return gnReacallRepository.findJudgeDatas( -// scDatagb, -// PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("scCode").descending())); + return gnReacallRepository.findJudgeDatas( + scDatagb, + PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("scCode").descending())); + // List userList = page.getContent(); + } + + @Override + @Transactional(readOnly = true) + public GnRecallScDto findJudgeData(final Long scCode) { + return gnReacallRepository.findJudgeData(scCode); + } + + @Override + @Transactional + public void saveJudgeData(GnRecallScDto dto) { + boolean isNew = Checks.isEmpty(dto.getScCode()) || dto.getScCode() == 0L; + + if(dto.getPicadFiles() != null) { + if(!isNew) changeFileUpload(dto, dto.getPicadFiles()); + else setFileInfoAndFileUpload(dto, dto.getPicadFiles(), "setScPicad"); + } + + if(dto.getFrecadFiles() != null) { + if(!isNew) changeFileUpload(dto, dto.getFrecadFiles()); + else setFileInfoAndFileUpload(dto, dto.getFrecadFiles(), "setScFrecad"); + } + + if(dto.getContadFiles() != null) { + if(!isNew) changeFileUpload(dto, dto.getContadFiles()); + else setFileInfoAndFileUpload(dto, dto.getContadFiles(), "setScContad"); + } + + GnRecallSc entity = null; + // 신규 + if (isNew) { + // 접수번호 채번 : 년도 + seq 10자리 + dto.setScSeq(gnReacallRepository.getGnRecallScMaxScSeq(String.valueOf(DateUtil.getCurrentYear()), CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); + entity = mapstruct.toEntity(dto); + }else{ + entity = mapstruct.toEntity(dto); + } + gnReacallRepository.save(entity); + + } + + + @Override + @Transactional + public void removeJudgeData(final Long scCode){ + gnReacallRepository.deleteById(scCode); + } + + @Override + @Transactional(readOnly = true) + public List findJudgeTargets(JudgeTargetDto dto) { + return gnReacallRepository.findJudgeTargets(dto); + } + + @Override + @Transactional + public void saveJudgeTargets(JudgeTargetDto dto) { + boolean isFirst = true; + + for(Long scCode : dto.getScCodes()) { + + //--------------------------------------------------------- + // 심사대상 등록 + //--------------------------------------------------------- + dto.setScCode(scCode); + + if (isFirst) { + dto.setMsYear(dto.getMsSdate().toString().substring(0, 4)); + dto.setMsResult("0"); + isFirst = false; + } + if(residentAndDisabledMapper.insertJudgeTargetIntoSelect(dto) == 0) throw new CustomBaseException(String.format("처리된 데이타가 있습니다[ %s ]", dto.getScCarnum())); + + //--------------------------------------------------------- + // 등록한 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수, 심의결과 : 접수 -> 심사중 + //--------------------------------------------------------- + GnRecallSc entity = gnReacallRepository.findById(dto.getScCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); + entity.setScTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode()); + // entity.setScState(CtgyConstants.Judge.DATA_STATE_JUDGE.getCode()); + //JpaUtil.saveIfNullId(dto.getScCode(), repository, entity); + gnReacallRepository.save(entity); + + //--------------------------------------------------------- + // 심사자 등록 + //--------------------------------------------------------- + List userinfoList = userRepository.findAllByTeamAndIsenableAndAccesstype( + dto.getMsuTeam(), + CtgyConstants.UserInfo.ISENABLED_USE.getCode(), + CtgyConstants.UserInfo.ACCESSTYPE_SIMSA.getCode()); + + List simsaUserList = userinfoList.stream().map(u -> + MinSimsaUser680Sc.builder() + .msuMaincode(scCode) + .msuUserid(u.getUserid()) + .msuResult(CtgyConstants.SimsaUserInfo.MSU_RESULT_NONE.getCode()) + //.msuReason() + .msuTeam(dto.getMsuTeam()) + //.msuIndate() + .build() + ).collect(Collectors.toList()); + judgeUserRepository.saveAll(simsaUserList); + } + } + + @Override + @Transactional(readOnly = true) + public Page findJudges(JudgeListDto dto, Pageable pageable) { + + pageable = JpaUtil.getPagingInfo(pageable); + return gnReacallRepository.findJudges(dto, pageable); } -// @Override -// @Transactional(readOnly = true) -// public GnRecallScDto findJudgeData(final Long scCode) { -// return gnReacallRepository.findJudgeData(scCode); -// } -// -// @Override -// @Transactional -// public void saveJudgeData(GnRecallScDto dto) { -// boolean isNew = Checks.isEmpty(dto.getScCode()) || dto.getScCode() == 0L; -// -// if(dto.getPicadFiles() != null) { -// if(!isNew) changeFileUpload(dto, dto.getPicadFiles()); -// else setFileInfoAndFileUpload(dto, dto.getPicadFiles(), "setScPicad"); -// } -// -// if(dto.getFrecadFiles() != null) { -// if(!isNew) changeFileUpload(dto, dto.getFrecadFiles()); -// else setFileInfoAndFileUpload(dto, dto.getFrecadFiles(), "setScFrecad"); -// } -// -// if(dto.getContadFiles() != null) { -// if(!isNew) changeFileUpload(dto, dto.getContadFiles()); -// else setFileInfoAndFileUpload(dto, dto.getContadFiles(), "setScContad"); -// } -// -// GnRecallSc entity = null; -// // 신규 -// if (isNew) { -// // 접수번호 채번 : 년도 + seq 10자리 -// dto.setScSeq(gnReacallRepository.getGnRecallScMaxScSeq(String.valueOf(DateUtil.getCurrentYear()), CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); -// entity = mapstruct.toEntity(dto); -// }else{ -// entity = mapstruct.toEntity(dto); -// } -// gnReacallRepository.save(entity); -// -// } -// -// -// @Override -// @Transactional -// public void removeJudgeData(final Long scCode){ -// gnReacallRepository.deleteById(scCode); -// } -// -// @Override -// @Transactional(readOnly = true) -// public List findJudgeTargets(JudgeTargetDto dto) { -// return gnReacallRepository.findJudgeTargets(dto); -// } -// -// @Override -// @Transactional -// public void saveJudgeTargets(JudgeTargetDto dto) { -// boolean isFirst = true; -// -// for(Long scCode : dto.getScCodes()) { -// -// //--------------------------------------------------------- -// // 심사대상 등록 -// //--------------------------------------------------------- -// dto.setScCode(scCode); -// -// if (isFirst) { -// dto.setMsYear(dto.getMsSdate().toString().substring(0, 4)); -// dto.setMsResult("0"); -// isFirst = false; -// } -// if(residentAndDisabledMapper.insertJudgeTargetIntoSelect(dto) == 0) throw new CustomBaseException(String.format("처리된 데이타가 있습니다[ %s ]", dto.getScCarnum())); -// -// //--------------------------------------------------------- -// // 등록한 심사대상 데이타 등록 상태 변경 : 미접수 -> 접수, 심의결과 : 접수 -> 심사중 -// //--------------------------------------------------------- -// GnRecallSc entity = gnReacallRepository.findById(dto.getScCode()).orElseThrow(() -> new CustomBaseException(ErrorCode.DATA_NOT_FOUND)); -// entity.setScTransfer(CtgyConstants.Judge.TRANSFER_ACCEPT.getCode()); -// // entity.setScState(CtgyConstants.Judge.DATA_STATE_JUDGE.getCode()); -// //JpaUtil.saveIfNullId(dto.getScCode(), repository, entity); -// gnReacallRepository.save(entity); -// -// //--------------------------------------------------------- -// // 심사자 등록 -// //--------------------------------------------------------- -// List userinfoList = userRepository.findAllByTeamAndIsenableAndAccesstype( -// dto.getMsuTeam(), -// CtgyConstants.UserInfo.ISENABLED_USE.getCode(), -// CtgyConstants.UserInfo.ACCESSTYPE_SIMSA.getCode()); -// -// List simsaUserList = userinfoList.stream().map(u -> -// MinSimsaUser680Sc.builder() -// .msuMaincode(scCode) -// .msuUserid(u.getUserid()) -// .msuResult(CtgyConstants.SimsaUserInfo.MSU_RESULT_NONE.getCode()) -// //.msuReason() -// .msuTeam(dto.getMsuTeam()) -// //.msuIndate() -// .build() -// ).collect(Collectors.toList()); -// judgeUserRepository.saveAll(simsaUserList); -// } -// } -// -// @Override -// @Transactional(readOnly = true) -// public Page findJudges(JudgeListDto dto, Pageable pageable) { -// -// pageable = JpaUtil.getPagingInfo(pageable); -// return gnReacallRepository.findJudges(dto, pageable); -// } -// -// @Override -// @Transactional(readOnly = true) -// public Map findJudgeResults(JudgeListDto dto) { -// Map resultMap = new HashMap<>(); -// -// // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 -//// Map teamMap = residentAndDisabledMapper.selectTotJudgeResultGroupByTeamAndChasu(dto); -//// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); -//// List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); -//// totJudgeUserList.add(teamMap); -// -// List> teamList = residentAndDisabledMapper.selectJudgeTeamGroupByChasuAndTeamList(dto); -// if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); -// -// // 차수별 심사자별 심사결과 합산 -// dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); + @Override + @Transactional(readOnly = true) + public Map findJudgeResults(JudgeListDto dto) { + Map resultMap = new HashMap<>(); + + // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 +// Map teamMap = residentAndDisabledMapper.selectTotJudgeResultGroupByTeamAndChasu(dto); +// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); // List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); -// totJudgeUserList.add(teamList.get(0)); -// -// // 심사대상 차량 목록 -// List> judgeCarList = residentAndDisabledMapper.selectJudgeResultGroupByCarnum(dto); -// -// // 차량별 심사자 심사결과 목록 -// Map paramMap = new HashMap<>(); -// paramMap.put("msDatagb", dto.getMsDatagb()); -// paramMap.put("msChasu", dto.getMsChasu()); -// paramMap.put("msSdate", dto.getMsSdate()); -// paramMap.put("msEdate", dto.getMsEdate()); -// paramMap.put("msuTeam", dto.getMsuTeam()); -// -// paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); -// paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); -// List> jurgeUserList = residentAndDisabledMapper.selectJudgeResultList(paramMap); -// -//// List> resultList = judgeCarList.stream().peek((m) -> { -//// paramMap.put("msSeq", m.get("msSeq")); -//// paramMap.put("msCarnum", m.get("msCarnum")); -//// m.put("simsa", residentAndDisabledMapper.selectJudgeResultList(paramMap)); -//// }).collect(Collectors.toList()); -// -// -// resultMap.put("teamList", teamList); -// // 차수별 심사자별 심사결과 합산 -// resultMap.put("totJudgeUserData", totJudgeUserList); -// // 심사대상 차량 목록 -// resultMap.put("judgeCarData", judgeCarList); -// // 차량별 심사자 심사결과 목록 -// resultMap.put("judgeUserData", jurgeUserList); -// return resultMap; -// } -// -// @Override -// @Transactional(readOnly = true) -// public Map findJudgeResults2(JudgeListDto dto) { -// Map resultMap = new HashMap<>(); -// -// // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 -//// Map teamMap = residentAndDisabledMapper.selectTotJudgeResultGroupByTeamAndChasu(dto); -//// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); -//// List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); -//// totJudgeUserList.add(teamMap); -// -// List> teamList = residentAndDisabledMapper.selectJudgeTeamGroupByChasuAndTeamList(dto); -// if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); -// -// // 차수별 심사자별 심사결과 합산 -// dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); +// totJudgeUserList.add(teamMap); + + List> teamList = residentAndDisabledMapper.selectJudgeTeamGroupByChasuAndTeamList(dto); + if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); + + // 차수별 심사자별 심사결과 합산 + dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); + List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); + totJudgeUserList.add(teamList.get(0)); + + // 심사대상 차량 목록 + List> judgeCarList = residentAndDisabledMapper.selectJudgeResultGroupByCarnum(dto); + + // 차량별 심사자 심사결과 목록 + Map paramMap = new HashMap<>(); + paramMap.put("msDatagb", dto.getMsDatagb()); + paramMap.put("msChasu", dto.getMsChasu()); + paramMap.put("msSdate", dto.getMsSdate()); + paramMap.put("msEdate", dto.getMsEdate()); + paramMap.put("msuTeam", dto.getMsuTeam()); + + paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); + paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); + List> jurgeUserList = residentAndDisabledMapper.selectJudgeResultList(paramMap); + +// List> resultList = judgeCarList.stream().peek((m) -> { +// paramMap.put("msSeq", m.get("msSeq")); +// paramMap.put("msCarnum", m.get("msCarnum")); +// m.put("simsa", residentAndDisabledMapper.selectJudgeResultList(paramMap)); +// }).collect(Collectors.toList()); + + + resultMap.put("teamList", teamList); + // 차수별 심사자별 심사결과 합산 + resultMap.put("totJudgeUserData", totJudgeUserList); + // 심사대상 차량 목록 + resultMap.put("judgeCarData", judgeCarList); + // 차량별 심사자 심사결과 목록 + resultMap.put("judgeUserData", jurgeUserList); + return resultMap; + } + + @Override + @Transactional(readOnly = true) + public Map findJudgeResults2(JudgeListDto dto) { + Map resultMap = new HashMap<>(); + + // team && 팀별 부과현황 조회 : 팀이 선택되지 않은 경우 모두 +// Map teamMap = residentAndDisabledMapper.selectTotJudgeResultGroupByTeamAndChasu(dto); +// if (Checks.isEmpty(teamMap)) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); // List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); -// totJudgeUserList.add(teamList.get(0)); -// -// // 심사대상 차량 목록 -// List> judgeCarList = residentAndDisabledMapper.selectJudgeResultGroupByCarnum(dto); -// -// // 차량별 심사자 심사결과 목록 -// Map paramMap = new HashMap<>(); -// paramMap.put("msDatagb", dto.getMsDatagb()); -// paramMap.put("msChasu", dto.getMsChasu()); -// paramMap.put("msSdate", dto.getMsSdate()); -// paramMap.put("msEdate", dto.getMsEdate()); -// paramMap.put("msuTeam", dto.getMsuTeam()); -// -// paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); -// paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); -// List> jurgeUserList = residentAndDisabledMapper.selectJudgeResultList(paramMap); -// -//// List> resultList = judgeCarList.stream().peek((m) -> { -//// paramMap.put("msSeq", m.get("msSeq")); -//// paramMap.put("msCarnum", m.get("msCarnum")); -//// m.put("simsa", residentAndDisabledMapper.selectJudgeResultList(paramMap)); -//// }).collect(Collectors.toList()); -// -// -// resultMap.put("teamList", teamList); -// // 차수별 심사자별 심사결과 합산 -// resultMap.put("totJudgeUserData", totJudgeUserList); -// // 심사대상 차량 목록 -// resultMap.put("judgeCarData", judgeCarList); -// // 차량별 심사자 심사결과 목록 -// resultMap.put("judgeUserData", jurgeUserList); -// return resultMap; -// } -// -// /** -// * 심사자료 삭제 -// * 1. 삭제 대상 조회 : min_simsa680_sc 테이블 : ms_datagb, ms_chasu, ms_sdate, ms_edate 조건으로 ms_maincode 삭제 대상 조회 -// * 2. 심사자 삭제 : min_simsa_user680_sc 테이블 : msu_maincode = ms_maincode -// * 3. 단속데이타 정보 변경 : gn_recall_sc 테이블 : sc_transfer = '1', sc_state = '1', sc_code = ms_maincode -// * 4. 심사자료 삭제 : min_simsa680_sc 테이블 ms_maincode = ms_maincode -// * @param dto ParkingTargetDto -// */ -// @Override -// @Transactional -// public void removeJudge(final JudgeListDto dto) { -// -// List msMaincodes = judgeRepository.findAllMsMaincode(dto.getMsDatagb(), dto.getMsChasu(), dto.getMsSdate(), dto.getMsEdate()); -// -// msMaincodes.forEach(msMaincode -> { -// //List judgeUsers = judgeUserRepository.findByMsuMaincode() -// judgeUserRepository.deleteByMsuMaincode(msMaincode); -// // 전송상태 -> 미접수(1), 심의결과 -> 접수(1) -// gnReacallRepository.updateScTransferAndScState(dto.getMsDatagb(), msMaincode); -// judgeRepository.deleteById(msMaincode); -// }); -// } -// -// @Override -// @Transactional -// public void saveJudgeStds(final JudgeStdDto dto) { -// int stdCnt = dto.getJudgeStdCnt(); -// -// dto.getJudgeDataKeys().forEach(map -> { -// int cnt = 0; -// Long msMaincode = Long.valueOf(map.get("msMaincode").toString()); -// String msSeq = map.get("msSeq").toString(); -// -// // 미부과 -// String msResult = CtgyConstants.Judge.RESULT_JUDGE_NON_IMPOSE.getCode(); -// // 주정차 심사 -// if (Checks.isEmpty(dto.getDataGb())) { -// cnt = parkingRepository.getJudgeStdCnt(msMaincode); -// if(cnt >= stdCnt) msResult = CtgyConstants.Judge.RESULT_JUDGE_IMPOSE.getCode(); -// -// parkingRepository.updateMsResult(msMaincode, msSeq, msResult); -// -// // 거주자 장애인 심사 -// } else { -// cnt = gnReacallRepository.getJudgeStdCnt(msMaincode); -// if(cnt >= stdCnt) msResult = CtgyConstants.Judge.RESULT_JUDGE_IMPOSE.getCode(); -// -// judgeRepository.updateMsResult(msMaincode, msSeq, msResult); -// } -// }); -// } -// -// @Transactional(readOnly = true) -// public Map findDashboard(){ -// Map resultMap = new HashMap<>(); -// resultMap.put("pBoardList", pBoardService.findAll(MinInfoBoard680.builder().build(), PageRequest.of(0, 7))); -// resultMap.put("parkJudgeList", parkingMapper.selectDashboardJudgeList()); -// resultMap.put("residentJudgeList", residentAndDisabledMapper.selectDashboardJudgeList(CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); -// resultMap.put("disabledJudgeList", residentAndDisabledMapper.selectDashboardJudgeList(CtgyConstants.Judge.DATAGB_DISABLED.getCode())); -// -// return resultMap; -// } -// -// private void setFileInfoAndFileUpload(GnRecallScDto dto, MultipartFile[] mfs, String setMethodName) { -// String makePath = fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); -// //makePath = makePath + File.separator; -// -// for(int idx = 0; idx < mfs.length; idx++){ -// MultipartFile mf = mfs[idx]; -// try { -// Method method = GnRecallScDto.class.getMethod(setMethodName + (idx+1), String.class); -// method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); -// //method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); -// } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { -// e.printStackTrace(); -// } -// } -// } -// -// private void changeFileUpload(GnRecallScDto dto, MultipartFile[] mfs) { -// fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); -// } -// -// -// //--------------------------------------------------------------------------------- -// // 심사자 -// //--------------------------------------------------------------------------------- -// @Override -// @Transactional(readOnly = true) -// public List findByUserJudges(JudgeListDto dto) { -// return gnReacallRepository.findByUserJudges(dto); -// } -// -// @Override -// @Transactional -// public void saveJudgeResult(JudgeListDto dto){ -// judgeUserRepository.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), -// dto.getMsuResult(), -// dto.getMsuReason(), -// LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); -// } +// totJudgeUserList.add(teamMap); + + List> teamList = residentAndDisabledMapper.selectJudgeTeamGroupByChasuAndTeamList(dto); + if (Checks.isEmpty(teamList) || teamList.size() == 0) throw new CustomBaseException(ErrorCode.DATA_NOT_FOUND); + + // 차수별 심사자별 심사결과 합산 + dto.setMsuTeam(String.valueOf(teamList.get(0).get("msuTeam"))); + List> totJudgeUserList = residentAndDisabledMapper.selectTotJudgeResultGroupByUser(dto); + totJudgeUserList.add(teamList.get(0)); + + // 심사대상 차량 목록 + List> judgeCarList = residentAndDisabledMapper.selectJudgeResultGroupByCarnum(dto); + + // 차량별 심사자 심사결과 목록 + Map paramMap = new HashMap<>(); + paramMap.put("msDatagb", dto.getMsDatagb()); + paramMap.put("msChasu", dto.getMsChasu()); + paramMap.put("msSdate", dto.getMsSdate()); + paramMap.put("msEdate", dto.getMsEdate()); + paramMap.put("msuTeam", dto.getMsuTeam()); + + paramMap.put("seqList", judgeCarList.stream().map(m -> m.get("msSeq")).collect(Collectors.toList())); + paramMap.put("carnumList", judgeCarList.stream().map(m -> m.get("msCarnum")).collect(Collectors.toList())); + List> jurgeUserList = residentAndDisabledMapper.selectJudgeResultList(paramMap); + +// List> resultList = judgeCarList.stream().peek((m) -> { +// paramMap.put("msSeq", m.get("msSeq")); +// paramMap.put("msCarnum", m.get("msCarnum")); +// m.put("simsa", residentAndDisabledMapper.selectJudgeResultList(paramMap)); +// }).collect(Collectors.toList()); + + + resultMap.put("teamList", teamList); + // 차수별 심사자별 심사결과 합산 + resultMap.put("totJudgeUserData", totJudgeUserList); + // 심사대상 차량 목록 + resultMap.put("judgeCarData", judgeCarList); + // 차량별 심사자 심사결과 목록 + resultMap.put("judgeUserData", jurgeUserList); + return resultMap; + } + + /** + * 심사자료 삭제 + * 1. 삭제 대상 조회 : min_simsa680_sc 테이블 : ms_datagb, ms_chasu, ms_sdate, ms_edate 조건으로 ms_maincode 삭제 대상 조회 + * 2. 심사자 삭제 : min_simsa_user680_sc 테이블 : msu_maincode = ms_maincode + * 3. 단속데이타 정보 변경 : gn_recall_sc 테이블 : sc_transfer = '1', sc_state = '1', sc_code = ms_maincode + * 4. 심사자료 삭제 : min_simsa680_sc 테이블 ms_maincode = ms_maincode + * @param dto ParkingTargetDto + */ + @Override + @Transactional + public void removeJudge(final JudgeListDto dto) { + + List msMaincodes = judgeRepository.findAllMsMaincode(dto.getMsDatagb(), dto.getMsChasu(), dto.getMsSdate(), dto.getMsEdate()); + + msMaincodes.forEach(msMaincode -> { + //List judgeUsers = judgeUserRepository.findByMsuMaincode() + judgeUserRepository.deleteByMsuMaincode(msMaincode); + // 전송상태 -> 미접수(1), 심의결과 -> 접수(1) + gnReacallRepository.updateScTransferAndScState(dto.getMsDatagb(), msMaincode); + judgeRepository.deleteById(msMaincode); + }); + } + + @Override + @Transactional + public void saveJudgeStds(final JudgeStdDto dto) { + int stdCnt = dto.getJudgeStdCnt(); + + dto.getJudgeDataKeys().forEach(map -> { + int cnt = 0; + Long msMaincode = Long.valueOf(map.get("msMaincode").toString()); + String msSeq = map.get("msSeq").toString(); + + // 미부과 + String msResult = CtgyConstants.Judge.RESULT_JUDGE_NON_IMPOSE.getCode(); + // 주정차 심사 + if (Checks.isEmpty(dto.getDataGb())) { + cnt = parkingRepository.getJudgeStdCnt(msMaincode); + if(cnt >= stdCnt) msResult = CtgyConstants.Judge.RESULT_JUDGE_IMPOSE.getCode(); + + parkingRepository.updateMsResult(msMaincode, msSeq, msResult); + + // 거주자 장애인 심사 + } else { + cnt = gnReacallRepository.getJudgeStdCnt(msMaincode); + if(cnt >= stdCnt) msResult = CtgyConstants.Judge.RESULT_JUDGE_IMPOSE.getCode(); + + judgeRepository.updateMsResult(msMaincode, msSeq, msResult); + } + }); + } + + @Transactional(readOnly = true) + public Map findDashboard(){ + Map resultMap = new HashMap<>(); + resultMap.put("pBoardList", pBoardService.findAll(MinInfoBoard680.builder().build(), PageRequest.of(0, 7))); + resultMap.put("parkJudgeList", parkingMapper.selectDashboardJudgeList()); + resultMap.put("residentJudgeList", residentAndDisabledMapper.selectDashboardJudgeList(CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); + resultMap.put("disabledJudgeList", residentAndDisabledMapper.selectDashboardJudgeList(CtgyConstants.Judge.DATAGB_DISABLED.getCode())); + + return resultMap; + } + + private void setFileInfoAndFileUpload(GnRecallScDto dto, MultipartFile[] mfs, String setMethodName) { + String makePath = fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); + //makePath = makePath + File.separator; + + for(int idx = 0; idx < mfs.length; idx++){ + MultipartFile mf = mfs[idx]; + try { + Method method = GnRecallScDto.class.getMethod(setMethodName + (idx+1), String.class); + method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); + //method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + private void changeFileUpload(GnRecallScDto dto, MultipartFile[] mfs) { + fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); + } + + + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- + @Override + @Transactional(readOnly = true) + public List findByUserJudges(JudgeListDto dto) { + return gnReacallRepository.findByUserJudges(dto); + } + + @Override + @Transactional + public void saveJudgeResult(JudgeListDto dto){ + judgeUserRepository.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), + dto.getMsuResult(), + dto.getMsuReason(), + LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); + } } diff --git a/src/main/java/com/xit/core/config/SecurityConfig.java b/src/main/java/com/xit/core/config/SecurityConfig.java index 414e1c7..1bdc0e1 100644 --- a/src/main/java/com/xit/core/config/SecurityConfig.java +++ b/src/main/java/com/xit/core/config/SecurityConfig.java @@ -3,10 +3,8 @@ package com.xit.core.config; import com.xit.biz.ctgy.auth.MinPasswordEncoder; import com.xit.biz.ctgy.auth.service.impl.CustomMinOAuth2UserService; import com.xit.biz.ctgy.auth.service.impl.CustomMinUserDetailsService; -import com.xit.biz.ctgy.repository.IMinUserRepository; -import com.xit.biz.ctgy.v2.dao.MinUserinfoDao; +import com.xit.biz.ctgy.v2.repository.MinUserinfoDao; import com.xit.core.oauth2.api.dao.RefreshTokenDao; -import com.xit.core.oauth2.api.repository.RefreshTokenRepository; import com.xit.core.oauth2.config.properties.AppProperties; import com.xit.core.oauth2.config.properties.CorsProperties; import com.xit.core.oauth2.oauth.exception.RestAuthenticationEntryPoint;