Forráskód Böngészése

签约居民关注、缴费提醒修改

lyr 8 éve
szülő
commit
8a9972f047

+ 24 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/PatientRemindService.java

@ -25,10 +25,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -172,6 +169,11 @@ public class PatientRemindService extends BaseService {
     */
    public JSONObject remindPatientExpenses(Patient p, Doctor doc, Hospital hos, boolean ignore) throws Exception {
        try {
            Calendar today = Calendar.getInstance();
            today.set(Calendar.HOUR,23);
            today.set(Calendar.MINUTE,59);
            today.set(Calendar.SECOND,59);
            today.set(Calendar.MILLISECOND,59);
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            JSONObject reObj = new JSONObject();
            String mDesc = "";
@ -212,13 +214,17 @@ public class PatientRemindService extends BaseService {
                    "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
            if (ignore) {
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
                redisTemplate.expire("expenses:remind:" + p.getCode(), 1, TimeUnit.DAYS);
                redisTemplate.expireAt("expenses:remind:" + p.getCode(), today.getTime());
                redisTemplate.opsForSet().add("wechat:focus:remind:set",p.getCode());
                redisTemplate.expireAt("wechat:focus:remind:set", today.getTime());
            }
            if (wFlag || mFlag) {
                reObj.put("status", 200);
                redisTemplate.opsForValue().set("expenses:remind:" + p.getCode(), df.format(new Date()));
                redisTemplate.expire("expenses:remind:" + p.getCode(), 1, TimeUnit.DAYS);
                redisTemplate.expireAt("expenses:remind:" + p.getCode(), today.getTime());
                redisTemplate.opsForSet().add("expenses:remind:set",p.getCode());
                redisTemplate.expireAt("expenses:remind:set", today.getTime());
                if (wFlag && mFlag) {
                    reObj.put("msg", "提醒成功");
                } else if (mFlag && !wFlag) {
@ -316,6 +322,10 @@ public class PatientRemindService extends BaseService {
                if (result != null && result.size() > 0) {
                    for (Map<String, Object> map : result) {
                        String epTime = redisTemplate.opsForValue().get("wechat:focus:remind:" + map.get("code").toString());
                        if (StringUtils.isNotEmpty(epTime)) {
                            continue;
                        }
                        remindWechatFocus(map, doc);
                    }
                    page = page + 1;
@ -343,10 +353,17 @@ public class PatientRemindService extends BaseService {
     * @return
     */
    public JSONObject remindWechatFocus(Map<String, Object> p, Doctor doctor) {
        Calendar today = Calendar.getInstance();
        today.set(Calendar.HOUR,23);
        today.set(Calendar.MINUTE,59);
        today.set(Calendar.SECOND,59);
        today.set(Calendar.MILLISECOND,59);
        JSONObject result = new JSONObject();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        redisTemplate.opsForValue().set("wechat:focus:remind:" + p.get("code").toString(), df.format(new Date()));
        redisTemplate.expire("wechat:focus:remind:" + p.get("code").toString(), 1, TimeUnit.DAYS);
        redisTemplate.expireAt("wechat:focus:remind:" + p.get("code").toString(), today.getTime());
        redisTemplate.opsForSet().add("wechat:focus:remind:set",p.get("code").toString());
        redisTemplate.expireAt("wechat:focus:remind:set", today.getTime());
        if (p.get("mobile") == null || StringUtils.isEmpty(p.get("mobile").toString())) {
            result.put("status", -1);

+ 71 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.sign;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
@ -10,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -33,6 +35,8 @@ public class SignWebService extends BaseService {
    private SignFamilyDao signFamilyDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -142,6 +146,73 @@ public class SignWebService extends BaseService {
        return patients;
    }
    /**
     * 查询家庭签约已缴费未关注人数
     *
     * @param doctor
     * @return
     */
    public int isRemindFocusAll(String doctor) {
        boolean isAll = true;
        // 查询语句
        String sql = "select distinct b.code" +
                " from " +
                "     wlyy_sign_family f" +
                "     ,wlyy_patient b " +
                " where " +
                "     f.patient = b.code " +
                "     and (f.doctor = ? or f.doctor_health = ?)" +
                "     and f.expenses_status = '1' " +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and (b.openid is null or LENGTH(trim(ifnull(b.openid,''))) < 1)";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
        if (result != null && result.size() > 0) {
            Set<String> set = redisTemplate.opsForSet().members("wechat:focus:remind:set");
            if (set == null) {
                isAll = false;
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        }
        return isAll ? 1 : 0;
    }
    /**
     * 查询家庭签约已缴费未关注人数
     *
     * @param doctor
     * @return
     */
    public int isRemindExpensesAll(String doctor) {
        boolean isAll = true;
        // 查询语句
        String sql = "select distinct f.patient" +
                " from " +
                "     wlyy_sign_family f" +
                " where " +
                "     (f.doctor = ? or f.doctor_health = ?)" +
                "     and f.status > 0 " +
                "     and f.type = 2 " +
                "     and (f.expenses_status is null or LENGTH(trim(ifnull(f.expenses_status,''))) < 1)";
        List<String> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor},String.class);
        if (result != null && result.size() > 0) {
            Set<String> set = redisTemplate.opsForSet().members("expenses:remind:set");
            if (set == null) {
                isAll = false;
            } else if(!set.containsAll(result)) {
                isAll = false;
            }
        }
        return isAll ? 1 : 0;
    }
    /**
     * 根据代码查找签约信息明细
     *

+ 32 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -5,6 +5,7 @@ import java.util.*;
import com.yihu.wlyy.util.IdCardUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -313,4 +314,35 @@ public class DoctorSignController extends BaseController {
        }
    }
    /**
     * 查询今天是否全部提醒关注
     *
     * @return
     */
    @RequestMapping(value = "/is_remind_focus_all")
    @ApiOperation(value = "今天是否已全部提醒关注")
    public String isRemindFocusAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindFocusAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    /**
     * 查询今天是否全部提醒关注
     *
     * @return
     */
    @RequestMapping(value = "/is_remind_expenses_all")
    @ApiOperation(value = "今天是否已全部提醒缴费")
    public String isRemindFExpensesAllToday(){
        try{
            return write(200,"查询成功","data",signWebService.isRemindExpensesAll(getUID()));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}