package com.dg.core.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.dg.core.db.gen.entity.AreaCode2022;
|
import com.dg.core.db.gen.entity.OrganizationChartEntity;
|
import com.dg.core.db.gen.entity.TransactionEvent;
|
import com.dg.core.db.gen.mapper.AreaCode2022Mapper;
|
import com.dg.core.db.gen.mapper.OrganizationChartMapper;
|
import com.dg.core.db.gen.mapper.TransactionEventMapper;
|
import com.dg.core.service.IAreaCodeService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Service
|
public class AreaCodeServiceImpl extends ServiceImpl<AreaCode2022Mapper, AreaCode2022> implements IAreaCodeService {
|
|
@Resource
|
private OrganizationChartMapper organizationChartMapper;
|
|
@Resource
|
private TransactionEventMapper transactionEventMapper;
|
|
@Override
|
public List<AreaCode2022> getAreaCodeByTransactionId(Integer transactionId){
|
TransactionEvent transactionEvent = transactionEventMapper.selectOne(new QueryWrapper<TransactionEvent>().lambda().
|
eq(TransactionEvent::getId, transactionId));
|
OrganizationChartEntity organizationChartEntity = organizationChartMapper.selectOne(new QueryWrapper<OrganizationChartEntity>().lambda()
|
.eq(OrganizationChartEntity::getId, transactionEvent.getDepartmentId()));
|
List<String> areaCodes=new ArrayList<>();
|
if (organizationChartEntity!=null){
|
if (organizationChartEntity.getCity()!=null)
|
areaCodes.add(organizationChartEntity.getCity());
|
if (organizationChartEntity.getDistrict()!=null)
|
areaCodes.add(organizationChartEntity.getDistrict());
|
if (organizationChartEntity.getVillage()!=null)
|
areaCodes.add(organizationChartEntity.getVillage());
|
getAreaCodeIds(areaCodes,organizationChartEntity);
|
}
|
return baseMapper.selectByIdSet(areaCodes);
|
}
|
|
public List<String> getAreaCodeIds(List<String> areaCodes, OrganizationChartEntity organizationChartEntity){
|
organizationChartEntity = organizationChartMapper.selectOne(new QueryWrapper<OrganizationChartEntity>().lambda()
|
.eq(OrganizationChartEntity::getParentId, organizationChartEntity.getId()));
|
if (organizationChartEntity!=null){
|
if (organizationChartEntity.getCity()!=null)
|
areaCodes.add(organizationChartEntity.getCity());
|
if (organizationChartEntity.getDistrict()!=null)
|
areaCodes.add(organizationChartEntity.getDistrict());
|
if (organizationChartEntity.getVillage()!=null)
|
areaCodes.add(organizationChartEntity.getVillage());
|
getAreaCodeIds(areaCodes,organizationChartEntity);
|
}
|
return areaCodes;
|
}
|
|
|
}
|