feat: 주정차 심의대상 등록 - mybatis로 처리

localDate converter 설정
dev
Lim Jonguk 3 years ago
parent 2bfff312e2
commit 04b0dba1db

@ -88,8 +88,7 @@ public class ParkingController {
@Valid
@RequestBody
final MinSimsaTargetDto dto) {
log.debug("{}", dto);
service.saveParkingSimsaTargets(dto);
service.saveParkingSimsaTargets2(dto);
return RestResponse.of(HttpStatus.OK);
}

@ -8,6 +8,7 @@ import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.sql.Date;
import java.time.LocalDate;
import java.util.List;
@Schema(name = "MinSimsTargetDto", description = "주정차의견진술심의자료대상")
@ -52,7 +53,7 @@ public class MinSimsaTargetDto {
@Schema(title = "심사시작일", example = "2022-03-23", description = "Input Description...")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date msSdate;
private LocalDate msSdate;
@Schema(title = "심사시작시간", example = " ", description = "Input Description...")
private String msStartsi;

@ -0,0 +1,11 @@
package com.xit.biz.ctgy.mapper;
import com.xit.biz.ctgy.dto.MinSimsaTargetDto;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface IParkingMapper {
void insertSimsaTargetIntoSelect(MinSimsaTargetDto dto);
}

@ -8,6 +8,7 @@ import org.springframework.data.repository.query.Param;
import javax.annotation.Nonnull;
import java.sql.Date;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@ -50,7 +51,7 @@ public interface IParkingRepository extends JpaRepository<MinSimsa680, Long>, IP
void insertSimsaTargetIntoSelect(@Nonnull @Param("msYear") final String msYear,
@Nonnull @Param("rcCode") Long rcCode,
@Nonnull @Param("msChasu") Long msChasu,
@Nonnull @Param("msSdate") Date msSdate,
@Nonnull @Param("msSdate") LocalDate msSdate,
@Nonnull @Param("msStartsi") String msStartsi,
@Nonnull @Param("msEdate") Date msEdate,
@Nonnull @Param("msCdate") Date msCdate,

@ -33,14 +33,6 @@ public class IParkingRepositoryImpl implements IParkingRepositoryCustom {
@Override
public Page<MinSimsa680GroupDto> findSimsas(final MinSimsa680GroupDto pMinSimsa680GroupDto, Pageable pageable) {
/*
SELECT MS_CHASU, MS_SDATE, MS_STARTSI, MS_EDATE, MS_CDATE, MS_CLOSESI, COUNT(*) CNT
FROM MIN_SIMSA680
WHERE MS_YEAR = '"& rYear &"' AND MS_CHASU LIKE '%"& rChasu &"%'
GROUP BY MS_CHASU, MS_SDATE, MS_STARTSI, MS_EDATE, MS_CDATE, MS_CLOSESI
ORDER BY MS_CHASU DESC
*/
BooleanBuilder builder = new BooleanBuilder();
if (!Checks.isEmpty(pMinSimsa680GroupDto.getMsYear())) {
@ -108,67 +100,6 @@ public class IParkingRepositoryImpl implements IParkingRepositoryCustom {
@Override
public List<MinSimsaTargetDto> findSimsaTargets(final MinSimsaTargetDto dto) {
/*
SELECT TM.MM_CODE,
TR.RC_CODE,
TR.RC_SEQ,
TM.MM_OCARNO,
TM.MM_NCARNO,
TR.RC_NAME,
TR.RC_CONT_DOC,
-- (1:, 2:, 3:, 4:, 5:, 6:, 7:, 8:, 9:, 10:, 11:, 12:, 13:, 14:)
CASE WHEN TR.RC_CONT_DOC = '1' THEN ''
WHEN TR.RC_CONT_DOC = '2' THEN ''
WHEN TR.RC_CONT_DOC = '3' THEN ''
WHEN TR.RC_CONT_DOC = '4' THEN ''
WHEN TR.RC_CONT_DOC = '5' THEN ''
WHEN TR.RC_CONT_DOC = '6' THEN ''
WHEN TR.RC_CONT_DOC = '7' THEN ''
WHEN TR.RC_CONT_DOC = '8' THEN ''
WHEN TR.RC_CONT_DOC = '9' THEN ''
WHEN TR.RC_CONT_DOC = '10' THEN ''
WHEN TR.RC_CONT_DOC = '11' THEN ''
WHEN TR.RC_CONT_DOC = '12' THEN ''
WHEN TR.RC_CONT_DOC = '13' THEN ''
WHEN TR.RC_CONT_DOC = '14' THEN ''
ELSE ''
END AS RC_COND_DOC_STR,
TCCS2.CODE_NM,
TR.RC_DATE,
-- (1:, 2:, 3:, 4:, 5:, 6:, 7:ARS, 8:, 9:)
TR.RC_INGB,
CASE WHEN TR.RC_INGB = '1' THEN ''
WHEN TR.RC_INGB = '2' THEN ''
WHEN TR.RC_INGB = '3' THEN ''
WHEN TR.RC_INGB = '4' THEN ''
WHEN TR.RC_INGB = '5' THEN ''
WHEN TR.RC_INGB = '6' THEN ''
WHEN TR.RC_INGB = '7' THEN 'ARS'
WHEN TR.RC_INGB = '8' THEN ''
WHEN TR.RC_INGB = '9' THEN ''
ELSE ''
END AS RC_INGB_STR,
TCCS1.CODE_NM
FROM TF680_MAIN TM
JOIN TF680_RECALL TR ON TM.MM_CODE = TR.RC_MAINCODE
LEFT JOIN TB_CMM_CODE_S TCCS1 ON TR.RC_INGB = TCCS1.CODE_CD
AND TCCS1.CODE_GRP_ID = 'TRAFFIC'
AND TCCS1.CODE_LCD = 'GANGNAM_SIMSA'
AND TCCS1.CODE_MCD = 'RC_INGB'
LEFT JOIN TB_CMM_CODE_S TCCS2 ON TR.RC_CONT_DOC = TCCS2.CODE_CD
AND TCCS2.CODE_GRP_ID = 'TRAFFIC'
AND TCCS2.CODE_LCD = 'GANGNAM_SIMSA'
AND TCCS2.CODE_MCD = 'RC_CONT_DOC'
WHERE MM_DBGB = '11' -- : 11-' 12-
AND MM_LSTATE != '75' -- 10:,11:,12:,13:,21:,49:,51:,52:,53:,54:,55:,61:,62:,65:,71:,72:,73:,74:,75:,81:,82:,91:,92:,98:,99:)
AND RC_GB = '1' -- : 1- 2-
AND RC_STATE = '0' -- (0:, 1:, 2:, 3:-OCR , 5:, 7:, 8:, 9:)
-- AND RC_SEQ >= '"& rtxtsNum &"'
-- AND RC_SEQ <= '"& rtxteNum &"'
AND RC_IR_TRANSFER = '1' -- : 1- 2-
order by RC_SEQ;
*/
BooleanBuilder builder = new BooleanBuilder();
// 과태료 코드 : 11-'주정차위반과태료 12-버스전용차로위반과태료

@ -19,9 +19,12 @@ public interface IParkingService {
Page<MinSimsa680> findAll(final MinSimsa680 minSimsa680, Pageable pageable);
void saveParkingSimsaTargets2(MinSimsaTargetDto dto);
void saveParkingSimsaTargets(MinSimsaTargetDto dto);
Page<MinSimsaReviewGroupDto> findMinSimsa680s2(final MinSimsa680 minSimsa680, Pageable pageable);
MinSimsa680 saveParkingSimsa(final MinSimsa680 toEntity);
void saveParkingSimsaTargets(MinSimsaTargetDto dto);
}

@ -4,6 +4,7 @@ import com.xit.biz.ctgy.dto.MinSimsa680GroupDto;
import com.xit.biz.ctgy.dto.MinSimsaReviewGroupDto;
import com.xit.biz.ctgy.dto.MinSimsaTargetDto;
import com.xit.biz.ctgy.entity.MinSimsa680;
import com.xit.biz.ctgy.mapper.IParkingMapper;
import com.xit.biz.ctgy.repository.IParkingRepository;
import com.xit.biz.ctgy.service.IParkingService;
import com.xit.core.support.jpa.JpaUtil;
@ -13,13 +14,11 @@ import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Map;
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains;
@ -28,10 +27,11 @@ import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatc
public class ParkingService implements IParkingService {
private final IParkingRepository repository;
private final IParkingMapper mapper;
@Override
@Transactional(readOnly = true)
public Page<MinSimsa680> findAll(final MinSimsa680 entity, Pageable pageable) {
public Page<MinSimsa680> findAll(@Nonnull final MinSimsa680 entity, Pageable pageable) {
pageable = JpaUtil.getPagingInfo(pageable);
ExampleMatcher exampleMatcher = ExampleMatcher.matchingAll()
.withMatcher("ciTitle", contains())
@ -89,6 +89,24 @@ public class ParkingService implements IParkingService {
@Override
public void saveParkingSimsaTargets2(MinSimsaTargetDto 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;
}
mapper.insertSimsaTargetIntoSelect(dto);
}
}
@Override
@Transactional(readOnly = true)
public Page<MinSimsaReviewGroupDto> findMinSimsa680s2(MinSimsa680 minSimsa680, Pageable pageable) {

@ -1,6 +1,6 @@
package com.xit.core.config.support;
import org.jetbrains.annotations.NotNull;
import lombok.NonNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.datetime.DateFormatter;
@ -19,7 +19,7 @@ import java.time.format.DateTimeFormatter;
@Configuration
public class DateTimeConfig extends WebMvcConfigurationSupport {
@NotNull
@NonNull
@Bean
@Override
public FormattingConversionService mvcConversionService() {

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xit.biz.ctgy.mapper.IParkingMapper">
<insert id="insertSimsaTargetIntoSelect" parameterType="com.xit.biz.ctgy.dto.MinSimsaTargetDto">
/* parking-mapper|insertSimsaTargetIntoSelect|julim */
insert
into min_simsa680(
ms_maincode,
ms_seq,
ms_carnum,
ms_year,
ms_chasu,
ms_sdate,
ms_startsi,
ms_edate,
ms_cdate,
ms_closesi,
ms_wdate,
ms_pos,
ms_result,
ms_jbtime
) select TR.rc_code,
TR.rc_seq,
TM.mm_ocarno,
#{msYear},
#{msChasu},
#{msSdate},
#{msStartsi},
#{msEdate},
#{msCdate},
#{msClosesi},
TM.mm_wdate,
TD.do_bname||''||TJ.mj_pos,
#{msResult},
TJ.mj_jbtime
from tf680_recall TR
join tf680_main TM on TR.rc_code = #{rcCode}
and TM.mm_code = TR.rc_maincode
join tf680_jucha TJ on TM.mm_code = TJ.mj_code
join tf680_dong TD
on TJ.mj_dong = TD.do_code
</insert>
</mapper>
Loading…
Cancel
Save