Browse Source

党员统计

master
zxc 5 years ago
parent
commit
2d300f6962
  1. 30
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/stats/result/GridBelongAgencyResultDTO.java
  2. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerPartymemberDao.java
  3. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java
  4. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java
  5. 43
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerPartymemberServiceImpl.java
  6. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java
  7. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/partymember/PartyMemberDao.xml
  8. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml
  9. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml

30
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;
}

8
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<DimCustomerPartymembe
*/
void insertPartyMemberInfo(@Param("partyMemberInfos")List<DimCustomerPartyMemberFormDTO> partyMemberInfos);
/**
* @Description 删除旧党员记录
* @param customerId
* @param dateId
* @author zxc
* @date 2020/9/17 2:43 下午
*/
void deleteOldPartyRecord(@Param("customerId")String customerId,@Param("dateId")String dateId);
}

9
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<DimGridEntity> {
List<SubAgencyIdResultDTO> selectSubAgencyId(@Param("formDTO")List<AgencyDTO> formDTO);
DimGridEntity getLastUpdatedGridDim();
/**
* @Description 查询网格属于哪个机关
* @param gridIds
* @author zxc
* @date 2020/9/17 2:34 下午
*/
List<GridBelongAgencyResultDTO> selectGridBelongAgencyInfo(@Param("gridIds") List<String> gridIds);
}

9
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<DimGridEntity> {
List<SubAgencyIdResultDTO> selectSubAgencyId(List<AgencyDTO> formDTO);
DimGridEntity getLastUpdatedGridDim();
/**
* @Description 查询网格属于哪个机关
* @param gridIds
* @author zxc
* @date 2020/9/17 2:34 下午
*/
List<GridBelongAgencyResultDTO> selectGridBelongAgencyInfo(List<String> gridIds);
}

43
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<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);
}
}
}

12
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<DimGridDao, DimGridEntit
public DimGridEntity getLastUpdatedGridDim() {
return baseDao.getLastUpdatedGridDim();
}
/**
* @Description 查询网格属于哪个机关
* @param gridIds
* @author zxc
* @date 2020/9/17 2:34 下午
*/
@Override
public List<GridBelongAgencyResultDTO> selectGridBelongAgencyInfo(List<String> gridIds) {
return baseDao.selectGridBelongAgencyInfo(gridIds);
}
}

7
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

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerPartymemberDao.xml

@ -51,4 +51,12 @@
)
</foreach>
</insert>
<!-- 删除旧党员记录 -->
<delete id="deleteOldPartyRecord">
DELETE FROM dim_customer_partymember
WHERE
CUSTOMER_ID = #{customerId}
AND DATE_ID = #{dateId}
</delete>
</mapper>

20
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml

@ -69,4 +69,24 @@
limit 1;
</select>
<!-- 查询网格属于哪个机关 -->
<select id="selectGridBelongAgencyInfo" resultType="com.epmet.dto.stats.result.GridBelongAgencyResultDTO">
SELECT
dg.id AS gridId,
dg.AGENCY_ID AS agencyId,
da.PID AS parentId
FROM
dim_grid dg
LEFT JOIN dim_agency da ON da.id = dg.agency_id
WHERE
dg.DEL_FLAG = '0'
AND da.DEL_FLAG = '0'
AND
(
<foreach collection="gridIds" item="gridId" separator=" OR ">
dg.id = #{gridId}
</foreach>
)
</select>
</mapper>
Loading…
Cancel
Save