123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- package com.yihu.wlyy.web.common.util;
- import com.yihu.wlyy.job.QuartzHelper;
- import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
- import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
- import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
- import com.yihu.wlyy.service.app.statistics.StatisticsService;
- import com.yihu.wlyy.web.BaseController;
- import io.swagger.annotations.Api;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.redis.core.StringRedisTemplate;
- import org.springframework.data.redis.hash.HashMapper;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- /**
- * Created by lyr on 2016/09/13.
- */
- @RestController
- @RequestMapping(value = "/manage_util")
- @Api(description = "管理工具及后台任务控制")
- public class ManagerUtilController extends BaseController {
- @Autowired
- PatientDiseaseService diseaseService;
- @Autowired
- StringRedisTemplate redisTemplate;
- @Autowired
- QuartzHelper quartzHelper;
- @Autowired
- DoctorWorkTimeService workTimeService;
- @Autowired
- StatisticsService statisticsService;
- /*********************************************患者疾病相关******************************************/
- /**
- * 更新到redis
- *
- * @return
- */
- @RequestMapping(value = "/disease/to_redis")
- public String updateToRedid() {
- try {
- diseaseService.updateToRedis();
- return write(200, "更新成功");
- } catch (Exception e) {
- return error(-1, "更新失败");
- }
- }
- /**
- * 更新到疾病表
- *
- * @return
- */
- @RequestMapping(value = "/disease/to_disease")
- public String updateToDisease() {
- try {
- diseaseService.updateToDisease();
- return write(200, "更新成功");
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "更新失败");
- }
- }
- /**
- * 查询患者redis疾病
- *
- * @param patient
- * @return
- */
- @RequestMapping(value = "/disease/patient")
- public String getDiseaseFromRedis(String patient) {
- try {
- return write(200, "查询成功", "data", redisTemplate.opsForValue().get("disease:" + patient));
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "查询失败");
- }
- }
- /***********************************************名医咨询相关****************************************/
- /**
- * 开始名医咨询剩余次数统计任务
- *
- * @return
- */
- @RequestMapping(value = "/famous_doctor/start_job")
- public String startConsultTimesJob() {
- try {
- if (!quartzHelper.isExistJob("famous-doctor-times")) {
- quartzHelper.addJob(FamousConsultTimesJob.class, "0 0 0 * * ?", "famous-doctor-times", new HashMap<String, Object>());
- return write(200, "启动成功");
- } else {
- return write(200, "任务已存在");
- }
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "启动失败");
- }
- }
- /**
- * 名医咨询剩余次数手动更新
- *
- * @return
- */
- @RequestMapping(value = "/famous_doctor/times_update")
- public String famousConsultTimeUpdate() {
- try {
- workTimeService.consultTimesRemain(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
- return write(200, "更新成功");
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "更新失败");
- }
- }
- /*********************************************统计相关*******************************************/
- /**
- * 更新人口数据到redis
- *
- * @return
- */
- @RequestMapping(value = "/people_num_to_redis")
- public String peopleNumToRedis() {
- try {
- statisticsService.peopleNumToRedis();
- return write(200, "更新成功");
- } catch (Exception e) {
- e.printStackTrace();
- return error(-1, "更新失败");
- }
- }
- }
|