trick9191 8 år sedan
förälder
incheckning
4f75febec4

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamilyRenew.java

@ -468,7 +468,7 @@ public class SignFamilyRenew extends IdEntity {
        this.expensesTime = expensesTime;
    }
    @Column(name = "is_valid")
    @Column(name="is_valid")
    public Integer getIsValid() {
        return isValid;
    }

+ 4 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/job/SignEndJob.java

@ -35,6 +35,7 @@ public class SignEndJob implements Job {
            int sucessT = jdbcTemplate.update(sqlT, start, end);
            int sucessTm = jdbcTemplate.update(sqlTm, start, end);
            int sucess = jdbcTemplate.update(sql, start, end);
            renewToSign();
            System.out.println("sign end job end");
        } catch (Exception e) {
            e.printStackTrace();
@ -42,4 +43,7 @@ public class SignEndJob implements Job {
        }
    }
    public void renewToSign(){
    }
}

+ 18 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java

@ -8,8 +8,26 @@ package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamilyRenew, Long>, JpaSpecificationExecutor<SignFamilyRenew> {
    @Query("select a from SignFamilyRenew a where a.idcard = ?1 and a.type = 2 and a.status >= 0")
    SignFamilyRenew findByIdcard(String idcard);
    /**
     * 获取所有有效的签约信息(不包含-1 -2)
     *
     * @param patient
     * @return
     */
    @Query(value = "select a from SignFamilyRenew a where a.patient = ?1 and a.status <> -1 and a.status <> -2")
    List<SignFamilyRenew> findAllActiveSignByPatient(String patient);
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient);
    List<SignFamilyRenew> findByDoctorHealthAndPatient(String doctorHealth,String patient);
}

+ 99 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -12,20 +12,14 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyCode;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.repository.statistics.WlyySignFamilyCodeDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
@ -122,6 +116,9 @@ public class FamilyContractService extends BaseService {
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
    public SignFamily findSignFamilyByCode(String code) {
        return signFamilyDao.findByCodeAndType(code, 2);
    }
@ -2876,4 +2873,98 @@ public class FamilyContractService extends BaseService {
        return result;
    }
    /**
     * 续签申请
     *
     * @param doctor  签约医生
     * @param patient 居民code
     * @return
     */
    public int signRenew(String doctor,String healthDoctor, String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
        SignFamilyRenew sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
        //判断身份证号是否已签约
        if (sc != null) {
            return -2;
        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
        if (d == null) {
            return -3;
        }
        if (hd == null) {
            return -3;
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        sf.setCode(getCode());
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        sf.setDoctor(doctor);
        sf.setDoctorName(d.getName());
        sf.setDoctorHealth(healthDoctor);
        sf.setDoctorHealthName(hd.getName());
        sf.setMobile(p.getMobile());
        sf.setName(p.getName());
        sf.setIdcard(p.getIdcard());
        sf.setOpenid(p.getOpenid());
        sf.setPatient(patient);
        sf.setHospital(d.getHospital());
        sf.setHospitalName(d.getHospitalName());
        sf.setSsc(p.getSsc());
        sf.setStatus(0);//0为初始状态
        sf.setType(2);// 设置为家庭签约
        sf.setSignType("1");//用户申请
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        sf.setIsValid(0);
        SignFamilyRenew temp = signFamilyRenewDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent(p.getName()+"申请与您续签家庭医生");
            message.setRead(1);//设置未读
            message.setReceiver(doctor);//设置接受医生的code
            message.setSender(patient);//设置发送的用户
            message.setSenderName(p.getName());
            message.setCode(getCode());
            message.setSenderPhoto(p.getPhoto());
            message.setTitle("家庭签约申请");
            message.setType(1);//家庭签约信息
            message.setReadonly(1);//是否只读消息
            message.setSignStatus("1");//新的签约
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(temp.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
            if (jsonObject.getString("status").equals("1")) {
                //如果在工作时间内就推送
                PushMsgTask.getInstance().put(doctor, MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.D_SW_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_SIGN_WEB.家庭签约.name(), "您有一条新的家庭签约申请!", patient);
            }
        }
        return 1;
    }
}

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

@ -8,11 +8,15 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
@ -54,6 +58,10 @@ public class SignWebService extends BaseService {
    private AdminTeamService adminTeamService;
    @Autowired
    private SystemDictService systemDictService;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -360,9 +368,10 @@ public class SignWebService extends BaseService {
        JSONArray jsonArray = new JSONArray();
        //加入续签表数据
        List<SignFamilyRenew> renews = jdbcTemplate.queryForList(
                "SELECT * FROM wlyy_sign_family_renew t " +
                        "WHERE t.patient = '"+patient+"' AND t.status <> -1 and t.status <> -2",SignFamilyRenew.class);
//        List<SignFamilyRenew> renews = jdbcTemplate.queryForList(
//                "SELECT * FROM wlyy_sign_family_renew t " +
//                        "WHERE t.patient = '"+patient+"' AND t.status <> -1 and t.status <> -2",SignFamilyRenew.class);
        List<SignFamilyRenew> renews = signFamilyRenewDao.findAllActiveSignByPatient(patient);
        for(SignFamilyRenew renew: renews){
            AdminTeam adminTeam = null;
@ -706,4 +715,243 @@ public class SignWebService extends BaseService {
        return resultObject;
    }
    /**
     * 根据医生代码及签约状态编码 获取该医生续签患者的信息列表
     *
     * @param doctor
     * @param status
     * @param page
     * @param pageSize
     * @return
     */
    public List<Map<String, Object>> getSignRenewWebByDoctor(String doctor, int status, int page, int pageSize) {
        // 查询语句
        String sql = "select " +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.idcard " +
                "    ,b.name " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                (status == 1 ? "    ,a.patient_apply_date as applyDate " : "    ,a.expenses_time as applyDate ") +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc limit " + page * pageSize + "," + pageSize;
        // 未缴费查询语句
        String sqlExpenses = "select " +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.idcard " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                "    ,a.apply_date as applyDate " +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                "    ,b.openid" +
                " from " +
                " ( select code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family_renew where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and (a.expenses_status = '0' or a.len < 1) order by a.begin desc limit " + page * pageSize + "," + pageSize;
        //1:待签约 2, 待缴费 3 已签约
        Page<Object> list = null;
        List<Map<String, Object>> patients = null;
        switch (status) {
            case 1:// 待处理
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 0});
                break;
            case 2:// 待缴费
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 1});
                break;
            case 3:// 已签约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 1});
                break;
        }
        return patients;
    }
    /**
     * 批量提醒用户
     * @param access_token
     * @param doctor
     * @return
     * @throws Exception
     */
    public int sendRenewToPatients(String access_token,String doctor) throws Exception{
        String sql = "SELECT p.name,p.openid,t.doctor_name doctorName,p.code,p.mobile FROM wlyy_sign_family t ,wlyy_patient p " +
                "WHERE t.patient = p.code AND t.doctor = ? AND t.status >=0 AND t.expenses_status ='1' AND " +
                "NOT EXISTS" +
                "(SELECT 1 FROM wlyy_sign_family_renew a WHERE a.patient =t.patient)  ";
        List<Map<String,Object>> signFamilies = jdbcTemplate.queryForList(sql,new Object[]{doctor});
        if(signFamilies!=null&&signFamilies.size()>0){
            for(Map<String,Object> signFamily : signFamilies){
                String openid = (String)signFamily.get("openid");
                String name = (String)signFamily.get("name");
                String doctorName =(String)signFamily.get("doctorName");
                JSONObject json = new JSONObject();
                json.put("keyword1", "续签家庭医生");
                json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("remark","提醒医生 :"+doctorName+"\n"
                        +"我们将继续为您提供优质的健康服务。");
                if(StringUtils.isNotBlank(openid)){
                    json.put("first",name+",您好!\n" +
                            "您的家庭医生签约将于7月31日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
                    PushMsgTask.getInstance().putWxMsg(access_token, 16, openid, name, json);
                    return 1;
                }else{
                    //如果自己没有绑定,则发给家人
                    String code = (String)signFamily.get("code");
                    JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(code);
                    Patient member = (Patient)j.get("member");
                    Patient p = patientService.findByCode(code);
                    if(StringUtils.isNotBlank(member.getOpenid())){
                        json.put("first",weiXinOpenIdUtils.getTitleMes(p,(int)j.get("relation"),member.getName())+"\n"+
                                name+",您好!\n" +
                                "您的家庭医生签约将于7月31日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 16, member.getOpenid(), member.getName(), json);
                        return 1;
                    }else{
                        //发送短信
                        String mobile = (String)signFamily.get("mobile");
                        if(StringUtils.isNotBlank(mobile)){
                            SMSService.sendMsg(mobile,name+"您好!您的家庭医生将于7月31日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                            return 2;
                        }
                    }
                }
            }
        }
        return 0;
    }
    /**
     * 同意或拒绝签约签约
     * @param access_token
     * @param dotorCode
     * @param state 1成功 0拒绝
     * @return
     * @throws Exception
     */
    public int agreeRenew(String access_token,String dotorCode,String patientCode,String state) throws Exception{
        List<SignFamilyRenew> renews =  signFamilyRenewDao.findByDoctorAndPatient(dotorCode,patientCode);
        if(renews==null||renews.size()==0){
            renews =  signFamilyRenewDao.findByDoctorHealthAndPatient(dotorCode,patientCode);
        }
        if(renews!=null&&renews.size()>0){
            for(SignFamilyRenew renew : renews){
                if(StringUtils.isNotBlank(state)){
                    if ("0".equals(state)){
                        renew.setStatus(-2);
                    }else if("1".equals(state)){
                        renew.setStatus(1);
                    }
                }
                renew.setStatus(1);
                signFamilyRenewDao.save(renew);
                //发送微信模板消息
                JSONObject data = new JSONObject();
                data.put("doctorName",renew.getDoctorName());
                data.put("date",DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                data.put("content","家庭医生续签");
                Patient patient = patientService.findByCode(renew.getPatient());
                if(patient!=null && StringUtils.isNotBlank(patient.getOpenid())){
                    if ("0".equals(state)){
                        data.put("first",renew.getName()+",您好!\n"+
                                "您的家庭医生续签申请已被拒绝");
                        data.put("remark","您可在到期后选择其他医生进行签约。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 2, patient.getOpenid(), patient.getName(), data);
                    }else if("1".equals(state)){
                        data.put("first",renew.getName()+",您好!\n"+
                                "您的家庭医生续签申请已通过");
                        data.put("remark","待自动扣费成功后,家庭医生将续签成功。");
                        PushMsgTask.getInstance().putWxMsg(access_token, 1, patient.getOpenid(), patient.getName(), data);
                    }
                }else{
                    //如果自己没有绑定,则发给家人
                    JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patient.getCode());
                    Patient member = (Patient)j.get("member");
                    if(StringUtils.isNotBlank(member.getOpenid())){
                        if ("0".equals(state)){
                            data.put("first",weiXinOpenIdUtils.getTitleMes(patient,(int)j.get("relation"),member.getName())+"\n"+
                                    patient.getName()+",您好!\n" +
                                    "您的家庭医生续签申请已被拒绝");
                            data.put("remark","您可在到期后选择其他医生进行签约。");
                            PushMsgTask.getInstance().putWxMsg(access_token, 2, member.getOpenid(), member.getName(), data);
                        }else if("1".equals(state)){
                            data.put("first",weiXinOpenIdUtils.getTitleMes(patient,(int)j.get("relation"),member.getName())+"\n"+
                                    patient.getName()+",您好!\n" +
                                    "您的家庭医生续签申请已通过");
                            data.put("remark","待自动扣费成功后,家庭医生将续签成功。");
                            PushMsgTask.getInstance().putWxMsg(access_token, 1, member.getOpenid(), member.getName(), data);
                        }
                    }
                }
            }
        }
        return 1;
    }
    /**
     * 获取年度列表
     * @return
     */
    public JSONObject getRenewYearCount(String doctorCode){
        StringBuffer sql = new StringBuffer("SELECT t.sign_year,COUNT(1) count " +
                "FROM  wlyy_sign_family t WHERE t.doctor ='"+doctorCode+"' AND t.end <=NOW() AND t.status=-4 AND sign_year IS NOT NULL GROUP BY t.sign_year DESC");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result",rs);
        return json;
    }
    /**
     * 获取用户信息
     * @return
     */
    public JSONObject getOverDuePatients(String year,String doctorCode,Integer page,Integer pageSize){
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "p.code,p.idcard,p.name,p.mobile,p.openid,p.phone,p.photo," +
                "p.ssc,t.sign_type,p.sex,t.emer_mobile,t.expenses_time,t.expenses_status " +
                "FROM wlyy_sign_family t ,wlyy_patient p " +
                "WHERE t.patient = p.code AND t.doctor ='"+doctorCode+"' AND t.sign_year ='"+year+"' LIMIT "+page*pageSize+","+pageSize+";");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result",rs);
        return json;
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -311,7 +311,7 @@ public class PatientService extends TokenService {
        JSONObject rs = new JSONObject();
        //判断是否签约
        List<SignFamily> signs =  jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status ='1' AND  t.patient ='"+patient+"'  NOW() >= t.begin and NOW() <= t.end",SignFamily.class);
        List<SignFamily> signs =  jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status ='1' AND  t.patient ='"+patient+"'  AND NOW() >= t.begin AND NOW() <= t.end",SignFamily.class);
        if(signs!=null){
            //当前年度已经签约
            rs.put("issign","1");

+ 9 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -524,6 +524,15 @@ public class PushMsgTask {
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
            }else if(type == 16){
                temp.setTemplate_id(SystemConf.getInstance().getSystemProperties().getProperty("template_doctor_survey"));
                WechatTemplateData  keyword1= new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                WechatTemplateData  keyword2= new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }
            temp.setData(m);

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

@ -1,28 +1,28 @@
package com.yihu.wlyy.web.doctor.sign;
import java.text.SimpleDateFormat;
import java.util.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 医生端:签约管理控制类
@ -33,7 +33,7 @@ import com.yihu.wlyy.web.BaseController;
@RestController
@RequestMapping(value = "/doctor/sign", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-签约管理")
public class DoctorSignController extends BaseController {
public class DoctorSignController extends WeixinBaseController {
    //	@Autowired
//	private SignContractService signContractService;
@ -344,4 +344,155 @@ public class DoctorSignController extends BaseController {
            return error(-1,"查询失败");
        }
    }
    /**
     * 获取续签约患者信息
     *
     * @param status     签约状态 1:待签约 2 待缴费 3 已签约
     * @return
     */
    @RequestMapping("/sign_info_renew")
    @ApiOperation(value = "医生获取获取列表")
    public String getSignRenewInfoByDoctor(
            @RequestParam(required = true)int status,
            @RequestParam(required = true)int page,
            @RequestParam(required = true)int pageSize) {
        try {
            page = page > 0 ? page -1 : 0;
            List<Map<String, Object>> listSign = signWebService.getSignRenewWebByDoctor(getUID(), status, page, pageSize);
            //List<Map<String, Object>> listSign = signWebService.getSignRenewWebByDoctor("64de930c-5b15-11e6-8344-fa163e8aee56", status, page, pageSize);
            JSONObject data = new JSONObject();
            List<JSONObject> jsonArray = new ArrayList<>();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            if (listSign != null) {
                for (Map<String, Object> temp : listSign) {
                    if (temp == null) {
                        continue;
                    }
                    JSONObject json = new JSONObject();
                    json.put("code", temp.get("code"));
                    json.put("doctorCode", temp.get("doctor"));
                    json.put("patientCode", temp.get("patient"));
                    json.put("patientName", temp.get("name"));
                    json.put("age", IdCardUtil.getAgeForIdcard(String.valueOf(temp.get("idcard"))));
                    json.put("provinceName", temp.get("provinceName"));
                    json.put("cityName", temp.get("cityName"));
                    json.put("townName", temp.get("townName"));
                    json.put("address", temp.get("address"));
                    json.put("photo", temp.get("photo"));
                    json.put("status", temp.get("status"));
                    json.put("openid", temp.get("openid"));
                    String statusName = "";
                    switch (Integer.parseInt(temp.get("status").toString())) {
                        case 0:
                            statusName = "待签约";
                            break;
                        case 1:
                            statusName = "已签约";
                            break;
                        case 2:
                            statusName = "待解约";
                            break;
                        case -3:
                        case -4:
                            statusName = "已解约";
                            break;
                    }
                    json.put("statusName", statusName);
                    json.put("id", temp.get("id"));
                    json.put("applyDate", DateUtil.dateToStrLong((Date) temp.get("applyDate")));
                    json.put("releaseSpeak", temp.get("reason"));
                    json.put("streetName", temp.get("streetName"));
                    json.put("sex", temp.get("sex"));
                    jsonArray.add(json);
                }
            }
            data.put("list", jsonArray);
            return write(200, "查询成功!", "data", data);
        } catch (Exception ex) {
            ex.printStackTrace();
            return error(-1, "系统错误,请联系管理员!");
        }
    }
    /**
     * 批量提醒居民续签
     * @return
     */
    @RequestMapping("/sendRenewToPatients")
    @ApiOperation(value = "提醒用户签约")
    public String sendRenewToPatients(){
        try{
            int rs = signWebService.sendRenewToPatients(getAccessToken(),getUID());
            //int rs = signWebService.sendRenewToPatients(getAccessToken(),"64de930c-5b15-11e6-8344-fa163e8aee56");
            if(rs == 0){
                return error(-1, "微信和短信,提醒失败");
            }else{
                return write(200, "提醒成功!", "data", rs);
            }
        }catch (Exception e){
            return error(-1, "提醒失败");
        }
    }
    /**
     * 同意或拒绝
     * @param state
     * @return
     */
    @RequestMapping("/agreeRenew")
    @ApiOperation(value = "医生处理签约")
    public String agreeRenew(@RequestParam(required = true)String state,
                             @RequestParam(required = true)String patient){
        try{
            int rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state);
            //int rs =signWebService.agreeRenew(getAccessToken(),"64de930c-5b15-11e6-8344-fa163e8aee56",patient,state);
            if(rs == 0){
                return error(-1, "操作失败");
            }else{
                return write(200, "操作成功!", "data", rs);
            }
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
    /**
     * 获取用户详情列表
     * @param year
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping("/getOverDuePatients")
    @ApiOperation(value = "获取用户详情列表")
    public String getOverDuePatients(@RequestParam(required = true)String year,
                                     @RequestParam(required = true)Integer page,
                                     @RequestParam(required = true)Integer pageSize){
        try{
            JSONObject rs =signWebService.getOverDuePatients(year,getUID(),page,pageSize);
            //JSONObject rs =signWebService.getOverDuePatients(year,"64de930c-5b15-11e6-8344-fa163e8aee56",page,pageSize);
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
    /**
     *
     * 获取去医生下年度分组列表
     * @return
     */
    @RequestMapping("/getRenewYearCount")
    @ApiOperation(value = "获取年度分组")
    public String getRenewYearCount(){
        try{
            //JSONObject rs =signWebService.getRenewYearCount(getUID());
            JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
            return error(-1, "请求失败");
        }
    }
}

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

@ -463,6 +463,38 @@ public class FamilyContractController extends BaseController {
        }
    }
    /**
     * 续签申请
     *
     * @param doctor     医生code
     * @return
     */
    @RequestMapping(value = "signRenew")
    @ResponseBody
    public String signRenew(@RequestParam(required = true) String doctor,
                            @RequestParam(required = true) String healthDoctor,
                            @RequestParam(required = true) String patient) {
        try {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
            }
            int result = familyContractService.signRenew(doctor,healthDoctor,patient);
            if (result == -1) {
                return error(-1, "用户信息查询失败");
            } else if (result == -2) {
                return error(-1, "用户已存在签约");
            } else if (result == -3) {
                return error(-1, "医生信息查询失败");
            } else {
                return write(200, "签约申请成功");
            }
        } catch (Exception e) {
            return error(-1, "签约申请失败");
        }
    }
    /**
     * 取消签约申请
     *

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

@ -274,6 +274,7 @@ public class PatientSignController extends BaseController {
	public String getSigns() {
		try {
			JSONArray jsonArray  = signWebService.getSigns(getUID());
			//JSONArray jsonArray  = signWebService.getSigns("915cc456-5b1d-11e6-8344-fa163e8aee56");
			return write(200, "查询成功!", "data", jsonArray);
		} catch (Exception ex) {
			ex.printStackTrace();