|
|
@ -20,24 +20,32 @@ package com.epmet.service.stats.impl; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.dto.form.TimeListResultDTO; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.dao.stats.DimCustomerPartymemberDao; |
|
|
|
import com.epmet.dto.stats.DimCustomerPartymemberDTO; |
|
|
|
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; |
|
|
|
import com.epmet.dto.stats.form.DimCustomerPartyMemberFormDTO; |
|
|
|
import com.epmet.dto.stats.result.GridBelongAgencyResultDTO; |
|
|
|
import com.epmet.entity.stats.DimCustomerPartymemberEntity; |
|
|
|
import com.epmet.service.partymember.PartyMemberService; |
|
|
|
import com.epmet.service.stats.DimCustomerPartymemberService; |
|
|
|
import com.epmet.service.stats.DimGridService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 党员维度表 |
|
|
@ -52,6 +60,8 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl<DimCustom |
|
|
|
private DimCustomerPartymemberDao partyMemberDao; |
|
|
|
@Autowired |
|
|
|
private PartyMemberService partyMemberService; |
|
|
|
@Autowired |
|
|
|
private DimGridService dimGridService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<DimCustomerPartymemberDTO> page(Map<String, Object> params) { |
|
|
@ -116,8 +126,39 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl<DimCustom |
|
|
|
String customerId = customerIdAndDateIdFormDTO.getCustomerId(); |
|
|
|
String dateId = customerIdAndDateIdFormDTO.getDateId(); |
|
|
|
List<DimCustomerPartyMemberFormDTO> partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId); |
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(partyMemberList)){ |
|
|
|
throw new RenException("hahah"); |
|
|
|
} |
|
|
|
List<String> gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList()); |
|
|
|
List<GridBelongAgencyResultDTO> agencyInfos = dimGridService.selectGridBelongAgencyInfo(gridIds); |
|
|
|
TimeListResultDTO timeList = DateUtils.getTimeList(dateId); |
|
|
|
partyMemberList.forEach(party -> { |
|
|
|
BeanUtils.copyProperties(timeList,party); |
|
|
|
agencyInfos.forEach(agency -> { |
|
|
|
if (party.getGridId().equals(agency.getGridId())){ |
|
|
|
party.setAgencyId(agency.getAgencyId()); |
|
|
|
party.setParentId(agency.getParentId()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
delAndInsertParty(partyMemberList,customerId,dateId); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 删除旧纪录,插入新纪录 |
|
|
|
* @param partyMemberList |
|
|
|
* @param customerId |
|
|
|
* @param dateId |
|
|
|
* @author zxc |
|
|
|
* @date 2020/9/17 2:46 下午 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delAndInsertParty(List<DimCustomerPartyMemberFormDTO> partyMemberList,String customerId,String dateId){ |
|
|
|
if (!CollectionUtils.isEmpty(partyMemberList)){ |
|
|
|
partyMemberDao.deleteOldPartyRecord(customerId, dateId); |
|
|
|
partyMemberDao.insertPartyMemberInfo(partyMemberList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |