Browse Source

"modify-reg-grid"修改注册网格

master
yinzuomei 3 years ago
parent
commit
0702034ca7
  1. 8
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  2. 11
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
  3. 11
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  4. 7
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/VolunteerInfoDao.java
  5. 6
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java
  6. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java
  7. 13
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml
  8. 26
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ModifyRegGridFormDTO.java
  9. 16
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java
  10. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java
  11. 101
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java

8
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java

@ -84,4 +84,12 @@ public interface EpmetHeartOpenFeignClient {
*/
@PostMapping("/heart/resi/volunteer/count")
Result<Integer> getVolunteerCount(@RequestBody VolunteerCommonFormDTO input);
/**
* 修改志愿者的注册网格
* @param volunteerInfoDTO
* @return
*/
@PostMapping("/heart/resi/volunteer/modifyVolunteerGrid")
Result modifyVolunteerGrid(@RequestBody VolunteerInfoDTO volunteerInfoDTO);
}

11
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java

@ -77,4 +77,15 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli
public Result<Integer> getVolunteerCount(VolunteerCommonFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "getVolunteerCount", input);
}
/**
* 修改志愿者的注册网格
*
* @param volunteerInfoDTO
* @return
*/
@Override
public Result modifyVolunteerGrid(VolunteerInfoDTO volunteerInfoDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "modifyVolunteerGrid", volunteerInfoDTO);
}
}

11
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java

@ -159,4 +159,15 @@ public class ResiVolunteerController {
Integer volunteerCount = volunteerInfoService.getVolunteerCount(customerId, agencyId);
return new Result<Integer>().ok(volunteerCount);
}
/**
* 修改志愿者注册信息_的网格信息
* @param volunteerInfoDTO
* @return
*/
@PostMapping("modifyVolunteerGrid")
public Result modifyVolunteerGrid(@RequestBody VolunteerInfoDTO volunteerInfoDTO){
volunteerInfoService.modifyVolunteerGrid(volunteerInfoDTO);
return new Result();
}
}

7
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/VolunteerInfoDao.java

@ -74,4 +74,11 @@ public interface VolunteerInfoDao extends BaseDao<VolunteerInfoEntity> {
* @date 2020.08.13 10:06
**/
List<String> selectVolunteerIds(@Param("customerId")String customerId);
/**
* 修改志愿者注册信息_网格信息
* @param volunteerInfoDTO
* @return
*/
int updateVolunteerGrid(VolunteerInfoDTO volunteerInfoDTO);
}

6
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java

@ -111,4 +111,10 @@ public interface VolunteerInfoService extends BaseService<VolunteerInfoEntity> {
* @return
*/
Integer getVolunteerCount(String customerId, String agencyId);
/**
* 修改志愿者注册信息_的网格信息
* @param volunteerInfoDTO
*/
void modifyVolunteerGrid(VolunteerInfoDTO volunteerInfoDTO);
}

10
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java

@ -414,4 +414,14 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
return pidsAndAgencyIdPath;
}
/**
* 修改志愿者注册信息_的网格信息
*
* @param volunteerInfoDTO
*/
@Override
public void modifyVolunteerGrid(VolunteerInfoDTO volunteerInfoDTO) {
baseDao.updateVolunteerGrid(volunteerInfoDTO);
}
}

13
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/VolunteerInfoDao.xml

@ -72,4 +72,17 @@
AND CUSTOMER_ID = #{customerId}
order by CREATED_TIME asc
</select>
<update id="updateVolunteerGrid" parameterType="com.epmet.dto.VolunteerInfoDTO">
UPDATE volunteer_info
SET GRID_ID = #{gridId},
GRID_NAME = #{gridName},
PID = #{pid},
PIDS = #{pids},
UPDATED_TIME = NOW()
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND user_id = #{userId}
</update>
</mapper>

26
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ModifyRegGridFormDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
@Data
public class ModifyRegGridFormDTO implements Serializable {
public interface AddUserInternalGroup {
}
public interface AddUserShowGroup extends CustomerClientShowGroup {
}
@NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class)
private String userId;
@NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class)
private String customerId;
@NotBlank(message = "请选择您所在的网格", groups = AddUserShowGroup.class)
private String gridId;
}

16
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserController.java

@ -210,4 +210,20 @@ public class UserController {
ValidatorUtils.validateEntity(findIcUserFormDTO,FindIcUserFormDTO.AddUserInternalGroup.class);
return new Result<EpmetUserFamilyDTO>().ok(userService.findIcUser(findIcUserFormDTO));
}
/**
* 居民端-修改注册网格
* @param tokenDto
* @param formDTO
* @return
*/
@PostMapping(value = "modify-reg-grid")
public Result modifyRegGrid(@LoginUser TokenDto tokenDto,@RequestBody ModifyRegGridFormDTO formDTO){
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,ModifyRegGridFormDTO.AddUserShowGroup.class,
ModifyRegGridFormDTO.AddUserInternalGroup.class);
userService.modifyRegGrid(formDTO);
return new Result();
}
}

6
epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserService.java

@ -121,4 +121,10 @@ public interface UserService extends BaseService<UserEntity> {
* @return
*/
EpmetUserFamilyDTO findIcUser(FindIcUserFormDTO findIcUserFormDTO);
/**
* 居民端-修改注册网格
* @param formDTO
*/
void modifyRegGrid(ModifyRegGridFormDTO formDTO);
}

101
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserServiceImpl.java

@ -1,26 +1,27 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.UserConstant;
import com.epmet.dao.UserDao;
import com.epmet.dao.UserResiInfoDao;
import com.epmet.dao.UserRoleDao;
import com.epmet.dao.UserWechatDao;
import com.epmet.dao.*;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.UserBaseInfoEntity;
import com.epmet.entity.UserEntity;
import com.epmet.entity.UserWechatEntity;
import com.epmet.entity.*;
import com.epmet.feign.EpmetHeartOpenFeignClient;
import com.epmet.feign.EpmetPointOpenFeignClient;
import com.epmet.feign.GovOrgFeignClient;
import com.epmet.redis.UserBaseInfoRedis;
import com.epmet.service.IcResiUserService;
import com.epmet.service.UserBaseInfoService;
import com.epmet.service.UserService;
@ -31,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
@ -63,6 +65,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
private UserResiInfoDao userResiInfoDao;
@Autowired
private IcResiUserService icResiUserService;
@Autowired
private RegisterRelationDao registerRelationDao;
@Autowired
private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient;
@Autowired
private ResiUserBadgeDao resiUserBadgeDao;
@Autowired
private UserBadgeCertificateRecordDao userBadgeCertificateRecordDao;
@Autowired
private UserBaseInfoRedis userBaseInfoRedis;
private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
@ -417,4 +429,79 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
return result;
}
/**
* 居民端-修改注册网格
*
* @param formDTO
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void modifyRegGrid(ModifyRegGridFormDTO formDTO) {
GridInfoCache newGridInfo= CustomerOrgRedis.getGridInfo(formDTO.getGridId());
if (null == newGridInfo) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询当前网格信息异常", "服务器开小差了...");
}
//修改register_relation表
//原始注册记录
LambdaQueryWrapper<RegisterRelationEntity> wrapper=new LambdaQueryWrapper();
wrapper.eq(RegisterRelationEntity::getCustomerId,formDTO.getCustomerId())
.eq(RegisterRelationEntity::getUserId,formDTO.getUserId())
.eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR);
RegisterRelationEntity originReg=registerRelationDao.selectOne(wrapper);
if(null==originReg){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询用户原始注册网格记录异常", "服务器开小差了...");
}
//1、删除废弃网格的
registerRelationDao.deleteById(originReg.getId());
//2、当前选择的网格,是否有记录,有更新没有删除
LambdaQueryWrapper<RegisterRelationEntity> query=new LambdaQueryWrapper();
query.eq(RegisterRelationEntity::getCustomerId,formDTO.getCustomerId())
.eq(RegisterRelationEntity::getUserId,formDTO.getUserId())
.eq(RegisterRelationEntity::getGridId, formDTO.getGridId());
RegisterRelationEntity nowReg=registerRelationDao.selectOne(query);
if (null != nowReg) {
nowReg.setFirstRegister(NumConstant.ONE_STR);
nowReg.setRegister(NumConstant.ONE_STR);
nowReg.setParticipation(NumConstant.ONE_STR);
registerRelationDao.updateById(nowReg);
} else {
RegisterRelationEntity insert=new RegisterRelationEntity();
insert.setCustomerId(formDTO.getCustomerId());
insert.setGridId(formDTO.getGridId());
insert.setUserId(formDTO.getUserId());
insert.setFirstRegister(NumConstant.ONE_STR);
insert.setRegister(NumConstant.ONE_STR);
insert.setParticipation(NumConstant.ONE_STR);
registerRelationDao.insert(insert);
}
//2、修改历史徽章表
LambdaUpdateWrapper<UserBadgeCertificateRecordEntity> recUpdate=new LambdaUpdateWrapper<>();
recUpdate.set(UserBadgeCertificateRecordEntity::getGridId,newGridInfo.getId());
recUpdate.eq(UserBadgeCertificateRecordEntity::getCustomerId,formDTO.getCustomerId())
.eq(UserBadgeCertificateRecordEntity::getUserId,formDTO.getUserId());
userBadgeCertificateRecordDao.update(null,recUpdate);
LambdaUpdateWrapper<ResiUserBadgeEntity> badgeUpdate=new LambdaUpdateWrapper<>();
badgeUpdate.set(ResiUserBadgeEntity::getGridId,newGridInfo.getId());
badgeUpdate.eq(ResiUserBadgeEntity::getCustomerId,formDTO.getCustomerId())
.eq(ResiUserBadgeEntity::getUserId,formDTO.getUserId());
resiUserBadgeDao.update(null,badgeUpdate);
//3、修改支援者信息表
VolunteerInfoDTO volunteerInfoDTO=new VolunteerInfoDTO();
volunteerInfoDTO.setCustomerId(formDTO.getCustomerId());
volunteerInfoDTO.setUserId(formDTO.getUserId());
volunteerInfoDTO.setGridId(newGridInfo.getId());
volunteerInfoDTO.setPid(newGridInfo.getPid());
volunteerInfoDTO.setPids(newGridInfo.getPids());
volunteerInfoDTO.setGridName(newGridInfo.getGridName());
Result volunteerRes=epmetHeartOpenFeignClient.modifyVolunteerGrid(volunteerInfoDTO);
if (!volunteerRes.success()) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:修改用户志愿者信息异常", "服务器开小差了...");
}
//4、删除用户缓存信息
userBaseInfoRedis.clearUserCache(Arrays.asList(formDTO.getUserId()));
}
}

Loading…
Cancel
Save