package com.ydtech.modules.protocol.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ydtech.modules.protocol.dao.PtlAgreementUndwrtRulesMapper; import com.ydtech.modules.protocol.entity.dto.PtlAgreementUndwrtRulesSaveDto; import com.ydtech.modules.protocol.entity.po.PtlAgreementUndwrtRules; import com.ydtech.modules.protocol.service.PtlAgreementAttributionService; import com.ydtech.modules.protocol.service.PtlAgreementUndwrtRulesService; import com.ydtech.modules.protocol.utils.AssertionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * @author CXP * @description 针对表【ptl_agreement_undwrt_rules(协议承保规则)】的数据库操作Service实现 * @createDate 2023年12月20日22:25:57 */ @Service public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl implements PtlAgreementUndwrtRulesService { private final PtlAgreementAttributionService ptlAgreementAttributionService; public PtlAgreementUndwrtRulesServiceImpl(PtlAgreementAttributionService ptlAgreementAttributionService) { this.ptlAgreementAttributionService = ptlAgreementAttributionService; } @Override public void deleteByAgreementId(String agreementId) { baseMapper.delete(getByAgreementIdWrapper(agreementId)); } @Override public List getByAgreementId(String agreementId) { List ptlAgreementUndwrtRulesList = baseMapper.selectList(getByAgreementIdWrapper(agreementId)); List undwrtRulesSaveDtoList = PtlAgreementUndwrtRulesSaveDto.toPltAgreementRuleSaveDto(ptlAgreementUndwrtRulesList); return undwrtRulesSaveDtoList; } @Override @Transactional public void saveBatchProductCosts(String agreementId, List undwrtRulesSaveDtoList) { if (undwrtRulesSaveDtoList != null && !undwrtRulesSaveDtoList.isEmpty()) { List ptlAgreementUndwrtRulesList = PtlAgreementUndwrtRules.toPtlAgreementUndwrtRulesSaveDtoList(agreementId, undwrtRulesSaveDtoList); boolean b = saveBatch(ptlAgreementUndwrtRulesList); AssertionUtils.isSucceed(b, "批量添加承保规则失败"); } } /** * 通过协议ID 获取需要进行匹配的核保规则 * @param agreementId * @return */ @Override public List selectVliadRules(String agreementId){ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(PtlAgreementUndwrtRules::getAgreementId, agreementId); wrapper.eq(PtlAgreementUndwrtRules::getValidInd,1); List ptlAgreementProductCosts = baseMapper.selectList(wrapper); return ptlAgreementProductCosts; } }