浏览代码

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

wujunjie 8 年之前
父节点
当前提交
262d14afdb
共有 17 个文件被更改,包括 599 次插入78 次删除
  1. 3 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java
  2. 4 2
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/FollowUpJob.java
  3. 6 5
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/WlyyQuotaResult.java
  4. 6 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/statistics/WlyyQuotaResult.java
  5. 12 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  6. 5 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java
  7. 0 8
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/WlyyQuotaResultDao.java
  8. 295 19
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  9. 109 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  10. 28 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  11. 5 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  12. 10 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  13. 30 18
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  14. 16 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  15. 13 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  16. 53 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  17. 4 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

+ 3 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java

@ -13,6 +13,7 @@ import com.yihu.wlyy.statistics.model.job.WlyyQuotaResult;
import com.yihu.wlyy.statistics.model.system.City;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
@ -29,6 +30,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -765,7 +767,7 @@ public class DBStorage   {
        wlyyQuotaResult.setCityName(cityName);
        wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
        wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
        wlyyQuotaResult.setQuotaDate(date);
        wlyyQuotaResult.setQuotaDate(DateUtil.strToDateShort(date));
        wlyyQuotaResult.setCreateTime(new Date());
        wlyyQuotaResult.setQkdoctorJobName(doctorJob);
        wlyyQuotaResult.setQkdoctorName(doctorName);

+ 4 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/FollowUpJob.java

@ -12,6 +12,7 @@ import com.yihu.wlyy.statistics.model.job.WlyyQuotaResult;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
@ -123,8 +124,9 @@ public class FollowUpJob implements Job {
        return string.toString();
    }
    public String getYesterday() {
        return yesterday;
    public Date getYesterday() {
        return DateUtil.strToDateShort(yesterday);
    }
    private void save(Map<String, Long> tjTownMap, String city, String cityName, String town, String townName, String org, String orgName, String doctorCode, String doctorName, String doctorJob, String level, String key) {

+ 6 - 5
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/WlyyQuotaResult.java

@ -12,7 +12,7 @@ import java.util.Date;
@Table(name = "wlyy_quota_result")
public class WlyyQuotaResult implements java.io.Serializable {
    private String id;
    private String quotaDate;//统计时间
    private Date quotaDate;//统计时间
    private String quatoCode;//指标code
    private String quatoName;//指标name
    private String result;//统计结果
@ -63,15 +63,16 @@ public class WlyyQuotaResult implements java.io.Serializable {
        this.orgName = orgName;
    }
    @Column(name = "quota_date", length = 0)
    public String getQuotaDate() {
        return this.quotaDate;
    @Column(name = "quota_date")
    public Date getQuotaDate() {
        return quotaDate;
    }
    public void setQuotaDate(String quotaDate) {
    public void setQuotaDate(Date quotaDate) {
        this.quotaDate = quotaDate;
    }
    @Column(name = "quato_code", length = 100)
    public String getQuatoCode() {
        return this.quatoCode;

+ 6 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/statistics/WlyyQuotaResult.java

@ -16,7 +16,7 @@ import org.hibernate.annotations.GenericGenerator;
@Table(name = "wlyy_quota_result")
public class WlyyQuotaResult implements java.io.Serializable {
    private String id;
    private String quotaDate;//统计时间
    private Date quotaDate;//统计时间
    private String quatoCode;//指标code
    private String quatoName;//指标name
    private String result;//统计结果
@ -67,15 +67,16 @@ public class WlyyQuotaResult implements java.io.Serializable {
        this.orgName = orgName;
    }
    @Column(name = "quota_date", length = 0)
    public String getQuotaDate() {
        return this.quotaDate;
    @Column(name = "quota_date")
    public Date getQuotaDate() {
        return quotaDate;
    }
    public void setQuotaDate(String quotaDate) {
    public void setQuotaDate(Date quotaDate) {
        this.quotaDate = quotaDate;
    }
    @Column(name = "quato_code", length = 100)
    public String getQuatoCode() {
        return this.quatoCode;

+ 12 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -42,6 +42,9 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    SignFamily findByTeamCode(String TeamCode);
    @Query("select a from SignFamily a where a.teamCode = ?1 and a.type = 2 and a.status >= 0")
    List<SignFamily> findByTeamCodeIsValid(String teamCode);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
    SignFamily findByDoctorPatient(String doctor, String patient);
@ -67,6 +70,12 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a,DoctorTeamMember w where a.teamCode = w.team and w.del = '1' and w.memberCode = ?1 and a.patient = ?2 and a.status > 0")
    List<SignFamily> findByDoctorAndPatient(String doctor, String patient);
    @Query(value = "select a from SignFamily a where a.doctor =?1 and a.patient = ?2 and a.status =0 and a.signYear =?3")
    List<SignFamily> findByDoctorAndPatientOverDue(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamily a where a.doctorHealth =?1 and a.patient = ?2 and a.status =0 and a.signYear =?3")
    List<SignFamily> findByDoctorHealthAndPatient(String doctorHealth,String patient,String signYear);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 2")
    SignFamily findByFamilyDoctorAndPatient(String doctor, String patient);
@ -271,6 +280,9 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status in (0,1,2)")
    SignFamily findFamilySignByPatient(String patientCode);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type = 2 and a.status =-4 and a.signYear =?2")
    SignFamily findFamilySignByPatientOverDue(String patientCode,String signYear);
    @Query("select p.code, p.name, p.photo, p.birthday, p.sex, p.diseaseCondition, p.disease, p.recordAmount,a.type,a.applyDate,p.idcard from SignFamily a,Patient p where (a.doctor = ?1 or a.doctorHealth = ?1) and a.patient = p.code and a.status in (1,2,3)")
    List<Object> findDoctorSignPatients(String doctor);

+ 5 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java

@ -27,12 +27,13 @@ public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamil
    @Query(value = "select a from SignFamilyRenew a where a.patient = ?1 and a.status <> -1 and a.status <> -2")
    List<SignFamilyRenew> findAllActiveSignByPatient(String patient);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 ")
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3")
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient,String signYear);
    List<SignFamilyRenew> findByDoctorHealthAndPatient(String doctorHealth,String patient);
    @Query(value = "select a from SignFamilyRenew a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3")
    List<SignFamilyRenew> findByDoctorHealthAndPatient(String doctorHealth,String patient,String signYear);
    // 查询患者已生效的家庭续签约
    @Query("select a from SignFamilyRenew a where a.patient = ?1 and a.type = 2 and a.status = 0")
    SignFamily findSigningByPatient(String patient);
    SignFamilyRenew findSigningByPatient(String patient);
}

+ 0 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/statistics/WlyyQuotaResultDao.java

@ -12,13 +12,5 @@ import java.util.List;
 * Created by Administrator on 2016/8/16.
 */
public interface WlyyQuotaResultDao extends PagingAndSortingRepository<WlyyQuotaResult, String>, JpaSpecificationExecutor<WlyyQuotaResult> {
    @Query(" FROM WlyyQuotaResult a WHERE a.quotaDate =?1 and a.quatoCode=?2")
    List<WlyyQuotaResult> findByYesterday(String yesterday, String quatoCode);
    @Modifying
    @Query(" delete FROM WlyyQuotaResult a WHERE a.quotaDate =?1 and a.quatoCode=?2")
    void deleteByDateAndCode(String yesterday, String quatoCode);
    @Query(" FROM WlyyQuotaResult a WHERE a.level1Type =?1 and a.qkdoctorJobName != ?2 and a.quatoCode=1")
    List<WlyyQuotaResult> findByLevel1TypeAndQkdoctorJobName(String level1Type, String qkdoctorJobName);
}

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

@ -32,9 +32,11 @@ import com.yihu.wlyy.task.SignUploadTask;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.CachedIntrospectionResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -155,7 +157,7 @@ public class FamilyContractService extends BaseService {
     * @return
     */
    public SignFamily findSigningRenewByPatient(String patient) {
        return signFamilyRenewDao.findSigningByPatient(patient);
        return signFamilyDao.findSigningByPatient(patient);
    }
    /**
     * 查询医院列表
@ -821,13 +823,23 @@ public class FamilyContractService extends BaseService {
            throw new Exception("已签约了家庭医生!");
        }
        //判断是否有三师签约 并且判断全科医生一致
        SignFamily sssignFamily = signFamilyDao.findSSByIdcard(idcard);
        if (sssignFamily != null && !doctor.equals(sssignFamily.getDoctor())) {
            throw new Exception("全科医生不一致!");
        }
        //屏蔽三师签约判断
//        SignFamily sssignFamily = signFamilyDao.findSSByIdcard(idcard);
//        if (sssignFamily != null && !doctor.equals(sssignFamily.getDoctor())) {
//            throw new Exception("全科医生不一致!");
//        }
        List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
        String signYear = systemDicts.get(0).getCode();
//        List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
        Calendar cal = Calendar.getInstance();
        int m = cal.get(Calendar.MONTH)+1;
        String signYear = "" ;
        if(m>=4){
            //签约当前年度
            signYear = cal.get(Calendar.YEAR)+"";
        }else{
            //签约过去年度
            signYear = (cal.get(Calendar.YEAR)-1)+"";
        }
        SignFamily sf = new SignFamily();
        sf.setSignYear(signYear);//设置签约年度
@ -1119,8 +1131,17 @@ public class FamilyContractService extends BaseService {
                }
            }
            List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
            String year = systemDicts.get(0).getCode();
            //List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
            Calendar cal = Calendar.getInstance();
            int m = cal.get(Calendar.MONTH)+1;
            String year = "" ;
            if(m>=4){
                //签约当前年度
                year = cal.get(Calendar.YEAR)+"";
            }else{
                //签约过去年度
                year = (cal.get(Calendar.YEAR)-1)+"";
            }
            Calendar now = Calendar.getInstance();
            int month = now.get(Calendar.MONTH) + 1;
@ -2902,11 +2923,11 @@ public class FamilyContractService extends BaseService {
            return -1;
        }
        List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
        //判断身份证号是否已签约
        if (sc != null&&sc.size()>0) {
            return -2;
        }
//        List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
//        //判断身份证号是否已签约
//        if (sc != null&&sc.size()>0) {
//            return -2;
//        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
@ -2915,8 +2936,14 @@ public class FamilyContractService extends BaseService {
            return -3;
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        Calendar cal = Calendar.getInstance();
        int year =cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH)+1;
        String sql = "";
        //判断是否有生效记录SQL
        String sql = "SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1'";
        sql ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='"+(year-1)+"'";
        List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
        if(signs==null||signs.size()==0){
            return -4;
@ -2926,7 +2953,8 @@ public class FamilyContractService extends BaseService {
        if(doctor.equals((String)sign.get("doctor"))){
            //如果一致保存团队信息
            sf.setTeamCode((String)sign.get("teamCode"));
            sf.setAdminTeamId((Long)sign.get("adminTeamId"));
            Integer c=(Integer)sign.get("adminTeamCode");
            sf.setAdminTeamId(c.longValue());
        }else {
            //如果不一致 查看医生团队
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
@ -3018,8 +3046,7 @@ public class FamilyContractService extends BaseService {
        sf.setSignSource("2");//签约来源【1 社区签约 2 移动签约】
        //******************扣费接口**********************/
        sf.setExpensesStatus("0");   //扣费状态 【0未扣费 1已扣费 2已退费】
        Calendar cal = Calendar.getInstance();
        int year =cal.get(Calendar.YEAR);
        sf.setSignYear(year+"");
        sf.setIsValid(0);
        sf.setBegin(new Date());
@ -3044,7 +3071,7 @@ public class FamilyContractService extends BaseService {
            message.setSignStatus("8");//续签
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(temp.getCode());
            message.setData(sf.getCode());
            messageDao.save(message);
            // 发送消息给医生
            JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(doctor);
@ -3056,4 +3083,253 @@ public class FamilyContractService extends BaseService {
        return 1;
    }
    /**
     * 续签申请(7月之后)
     *
     * @param doctor  签约医生
     * @param patient 居民code
     * @return
     */
    @Transactional
    public int signRenewOverdue(String doctor,String healthDoctor, String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        if (p == null) {
            return -1;
        }
        Doctor d = doctorDao.findByCode(doctor);
        Doctor hd = doctorDao.findByCode(healthDoctor);
        if (d == null) {
            return -3;
        }
        SignFamily sf = new SignFamily();
        Calendar cal = Calendar.getInstance();
        int year =cal.get(Calendar.YEAR);
        int month = cal.get(Calendar.MONTH)+1;
        String sql  ="SELECT t.doctor,t.team_code teamCode,t.admin_team_code adminTeamCode FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND t.expenses_status='1' AND t.sign_year ='"+(year-1)+"'";
        List<Map<String,Object>> signs = jdbcTemplate.queryForList(sql);
        if(signs==null||signs.size()==0){
            return -4;
        }
        Map<String,Object> sign = signs.get(0);
        //判断续签医生是否一致
        if(doctor.equals((String)sign.get("doctor"))){
            //如果一致保存团队信息
            sf.setTeamCode((String)sign.get("teamCode"));
            Integer c=(Integer)sign.get("adminTeamCode");
            sf.setAdminTeamId(c.longValue());
        }else {
            //如果不一致 查看医生团队
            String tcSql = "SELECT t.id FROM wlyy_admin_team t WHERE t.leader_code ='"+doctor+"'";
            List<Map<String ,Object>> ids = jdbcTemplate.queryForList(tcSql);
            if(ids!=null&&ids.size()>0){
                Integer id =  (Integer)ids.get(0).get("id");
                Long lid = id.longValue();
                sf.setAdminTeamId(lid);
            }else{
                //未找到团队信息
                return -5;
            }
            //新建咨询团队组
            DoctorTeam team = new DoctorTeam();
            String code = getCode();
            team.setCode(code);
            team.setCzrq(new Date());
            team.setDel("1");
            team.setSignType("2");
            //判断是否有健康管理师
            if(hd!=null&&StringUtils.isNotBlank(hd.getName())){
                team.setName(d.getName()+","+hd.getName()+","+p.getName());
                //新建健康管理师
                DoctorTeamMember hdmb = new DoctorTeamMember();
                hdmb.setName(hd.getName());
                hdmb.setMemberCode(healthDoctor);
                hdmb.setCode(getCode());
                hdmb.setDel("1");
                hdmb.setCzrq(new Date());
                hdmb.setTeam(code);
                hdmb.setType(hd.getLevel());
                hdmb.setSignType("2");
                doctorTeamDoctor.save(hdmb);
            }else{
                team.setName(d.getName()+","+p.getName());
            }
            //新建医生成员
            DoctorTeamMember dmb = new DoctorTeamMember();
            dmb.setName(d.getName());
            dmb.setMemberCode(doctor);
            dmb.setCode(getCode());
            dmb.setDel("1");
            dmb.setCzrq(new Date());
            dmb.setTeam(code);
            dmb.setType(d.getLevel());
            dmb.setSignType("2");
            //新建病人
            DoctorTeamMember pmb = new DoctorTeamMember();
            pmb.setName(p.getName());
            pmb.setMemberCode(patient);
            pmb.setCode(getCode());
            pmb.setDel("1");
            pmb.setCzrq(new Date());
            pmb.setTeam(code);
            pmb.setType(5);
            pmb.setSignType("2");
            doctorTeamDoctor.save(dmb);
            doctorTeamDoctor.save(pmb);
            doctorTeamDao.save(team);
            //关联新团队
            sf.setTeamCode(code);
        }
        sf.setCode(getCode());
        sf.setCzrq(new Date());
        sf.setPatientApplyDate(new Date());
        if(d!=null){
            sf.setDoctor(doctor);
            sf.setDoctorName(d.getName());
        }
        if(hd!=null){
            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.setSignYear(year+"");
        sf.setBegin(new Date());
        sf.setEnd(DateUtil.stringToDate(year+1+"-07-01 00:00:00","yyyy-MM-dd HH:mmm:ss"));
        SignFamily temp = signFamilyDao.save(sf);
        if (temp != null) {
            // 添加签约消息
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setContent("您有一条新的家庭医生续签申请!");
            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("8");//续签
            message.setSex(p.getSex());
            message.setOver("1");//未处理
            message.setData(sf.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(), p.getName()+"申请与您续签家庭医生", patient);
            }
        }
        return 1;
    }
    /**
     *
     * @param code
     * @return
     */
    public String getTeamName(String code){
        try{
            String sql = "SELECT t.name FROM wlyy_doctor_team t WHERE t.code ='"+code+"'";
            List<Map<String,Object>> map = jdbcTemplate.queryForList(sql);
            if(map!=null&&map.size()>0){
                return (String)map.get(0).get("name");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return "";
    }
    public JSONArray getSignDoctorMessageOverDue(String patientCode) {
        JSONArray jsonArray = new JSONArray();
        //找出患者的三师签约信息
        Patient patient = patientDao.findByCode(patientCode);
        Calendar cal = Calendar.getInstance();
        int year = cal.get(Calendar.YEAR);
        //得到家庭签约
        SignFamily jtSignFamily = signFamilyDao.findFamilySignByPatientOverDue(patientCode,(year-1)+"");
        if (jtSignFamily != null) {
            //家庭签约只找全科医生
            Doctor doctor = doctorDao.findByCode(jtSignFamily.getDoctor());
            Doctor doctorHealth = doctorDao.findByCode(jtSignFamily.getDoctorHealth());
            if (doctor != null) {
                JSONObject jo = new JSONObject();
                jo.put("code", doctor.getCode());
                jo.put("sex", doctor.getSex());
                jo.put("name", doctor.getName());
                jo.put("photo", doctor.getPhoto());
                jo.put("hosptialName", doctor.getHospitalName());
                jo.put("level", doctor.getLevel());
                jo.put("signType", "2");//三师签约
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctor.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.put(jo);
            }
            if (doctorHealth != null) {
                JSONObject jo = new JSONObject();
                jo.put("code", doctorHealth.getCode());
                jo.put("sex", doctorHealth.getSex());
                jo.put("name", doctorHealth.getName());
                jo.put("photo", doctorHealth.getPhoto());
                jo.put("hosptialName", doctorHealth.getHospitalName());
                jo.put("level", doctorHealth.getLevel());
                jo.put("signType", "2");//三师签约
                jo.put("signStatus", jtSignFamily.getStatus());
                jo.put("jobName", doctorHealth.getJobName());
                jo.put("disease", patient.getDisease());//0健康,1高血压,2糖尿病,3高血压+糖尿病
                if (jtSignFamily.getStatus() == 0) {
                    jo.put("sqDate", DateUtil.dateToStrShort(jtSignFamily.getPatientApplyDate()));//申请时间
                } else {
                    jo.put("qyDate", DateUtil.dateToStrShort(jtSignFamily.getBegin()));//签约时间
                    jo.put("endDate", DateUtil.dateToStrShort(jtSignFamily.getEnd()));//结束时间
                }
                jsonArray.put(jo);
            }
        }
        return jsonArray;
    }
}

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

@ -5,11 +5,13 @@ import java.util.*;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.message.Message;
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.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.app.team.AdminTeamService;
@ -67,6 +69,8 @@ public class SignWebService extends BaseService {
    private SignFamilyRenewDao signFamilyRenewDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private MessageDao messageDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
     *
@ -465,10 +469,13 @@ public class SignWebService extends BaseService {
    }
    public JSONObject getSignInfo(String teamCode){
          SignFamily signFamily = signFamilyDao.findByTeamCode(teamCode);
          if(signFamily==null){
          List<SignFamily> signFamilys = signFamilyDao.findByTeamCodeIsValid(teamCode);
          SignFamily signFamily =null;
          if(signFamilys==null||signFamilys.size()==0){
              throw new RuntimeException("找不到签约关系!");
          }
          }else{
              signFamily = signFamilys.get(0);
;          }
          Patient p = patientService.findByCode(signFamily.getPatient());
          String patient = p.getCode();
          JSONObject resultObject = new JSONObject();
@ -894,11 +901,12 @@ public class SignWebService extends BaseService {
     * @return
     * @throws Exception
     */
    public int agreeRenew(String access_token,String dotorCode,String patientCode,String state) throws Exception{
        List<SignFamilyRenew> renews =  signFamilyRenewDao.findByDoctorAndPatient(dotorCode,patientCode);
    public int agreeRenew(String access_token,String dotorCode,String patientCode,String state,Long mesId,String signYear) throws Exception{
        List<SignFamilyRenew> renews =  signFamilyRenewDao.findByDoctorAndPatient(dotorCode,patientCode,signYear);
        if(renews==null||renews.size()==0){
            renews =  signFamilyRenewDao.findByDoctorHealthAndPatient(dotorCode,patientCode);
            renews =  signFamilyRenewDao.findByDoctorHealthAndPatient(dotorCode,patientCode,signYear);
        }
        if(renews!=null&&renews.size()>0){
@ -913,6 +921,101 @@ public class SignWebService extends BaseService {
                renew.setApplyDate(new Date());
                signFamilyRenewDao.save(renew);
                if(mesId!=null&&mesId>0){
                    Message mes = messageDao.findOne(mesId);
                    mes.setRead(0);//设置已读
                    mes.setOver("0");//设置消息操作结束
                    mes.setCzrq(new Date());
                    messageDao.save(mes);
                }
                //发送微信模板消息
                JSONObject data = new JSONObject();
                data.put("doctorName",renew.getDoctorName());
                data.put("date",DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                data.put("content","家庭医生续签");
                data.put("doctor",dotorCode);
                data.put("toUser",patientCode);
                data.put("toName",renew.getName());
                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);
                        }
                    }
                }
            }
        }else{
            return 0;
        }
        return 1;
    }
    /**
     * 同意或拒绝签约签约(七月份的流程)
     * @param access_token
     * @param dotorCode
     * @param state 1成功 0拒绝
     * @return
     * @throws Exception
     */
    public int agreeRenewOverDue (String access_token,String dotorCode,String patientCode,String state,Long mesId,String signYear) throws Exception{
        List<SignFamily> renews =  signFamilyDao.findByDoctorAndPatientOverDue(dotorCode,patientCode,signYear);
        if(renews==null||renews.size()==0){
            renews =  signFamilyDao.findByDoctorHealthAndPatient(dotorCode,patientCode,signYear);
        }
        if(renews!=null&&renews.size()>0){
            for(SignFamily renew : renews){
                if(StringUtils.isNotBlank(state)){
                    if ("0".equals(state)){
                        renew.setStatus(-2);
                    }else if("1".equals(state)){
                        renew.setStatus(1);
                    }
                }
                renew.setApplyDate(new Date());
                signFamilyDao.save(renew);
                if(mesId!=null&&mesId>0){
                    Message mes = messageDao.findOne(mesId);
                    mes.setRead(0);//设置已读
                    mes.setOver("0");//设置消息操作结束
                    mes.setCzrq(new Date());
                    messageDao.save(mes);
                }
                //发送微信模板消息
                JSONObject data = new JSONObject();
                data.put("doctorName",renew.getDoctorName());

+ 28 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -3,14 +3,17 @@ package com.yihu.wlyy.service.app.team;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.hospital.HospitalService;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
@ -48,6 +51,9 @@ public class AdminTeamService extends BaseService {
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    HospitalDao hospitalDao;
    /**
     * 获取团队数量。
     *
@ -372,4 +378,26 @@ public class AdminTeamService extends BaseService {
    public List<AdminTeamMember> findByAdminTeam(String patient,String doctorCode){
        return memberDao.findByAdminTeam(patient,doctorCode);
    }
    public JSONObject getTeamInfo(Integer teamId){
        AdminTeam adminTeam = this.getTeam(teamId);
        JSONObject result = new JSONObject();
        JSONObject teamInfo = new JSONObject(adminTeam);
        Doctor doctor = doctorDao.findByCode(adminTeam.getLeaderCode());
        teamInfo.put("leaderName",doctor.getName());
        Hospital hospital =hospitalDao.findByCode(adminTeam.getOrgCode());
        teamInfo.put("hospitalName",hospital.getName());
        result.put("team",teamInfo);
        List<Doctor> members = memberDao.findAllMembers(teamId);
        List<JSONObject> doctors = new ArrayList<>();
        for(Doctor d:members){
            JSONObject doctorInfo = new JSONObject();
            doctorInfo.put("name",d.getName());
            doctorInfo.put("code",d.getCode());
            doctors.add(doctorInfo);
        }
        result.put("members",doctors);
        return result;
    }
}

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

@ -385,7 +385,7 @@ public class PatientService extends TokenService {
        //用于判断续签表是否有记录QL,有记录则不允许续签
        String sqlRenew = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family_renew t WHERE t.patient ='" + patient + "' AND t.status>=0 ";
        //判读是否有当前年度的记录SQL
        String signSql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1' AND t.sign_year ='" + year + "'";
        String signSql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0  AND t.sign_year ='" + year + "'";
        //判读是否有旧的已到期记录SQL
        String oldSignSql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND  t.expenses_status='1' AND t.sign_year ='" + (year - 1) + "'";
        //判断时间是否在6月30之前
@ -419,14 +419,14 @@ public class PatientService extends TokenService {
            }
        } else {
            //如果在签约七月份之后判断是否已经生效,判断是否有旧数据
            List<SignFamily> signFamilys1 = jdbcTemplate.queryForList(signSql, SignFamily.class);
            List<Map<String,Object>> signFamilys1 = jdbcTemplate.queryForList(signSql);
            if (signFamilys1 != null && signFamilys1.size() > 0) {
                rs.put("mes", "当前年度已经签约");
                rs.put("code", "-2");
                return rs;
            }
            List<SignFamily> signFamilys2 = jdbcTemplate.queryForList(oldSignSql, SignFamily.class);
            if (signFamilys1 != null && signFamilys1.size() > 0) {
            List<Map<String,Object>> signFamilys2 = jdbcTemplate.queryForList(oldSignSql);
            if (signFamilys2 != null && signFamilys2.size() > 0) {
                rs.put("mes", "可以续签(已到期)");
                rs.put("code", "2");
                return rs;
@ -474,4 +474,5 @@ public class PatientService extends TokenService {
        return "";
    }
}

+ 10 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -755,4 +755,14 @@ public class DateUtil {
		}
		return date;
	}
	public static int getNowMonth(){
		Calendar cal = Calendar.getInstance();
		return cal.get(Calendar.MONTH)+1;
	}
	public static int getNowYear(){
		Calendar cal = Calendar.getInstance();
		return cal.get(Calendar.YEAR);
	}
}

+ 30 - 18
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java

@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.service.app.account.PatientInfoService;
@ -211,6 +212,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.getPatientByLable(doctorcode, labelType, level, team);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -253,6 +255,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            map.put("patients",listNum);
            return write(200, "查询成功", "data", map);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -510,7 +513,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    error(e);
                }
            }
@ -746,7 +749,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
//                    }
//                }
            } catch (Exception e) {
                e.printStackTrace();
                error(e);
            }
            result = familyContractService.getSanshiSingInfoByPatientIdCard(idCard);
@ -758,6 +761,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
@ -796,6 +800,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return write(-1, "不存在该患者签约");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "更新失败");
        }
    }
@ -834,12 +839,12 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                // 设置患者联系电话
                json.put("phone", temp.getPhone());
                // 设置患者居住省份
                json.put("provinceName", temp.getProvinceName());
                json.put("cityName", temp.getCityName());
                json.put("townName", temp.getTownName());
                json.put("streetName", temp.getStreetName());
                json.put("provinceName", temp.getProvinceName()==null?"":temp.getProvinceName());
                json.put("cityName", temp.getCityName()==null?"":temp.getCityName());
                json.put("townName", temp.getTownName()==null?"":temp.getTownName());
                json.put("streetName", temp.getStreetName()==null?"":temp.getStreetName());
                // 设置患者地址
                json.put("address", temp.getAddress());
                json.put("address", temp.getAddress()==null?"":temp.getAddress());
                //设置患者医保号
                json.put("ssc", temp.getSsc());
@ -866,7 +871,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "患者信息查询失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "患者信息查询失败");
        }
    }
@ -937,7 +942,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "患者信息查询失败!");
            }
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "患者信息查询失败");
        }
    }
@ -970,6 +975,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功", "data", json);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -995,7 +1001,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            return write(200, "查询成功", "data", new JSONObject(signFamily));
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1029,6 +1035,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            return write(200, "更新成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "更新失败");
        }
    }
@ -1112,7 +1119,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findNoHealthSignFamilyHealth(getUID(), labelType, patientName, teamCode);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1132,6 +1139,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findNoHealthSignFamilyHealthByParams(getUID(), teamCode, params);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1151,6 +1159,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject list = familyContractService.findByParamsWithDoctor(doctor, teamCode, params, level);
            return write(200, "签约数据加载成功!", "data", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1175,7 +1184,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1246,7 +1255,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1271,6 +1280,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.isPatientAndDoctorExistSign(patient, doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1295,7 +1305,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.isPatientAndDoctorCanSign(patient, doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1316,6 +1326,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientDoctors(patient, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1336,6 +1347,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getTeamDoctors(sessionId, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1354,7 +1366,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientSignDoctors(patient);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1372,7 +1384,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientSignDoctorsByTeam(sessionId);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1389,7 +1401,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            JSONObject result = familyContractService.getPatientAndDoctorTeams(patient, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -1457,7 +1469,7 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }

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

@ -444,12 +444,25 @@ public class DoctorSignController extends WeixinBaseController {
    @RequestMapping("/agreeRenew")
    @ApiOperation(value = "医生处理签约")
    public String agreeRenew(@RequestParam(required = true)String state,
                             @RequestParam(required = true)String patient){
                             @RequestParam(required = true)String patient,
                             @RequestParam(required = false) Long mesId ){
        try{
            int rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state);
            Calendar cal = Calendar.getInstance();
            int year = cal.get(Calendar.YEAR);
            int month = cal.get(Calendar.MONTH)+1;
            int rs = 0;
            if(month<7){
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"");
//            int rs =signWebService.agreeRenew(getAccessToken(),"test00000000005",patient,state);
            }else{
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"");
                //如果没有续签记录,走签约记录
                if(rs==0){
                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"");
                }
            }
            if(rs == 0){
                return error(-1, "操作失败");
                return  write(200, "未找到签约记录", "data", rs);
            }else{
                return write(200, "操作成功!", "data", rs);
            }

+ 13 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -313,6 +313,19 @@ public class AdminTeamController extends BaseController {
        }
    }
    @RequestMapping(value = "/teams/info", method = RequestMethod.GET)
    @ApiOperation(value = "查询机构下的团队")
    public String getTeamInfo( @RequestParam(value = "teamId", defaultValue = "0", required = true) int teamId){
        try{
            JSONObject result =  teamService.getTeamInfo(teamId);
            return write(200,"查询成功","data",result);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/teams/{hospital}", method = RequestMethod.GET)
    @ApiOperation(value = "查询机构下的团队")
    public String getHospitalTeams(@PathVariable  String hospital){

+ 53 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.service.common.account.*;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.DateUtil;
@ -17,11 +18,13 @@ import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
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.http.CacheControl;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -30,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.net.URLDecoder;
import java.util.Calendar;
import java.util.List;
/**
@ -52,6 +56,8 @@ public class FamilyContractController extends BaseController {
    private FamilyService familyService;
    @Autowired
    private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
    @Autowired
    private SignWebService signWebService;
    /**
     * 得到患者的签约的医生的信息
@ -73,6 +79,20 @@ public class FamilyContractController extends BaseController {
        }
    }
    @RequestMapping(value = "getSignMessageOverdue")
    @ResponseBody
    public String getSignDoctorMessageOverDue(String patientCode) {
        try {
            JSONArray array = familyContractService.getSignDoctorMessageOverDue(patientCode);
            return write(200, "获取列表成功!", "list", array);
        } catch (Exception e) {
            error(e);
            return error(-1, "获取列表失败!");
        }
    }
    /**
     * 社区医院列表查询接口
@ -459,6 +479,7 @@ public class FamilyContractController extends BaseController {
                return write(200, "签约申请成功");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "签约申请失败");
        }
    }
@ -478,8 +499,15 @@ public class FamilyContractController extends BaseController {
            if (StringUtils.isEmpty(doctor)) {
                return error(-1, "签约医生不能为空");
            }
            Calendar cal = Calendar.getInstance();
            int month = cal.get(Calendar.MONTH)+1;
            int result = -1;
            if(month<7){
                result = familyContractService.signRenew(doctor,healthDoctor,patient);
            }else{
                result = familyContractService.signRenewOverdue(doctor,healthDoctor,patient);
            }
            int result = familyContractService.signRenew(doctor,healthDoctor,patient);
            if (result == -1) {
                return error(-1, "用户信息查询失败");
@ -495,6 +523,7 @@ public class FamilyContractController extends BaseController {
                return write(200, "签约申请成功");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "签约申请失败");
        }
    }
@ -624,7 +653,7 @@ public class FamilyContractController extends BaseController {
            JSONObject result = familyContractService.isPatientAndDoctorExistSign(getUID(), doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -645,6 +674,7 @@ public class FamilyContractController extends BaseController {
            JSONObject result = familyContractService.isPatientAndDoctorCanSign(getUID(), doctor);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
@ -661,7 +691,28 @@ public class FamilyContractController extends BaseController {
            JSONObject result = patientService.checkCanSignRenew(patient);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     *
     *统计
     * 咨询量、获取待预约、获取健康教育、获取健康指导
     * @return
     */
    @RequestMapping("/getSignCountInfoInYear")
    @ApiOperation(value = "统计咨询量、获取待预约、获取健康教育、获取健康指导")
    @ResponseBody
    public String getSignCountInfoInYear(@RequestParam(required = true)String patient){
        try{
            JSONObject rs =signWebService.getSignCountInfoInYear(patient);
            //JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
            return write(200, "操作成功!", "data", rs);
        }catch (Exception e){
            error(e);
            return error(-1, "请求失败");
        }
    }
}

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

@ -247,6 +247,7 @@ public class PatientSignController extends BaseController {
			return write(200, "查询成功!", "list", jsonArray);
		} catch (Exception ex) {
			error(ex);
			return error(-1, "系统错误,请联系管理员!");
		}
	}
@ -256,6 +257,7 @@ public class PatientSignController extends BaseController {
			JSONObject resultObj = signWebService.getSignInfo(teamCode);
			return write(200, "查询成功!", "data", resultObj);
		} catch (Exception ex) {
			error(ex);
			return error(-1, "系统错误,请联系管理员!");
		}
	}
@ -266,6 +268,7 @@ public class PatientSignController extends BaseController {
			JSONObject resultObj = signWebService.getSignServiceInfo(teamCode);
			return write(200, "查询成功!", "data", resultObj);
		} catch (Exception ex) {
			error(ex);
			return error(-1, "系统错误,请联系管理员!");
		}
	}
@ -277,7 +280,7 @@ public class PatientSignController extends BaseController {
			//JSONArray jsonArray  = signWebService.getSigns("915cc456-5b1d-11e6-8344-fa163e8aee56");
			return write(200, "查询成功!", "data", jsonArray);
		} catch (Exception ex) {
			ex.printStackTrace();
			error(ex);
			return error(-1, "系统错误,请联系管理员!");
		}
	}