Browse Source

党员只能建在支部上,志愿者抽取逻辑修改

master
zhaoqifeng 3 years ago
parent
commit
0ade16d689
  1. 12
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartyMemberServiceImpl.java
  2. 12
      epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartyMemberDao.xml
  3. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVolunteerPolyDTO.java
  4. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  5. 34
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java
  6. 65
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVolunteerPolyServiceImpl.java
  7. 34
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

12
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartyMemberServiceImpl.java

@ -222,6 +222,12 @@ public class IcPartyMemberServiceImpl extends BaseServiceImpl<IcPartyMemberDao,
public String save(IcPartyMemberDTO dto) {
//获取党组织信息
IcPartyOrgEntity org = icPartyOrgService.selectById(dto.getSszb());
if (null == org) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "党组织不存在", "党组织不存在");
}
if (!NumConstant.FIVE_STR.equals(org.getPartyOrgType())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所选党组织不是支部", "所选党组织不是支部");
}
dto.setCustomerId(org.getCustomerId());
dto.setAgencyId(org.getAgencyId());
dto.setAgencyPids(org.getAgencyPids());
@ -258,6 +264,12 @@ public class IcPartyMemberServiceImpl extends BaseServiceImpl<IcPartyMemberDao,
public void update(IcPartyMemberDTO dto) {
//获取党组织信息
IcPartyOrgEntity org = icPartyOrgService.selectById(dto.getSszb());
if (null == org) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "党组织不存在", "党组织不存在");
}
if (!NumConstant.FIVE_STR.equals(org.getPartyOrgType())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "所选党组织不是支部", "所选党组织不是支部");
}
dto.setAgencyId(org.getAgencyId());
dto.setAgencyPids(org.getAgencyPids());
dto.setOrgPids(org.getOrgPids());

12
epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/IcPartyMemberDao.xml

@ -59,16 +59,8 @@
a.REMARK
FROM
ic_party_member a
LEFT JOIN ( SELECT * FROM ( SELECT * FROM ic_party_member_pay_record ORDER BY PAY_DATE DESC LIMIT 1) record GROUP BY record.PARTY_MEMBER_ID ) b ON a.ID = b.PARTY_MEMBER_ID
AND b.DEL_FLAG = 0 AND b.CUSTOMER_ID = #{customerId}
LEFT JOIN (
SELECT PARTY_MEMBER_ID, SUM(TOTAL_SCORE) AS "total", COUNT(ID) as "count"
FROM ic_party_member_point
WHERE
DEL_FLAG = 0
AND CUSTOMER_ID = #{customerId}
AND YEAR = #{year}
GROUP BY PARTY_MEMBER_ID) c ON a.ID = c.PARTY_MEMBER_ID
LEFT JOIN ( SELECT CUSTOMER_ID,PARTY_MEMBER_ID,PAY_DATE FROM ( SELECT CUSTOMER_ID,PARTY_MEMBER_ID,PAY_DATE FROM ic_party_member_pay_record WHERE DEL_FLAG = 0 ORDER BY PAY_DATE DESC LIMIT 1) record GROUP BY record.PARTY_MEMBER_ID ) b ON a.ID = b.PARTY_MEMBER_ID
AND b.CUSTOMER_ID = #{customerId}
INNER JOIN ic_party_org d ON a.SSZB = d.ID
AND d.DEL_FLAG = 0
WHERE

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVolunteerPolyDTO.java

@ -76,6 +76,8 @@ public class IcVolunteerPolyDTO implements Serializable {
* 纬度
*/
private String latitude;
private String isParty;
private String isDyzxh;
private String volunteerCategory;
/**

6
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -1068,7 +1068,11 @@ public class IcResiUserController implements ResultDataResolver {
*/
@PostMapping("icPartyMemberSync")
public Result<IcPartyMemberDTO> icPartyMemberSync(@RequestBody IcPartyMemberDTO formDTO) {
return new Result<IcPartyMemberDTO>().ok(icResiUserService.icPartyMemberSync(formDTO));
IcPartyMemberDTO dto = icResiUserService.icPartyMemberSync(formDTO);
if (StringUtils.isNotBlank(dto.getIcResiUser())) {
this.sendVolunteerMsg(formDTO.getCustomerId(), dto.getIcResiUser());
}
return new Result<IcPartyMemberDTO>().ok(dto);
}
/**

34
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -205,6 +205,16 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
String name = "";
LinkedHashMap<String, String> map = new LinkedHashMap<>();
com.epmet.resi.partymember.dto.partymember.IcPartyMemberDTO partyMemberDTO = new com.epmet.resi.partymember.dto.partymember.IcPartyMemberDTO();
Map<String, List<LinkedHashMap<String,String>>> formMap = formDTO.stream().collect(Collectors.toMap(IcResiUserFormDTO::getTableName, IcResiUserFormDTO::getList));
boolean isDyzxh = false;
//判断是否是党员中心户
if (formMap.containsKey("ic_party_member")) {
for (LinkedHashMap<String, String> hash : formMap.get("ic_party_member")) {
if (NumConstant.ONE_STR.equals(hash.get("IS_DYZXH"))) {
isDyzxh = true;
}
}
}
for (IcResiUserFormDTO d : formDTO) {
if ("ic_resi_user".equals(d.getTableName())) {
map = d.getList().get(0);
@ -248,6 +258,9 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
} else {
throw new RenException(String.format("新增居民信息-根据agencyId查询组织信息失败,agencyId->%s", agencyId));
}
if (isDyzxh) {
map.put("IS_VOLUNTEER", NumConstant.ONE_STR);
}
//新增主表数据
baseDao.add(d.getTableName(), map);
@ -402,6 +415,16 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
String resiUserId = "";
LinkedHashMap<String, String> map = new LinkedHashMap<>();
com.epmet.resi.partymember.dto.partymember.IcPartyMemberDTO partyMemberDTO = new com.epmet.resi.partymember.dto.partymember.IcPartyMemberDTO();
Map<String, List<LinkedHashMap<String,String>>> formMap = formDTO.stream().collect(Collectors.toMap(IcResiUserFormDTO::getTableName, IcResiUserFormDTO::getList));
boolean isDyzxh = false;
//判断是否是党员中心户
if (formMap.containsKey("ic_party_member")) {
for (LinkedHashMap<String, String> hash : formMap.get("ic_party_member")) {
if (NumConstant.ONE_STR.equals(hash.get("IS_DYZXH"))) {
isDyzxh = true;
}
}
}
for (IcResiUserFormDTO d : formDTO) {
if ("ic_resi_user".equals(d.getTableName())) {
map = d.getList().get(0);
@ -497,6 +520,9 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
//2022-1-18 sun end
//2.更新主表数据
if (map.size() > NumConstant.ONE) {
if (isDyzxh) {
map.put("IS_VOLUNTEER", NumConstant.ONE_STR);
}
map.put("updated_by", tokenDto.getUserId());
baseDao.upTable("ic_resi_user", resiUserId, map);
}
@ -2073,6 +2099,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
user.setName(formDTO.getName());
user.setMobile(formDTO.getMobile());
user.setIsParty(NumConstant.ONE_STR);
//如果是党员中心户,则居民是志愿者
if (NumConstant.ONE_STR.equals(formDTO.getIsDyzxh())) {
user.setIsVolunteer(NumConstant.ONE_STR);
}
user.setUpdatedBy(null);
user.setUpdatedTime(null);
baseDao.updateById(user);
@ -2107,6 +2137,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
user.setName(formDTO.getName());
user.setMobile(formDTO.getMobile());
user.setIsParty(NumConstant.ONE_STR);
//如果是党员中心户,则居民是志愿者
if (NumConstant.ONE_STR.equals(formDTO.getIsDyzxh())) {
user.setIsVolunteer(NumConstant.ONE_STR);
}
user.setUpdatedBy(null);
user.setUpdatedTime(null);
baseDao.updateById(user);

65
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVolunteerPolyServiceImpl.java

@ -2,6 +2,7 @@ package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
@ -18,10 +19,7 @@ import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.redis.common.bean.HouseInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IcResiUserDao;
import com.epmet.dao.IcVolunteerPolyCategoryDao;
import com.epmet.dao.IcVolunteerPolyDao;
import com.epmet.dao.UserBaseInfoDao;
import com.epmet.dao.*;
import com.epmet.dto.IcVolunteerPolyDTO;
import com.epmet.dto.VolunteerInfoDTO;
import com.epmet.dto.form.*;
@ -29,10 +27,7 @@ import com.epmet.dto.result.ResiUserBaseInfoResultDTO;
import com.epmet.dto.result.VolunteerPolyListResultDTO;
import com.epmet.dto.result.VolunteerPolyMapDataResultDTO;
import com.epmet.dto.result.VolunteerPolyPieResultDTO;
import com.epmet.entity.IcResiUserEntity;
import com.epmet.entity.IcVolunteerPolyCategoryEntity;
import com.epmet.entity.IcVolunteerPolyEntity;
import com.epmet.entity.UserBaseInfoEntity;
import com.epmet.entity.*;
import com.epmet.feign.EpmetHeartOpenFeignClient;
import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.service.IcVolunteerPolyCategoryService;
@ -77,6 +72,8 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
private IcVolunteerPolyCategoryService icVolunteerPolyCategoryService;
@Resource
private IcVolunteerPolyCategoryDao icVolunteerPolyCategoryDao;
@Resource
private IcPartyMemberDao icPartyMemberDao;
@Override
public PageData<IcVolunteerPolyDTO> page(Map<String, Object> params) {
@ -202,10 +199,14 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
log.error("志愿者数据抽取-获取小程序志愿者失败");
}
List<IcVolunteerPolyDTO> appVolunteerList = result.getData();
appVolunteerList.forEach(item -> {
if(NumConstant.ONE_STR.equals(item.getIsParty()) && (NumConstant.ONE_STR.equals(item.getIsDyzxh()))) {
item.setVolunteerCategory(item.getVolunteerCategory().concat(",dangyuanzhongxinhu"));
}
});
if (CollectionUtils.isNotEmpty(appVolunteerList)) {
//获取居民信息
List<String> userIds = appVolunteerList.stream().map(IcVolunteerPolyDTO::getUserId).collect(Collectors.toList());
//根据志愿者的userId获取居民信息并转成map
List<UserBaseInfoEntity> userList = new ArrayList<>();
List<List<String>> partition = ListUtils.partition(userIds, NumConstant.FIFTY);
@ -301,6 +302,7 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
*/
private void icVolunteer(String customerId, String userId) {
IcResiUserEntity icUser = icResiUserDao.selectById(userId);
boolean isDyzxh = false;
if (null != icUser) {
//设置wrapper条件
List<IcVolunteerPolyDTO> volunteerList = icResiUserDao.getVolunteerList(customerId, userId);
@ -312,6 +314,15 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
categoryWrapper.eq(IcVolunteerPolyCategoryEntity::getCustomerId, customerId);
categoryWrapper.eq(IcVolunteerPolyCategoryEntity::getIdCard, icUser.getIdCard());
//判断是否党员中心户
if (NumConstant.ONE_STR.equals(icUser.getIsParty())) {
LambdaUpdateWrapper<IcPartyMemberEntity> memberWrapper = new LambdaUpdateWrapper<>();
memberWrapper.eq(IcPartyMemberEntity::getIcResiUser, icUser.getId());
IcPartyMemberEntity memberEntity = icPartyMemberDao.selectOne(memberWrapper);
if (null != memberEntity && NumConstant.ONE_STR.equals(memberEntity.getIsDyzxh())) {
isDyzxh = true;
}
}
//判断是否是志愿者
if (NumConstant.ONE_STR.equals(icUser.getIsVolunteer())) {
if (CollectionUtils.isNotEmpty(volunteerList)) {
@ -325,6 +336,9 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
baseDao.insert(entity);
}
List<String> categoryList = Arrays.asList(volunteerList.get(NumConstant.ZERO).getVolunteerCategory().split(StrConstant.COMMA));
if (isDyzxh) {
categoryList.add("dangyuanzhongxinhu");
}
List<IcVolunteerPolyCategoryEntity> entityList = categoryList.stream().map(o -> {
IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity();
category.setCustomerId(entity.getCustomerId());
@ -340,9 +354,31 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
icVolunteerPolyCategoryService.insertBatch(entityList);
}
} else {
if (!isDyzxh) {
//删除志愿者信息
baseDao.delete(wrapper);
icVolunteerPolyCategoryDao.delete(categoryWrapper);
} else {
IcVolunteerPolyEntity volunteer = baseDao.selectOne(wrapper);
IcVolunteerPolyEntity entity = ConvertUtils.sourceToTarget(volunteerList.get(NumConstant.ZERO), IcVolunteerPolyEntity.class);
if (null != volunteer) {
entity.setId(volunteer.getId());
baseDao.updateById(entity);
} else {
baseDao.insert(entity);
}
IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity();
category.setCustomerId(entity.getCustomerId());
category.setIdCard(entity.getIdCard());
if (null != volunteer) {
category.setLatitude(volunteer.getLatitude());
category.setLongitude(volunteer.getLongitude());
}
category.setVolunteerCategory("dangyuanzhongxinhu");
icVolunteerPolyCategoryDao.delete(categoryWrapper);
icVolunteerPolyCategoryService.insert(category);
}
}
}
}
@ -402,15 +438,6 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
}
baseDao.updateById(entity);
IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity();
category.setCustomerId(entity.getCustomerId());
category.setIdCard(entity.getIdCard());
category.setLatitude(volunteer.getLatitude());
category.setLongitude(volunteer.getLongitude());
category.setVolunteerCategory("qita");
icVolunteerPolyCategoryDao.delete(categoryWrapper);
icVolunteerPolyCategoryDao.insert(category);
} else if (null == volunteer) {
if (null != icResiUser) {
entity.setIcResiUser(icResiUser.getId());
@ -419,8 +446,6 @@ public class IcVolunteerPolyServiceImpl extends BaseServiceImpl<IcVolunteerPolyD
IcVolunteerPolyCategoryEntity category = new IcVolunteerPolyCategoryEntity();
category.setCustomerId(entity.getCustomerId());
category.setIdCard(entity.getIdCard());
category.setLatitude(volunteer.getLatitude());
category.setLongitude(volunteer.getLongitude());
category.setVolunteerCategory("qita");
icVolunteerPolyCategoryDao.delete(categoryWrapper);

34
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -982,11 +982,15 @@
ID_CARD,
MOBILE,
GENDER,
VOLUNTEER_CATEGORY
IS_PARTY,
IFNULL( VOLUNTEER_CATEGORY, "qita" ) AS VOLUNTEER_CATEGORY,
IFNULL( IS_DYZXH, "0" ) AS IS_DYZXH
FROM
ic_resi_user a
INNER JOIN ic_volunteer b ON a.ID = b.IC_RESI_USER
LEFT JOIN ic_volunteer b ON a.ID = b.IC_RESI_USER
AND b.DEL_FLAG = '0'
LEFT JOIN ic_party_member c ON a.ID = c.IC_RESI_USER
AND c.DEL_FLAG = '0'
WHERE
a.DEL_FLAG = '0'
AND a.IS_VOLUNTEER = '1'
@ -994,6 +998,32 @@
<if test="null != userId and userId.trim() != ''">
AND a.ID = #{userId}
</if>
UNION ALL
SELECT
a.ID AS icResiUser,
a.CUSTOMER_ID,
a.AGENCY_ID,
a.PIDS AS agencyPids,
`NAME`,
ID_CARD,
MOBILE,
GENDER,
IS_PARTY,
'dangyuanzhongxinhu' AS VOLUNTEER_CATEGORY,
IFNULL( IS_DYZXH, "0" ) AS IS_DYZXH
FROM
ic_resi_user a
INNER JOIN ic_party_member c ON a.ID = c.IC_RESI_USER
AND c.DEL_FLAG = '0'
WHERE
a.DEL_FLAG = '0'
AND a.IS_VOLUNTEER != '1'
AND a.IS_PARTY = '1'
AND a.CUSTOMER_ID = #{customerId}
AND c.IS_DYZXH = '1'
<if test="null != userId and userId.trim() != ''">
AND a.ID = #{userId}
</if>
</select>
</mapper>

Loading…
Cancel
Save