From 90126a3d4c743495fdc381a8b32e1195a39e320c Mon Sep 17 00:00:00 2001 From: xiezhijun <15270898033@163.com> Date: Wed, 28 Apr 2021 20:48:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E7=82=B9=E6=92=AD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 ++ .../custom/SysCustomerController.java | 19 ++++ .../custom/WechatAppletController.java | 63 +++++++++++ .../stdiet/common/utils/AliyunVideoUtils.java | 101 ++++++++++++++++++ .../com/stdiet/custom/domain/SysCustomer.java | 8 ++ .../response/NutritionalVideoResponse.java | 39 +++++++ .../custom/mapper/SysPhysicalSignsMapper.java | 8 ++ .../service/ISysPhysicalSignsService.java | 7 ++ .../impl/SysPhysicalSignsServiceImpl.java | 10 ++ .../mapper/custom/SysCustomerMapper.xml | 45 +++++--- .../mapper/custom/SysPhysicalSignsMapper.xml | 5 + .../src/views/custom/askQuestion/index.vue | 1 + stdiet-ui/src/views/custom/customer/index.vue | 27 +++++ 13 files changed, 324 insertions(+), 15 deletions(-) create mode 100644 stdiet-common/src/main/java/com/stdiet/common/utils/AliyunVideoUtils.java create mode 100644 stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalVideoResponse.java diff --git a/pom.xml b/pom.xml index b49f0bd5d..c96194afb 100644 --- a/pom.xml +++ b/pom.xml @@ -198,6 +198,12 @@ aliyun-sdk-oss ${aliyun-oss.version} + + + com.aliyun + vod20170321 + 2.0.0 + diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java index a4660d826..a85fc2e2d 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerController.java @@ -15,12 +15,14 @@ import com.stdiet.custom.domain.SysCustomerPhysicalSigns; import com.stdiet.custom.service.ISysCustomerHealthyService; import com.stdiet.custom.service.ISysCustomerPhysicalSignsService; import com.stdiet.custom.service.ISysCustomerService; +import com.stdiet.custom.service.ISysPhysicalSignsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; import java.util.List; +import java.util.regex.Pattern; /** * 客户体征信息Controller @@ -40,6 +42,9 @@ public class SysCustomerController extends BaseController { @Autowired private ISysCustomerHealthyService sysCustomerHealthyService; + @Autowired + private ISysPhysicalSignsService sysPhysicalSignsService; + /** * 查询客户信息列表 */ @@ -56,6 +61,20 @@ public class SysCustomerController extends BaseController { sysCustomer.setChannels(remark.split("\\|")); } } + + //体征查询 + if(StringUtils.isNotEmpty(sysCustomer.getPhysicalSignsId())){ + //判断是否数字ID + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + if(pattern.matcher(sysCustomer.getPhysicalSignsId()).matches()){ + List signIdList = new ArrayList<>(); + signIdList.add(Long.parseLong(sysCustomer.getPhysicalSignsId())); + sysCustomer.setSignIdList(signIdList); + }else { + sysCustomer.setSignIdList(sysPhysicalSignsService.getSignIdByName(sysCustomer.getPhysicalSignsId())); + } + } + list = sysCustomerService.selectSysCustomerList(sysCustomer); if (list != null && list.size() > 0) { for (SysCustomer sysCus : list) { diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java index abcee28f7..6c7df9d0f 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/WechatAppletController.java @@ -1,11 +1,15 @@ package com.stdiet.web.controller.custom; +import com.aliyun.vod20170321.models.GetPlayInfoResponseBody; +import com.aliyun.vod20170321.models.GetVideoInfoResponseBody; +import com.aliyun.vod20170321.models.GetVideoListResponseBody; import com.itextpdf.io.util.DateTimeUtil; import com.stdiet.common.core.controller.BaseController; import com.stdiet.common.core.domain.AjaxResult; import com.stdiet.common.core.page.TableDataInfo; import com.stdiet.common.enums.BusinessType; import com.stdiet.common.exception.file.FileNameLengthLimitExceededException; +import com.stdiet.common.utils.AliyunVideoUtils; import com.stdiet.common.utils.DateUtils; import com.stdiet.common.utils.StringUtils; import com.stdiet.common.utils.file.FileUploadUtils; @@ -15,6 +19,7 @@ import com.stdiet.common.utils.sign.AesUtils; import com.stdiet.custom.domain.*; import com.stdiet.custom.dto.response.CustomerCaseResponse; import com.stdiet.custom.dto.response.MessageNoticeResponse; +import com.stdiet.custom.dto.response.NutritionalVideoResponse; import com.stdiet.custom.page.WxLogInfo; import com.stdiet.custom.service.*; import org.aspectj.weaver.loadtime.Aj; @@ -353,4 +358,62 @@ public class WechatAppletController extends BaseController { sysMessageNotice.setId(id); return toAjax(sysMessageNoticeService.updateSysMessageNotice(sysMessageNotice)); } + + /** + * 更新用户通知消息已读状态 + */ + @GetMapping(value = "/getVideoList") + public AjaxResult getVideoList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) { + AjaxResult result = AjaxResult.success(); + int total = 0; + List nutritionalVideoList = new ArrayList<>(); + try{ + GetVideoListResponseBody videoListResponseBody = AliyunVideoUtils.getVideoListByPage(null, "Normal", pageNum, pageSize); + if(videoListResponseBody != null){ + total = videoListResponseBody.total; + for (GetVideoListResponseBody.GetVideoListResponseBodyVideoListVideo video : videoListResponseBody.videoList.video) { + NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); + nutritionalVideoResponse.setCoverURL(video.getCoverURL()); + nutritionalVideoResponse.setTitle(video.getTitle()); + nutritionalVideoResponse.setVideoId(video.getVideoId()); + nutritionalVideoResponse.setDescription(video.getDescription()); + nutritionalVideoResponse.setTags(video.getTags()); + nutritionalVideoList.add(nutritionalVideoResponse); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + result.put("total", total); + result.put("nutritionalVideoList", nutritionalVideoList); + return result; + } + + + /** + * 根据视频id获取播放链接 + */ + @GetMapping(value = "/getVideoDetailById") + public AjaxResult getVideoDetailById(@RequestParam(value = "videoId") String videoId) { + AjaxResult result = AjaxResult.success(); + NutritionalVideoResponse nutritionalVideoResponse = new NutritionalVideoResponse(); + try{ + GetPlayInfoResponseBody playInfoResponseBody = AliyunVideoUtils.getVideoVisitDetail(videoId); + GetVideoInfoResponseBody videoInfoResponseBody = AliyunVideoUtils.getVideoById(videoId); + List playList = playInfoResponseBody.playInfoList.playInfo; + if(playList != null && playList.size() > 0){ + nutritionalVideoResponse.setPlayUrl(playList.get(0).getPlayURL()); + } + if(videoInfoResponseBody != null){ + nutritionalVideoResponse.setDescription(videoInfoResponseBody.video.description); + nutritionalVideoResponse.setTags(videoInfoResponseBody.video.tags); + nutritionalVideoResponse.setTitle(videoInfoResponseBody.video.title); + nutritionalVideoResponse.setCreateTime(videoInfoResponseBody.video.creationTime); + } + }catch (Exception e){ + e.printStackTrace(); + } + result.put("videoDetail", nutritionalVideoResponse); + return result; + } } diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/AliyunVideoUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/AliyunVideoUtils.java new file mode 100644 index 000000000..0133e9c05 --- /dev/null +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/AliyunVideoUtils.java @@ -0,0 +1,101 @@ +package com.stdiet.common.utils; + +import com.aliyun.vod20170321.models.*; +import com.aliyun.teaopenapi.models.*; +import com.stdiet.common.config.AliyunOSSConfig; + +public class AliyunVideoUtils { + + public static com.aliyun.vod20170321.Client videoClient = null; + + public static final String default_definition = "FD,LD,SD,HD"; + + public static final String default_stream_type = "video"; + + public static final String default_output_type = "oss"; + + public static final String default_formats = "mp4"; + + /** + * 初始化视频点播Client + * @return + * @throws Exception + */ + public static com.aliyun.vod20170321.Client createClient() throws Exception { + if(videoClient == null){ + synchronized (com.aliyun.vod20170321.Client.class){ + if(videoClient == null){ + Config config = new Config() + // 您的AccessKey ID + .setAccessKeyId(AliyunOSSConfig.AccessKeyID) + // 您的AccessKey Secret + .setAccessKeySecret(AliyunOSSConfig.AccessKeySecret); + // 访问的域名 + config.endpoint = "vod.cn-shenzhen.aliyuncs.com"; + videoClient = new com.aliyun.vod20170321.Client(config); + } + } + } + return videoClient; + } + + /** + * 分页获取视频列表 + * @param pageNo 页码 + * @param pageSize 每页数量 + * @return + * @throws Exception + */ + public static GetVideoListResponseBody getVideoListByPage(Long cateId, String status, Integer pageNo, Integer pageSize) throws Exception{ + com.aliyun.vod20170321.Client client = AliyunVideoUtils.createClient(); + GetVideoListRequest getVideoListRequest = new GetVideoListRequest() + .setCateId(cateId == null ? null : cateId) + .setStatus(status == null ? "Normal": status) + .setPageNo(pageNo == null ? 1 : pageNo) + .setPageSize(pageSize == null ? 10 : pageSize); + GetVideoListResponse videoListResponse = client.getVideoList(getVideoListRequest); + if(videoListResponse != null){ + return videoListResponse.getBody(); + } + return null; + } + + /** + * 根据videoID获取视频访问地址信息 + * @param videoId + * @throws Exception + */ + public static GetPlayInfoResponseBody getVideoVisitDetail(String videoId) throws Exception{ + com.aliyun.vod20170321.Client client = AliyunVideoUtils.createClient(); + GetPlayInfoRequest getPlayInfoRequest = new GetPlayInfoRequest() + .setVideoId(videoId) + .setStreamType(default_stream_type) + .setOutputType(default_output_type) + .setFormats(default_formats); + GetPlayInfoResponse getPlayInfoResponse = client.getPlayInfo(getPlayInfoRequest); + if(getPlayInfoResponse != null){ + return getPlayInfoResponse.getBody(); + } + return null; + } + + /** + * 根据videoID获取视频信息 + * @param videoId + * @throws Exception + */ + public static GetVideoInfoResponseBody getVideoById (String videoId) throws Exception{ + com.aliyun.vod20170321.Client client = AliyunVideoUtils.createClient(); + GetVideoInfoRequest getVideoInfoRequest = new GetVideoInfoRequest() + .setVideoId(videoId); + GetVideoInfoResponse response = client.getVideoInfo(getVideoInfoRequest); + if(response != null){ + return response.body; + } + return null; + } + + + + +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java index a99cd9447..072923305 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysCustomer.java @@ -2,6 +2,8 @@ package com.stdiet.custom.domain; import java.math.BigDecimal; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -102,4 +104,10 @@ public class SysCustomer extends BaseEntity private String[] channels; + //病史体征ID集合,非持久化字段 + private List signIdList; + + //病史体征ID + private String physicalSignsId; + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalVideoResponse.java b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalVideoResponse.java new file mode 100644 index 000000000..d3827493c --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/dto/response/NutritionalVideoResponse.java @@ -0,0 +1,39 @@ +package com.stdiet.custom.dto.response; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class NutritionalVideoResponse implements Serializable { + + private static final long serialVersionUID = 1L; + + //分类ID + public Long cateId; + + //分类名称 + public String cateName; + + //标题 + public String title; + + //标签 + public String tags; + + //视频ID + public String videoId; + + //封面URL + public String coverURL; + + //视频描述 + public String description; + + //播放链接 + public String playUrl; + + + public String createTime; + +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPhysicalSignsMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPhysicalSignsMapper.java index 22cca22d8..cbd9b349b 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPhysicalSignsMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysPhysicalSignsMapper.java @@ -2,6 +2,7 @@ package com.stdiet.custom.mapper; import java.util.List; import com.stdiet.custom.domain.SysPhysicalSigns; +import org.apache.ibatis.annotations.Param; /** * 体征Mapper接口 @@ -58,4 +59,11 @@ public interface SysPhysicalSignsMapper * @return 结果 */ public int deleteSysPhysicalSignsByIds(Long[] ids); + + /** + * 根据名称查询体征ID集合 + * @param name + * @return + */ + List getSignIdByName(@Param("name") String name); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPhysicalSignsService.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPhysicalSignsService.java index 204ba992a..eee6b4ce0 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPhysicalSignsService.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/ISysPhysicalSignsService.java @@ -58,4 +58,11 @@ public interface ISysPhysicalSignsService * @return 结果 */ public int deleteSysPhysicalSignsById(Long id); + + /** + * 根据名称查询体征ID集合 + * @param name + * @return + */ + List getSignIdByName(String name); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPhysicalSignsServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPhysicalSignsServiceImpl.java index 71d5a4182..1aa9f149e 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPhysicalSignsServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysPhysicalSignsServiceImpl.java @@ -90,4 +90,14 @@ public class SysPhysicalSignsServiceImpl implements ISysPhysicalSignsService { return sysPhysicalSignsMapper.deleteSysPhysicalSignsById(id); } + + /** + * 根据名称查询体征ID集合 + * @param name + * @return + */ + @Override + public List getSignIdByName(String name){ + return sysPhysicalSignsMapper.getSignIdByName(name); + } } \ No newline at end of file diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml index 086da23a6..0e7b805e0 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCustomerMapper.xml @@ -34,26 +34,41 @@ + select sps.id from sys_physical_signs sps where sps.name like concat('%', #{name}, '%') + + \ No newline at end of file diff --git a/stdiet-ui/src/views/custom/askQuestion/index.vue b/stdiet-ui/src/views/custom/askQuestion/index.vue index 5db66b6ad..f0ee6985c 100644 --- a/stdiet-ui/src/views/custom/askQuestion/index.vue +++ b/stdiet-ui/src/views/custom/askQuestion/index.vue @@ -49,6 +49,7 @@ +