| | |
| | | import com.smartor.config.PhoneUtils; |
| | | import com.smartor.domain.DTO.ServiceSubtaskDetailDTO; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.domain.VO.HeLibraryCountVO; |
| | | import com.smartor.domain.VO.ServiceSubtaskCotinueCountVO; |
| | | import com.smartor.domain.entity.ServiceSubtaskEntity; |
| | | import com.smartor.mapper.*; |
| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | |
| | | map.put("content", sendMagParam.getContent()); |
| | | String result = HttpUtil.postJsonRequest(xhsmsPath, new Gson().toJson(map)); |
| | | redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES); |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getRemark())) serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功"); |
| | | if (StringUtils.isNotEmpty(serviceSubtask.getRemark())) |
| | | serviceSubtask.setRemark("电话发送拒接,短信补偿发送成功"); |
| | | else serviceSubtask.setRemark("短信补偿发送成功"); |
| | | serviceSubtask.setSendstate(3L); |
| | | serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getHeLibraryCount(@RequestBody HeLibraryCountVO heLibraryCountVO) { |
| | | if (ObjectUtils.isEmpty(heLibraryCountVO)) { |
| | | return new HashMap<>(); |
| | | } |
| | | // 1. 查询分组统计(发送总量、发送成功量、已读量) |
| | | List<Map<String, Object>> groupStats = serviceSubtaskMapper.getHeLibraryCount(heLibraryCountVO); |
| | | |
| | | // 2. 计算各组的发送成功率和已读率 |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | if (CollectionUtils.isNotEmpty(groupStats)) { |
| | | for (Map<String, Object> row : groupStats) { |
| | | long totalCount = row.get("totalCount") != null ? ((Number) row.get("totalCount")).longValue() : 0L; |
| | | long sendSuccessCount = row.get("sendSuccessCount") != null ? ((Number) row.get("sendSuccessCount")).longValue() : 0L; |
| | | long readCount = row.get("readCount") != null ? ((Number) row.get("readCount")).longValue() : 0L; |
| | | // 发送成功率 |
| | | double sendSuccessRate = totalCount > 0 ? (double) sendSuccessCount / totalCount : 0.0; |
| | | // 已读率(基于发送成功的数量计算) |
| | | double readRate = sendSuccessCount > 0 ? (double) readCount / sendSuccessCount : 0.0; |
| | | row.put("sendSuccessRate", sendSuccessRate); |
| | | row.put("readRate", readRate); |
| | | result.add(row); |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | resultMap.put("list", result); |
| | | resultMap.put("total", result.size()); |
| | | return resultMap; |
| | | } |
| | | |
| | | |
| | | private Boolean saveServiceSubtaskDetail(ServiceSubtask serviceSubtask) { |
| | | Boolean result = true; |
| | | //3.4 如果3.1或3.2为true的话,根据type判断什么类型 |