trick9191 %!s(int64=8) %!d(string=hai) anos
pai
achega
ca38641cca

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

@ -16,7 +16,7 @@ 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);
    List<SignFamilyRenew> findByIdcard(String idcard);
    /**
     * 获取所有有效的签约信息(不包含-1 -2)

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

@ -99,6 +99,9 @@ public class FamilyContractService extends BaseService {
    MessageService messageService;
    @Autowired
    AdminTeamService adminTeamService;
    @Autowired
    SignPatientLabelDao labelDao;
    @Autowired
@ -2882,15 +2885,16 @@ public class FamilyContractService extends BaseService {
     * @param patient 居民code
     * @return
     */
    @Transactional
    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());
        List<SignFamilyRenew> sc = signFamilyRenewDao.findByIdcard(p.getIdcard());
        //判断身份证号是否已签约
        if (sc != null) {
        if (sc != null&&sc.size()>0) {
            return -2;
        }
@ -2900,25 +2904,96 @@ public class FamilyContractService extends BaseService {
        if (d == null) {
            return -3;
        }
        if (hd == null) {
            return -3;
        }
        SignFamilyRenew sf = new SignFamilyRenew();
        //判断是否有生效记录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'";
        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"));
            sf.setAdminTeamId((Long)sign.get("adminTeamId"));
        }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());
        }
        sf.setDoctor(doctor);
        sf.setDoctorName(d.getName());
        sf.setDoctorHealth(healthDoctor);
        sf.setDoctorHealthName(hd.getName());
        if(hd!=null){
            sf.setDoctorHealth(healthDoctor);
            sf.setDoctorHealthName(hd.getName());
        }
        sf.setMobile(p.getMobile());
        sf.setName(p.getName());
        sf.setIdcard(p.getIdcard());
@ -2933,8 +3008,12 @@ 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());
        sf.setEnd(DateUtil.stringToDate(year+1+"-07-01 00:00:00","yyyy-MM-dd HH:mmm:ss"));
        SignFamilyRenew temp = signFamilyRenewDao.save(sf);
        if (temp != null) {

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

@ -931,7 +931,7 @@ public class SignWebService extends BaseService {
     * @return
     */
    public JSONObject getRenewYearCount(String doctorCode){
        StringBuffer sql = new StringBuffer("SELECT t.sign_year,COUNT(1) count " +
        StringBuffer sql = new StringBuffer("SELECT t.sign_year labelCode,COUNT(1) amount " +
                "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();

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

@ -17,10 +17,12 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.task.SignSsGetTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -31,6 +33,8 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.utils.Clock;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -58,6 +62,8 @@ public class PatientService extends TokenService {
    JdbcTemplate jdbcTemplate;
    private Clock clock = Clock.DEFAULT;
    //可续签月份
    private int[] canRenewMonth = {4, 5, 6, 7};
    public void setClock(Clock clock) {
        this.clock = clock;
@ -214,7 +220,7 @@ public class PatientService extends TokenService {
                " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE idcard = ?";
        jdbcTemplate.update(sql, new Object[]{code, idcard, name, ssc, mobile, password, salt, imei, 1, ie.getBirthday()
                , ie.getGender(), clock.getCurrentDate(),clock.getCurrentDate(), 0, 0, 0, 0,idcard});
                , ie.getGender(), clock.getCurrentDate(), clock.getCurrentDate(), 0, 0, 0, 0, idcard});
        Patient temp = patientDao.findByIdcard(idcard);
        if (temp != null) {
@ -299,10 +305,11 @@ public class PatientService extends TokenService {
    /**
     * 判断是否续签
     *
     * @param patient
     * @return
     */
    public JSONObject checkCanRenew(String patient){
    public JSONObject checkCanRenew(String patient) {
        // 是否可以续签逻辑
        //A:wlyy_sign_family
        //B: wlyy_sign_family_renew
@ -311,60 +318,158 @@ 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+"'  AND NOW() >= t.begin AND NOW() <= t.end",SignFamily.class);
        if(signs!=null){
        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");
        }else{
            rs.put("issign", "1");
        } else {
            //当前年度未签约
            rs.put("issign","0");
            rs.put("issign", "0");
        }
        //A表有已签约,但还没有扣费的记录的,不允许续签
        List<SignFamily>  signFamilys1 = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status <>'1' AND t.patient ='"+patient+"'",SignFamily.class);
        if(signFamilys1!=null){
            rs.put("isrenew","0");
        List<SignFamily> signFamilys1 = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status <>'1' AND t.patient ='" + patient + "'", SignFamily.class);
        if (signFamilys1 != null) {
            rs.put("isrenew", "0");
            return rs;
        }
        //A表有已签约,且已扣费,当前日期超过了7月1日,且当前日期在合约的有效期范围内,不允许续签
        Calendar calendar =Calendar.getInstance();
        String year = calendar.get(Calendar.YEAR)+"";
        List<SignFamily>  signFamilys2 = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status ='1' AND  t.patient ='"+patient+"' AND CURDATE()>'"+year+"-07-01' NOW() >= t.begin and NOW() <= t.end",SignFamily.class);
        if(signFamilys2!=null){
            rs.put("isrenew","0");
        Calendar calendar = Calendar.getInstance();
        String year = calendar.get(Calendar.YEAR) + "";
        List<SignFamily> signFamilys2 = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family t WHERE t.status >=0 AND t.expenses_status ='1' AND  t.patient ='" + patient + "' AND CURDATE()>'" + year + "-07-01' NOW() >= t.begin and NOW() <= t.end", SignFamily.class);
        if (signFamilys2 != null) {
            rs.put("isrenew", "0");
            return rs;
        }
        //B表:已签约且未生效,不允许续签
        List<SignFamilyRenew> signFamilyRenews = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family_renew t WHERE t.status>=0 AND  t.is_valid = 0 AND t.patient ='"+patient+"'",SignFamilyRenew.class);
        if(signFamilyRenews!=null){
            rs.put("isrenew","0");
        List<SignFamilyRenew> signFamilyRenews = jdbcTemplate.queryForList("SELECT t.id FROM wlyy_sign_family_renew t WHERE t.status>=0 AND  t.is_valid = 0 AND t.patient ='" + patient + "'", SignFamilyRenew.class);
        if (signFamilyRenews != null) {
            rs.put("isrenew", "0");
            return rs;
        }
        //都未有记录则允许续签
        rs.put("isrenew","1");
        rs.put("isrenew", "1");
        return rs;
    }
    /**
     * 判断是否可以续签
     * @param patient
     * @return
     */
    public JSONObject checkCanSignRenew(String patient) {
        JSONObject rs = new JSONObject();
        //得到当前年度,和当前月份,年度
        Calendar cal = Calendar.getInstance();
        int month = cal.get(Calendar.MONTH) + 1;
        int year = cal.get(Calendar.YEAR);
        //判断是否在续签允许的范围内
        boolean flag = false;
        for (int i = 0; i < canRenewMonth.length; i++) {
            if (month == canRenewMonth[i]) {
                flag = true;
                break;
            }
        }
        if (!flag) {
            rs.put("mes", "当前时间段不允许续签");
            rs.put("code", "-1");
            return rs;
        }
        //判断是否有生效记录SQL
        String sql = "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'";
        //用于判断续签表是否有记录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 + "'";
        //判读是否有旧的已到期记录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之前
        if (month < 7) {
            //判断是否有签约记录
            List<SignFamily> signFamilys1 = jdbcTemplate.queryForList(sql, SignFamily.class);
            if (signFamilys1 != null && signFamilys1.size() > 0) {
                //如果有记录则判断其年份是否为当前年份,如果为当前年份,不允许续签
                SignFamily sign = signFamilys1.get(0);
                if (StringUtils.isNotBlank(sign.getSignYear())) {
                    int y = Integer.parseInt(sign.getSignYear());
                    if (y == year) {
                        rs.put("mes", "当前年度已经签约");
                        rs.put("code", "-2");
                        return rs;
                        //如果不等于当前年份,则判断续签表是否有数据
                    } else {
                        return checkRenewData(sqlRenew,rs);
                    }
                } else {
                    rs.put("mes", "签约记录为脏数据");
                    rs.put("code", "0");
                    return rs;
                }
            } else {
                //没有签约记录,不允许续签,提示前往签约
                rs.put("mes", "没有签约记录,请前往签约");
                rs.put("code", "-4");
                return rs;
            }
        } else {
            //如果在签约七月份之后判断是否已经生效,判断是否有旧数据
            List<SignFamily> signFamilys1 = jdbcTemplate.queryForList(signSql, SignFamily.class);
            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) {
                rs.put("mes", ",可以续签(已到期)");
                rs.put("code", "2");
                return rs;
            } else {
                rs.put("mes", "没有签约记录,请前往签约");
                rs.put("code", "-4");
                return rs;
            }
        }
    }
    public JSONObject checkRenewData(String sqlRenew,JSONObject rs){
        List<SignFamilyRenew> renews = jdbcTemplate.queryForList(sqlRenew, SignFamilyRenew.class);
        //如果续签表没有数据,则可以续签,有数据提示已经续签
        if (renews != null && renews.size() > 0) {
            rs.put("mes", "已经提交续签");
            rs.put("code", "-3");
            return rs;
        } else {
            rs.put("mes", ",可以续签(未到期)");
            rs.put("code", "1");
            return rs;
        }
    }
    /**
     * 根据居民ID查询签约CODE
     *
     * @param patient
     * @return
     */
    public String getSignCodeByPatient(String patient){
    public String getSignCodeByPatient(String patient) {
        if(StringUtils.isBlank(patient)){
        if (StringUtils.isBlank(patient)) {
            return "";
        }
        try{
            List<SignFamily> signFamilies = jdbcTemplate.queryForList("SELECT * FROM wlyy_sign_family WHERE t.patient = '"+patient+"' AND t.status >=0 AND t.expenses_status ='1' ",SignFamily.class);
            if(signFamilies!=null && signFamilies.size()>0){
        try {
            List<SignFamily> signFamilies = jdbcTemplate.queryForList("SELECT * FROM wlyy_sign_family WHERE t.patient = '" + patient + "' AND t.status >=0 AND t.expenses_status ='1' ", SignFamily.class);
            if (signFamilies != null && signFamilies.size() > 0) {
                return signFamilies.get(0).getCode();
            }
        }catch (Exception e){
        } catch (Exception e) {
            return "";
        }
        return "";
    }
}

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

@ -1,6 +1,7 @@
package com.yihu.wlyy.util;
import java.sql.Time;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@ -735,4 +736,23 @@ public class DateUtil {
//
		System.out.println(getNextYear(new Date(), -65));
	}
	/**
	 *  字符串转时间
	 * @param str 时间字符串
	 * @param eg 格式
	 * @return
	 */
	public static Date stringToDate(String str, String eg) {
		DateFormat format = new SimpleDateFormat(eg);
		Date date = null;
		if (str != null && !"".equals(str)) {
			try {
				date = format.parse(str);
			} catch (Exception e) {
				return null;
			}
		}
		return date;
	}
}

+ 16 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -25,6 +26,8 @@ public class SignPatientLabelInfoController extends BaseController {
    @Autowired
    SignPatientLabelInfoService labelInfoService;
    @Autowired
    SignWebService signWebService;
    /**
     * 根据姓名,地址,身份证号搜索团队内居民
@ -147,6 +150,12 @@ public class SignPatientLabelInfoController extends BaseController {
            }
            page = page - 1;
            if(labelType.equals("9")){
                JSONObject jsonObject = signWebService.getOverDuePatients(labelCode,getUID(),page,pagesize);
                return write(200, "查询成功", "data", jsonObject);
            }
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
@ -235,6 +244,13 @@ public class SignPatientLabelInfoController extends BaseController {
                teamCode = 0L;
            }
            //计算年度数目
            if(labelType.equals("9")){
                JSONObject r= signWebService.getRenewYearCount(getUID());
                return write(200, "查询成功", "data", r);
            }
            JSONArray result = labelInfoService.getPatientAmountByLabelType(getUID(), labelType, teamCode);
            return write(200, "查询成功", "data", result);

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

@ -488,8 +488,8 @@ public class DoctorSignController extends WeixinBaseController {
    @ApiOperation(value = "获取年度分组")
    public String getRenewYearCount(){
        try{
            //JSONObject rs =signWebService.getRenewYearCount(getUID());
            JSONObject rs =signWebService.getRenewYearCount("64de930c-5b15-11e6-8344-fa163e8aee56");
            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, "请求失败");

+ 5 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -487,6 +487,10 @@ public class FamilyContractController extends BaseController {
                return error(-1, "用户已存在签约");
            } else if (result == -3) {
                return error(-1, "医生信息查询失败");
            } else if (result == -4) {
                return error(-1, "未找到有效签约记录");
            } else if (result == -5) {
                return error(-1, "未找到有效团队记录");
            } else {
                return write(200, "签约申请成功");
            }
@ -654,7 +658,7 @@ public class FamilyContractController extends BaseController {
    @ResponseBody
    public String checkCanRenew(@RequestParam(required = true) String patient){
        try {
            JSONObject result = patientService.checkCanRenew(patient);
            JSONObject result = patientService.checkCanSignRenew(patient);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");