public ResponseEntity<N01_02_01_RelateGolfCourseCodeResponseDto> relateGolfCourseCode(N01_02_01_RelateGolfCourseCodeRequestDto n01_02_01_relateGolfCourseCodeRequestDto) { N01_02_01_RelateGolfCourseCodeResponseDto response = new N01_02_01_RelateGolfCourseCodeResponseDto(); List<ClubPaymentHistory> clubPaymentHistories = relateGolfCourseCodeMapper.selectRelateGolfCourseCode(n01_02_01_relateGolfCourseCodeRequestDto); if (clubPaymentHistories.size()==0){ response.setErrorCode("error.common.2002"); return new ResponseEntity(response, HttpStatus.BAD_REQUEST); } List<String> bankAccountNos = clubPaymentHistories.stream()//口座番号List .map(item -> item.getBankAccountNo()).collect(Collectors.toList()); //club List<ClubPaymentInfo> clubPaymentInfos = relateGolfCourseCodeMapper.selectClubPaymentInfo(bankAccountNos); //group List<ClubGroup> clubGroupInfos = relateGolfCourseCodeMapper.selectClubGroup(bankAccountNos); for (ClubPaymentHistory clubPaymentHistory: clubPaymentHistories) { List<ClubGroup> clubBankAccountNoList = clubGroupInfos.stream().filter(item->item.getBankAccountNo().equals(clubPaymentHistory.getBankAccountNo()) && item.getBankAccountName().equals(clubPaymentHistory.getBankAccountName()) && item.getBankName().equals(clubPaymentHistory.getBankName()) && item.getBankBranchName().equals(clubPaymentHistory.getBankBranchName())).collect(Collectors.toList()); List<ClubPaymentInfo> BankAccountNoList = clubPaymentInfos.stream().filter(item->item.getBankAccountNo().equals(clubPaymentHistory.getBankAccountNo()) && item.getBankAccountName().equals(clubPaymentHistory.getBankAccountName()) && item.getBankName().equals(clubPaymentHistory.getBankName()) && item.getBankBranchName().equals(clubPaymentHistory.getBankBranchName())).collect(Collectors.toList()); //group if(clubBankAccountNoList.size()>0){ ClubGroup clubPaymentInfo = clubBankAccountNoList.get(0); clubPaymentHistory.setClubGroup(clubPaymentInfo.getClubGroupId()); clubPaymentHistory.setClubGroupName(clubPaymentInfo.getClubGroupName()); //club }else if(BankAccountNoList.size()>0){ ClubPaymentInfo PaymentInfo = BankAccountNoList.get(0); clubPaymentHistory.setClubname(PaymentInfo.getClubname()); clubPaymentHistory.setClubcode(PaymentInfo.getClubcode()); List<ClubPaymentHistory> clubPayment = relateGolfCourseCodeMapper.selectClub(n01_02_01_relateGolfCourseCodeRequestDto); //判断状态 入金金额 } } return new ResponseEntity(HttpStatus.OK); } }
//全項目
List <ClubPaymentHistory> selectRelateGolfCourseCode(N01_02_01_RelateGolfCourseCodeRequestDto n01_02_01_relateGolfCourseCodeRequestDto);
//club_payment_info取得項目
List<ClubPaymentInfo> selectClubPaymentInfo(@Param("bankAccountNos") List<String> bankAccountNos);
//club_group取得項目
List<ClubGroup> selectClubGroup(@Param("bankAccountNos") List<String> bankAccountNos);
<select id="selectRelateGolfCourseCode" parameterType="com.sunflower.rm.web.domain.model.request.N01_02_01_RelateGolfCourseCodeRequestDto"
resultType="com.sunflower.rm.web.domain.model.entity.ClubPaymentHistory">
SELECT *
FROM club_payment_history
WHERE payment_input_date = #{paymentInputDate}
</select>
<select id="selectClubPaymentInfo" parameterType="List"
resultType="com.sunflower.rm.web.domain.model.entity.ClubPaymentInfo">
SELECT *
FROM club_payment_info
WHERE
bank_account_no in
<foreach item="item" index="index" collection="bankAccountNos" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectClubGroup" parameterType="List"
resultType="com.sunflower.rm.web.domain.model.entity.ClubGroup">
SELECT
*
FROM
club_group
WHERE
bank_account_no in
<foreach item="item" index="index" collection="bankAccountNos" open="(" separator="," close=")">
#{item}
</foreach>
</select>
当参数类型是一个map时
https://blog.csdn.net/weixin_43941676/article/details/108570499
当参数为list时,需要注意一个问题,当list为null时,会出现报错
可以进行非空判断,采用下面方法