|
@@ -0,0 +1,63 @@
|
|
|
+package thyyxxk.wxservice_server.scheduled;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import thyyxxk.wxservice_server.dao.AssessmentDao;
|
|
|
+import thyyxxk.wxservice_server.entity.assessment.PushQuestionnaireVisit;
|
|
|
+import thyyxxk.wxservice_server.service.PushWxMessageService;
|
|
|
+import thyyxxk.wxservice_server.service.RedisLikeService;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/")
|
|
|
+public class QuestionnaireAfterVisit {
|
|
|
+ private final AssessmentDao dao;
|
|
|
+ private final RedisLikeService redis;
|
|
|
+ private final PushWxMessageService messageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public QuestionnaireAfterVisit(AssessmentDao dao, RedisLikeService redis, PushWxMessageService messageService) {
|
|
|
+ this.dao = dao;
|
|
|
+ this.redis = redis;
|
|
|
+ this.messageService = messageService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 11 * * ?")
|
|
|
+ public void start() {
|
|
|
+ int frequency = dao.selectQuestionnaireFrequency("clinic_satisfied_questionnaire");
|
|
|
+ List<PushQuestionnaireVisit> list = dao.selectPushQuestionnairePatients();
|
|
|
+ for (PushQuestionnaireVisit item : list) {
|
|
|
+ if (null == item.getQuestionnaireOffset() || item.getQuestionnaireOffset() >= frequency) {
|
|
|
+ item.setDeptName(redis.getDepartmentName(item.getDeptCode()));
|
|
|
+ item.setDoctorName(redis.getEmployeeName(item.getDoctorCode()));
|
|
|
+ pushMessage(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushMessage(PushQuestionnaireVisit visit) {
|
|
|
+ String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbde6b16acad84204&redirect_uri=" +
|
|
|
+ "http://staticweb.hnthyy.cn/wxserver/redirect/page2?to=clinicSatisfiedByPush_" + visit.getPatientId() +
|
|
|
+ "&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
|
|
|
+ String msgContent = "{\"touser\":\"" + visit.getOpenId() + "\",\"data\":" +
|
|
|
+ "{\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + visit.getPatName() + "\"}," +
|
|
|
+ "\"keyword2\":{\"color\":\"#173177\",\"value\":\"长沙泰和医院\"}," +
|
|
|
+ "\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + visit.getDeptName() + "\"}," +
|
|
|
+ "\"keyword4\":{\"color\":\"#173177\",\"value\":\"" + visit.getDoctorName() + "\"}," +
|
|
|
+ "\"keyword5\":{\"color\":\"#173177\",\"value\":\"" + visit.getVisitDate() + "\"}," +
|
|
|
+ "\"remark\":{\"color\":\"#FF0000\",\"value\":\"特邀请您进行本次诊疗的满意度调查,我们很重视您提出的宝贵意见!\"}," +
|
|
|
+ "\"first\":{\"color\":\"#FF0000\",\"value\":\"您曾在我院进行诊疗。\"}}," +
|
|
|
+ "\"template_id\":\"G4YAN56RmDjEPpNyP5fpCdr5TghyqspDeWlWaD5Eg2o\"," +
|
|
|
+ "\"url\":\"" + url + "\"}";
|
|
|
+ JSONObject message = JSONObject.parseObject(msgContent);
|
|
|
+ if (messageService.pushMessage(message)) {
|
|
|
+ dao.updateQuestionnaireTime(visit.getPatientId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|