From 2d300f6962dfd05b911a49d85eba281c636af5a6 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 17 Sep 2020 14:55:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E5=91=98=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../result/GridBelongAgencyResultDTO.java | 30 +++++++++++++ .../dao/stats/DimCustomerPartymemberDao.java | 8 ++++ .../java/com/epmet/dao/stats/DimGridDao.java | 9 ++++ .../epmet/service/stats/DimGridService.java | 9 ++++ .../DimCustomerPartymemberServiceImpl.java | 43 ++++++++++++++++++- .../stats/impl/DimGridServiceImpl.java | 12 ++++++ .../mapper/partymember/PartyMemberDao.xml | 7 +-- .../stats/DimCustomerPartymemberDao.xml | 8 ++++ .../resources/mapper/stats/DimGridDao.xml | 20 +++++++++ 9 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/result/GridBelongAgencyResultDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/result/GridBelongAgencyResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/result/GridBelongAgencyResultDTO.java new file mode 100644 index 0000000000..a04c5fe2b4 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/result/GridBelongAgencyResultDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.stats.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/9/17 2:32 下午 + */ +@Data +public class GridBelongAgencyResultDTO implements Serializable { + + private static final long serialVersionUID = 6781297915444918432L; + + /** + * 网格ID + */ + private String gridId; + + /** + * 网格所属机关ID + */ + private String agencyId; + + /** + * 机关的上级ID + */ + private String parentId; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java index f8d3e8c295..afab95849a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java @@ -42,4 +42,12 @@ public interface DimCustomerPartymemberDao extends BaseDao partyMemberInfos); + /** + * @Description 删除旧党员记录 + * @param customerId + * @param dateId + * @author zxc + * @date 2020/9/17 2:43 下午 + */ + void deleteOldPartyRecord(@Param("customerId")String customerId,@Param("dateId")String dateId); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java index c1671131b1..dd2338bb69 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.result.AgencyGridInfoResultDTO; import com.epmet.dto.group.result.SubAgencyIdResultDTO; +import com.epmet.dto.stats.result.GridBelongAgencyResultDTO; import com.epmet.entity.stats.DimGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -60,4 +61,12 @@ public interface DimGridDao extends BaseDao { List selectSubAgencyId(@Param("formDTO")List formDTO); DimGridEntity getLastUpdatedGridDim(); + + /** + * @Description 查询网格属于哪个机关 + * @param gridIds + * @author zxc + * @date 2020/9/17 2:34 下午 + */ + List selectGridBelongAgencyInfo(@Param("gridIds") List gridIds); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java index b937efdf9e..399781d3d3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java @@ -23,6 +23,7 @@ import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.result.AgencyGridInfoResultDTO; import com.epmet.dto.group.result.SubAgencyIdResultDTO; import com.epmet.dto.stats.DimGridDTO; +import com.epmet.dto.stats.result.GridBelongAgencyResultDTO; import com.epmet.entity.stats.DimGridEntity; import com.epmet.entity.stats.LastExecRecordEntity; @@ -129,4 +130,12 @@ public interface DimGridService extends BaseService { List selectSubAgencyId(List formDTO); DimGridEntity getLastUpdatedGridDim(); + + /** + * @Description 查询网格属于哪个机关 + * @param gridIds + * @author zxc + * @date 2020/9/17 2:34 下午 + */ + List selectGridBelongAgencyInfo(List gridIds); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java index 5585cebb89..b1c349daae 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java @@ -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 page(Map params) { @@ -116,8 +126,39 @@ public class DimCustomerPartymemberServiceImpl extends BaseServiceImpl partyMemberList = partyMemberService.selectPartyMemberInfo(customerId, dateId); - + if (CollectionUtils.isEmpty(partyMemberList)){ + throw new RenException("hahah"); + } + List gridIds = partyMemberList.stream().map(party -> party.getGridId()).distinct().collect(Collectors.toList()); + List 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 partyMemberList,String customerId,String dateId){ + if (!CollectionUtils.isEmpty(partyMemberList)){ + partyMemberDao.deleteOldPartyRecord(customerId, dateId); + partyMemberDao.insertPartyMemberInfo(partyMemberList); + } + } + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java index cf1b8810ea..241a4b6ddc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java @@ -32,6 +32,7 @@ import com.epmet.dto.group.AgencyDTO; import com.epmet.dto.group.result.AgencyGridInfoResultDTO; import com.epmet.dto.group.result.SubAgencyIdResultDTO; import com.epmet.dto.stats.DimGridDTO; +import com.epmet.dto.stats.result.GridBelongAgencyResultDTO; import com.epmet.entity.stats.DimGridEntity; import com.epmet.entity.stats.LastExecRecordEntity; import com.epmet.service.stats.DimGridService; @@ -164,4 +165,15 @@ public class DimGridServiceImpl extends BaseServiceImpl selectGridBelongAgencyInfo(List gridIds) { + return baseDao.selectGridBelongAgencyInfo(gridIds); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml index 85079be740..847228f46a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml @@ -10,12 +10,7 @@ GRID_ID, USER_ID, ID_CARD, - CONCAT( - SUBSTRING( ID_CARD, 7, 4 ), - '-', - SUBSTRING( ID_CARD, 11, 2 ), - '-', - SUBSTRING( ID_CARD, 12, 2 )) AS birthday + STR_TO_DATE( SUBSTRING( ID_CARD, 7, 8 ),'%Y%m%d') AS birthday FROM partymember_info WHERE diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml index 9b8009c7a9..8dbc158531 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml @@ -51,4 +51,12 @@ ) + + + + DELETE FROM dim_customer_partymember + WHERE + CUSTOMER_ID = #{customerId} + AND DATE_ID = #{dateId} + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml index eef43456f7..d3f6c044a3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml @@ -69,4 +69,24 @@ limit 1; + + + \ No newline at end of file