|
|
|
@ -10,6 +10,7 @@ import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.PhoneValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.constant.BadgeConstant; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.constant.SmsTemplateConstant; |
|
|
|
import com.epmet.dao.*; |
|
|
|
import com.epmet.dto.ResiUserBadgeDTO; |
|
|
|
@ -17,9 +18,12 @@ import com.epmet.dto.UserBadgeCertificateRecordDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.redis.UserBadgeRedis; |
|
|
|
import com.epmet.service.UserBadgeService; |
|
|
|
import com.epmet.service.UserBaseInfoService; |
|
|
|
import com.epmet.util.ModuleConstant; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -56,6 +60,10 @@ public class UserBadgeServiceImpl implements UserBadgeService { |
|
|
|
@Autowired |
|
|
|
private BadgeDao badgeDao; |
|
|
|
@Autowired |
|
|
|
private GovOrgFeignClient govOrgFeignClient; |
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private BadgeCertificationConfigDao badgeCertificationConfigDao; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -74,7 +82,7 @@ public class UserBadgeServiceImpl implements UserBadgeService { |
|
|
|
List<UserBadgeListResultDTO> redisUserBadgeList = JSON.parseArray(userBadge.toString(), UserBadgeListResultDTO.class); |
|
|
|
List<UserBadgeListResultDTO> userBadgeListResultDTOS = userBadgeDao.selectBadgeList(userBadgeListFormDTO); |
|
|
|
if (CollectionUtils.isEmpty(userBadgeListResultDTOS)){ |
|
|
|
return redisUserBadgeList; |
|
|
|
return redisUserBadgeList.stream().sorted(Comparator.comparing(UserBadgeListResultDTO::getSort)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
redisUserBadgeList.forEach(u -> { |
|
|
|
userBadgeListResultDTOS.forEach(badge -> { |
|
|
|
@ -84,11 +92,13 @@ public class UserBadgeServiceImpl implements UserBadgeService { |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
List<UserBadgeListResultDTO> noOpenBadge = new ArrayList<>(); |
|
|
|
redisUserBadgeList.forEach(u -> { |
|
|
|
if (!u.getStatus()){ |
|
|
|
userBadgeListResultDTOS.add(u); |
|
|
|
noOpenBadge.add(u); |
|
|
|
} |
|
|
|
}); |
|
|
|
userBadgeListResultDTOS.addAll(noOpenBadge.stream().sorted(Comparator.comparing(UserBadgeListResultDTO::getSort)).collect(Collectors.toList())); |
|
|
|
return userBadgeListResultDTOS; |
|
|
|
} |
|
|
|
|
|
|
|
@ -121,7 +131,14 @@ public class UserBadgeServiceImpl implements UserBadgeService { |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
return userOperListResultDTOS.stream().sorted(Comparator.comparing(UserOperListResultDTO::getBadgeName)).collect(Collectors.toList()); |
|
|
|
Map<String, List<UserOperListResultDTO>> collect = userOperListResultDTOS.stream().collect(Collectors.groupingBy(UserOperListResultDTO::getIsLighted)); |
|
|
|
List<UserOperListResultDTO> result = collect.get(BadgeConstant.YES); |
|
|
|
List<UserOperListResultDTO> noLight = collect.get(BadgeConstant.NO); |
|
|
|
if (CollectionUtils.isEmpty(noLight)){ |
|
|
|
return result; |
|
|
|
} |
|
|
|
result.addAll(noLight.stream().sorted(Comparator.comparing(UserOperListResultDTO::getSort)).collect(Collectors.toList())); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -241,8 +258,9 @@ public class UserBadgeServiceImpl implements UserBadgeService { |
|
|
|
log.info(JSON.toJSONString(form)); |
|
|
|
userBadgeDao.insertUserBadgeCertificateRecord(form); |
|
|
|
|
|
|
|
//TODO 站内信发送 您好,您的xxx徽章因认证失败未成功点亮,请查看
|
|
|
|
this.sendMessageByUser(form); |
|
|
|
//TODO 站内信发送
|
|
|
|
String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId()); |
|
|
|
sendMessage(BadgeConstant.AUTH_TITLE,String.format(BadgeConstant.READ_FLAG,userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()),badgeName),form.getGridId(),form.getUserId(),form.getCustomerId()); |
|
|
|
|
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
@ -407,4 +425,69 @@ public class UserBadgeServiceImpl implements UserBadgeService { |
|
|
|
return badges.stream().collect(Collectors.groupingBy(UserBadgeInfoResultDTO::getUserId)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 发送站内信 |
|
|
|
* @Param title 标题 |
|
|
|
* @Param msg 信息 |
|
|
|
* @Param gridId 网格ID |
|
|
|
* @Param userId 用户ID |
|
|
|
* @Param customerId 客户ID |
|
|
|
* @author zxc |
|
|
|
* @date 2020/11/19 上午9:16 |
|
|
|
*/ |
|
|
|
public void sendMessage(String title,String msg,String gridId,String userId,String customerId){ |
|
|
|
//1.查询加入当前网格下的人员 customer_staff_grid
|
|
|
|
CommonGridIdFormDTO commonGridIdFormDTO = new CommonGridIdFormDTO(); |
|
|
|
commonGridIdFormDTO.setGridId(gridId); |
|
|
|
commonGridIdFormDTO.setUserId(userId); |
|
|
|
Result<List<String>> gridstaffs = |
|
|
|
govOrgFeignClient.getGridStaffs(commonGridIdFormDTO); |
|
|
|
//2.查询这些人是否有管理员身份且未被禁用 staff_role customer_staff
|
|
|
|
if(gridstaffs.success() && null != gridstaffs.getData() && gridstaffs.getData().size() > 0){ |
|
|
|
RolesUsersListFormDTO rolesUsersListFormDTO = new RolesUsersListFormDTO(); |
|
|
|
rolesUsersListFormDTO.setCustomerId(customerId); |
|
|
|
List<String> roleKeys = new ArrayList<String>(); |
|
|
|
roleKeys.add(ModuleConstant.STAFF_ROLE_GRID_MANAGER); |
|
|
|
rolesUsersListFormDTO.setRoleKeys(roleKeys); |
|
|
|
rolesUsersListFormDTO.setUserIds(gridstaffs.getData()); |
|
|
|
Result<List<String>> staffRoles = |
|
|
|
epmetUserOpenFeignClient.specificRolesStaffs(rolesUsersListFormDTO); |
|
|
|
//3.发送消息
|
|
|
|
if(staffRoles.success() && null != staffRoles.getData() && staffRoles.getData().size() > 0){ |
|
|
|
List<UserMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
List<WxSubscribeMessageFormDTO> subscribeList = new ArrayList<>(); |
|
|
|
for(String to : staffRoles.getData()){ |
|
|
|
//站内信
|
|
|
|
UserMessageFormDTO msgObj = new UserMessageFormDTO(); |
|
|
|
msgObj.setApp(ModuleConstant.APP_GOV); |
|
|
|
msgObj.setCustomerId(customerId); |
|
|
|
msgObj.setGridId(gridId); |
|
|
|
msgObj.setMessageContent(msg); |
|
|
|
msgObj.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
msgObj.setTitle(title); |
|
|
|
msgObj.setUserId(to); |
|
|
|
msgList.add(msgObj); |
|
|
|
//微信订阅
|
|
|
|
WxSubscribeMessageFormDTO subscribeDTO = new WxSubscribeMessageFormDTO(); |
|
|
|
subscribeDTO.setClientType(ModuleConstant.APP_GOV); |
|
|
|
subscribeDTO.setGridId(gridId); |
|
|
|
subscribeDTO.setCustomerId(customerId); |
|
|
|
subscribeDTO.setUserId(to); |
|
|
|
subscribeDTO.setBehaviorType(ModuleConstant.BADGE_AUDIT_MESSAGE); |
|
|
|
subscribeDTO.setMessageContent(msg); |
|
|
|
subscribeDTO.setMessageTime(new Date()); |
|
|
|
subscribeList.add(subscribeDTO); |
|
|
|
} |
|
|
|
if (subscribeList.size() > NumConstant.ZERO){ |
|
|
|
epmetMessageOpenFeignClient.sendWxSubscribeMessage(subscribeList); |
|
|
|
} |
|
|
|
Result result = epmetMessageOpenFeignClient.saveUserMessageList(msgList); |
|
|
|
if(result.success()){ |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|