Commit 64b6762dcfd13e3da0ec08962e27b3490a4e0efd
1 parent
12efe23ded
Exists in
master
and in
1 other branch
小程序医生回访统计
Showing 2 changed files with 107 additions and 4 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/DoctorController.java
View file @
64b6762
| ... | ... | @@ -11,10 +11,7 @@ |
| 11 | 11 | import com.lyms.talkonlineweb.domain.*; |
| 12 | 12 | import com.lyms.talkonlineweb.result.BaseResponse; |
| 13 | 13 | import com.lyms.talkonlineweb.service.*; |
| 14 | -import com.lyms.talkonlineweb.util.Constant; | |
| 15 | -import com.lyms.talkonlineweb.util.HXService; | |
| 16 | -import com.lyms.talkonlineweb.util.JwtUtils; | |
| 17 | -import com.lyms.talkonlineweb.util.StringUtil; | |
| 14 | +import com.lyms.talkonlineweb.util.*; | |
| 18 | 15 | import lombok.extern.log4j.Log4j2; |
| 19 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 20 | 17 | import org.springframework.util.DigestUtils; |
| ... | ... | @@ -23,6 +20,7 @@ |
| 23 | 20 | import org.springframework.validation.annotation.Validated; |
| 24 | 21 | import org.springframework.web.bind.annotation.*; |
| 25 | 22 | |
| 23 | +import java.text.NumberFormat; | |
| 26 | 24 | import java.util.*; |
| 27 | 25 | |
| 28 | 26 | /** |
| ... | ... | @@ -53,6 +51,10 @@ |
| 53 | 51 | private AppgetdoctorlistInfoService appgetdoctorlistInfoService; |
| 54 | 52 | @Autowired |
| 55 | 53 | private LymsChatgroupService lymsChatgroupService; |
| 54 | + @Autowired | |
| 55 | + private LymsReturnVisitRecordService lymsReturnVisitRecordService; | |
| 56 | + @Autowired | |
| 57 | + private LymsMessageService lymsMessageService; | |
| 56 | 58 | |
| 57 | 59 | /** |
| 58 | 60 | * 获取医生列表 |
| ... | ... | @@ -355,6 +357,78 @@ |
| 355 | 357 | } |
| 356 | 358 | baseResponse.setObject(doctorAminList); |
| 357 | 359 | baseResponse.setErrormsg("成功"); |
| 360 | + return baseResponse; | |
| 361 | + } | |
| 362 | + /** | |
| 363 | + * 小程序回访统计,按医生 | |
| 364 | + * @param groupId 群组ID | |
| 365 | + * @return | |
| 366 | + */ | |
| 367 | + @GetMapping("getReturnVisit") | |
| 368 | + @TokenRequired | |
| 369 | + public BaseResponse getReturnVisit(String dlogin,String startTime,String endTime){ | |
| 370 | + BaseResponse baseResponse=new BaseResponse(); | |
| 371 | + try { | |
| 372 | + //总回访数 | |
| 373 | + int visitCount=0; | |
| 374 | + //有效回访数 | |
| 375 | + int visitRateCount=0; | |
| 376 | + | |
| 377 | + LambdaQueryWrapper<LymsReturnVisitRecord> wrapper = new QueryWrapper().lambda(); | |
| 378 | + wrapper.eq(LymsReturnVisitRecord::getDlogin, dlogin); | |
| 379 | + if(StringUtil.isNotEmpty(startTime) && StringUtil.isNotEmpty(endTime)){ | |
| 380 | + wrapper.ge(LymsReturnVisitRecord::getCreatedtime,DateUtil.getYyyyMmDdHhMmSs(DateUtil.getDayFirstSecond(DateUtil.parseYMD(startTime)))); | |
| 381 | + wrapper.le(LymsReturnVisitRecord::getCreatedtime, DateUtil.getYyyyMmDdHhMmSs(DateUtil.getDayLastSecond(DateUtil.parseYMD(endTime)))); | |
| 382 | + } | |
| 383 | + wrapper.groupBy(LymsReturnVisitRecord::getHxgroupid); | |
| 384 | + final List<LymsReturnVisitRecord> visitRecordHxgroupid = lymsReturnVisitRecordService.list(wrapper); | |
| 385 | + for (LymsReturnVisitRecord visitRecord : visitRecordHxgroupid) { | |
| 386 | + final List<LymsReturnVisitRecord> visitRecords = lymsReturnVisitRecordService.list(new QueryWrapper<LymsReturnVisitRecord>() | |
| 387 | + .lambda().eq(LymsReturnVisitRecord::getDlogin, dlogin) | |
| 388 | + .eq(LymsReturnVisitRecord::getHxgroupid,visitRecord.getHxgroupid()) | |
| 389 | + .orderByAsc(LymsReturnVisitRecord::getCreatedtime)); | |
| 390 | + visitCount+=visitRecords.size(); | |
| 391 | + for(int i=0;i<visitRecords.size();i++){ | |
| 392 | + if (i+1==visitRecords.size()) { | |
| 393 | + final int messageCount = lymsMessageService.count(new QueryWrapper<LymsMessage>() | |
| 394 | + .lambda().eq(LymsMessage::getTargetid,visitRecord.getHxgroupid()) | |
| 395 | + .eq(LymsMessage::getType,0) | |
| 396 | + .ge(LymsMessage::getSendtime, visitRecords.get(i).getCreatedtime())); | |
| 397 | + if (messageCount!=0) { | |
| 398 | + visitRateCount++; | |
| 399 | + } | |
| 400 | + }else { | |
| 401 | + final int messageCount = lymsMessageService.count(new QueryWrapper<LymsMessage>() | |
| 402 | + .lambda().eq(LymsMessage::getTargetid,visitRecord.getHxgroupid()) | |
| 403 | + .eq(LymsMessage::getType,0) | |
| 404 | + .ge(LymsMessage::getSendtime, visitRecords.get(i).getCreatedtime()) | |
| 405 | + .le(LymsMessage::getSendtime,visitRecords.get(i+1).getCreatedtime())); | |
| 406 | + if (messageCount!=0) { | |
| 407 | + visitRateCount++; | |
| 408 | + } | |
| 409 | + | |
| 410 | + } | |
| 411 | + } | |
| 412 | + } | |
| 413 | + String visitRate="0"; | |
| 414 | + if (visitCount!=0) { | |
| 415 | + // 创建一个数值格式化对象 | |
| 416 | + NumberFormat numberFormat = NumberFormat.getInstance(); | |
| 417 | + // 设置精确到小数点后2位 | |
| 418 | + numberFormat.setMaximumFractionDigits(2); | |
| 419 | + visitRate = numberFormat.format((float)visitRateCount/(float)visitCount*100); | |
| 420 | + } | |
| 421 | + | |
| 422 | + Map<String,Object> map=new HashMap<>(); | |
| 423 | + map.put("visitCount",visitCount); | |
| 424 | + map.put("visitRate",visitRate); | |
| 425 | + baseResponse.setObject(map); | |
| 426 | + baseResponse.setErrorcode(0); | |
| 427 | + baseResponse.setErrormsg("成功"); | |
| 428 | + } catch (Exception e) { | |
| 429 | + baseResponse.setErrorcode(1); | |
| 430 | + e.printStackTrace(); | |
| 431 | + } | |
| 358 | 432 | return baseResponse; |
| 359 | 433 | } |
| 360 | 434 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/DateUtil.java
View file @
64b6762
| ... | ... | @@ -260,6 +260,35 @@ |
| 260 | 260 | |
| 261 | 261 | return 0; |
| 262 | 262 | } |
| 263 | + /** | |
| 264 | + * 当前的开始时间 | |
| 265 | + * | |
| 266 | + * @param date | |
| 267 | + * @return | |
| 268 | + */ | |
| 269 | + public static Date getDayFirstSecond(Date date) { | |
| 270 | + Calendar instance = Calendar.getInstance(); | |
| 271 | + instance.setTime(date); | |
| 272 | + instance.set(Calendar.HOUR_OF_DAY, 0); | |
| 273 | + instance.set(Calendar.MINUTE, 0); | |
| 274 | + instance.set(Calendar.SECOND, 0); | |
| 275 | + instance.set(Calendar.MILLISECOND, 0); | |
| 276 | + return instance.getTime(); | |
| 277 | + } | |
| 278 | + | |
| 279 | + /** | |
| 280 | + * 把传进来的日期 设置为当天的最后一秒 | |
| 281 | + * | |
| 282 | + * @param date | |
| 283 | + */ | |
| 284 | + public static Date getDayLastSecond(Date date) { | |
| 285 | + Calendar calendar = Calendar.getInstance(); | |
| 286 | + calendar.setTime(date); | |
| 287 | + calendar.set(Calendar.HOUR_OF_DAY, 23); | |
| 288 | + calendar.set(Calendar.MINUTE, 59); | |
| 289 | + calendar.set(Calendar.SECOND, 59); | |
| 290 | + return calendar.getTime(); | |
| 291 | + } | |
| 263 | 292 | |
| 264 | 293 | } |