Explorar el Código

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

huangwenjie hace 7 años
padre
commit
6d50dccd1d
Se han modificado 39 ficheros con 2526 adiciones y 237 borrados
  1. 122 3
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java
  2. 4 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/util/RSAUtils.java
  3. 2 1
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  4. 2 2
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  5. 1 1
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorFeldsherTemplateController.java
  6. 22 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/RenewSignDataFilter.java
  7. 32 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/model/RenewCacheModel.java
  8. 243 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java
  9. 416 83
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  10. 1 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignServerTypeJob.java
  11. 1 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/WechatCountJob.java
  12. 116 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignOrgOutServerJob.java
  13. 115 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignOrgServerJob.java
  14. 115 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignServerJob.java
  15. 114 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTeamOutServerJob.java
  16. 113 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTeamServerJob.java
  17. 113 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTownOutServerJob.java
  18. 113 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTownServerJob.java
  19. 132 13
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  20. 72 64
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  21. 16 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  22. 20 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  23. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  24. 137 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java
  25. 66 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  26. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java
  27. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  28. 10 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  29. 11 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  30. 237 16
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  31. 3 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  32. 9 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  33. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  34. 8 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  35. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  36. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  37. 5 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/GcLoginController.java
  38. 98 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java
  39. 32 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinTempMsgSendUtils.java

+ 122 - 3
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java

@ -117,11 +117,11 @@ public class DoctorFeldsherTemplateService extends BaseService {
            Doctor doctor = doctorDao.findByCode(doctorCode);
            String doctorName = doctor.getName();
            String doctorOpenId = doctor.getOpenid();
            businessType = parseBusinessType(businessType);
            JSONObject sendJson = weiXinTempMsgSendUtils.packageTemplate(businessType, remark, content, dateFormat.format(new Date()));
            Boolean flag = weiXinTempMsgSendUtils.sendTemplateMessage(templateId, doctorOpenId, url, sendJson);
            logger.info("send wechat message param : " + doctorOpenId+" =======> "+content);
            logger.info("send wechat message retuen : " + flag+" =======> "+flag);
            logger.info("send wechat message param : " + doctorOpenId + " =======> " + content);
            logger.info("send wechat message retuen : " + flag + " =======> " + flag);
            logger.info("sendJson: " + sendJson);
            return true;
        } catch (Exception e) {
@ -129,4 +129,123 @@ public class DoctorFeldsherTemplateService extends BaseService {
            return false;
        }
    }
    /**
     * 解析businessType
     *
     * @param businessType 消息类型
     * @return
     */
    private String parseBusinessType(String businessType) {
        try {
            switch (businessType) {
                case "SYSTEM":
                    businessType = "系统消息";
                    break;
                case "P_FU_01":
                    businessType = "随访计划, 您有新的随访计划";
                    break;
                case "P_FU_02":
                    businessType = "随访提醒, 您有新的随访提醒";
                    break;
                case "P_HG_01":
                    businessType = "健康指导, 您有新的健康指导";
                    break;
                case "P_SI_01":
                    businessType = "体测提醒, 您有新的体测提醒";
                    break;
                case "P_IS_01":
                    businessType = "检查检验, 您有新的检查检验建议";
                    break;
                case "P_MG_01":
                    businessType = "用药指导, 您有新的用药指导";
                    break;
                case "P_MR_01":
                    businessType = "病历夹, 您有新的病历记录";
                    break;
                case "P_R_01":
                    businessType = "预约挂号";
                    break;
                case "P_HE_01":
                    businessType = "健康教育, 您有新的健康教育";
                    break;
                case "P_SW_01":
                    businessType = "家庭签约, 家庭签约已申请通过";
                    break;
                case "P_SW_02":
                    businessType = "家庭签约, 医生申请解除家庭签约";
                    break;
                case "P_SW_03":
                    businessType = "家庭签约, 医生已同意您解除家庭签约申请";
                    break;
                case "P_SW_04":
                    businessType = "家庭签约, 医生拒绝解除家庭签约申请";
                    break;
                case "P_CT_01":
                    businessType = "三师咨询, 医生回复了您";
                    break;
                case "P_CP_01":
                    businessType = "公共咨询, 医生回复了您";
                    break;
                case "P_CC_01":
                    businessType = "病友圈, 您有新的回复内容";
                    break;
                case "P_HN_01":
                    businessType = "健康资讯, 您有新的健康资讯";
                    break;
                case "D_CT_01":
                    businessType = "指定咨询, 您有新的指定咨询";
                    break;
                case "D_CT_02":
                    businessType = "名医咨询, 您有新的消息";
                    break;
                case "D_CT_03":
                    businessType = "名医咨询, 您有新的名医咨询";
                    break;
                case "D_CT_04":
                    businessType = "名医咨询, 您有新的名医咨询";
                    break;
                case "D_CT_05":
                    businessType = "续方咨询, 您有新的续方咨询";
                    break;
                case "D_SW_01":
                    businessType = "家庭签约";
                    break;
                case "D_SW_02":
                    businessType = "家庭签约, 患者申请解除家庭签约";
                    break;
                case "D_SW_03":
                    businessType = "家庭签约, 患者同意您的解除家庭签约申请";
                    break;
                case "D_SW_04":
                    businessType = "家庭签约, 患者拒绝您的解除家庭签约申请";
                    break;
                case "D_CV_01":
                    businessType = "视频咨询, 您有新的视频咨询";
                    break;
                case "D_FU_01":
                    businessType = "随访计划, 患者已完成随访计划";
                    break;
                case "D_FU_02":
                    businessType = "随访计划";
                    break;
                case "D_FU_03":
                    businessType = "随访计划";
                case "D_FU_04":
                    businessType = "随访计划, 患者已提交随访内容";
                case "D_HI_01":
                    businessType = "体征指标";
                case "D_P_WRD":
                    businessType = "续方消息, 待取药";
                    break;
                default:
                    businessType = "您有一条新的消息";
                    break;
            }
            return businessType;
        } catch (Exception e) {
            e.printStackTrace();
            return businessType;
        }
    }
}

+ 4 - 0
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/util/RSAUtils.java

@ -376,4 +376,8 @@ public class RSAUtils {
            e.printStackTrace();
        }
    }
    public void setBaseService(BaseService baseService) {
        this.baseService = baseService;
    }
}

+ 2 - 1
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -312,7 +312,8 @@ public class LoginController extends BaseController {
            if (type == 2) {
                // 医生端
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                rsaUtils.setBaseService(doctorService);
                String password = rsaUtils.decryptString(newpwd);
                password = StringUtils.reverse(password);
                password = MD5.GetMD5Code(password + doctor.getSalt());
                doctor.setPassword(password);

+ 2 - 2
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -1284,10 +1284,10 @@ public class DoctorController extends BaseController {
                    return error(-1, "身份证号与姓名不一致,请检查后重新输入");
                }
                if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0 && ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
                    return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
                    return error(-1, "您的社保卡不支持线上签约,请到社区卫生服务中心办理线下签约");
                }
            } else {
                return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
                return error(-1, "您的社保卡不支持线上签约,请到社区卫生服务中心办理线下签约");
            }
            return write(200, "查询成功!");
        } catch (Exception ex) {

+ 1 - 1
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorFeldsherTemplateController.java

@ -36,7 +36,7 @@ public class DoctorFeldsherTemplateController extends BaseController {
     * @param content      消息内容
     * @return
     */
    @RequestMapping(value = "/sendDoctorTemplate", method = RequestMethod.GET)
    @RequestMapping(value = "/sendDoctorTemplate", method = RequestMethod.POST)
    @ApiOperation(value = "医生助手给医生发送模板消息")
    public String sendDoctorTemplate(@RequestParam @ApiParam(value = "医生code") String doctorCode,
                                     @RequestParam @ApiParam(value = "会话Id", required = false) String sessionId,

+ 22 - 1
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/RenewSignDataFilter.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.statistics.etl.model.LogModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.model.hosptial.Hospital;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
@ -291,7 +292,7 @@ public class RenewSignDataFilter {
    /**
     * 得到二级维度的key
     * 1:性别 2:年龄 3:分组 4:费用 5:健康服务分布 6:年龄 7:年龄疾病
     * 1:理由 2:服务类型
     *
     * @param level2Key
     * @return
@ -305,6 +306,9 @@ public class RenewSignDataFilter {
                    returnLevel2Key = getReason(signFamily);
                    return returnLevel2Key;
                }
                case "2": {
                    return getServerType(signFamily);
                }
            }
        }
        return returnLevel2Key;
@ -314,6 +318,23 @@ public class RenewSignDataFilter {
        return signFamily.getRenewChangeReason();
    }
    private String getServerType(SignFamilyRenew signFamily) {
        //获取服务类型
        List<String> serverType = CachePool.getServerType(signFamily.getCode());
        //返回服务类型
        if (serverType != null && serverType.size() > 0) {
            StringBuffer str = new StringBuffer();
            for (int i = 0; i < serverType.size(); i++) {
                str.append(serverType.get(i));
                if (serverType.size() != (i + 1)) {
                    str.append(",");
                }
            }
            return str.toString();
        }
        return "0";
    }
    public FilterModel filterNoTeam(List<SignFamilyRenew> signFamilies, String level2Key, String level3Key, String sql, String filterDate) {
        //查找出系统全部的机构

+ 32 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/model/RenewCacheModel.java

@ -0,0 +1,32 @@
package com.yihu.wlyy.statistics.etl.model;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import java.util.List;
/**
 * Created by Administrator on 2016.10.19.
 * 缓存的model模型
 */
public class RenewCacheModel {
    private List<SignFamilyRenew> signFamilies;//数据
    private String sql;//执行的sql语句
    public List<SignFamilyRenew> getSignFamilies() {
        return signFamilies;
    }
    public void setSignFamilies(List<SignFamilyRenew> signFamilies) {
        this.signFamilies = signFamilies;
    }
    public String getSql() {
        return sql;
    }
    public void setSql(String sql) {
        this.sql = sql;
    }
}

+ 243 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java

@ -3,9 +3,11 @@ package com.yihu.wlyy.statistics.etl.mycache;
import com.yihu.wlyy.statistics.dao.SignPatientLabelInfoDao;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.CacheModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyServer;
import com.yihu.wlyy.statistics.util.SpringUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -29,6 +31,38 @@ public class CachePool {
     */
    private static Map<String, CacheModel> arriveSignFamilyExpenseStatus1Map = new HashMap<String, CacheModel>();
    /**
     * 续签城市达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String, RenewCacheModel> arriveRenewTotalCityMap = new HashMap<String, RenewCacheModel>();
    /**
     * 续签城镇达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String, RenewCacheModel> arriveRenewTotalTownMap = new HashMap<String, RenewCacheModel>();
    /**
     * 续签机构达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String, RenewCacheModel> arriveRenewTotalOrgMap = new HashMap<String, RenewCacheModel>();
    /**
     * 续签团队达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String, RenewCacheModel> arriveRenewTotalTeamMap = new HashMap<String, RenewCacheModel>();
    /**
     * 机构迁出达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String, RenewCacheModel> arriveRenewSignOrgOutMap = new HashMap<String, RenewCacheModel>();
    /**
     * 区迁出达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String, RenewCacheModel> arriveRenewSignTownOutMap = new HashMap<String, RenewCacheModel>();
    /**
     * 团队迁出达量的缓存  key 是时间yyyy-MM-dd
     */
    private static Map<String, RenewCacheModel> arriveRenewSignTeamOutMap = new HashMap<String, RenewCacheModel>();
    /**
     * 分组标签的缓存 key 是患者code
     */
@ -256,4 +290,213 @@ public class CachePool {
            e.printStackTrace();
        }
    }
    /**
     * 获取续签城市达量的缓存
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized RenewCacheModel getArriveRenewTotalCityMapByDate(String date) throws Exception {
        RenewCacheModel model = arriveRenewTotalCityMap.get(date);
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id  from wlyy_sign_family_renew_log fr where " +
                    "   fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(date)+"' " +
                    "   and LENGTH(fr.hospital)=10 " +
                    "   and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class,sql);
            model.setSql(sql);
            model.setSignFamilies(signFamilies);
            arriveRenewTotalCityMap.put(date, model);
            return model;
        } else {
            return model;
        }
    }
    /**
     * 获取续签城镇达量的缓存
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized RenewCacheModel getArriveRenewTotalTownMapByDate(String date) throws Exception {
        RenewCacheModel model = arriveRenewTotalTownMap.get(date);
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'   " +
                    "  and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6) " +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class,sql);
            model.setSql(sql);
            model.setSignFamilies(signFamilies);
            arriveRenewTotalTownMap.put(date, model);
            return model;
        } else {
            return model;
        }
    }
    /**
     * 获取续签机构达量的缓存
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized RenewCacheModel getArriveRenewTotalOrgMapByDate(String date) throws Exception {
        RenewCacheModel model = arriveRenewTotalOrgMap.get(date);
        if (model == null) {
            model = new RenewCacheModel();
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "   fr.apply_date<'"+date+ Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'  " +
                    "  and fr.hospital=fr.old_hospital " +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10";
            //抽取數據
            List<SignFamilyRenew> signFamilies= SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class,sql);
            model.setSql(sql);
            model.setSignFamilies(signFamilies);
            arriveRenewTotalOrgMap.put(date, model);
            return model;
        } else {
            return model;
        }
    }
    /**
     * 获取续签团队达量的缓存
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized RenewCacheModel getArriveRenewTotalTeamMapByDate(String date) throws Exception {
        RenewCacheModel model = arriveRenewTotalTeamMap.get(date);
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id  from wlyy_sign_family_renew_log fr where " +
                    "   fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(date)+"' " +
                    "   and fr.admin_team_id=fr.old_admin_team_id " +
                    "   and LENGTH(fr.hospital)=10 " +
                    "   and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class,sql);
            model.setSql(sql);
            model.setSignFamilies(signFamilies);
            arriveRenewTotalTeamMap.put(date, model);
            return model;
        } else {
            return model;
        }
    }
    /**
     * 获取续签团队迁出达量的缓存
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized RenewCacheModel getArriveRenewSignTeamOutMapByDate(String date) throws Exception {
        RenewCacheModel model = arriveRenewSignTeamOutMap.get(date);
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+ date + Constant.quota_date_last+"'" +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'" +
                    "   and fr.admin_team_id!=fr.old_admin_team_id " +
                    "   and LENGTH(fr.hospital)=10 " +
                    "   and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class,sql);
            model.setSql(sql);
            model.setSignFamilies(signFamilies);
            arriveRenewSignTeamOutMap.put(date, model);
            return model;
        } else {
            return model;
        }
    }
    /**
     * 获取续签机构迁出达量的缓存
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized RenewCacheModel getArriveRenewSignOrgOutMapByDate(String date) throws Exception {
        RenewCacheModel model = arriveRenewSignOrgOutMap.get(date);
        if (model == null) {
            model = new RenewCacheModel();
            String sql="select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+date+ Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'" +
                    "  and fr.hospital!=fr.old_hospital" +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10";
            //抽取數據
            List<SignFamilyRenew> signFamilies= SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class,sql);
            model.setSql(sql);
            model.setSignFamilies(signFamilies);
            arriveRenewSignOrgOutMap.put(date, model);
            return model;
        } else {
            return model;
        }
    }
    /**
     * 获取续签城镇迁出达量的缓存
     *
     * @param date
     * @return
     * @throws Exception
     */
    public synchronized RenewCacheModel getArriveRenewSignTownOutMapByDate(String date) throws Exception {
        RenewCacheModel model = arriveRenewSignTownOutMap.get(date);
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'" +
                    "  and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  " +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class,sql);
            model.setSql(sql);
            model.setSignFamilies(signFamilies);
            arriveRenewSignTownOutMap.put(date, model);
            return model;
        } else {
            return model;
        }
    }
}

+ 416 - 83
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java

@ -141,6 +141,137 @@ public class CurrentDayAllQuotaJob implements Job {
        }
    }
    /**
     * 获取市签约量
     * @return
     */
    public Map<String,Object> getCityRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where  " +
                    " fr.apply_date<'"+ tomorrow+"' and " +
                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
                    " LENGTH(fr.hospital)=10 and " +
                    " LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            Map<String,Object> map = new HashedMap();
            map.put("signFamilies",signFamilies);
            map.put("sql",sql);
            return map;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 获取城镇签约量
     * @return
     */
    public Map<String,Object> getTowmRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where  " +
                    " fr.apply_date<'"+ tomorrow+"' and " +
                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
                    " LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)  and " +
                    " LENGTH(fr.hospital)=10 and " +
                    " LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            Map<String,Object> map = new HashedMap();
            map.put("signFamilies",signFamilies);
            map.put("sql",sql);
            return map;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     *  获取机构签约量
      * @return
     */
    public Map<String,Object> getOrgRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "'and  fr.hospital=fr.old_hospital  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            Map<String,Object> map = new HashedMap();
            map.put("signFamilies",signFamilies);
            map.put("sql",sql);
            return map;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 获取团队机构签约量
     * @return
     */
    public Map<String,Object> getTeamRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            Map<String,Object> map = new HashedMap();
            map.put("signFamilies",signFamilies);
            map.put("sql",sql);
            return map;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public Map<String,Object> getTeamRenewOut(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where    fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            Map<String,Object> map = new HashedMap();
            map.put("signFamilies",signFamilies);
            map.put("sql",sql);
            return map;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public Map<String,Object> getOrgRenewOut(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            Map<String,Object> map = new HashedMap();
            map.put("signFamilies",signFamilies);
            map.put("sql",sql);
            return map;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    public Map<String,Object> getTownRenewOut(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            Map<String,Object> map = new HashedMap();
            map.put("signFamilies",signFamilies);
            map.put("sql",sql);
            return map;
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
    //统计
    private void computequota() throws Exception {
@ -165,52 +296,74 @@ public class CurrentDayAllQuotaJob implements Job {
        //抽取數據
        List<SignFamily> signFamilies = SpringUtil.getBean(DBExtract.class).extractByPage(SignFamily.class, sql, sqlCount, true);
        computequota_1(sql, signFamilies, null); //统计今天的签约
        computequota_2(); //统计今天的解约
        computequota_3(); //统计今天的健康咨询量
        computequota_4(); //统计今天的随访量
        computequota_5(); //统计今天的健康指导
        computequota_6(sql, signFamilies, null); //统计今天的签约患者性别
        computequota_7(sql, signFamilies, null);//统计今天的签约患者分组
        computequota_8(sql, signFamilies, null);//统计今天的签约患者年龄
        computequota_9();//统计今天的待签约
        computequota_10();//统计今天的改签
        computequota_12(sql, signFamilies, null);//统计今天的签约下按年龄分组后再
        computequota_13(sql, signFamilies, null);//统计今天的签约量
        computequota_16_1(sql, signFamilies, null);//统计今天的签约数的扣费钱
        computequota_15(sql, signFamilies, null);//统计今天的健康分布统计
        computequota_17(sql, signFamilies, null);//统计今天的年龄疾病
        computequota_20();//统计今天的已经签约患者绑定设备
        computequota_21();//统计今天的已经签约微信关注人数
        computequota_49();//统计今天的已经签约未扣费微信关注人数
        computequota_50();//统计今天的已经签约已扣费微信关注人数
        computequota_22();//未回复的咨询量
        computequota_23();//及时回复的咨询量
        computequota_24();//及时回复的咨询量时间分布
        computequota_25();//统计质询量总数
        computequota_26();//统计未缴费签约总数
        computequota_27();//统计代预约量
        computequota_28();//统计平均值
        computequota_31(); //统计续签夸团队
        computequota_32(); //统计续签夸社区
        computequota_33(); //统计续签夸区
        computequota_34(); //续签团队签入
        computequota_35(); //统计团队签出
        computequota_36(sql, signFamilies, null); //签约服务类型
        //computequota_37(); //统计团队转签 没用指标
        computequota_38(); //续签机构签入
        computequota_39(); //统计机构签出
        computequota_40(); //续签区签入
        computequota_41(); //统计区签出
        computequota_42(); //统计团队续签
        computequota_43(); //统计社区续签
        computequota_44(); //统计区续签
        computequota_29(); //统计市级续签
        //computequota_45(); //统计社区转签 没用指标
        //computequota_46(); //统计区转签  没用指标
        computequota_30(); //统计团队续签原因
//        computequota_47(); //统计社区续签原因 没用指标
//        computequota_48(); //统计区续签原因 没用指标
        //抽取數據签约数
        Map<String,Object>  citySignFamilies =getCityRenewTotals();
        Map<String,Object>  townSignFamilies =getTowmRenewTotals();
        Map<String,Object>  orgSignFamilies =getOrgRenewTotals();
        Map<String,Object>  teamSignFamilies =getTeamRenewTotals();
        //数据抽取迁出率
        Map<String,Object>  townSignOutFamilies =getTowmRenewTotals();
        Map<String,Object>  orgSignOutFamilies =getOrgRenewTotals();
        Map<String,Object>  teamSignOutFamilies =getTeamRenewTotals();
//        computequota_1(sql, signFamilies, null); //统计今天的签约
//        computequota_2(); //统计今天的解约
//        computequota_3(); //统计今天的健康咨询量
//        computequota_4(); //统计今天的随访量
//        computequota_5(); //统计今天的健康指导
//        computequota_6(sql, signFamilies, null); //统计今天的签约患者性别
//        computequota_7(sql, signFamilies, null);//统计今天的签约患者分组
//        computequota_8(sql, signFamilies, null);//统计今天的签约患者年龄
//        computequota_9();//统计今天的待签约
//        computequota_10();//统计今天的改签
//        computequota_12(sql, signFamilies, null);//统计今天的签约下按年龄分组后再
//        computequota_13(sql, signFamilies, null);//统计今天的签约量
//        computequota_16_1(sql, signFamilies, null);//统计今天的签约数的扣费钱
//        computequota_15(sql, signFamilies, null);//统计今天的健康分布统计
//        computequota_17(sql, signFamilies, null);//统计今天的年龄疾病
//        computequota_20();//统计今天的已经签约患者绑定设备
//        computequota_21();//统计今天的已经签约微信关注人数
//        computequota_49();//统计今天的已经签约未扣费微信关注人数
//        computequota_50();//统计今天的已经签约已扣费微信关注人数
//        computequota_22();//未回复的咨询量
//        computequota_23();//及时回复的咨询量
//        computequota_24();//及时回复的咨询量时间分布
//        computequota_25();//统计质询量总数
//        computequota_26();//统计未缴费签约总数
//        computequota_27();//统计代预约量
//        computequota_28();//统计平均值
//        computequota_31(); //统计续签夸团队
//        computequota_32(); //统计续签夸社区
//        computequota_33(); //统计续签夸区
//        computequota_34(); //续签团队签入
//        computequota_35(teamSignOutFamilies); //统计团队签出
//        computequota_36(sql, signFamilies, null); //签约服务类型
//        //computequota_37(); //统计团队转签 没用指标
//        computequota_38(); //续签机构签入
//        computequota_39(orgSignOutFamilies); //统计机构签出
//        computequota_40(); //续签区签入
//        computequota_41(townSignOutFamilies); //统计区签出
//        computequota_42(teamSignFamilies); //统计团队续签
//        computequota_43(townSignFamilies); //统计社区续签
//        computequota_44(orgSignFamilies); //统计区续签
//        computequota_29(citySignFamilies); //统计市级续签
//        //computequota_45(); //统计社区转签 没用指标
//        //computequota_46(); //统计区转签  没用指标
//        computequota_30(); //统计团队续签原因
////        computequota_47(); //统计社区续签原因 没用指标
////        computequota_48(); //统计区续签原因 没用指标
        //1.3.8需求开发
        computequota_51(citySignFamilies);//统计市级续签服务类型维度
        computequota_52(teamSignFamilies);//统计团队续签人数服务类型维度
        computequota_53(orgSignFamilies);//统计社区续签人数服务类型维度
        computequota_54(townSignFamilies);//统计区续签人数服务类型维度
        computequota_55(teamSignOutFamilies);//统计团队续签迁出人数服务类型维度
        computequota_56(orgSignOutFamilies);//统计社区续签迁出人数服务类型维度
        computequota_57(townSignOutFamilies);//统计区续签迁出人数服务类型维度
        quartzJobLog.setJobContent(allContent.toString());
@ -271,7 +424,7 @@ public class CurrentDayAllQuotaJob implements Job {
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 13, 10, 0);
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
@ -587,6 +740,7 @@ public class CurrentDayAllQuotaJob implements Job {
                    "   p.idcard = sf.idcard " +
                    " AND sf.type = 2 " +
                    " AND sf. STATUS IN (1, 2) " +
                    " AND ( sf.expenses_status =0 or sf.expenses_status =1 )" +
                    " AND p.openid is not null  " +
                    " AND p.openid_time <'" + tomorrow + "' " +
                    " and sf.sign_year ='"+Constant.getNowYearByDate(tomorrow)+"'  ";
@ -1235,15 +1389,11 @@ public class CurrentDayAllQuotaJob implements Job {
        }
    }
    private void computequota_29() {
    private void computequota_29(Map<String,Object>  sign) {
        String quotaId = "29";
        try {
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where  " +
                    " fr.apply_date<'"+ tomorrow+"' and " +
                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
                    " LENGTH(fr.hospital)=10 and " +
                    " LENGTH(fr.old_hospital)=10 "; //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
@ -1258,6 +1408,29 @@ public class CurrentDayAllQuotaJob implements Job {
        allContent.append("-----------29----------");
    }
    private void computequota_51(Map<String,Object>  sign) {
        String quotaId = "51";
        try {
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies,"2",null,sql,"now");
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------51----------");
    }
    private void computequota_30() {
        String quotaId = "30";
        try {
@ -1428,12 +1601,14 @@ public class CurrentDayAllQuotaJob implements Job {
        allContent.append("-----------34----------");
    }
    private void computequota_35() {
    private void computequota_35(Map<String,Object> sign) {
        String quotaId = "35";
        try {
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where    fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where    fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
@ -1447,6 +1622,30 @@ public class CurrentDayAllQuotaJob implements Job {
        }
        allContent.append("-----------35----------");
    }
    private void computequota_55(Map<String,Object> sign) {
        String quotaId = "55";
        try {
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies,"2",null ,sql, "now");
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------55----------");
    }
    private void computequota_38() {
        String quotaId = "38";
        try {
@ -1467,12 +1666,17 @@ public class CurrentDayAllQuotaJob implements Job {
        allContent.append("-----------38----------");
    }
    private void computequota_39() {
    private void computequota_39(Map<String,Object> sign) {
        String quotaId = "39";
        try {
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
@ -1486,6 +1690,31 @@ public class CurrentDayAllQuotaJob implements Job {
        }
        allContent.append("-----------39----------");
    }
    private void computequota_56(Map<String,Object> sign) {
        String quotaId = "56";
        try {
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies,"2",null,sql, "now");
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------56----------");
    }
    public List<Map<String, Object>> getCityTowms() {
        List<Map<String, Object>> map = jdbcTemplate.queryForList(getAvgSqlByCode("city_town_SQL"));
        return map;
@ -1511,12 +1740,14 @@ public class CurrentDayAllQuotaJob implements Job {
        allContent.append("-----------40----------");
    }
    private void computequota_41() {
    private void computequota_41(Map<String,Object> sign) {
        String quotaId = "41";
        try {
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
@ -1531,12 +1762,35 @@ public class CurrentDayAllQuotaJob implements Job {
        allContent.append("-----------41----------");
    }
    private void computequota_42() {
    private void computequota_57(Map<String,Object> sign) {
        String quotaId = "57";
        try {
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies,"2",null, sql, "now");
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------57----------");
    }
    private void computequota_42(Map<String,Object> sign) {
        String quotaId = "42";
        try {
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
@ -1550,12 +1804,14 @@ public class CurrentDayAllQuotaJob implements Job {
        }
        allContent.append("-----------42----------");
    }
    private void computequota_43() {
    private void computequota_43(Map<String,Object> sign) {
        String quotaId = "43";
        try {
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "'and  fr.hospital=fr.old_hospital  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "'and  fr.hospital=fr.old_hospital  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
@ -1569,17 +1825,64 @@ public class CurrentDayAllQuotaJob implements Job {
        }
        allContent.append("-----------43----------");
    }
    private void computequota_44() {
    private void computequota_52(Map<String,Object> sign) {
        String quotaId = "52";
        try {
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, "2",null,sql, "now");
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------52----------");
    }
    private void computequota_53(Map<String,Object> sign) {
        String quotaId = "53";
        try {
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "'and  fr.hospital=fr.old_hospital  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, "2",null,sql, "now");
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------53----------");
    }
    private void computequota_44(Map<String,Object> sign) {
        String quotaId = "44";
        try {
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where  " +
                    " fr.apply_date<'"+ tomorrow+"' and " +
                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
                    " LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)  and " +
                    " LENGTH(fr.hospital)=10 and " +
                    " LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where  " +
//                    " fr.apply_date<'"+ tomorrow+"' and " +
//                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
//                    " LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)  and " +
//                    " LENGTH(fr.hospital)=10 and " +
//                    " LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
@ -1593,6 +1896,36 @@ public class CurrentDayAllQuotaJob implements Job {
        }
        allContent.append("-----------44----------");
    }
    private void computequota_54(Map<String,Object> sign) {
        String quotaId = "54";
        try {
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where  " +
//                    " fr.apply_date<'"+ tomorrow+"' and " +
//                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
//                    " LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)  and " +
//                    " LENGTH(fr.hospital)=10 and " +
//                    " LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            List<SignFamilyRenew> signFamilies = (List<SignFamilyRenew>)sign.get("signFamilies");
            String sql =  (String)sign.get("sql");
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies,"2",null,sql,"now");
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(patientSexRoleData, null, quotaId, 12, 10, 0);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------54----------");
    }
    private void computequota_45() {
        String quotaId = "45";
        try {

+ 1 - 1
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignServerTypeJob.java

@ -100,7 +100,7 @@ public class SignServerTypeJob implements Job {
            List<Map<String, List<ETLModel>>> returnDatas = levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data = level2Role.elt(returnDatas);
            dbStorage.saveByLevel2(level2Data, yesterday, wlyyQuota, 13, 10, 0);
            dbStorage.saveByLevel2(level2Data, yesterday, wlyyQuota, 12, 10, 0);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());

+ 1 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/WechatCountJob.java

@ -96,6 +96,7 @@ public class WechatCountJob implements Job {
                    "   p.idcard = sf.idcard " +
                    " AND sf.type = 2 " +
                    " AND sf. STATUS IN (1, 2) " +
                    " AND (sf.expenses_status =0 or sf.expenses_status =1)" +
                    " AND p.openid is not null  " +
                    " AND p.openid_time <'" +yesterday+ Constant.quota_date_last+"' " +
                    " and sf.sign_year ='"+Constant.getNowYearByDateYeaterday(yesterday)+"'  " ;

+ 116 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignOrgOutServerJob.java

@ -0,0 +1,116 @@
package com.yihu.wlyy.statistics.job.business.signServer;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.job.business.SignJob;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签团队签入服务类型维度的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignOrgOutServerJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))? SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+39+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //抽取數據
            RenewCacheModel cacheModel= cachePool.getArriveRenewSignOrgOutMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),"2",null,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>>  level2Data= level2Role.elt(returnDatas);;
            //保存数据
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,12,10,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 115 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignOrgServerJob.java

@ -0,0 +1,115 @@
package com.yihu.wlyy.statistics.job.business.signServer;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.job.business.SignJob;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
/**
 * 续签的市级指标执行类(服务类型维度)
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignOrgServerJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))? SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标RenewSignTownJob
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+43+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalOrgMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),"2",null,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>>  level2Data= level2Role.elt(returnDatas);;
            //保存数据
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,12,10,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 115 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignServerJob.java

@ -0,0 +1,115 @@
package com.yihu.wlyy.statistics.job.business.signServer;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.CacheModel;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.SignJob;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签的市级指标执行类(服务类型维度)
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignServerJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))? SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+29+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalCityMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),"2",null,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>>  level2Data= level2Role.elt(returnDatas);;
            //保存数据
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,12,10,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 114 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTeamOutServerJob.java

@ -0,0 +1,114 @@
package com.yihu.wlyy.statistics.job.business.signServer;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.job.business.SignJob;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签团队签出服务类型维度的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTeamOutServerJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))? SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+35+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //抽取數據
            RenewCacheModel cacheModel= cachePool.getArriveRenewSignTeamOutMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),"2",null,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>>  level2Data= level2Role.elt(returnDatas);;
            //保存数据
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,12,10,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 113 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTeamServerJob.java

@ -0,0 +1,113 @@
package com.yihu.wlyy.statistics.job.business.signServer;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.job.business.SignJob;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签的团队级指标执行类(服务类型维度)
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTeamServerJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))? SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+42+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalTeamMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),"2",null,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>>  level2Data= level2Role.elt(returnDatas);;
            //保存数据
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,12,10,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 113 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTownOutServerJob.java

@ -0,0 +1,113 @@
package com.yihu.wlyy.statistics.job.business.signServer;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.job.business.SignJob;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签团队签出服务类型的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTownOutServerJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))? SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+41+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //抽取數據
            RenewCacheModel cacheModel= cachePool.getArriveRenewSignTownOutMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),"2",null,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>>  level2Data= level2Role.elt(returnDatas);;
            //保存数据
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,12,10,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 113 - 0
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTownServerJob.java

@ -0,0 +1,113 @@
package com.yihu.wlyy.statistics.job.business.signServer;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.job.business.SignJob;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签的城镇级指标执行类(服务类型维度)
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTownServerJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))? SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+44+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalTeamMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),"2",null,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>>  level2Data= level2Role.elt(returnDatas);;
            //保存数据
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,12,10,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 132 - 13
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.service.app.account;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.wlyy.entity.address.City;
import com.yihu.wlyy.entity.address.Province;
import com.yihu.wlyy.entity.address.Street;
@ -32,8 +34,7 @@ import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.service.third.jw.JwArchivesService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -42,17 +43,14 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.EncodesUtil;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.net.URLDecoder;
import java.util.*;
/**
 * 患者基本信息类.
 *
 * @author George
 * @author George.
 */
@Component
@Transactional
@ -73,8 +71,6 @@ public class PatientInfoService extends BaseService {
    @Autowired
    private TblBasicDao tblBasicDao;
    @Autowired
    private SocialSecurityInfoDao socialSecurityInfoDao;
    @Autowired
    SMSService smsService;
    @Autowired
    SignFamilyDao signFamilyDao;
@ -94,6 +90,10 @@ public class PatientInfoService extends BaseService {
    JwArchivesService jwArchivesService;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    RSAUtils rsaUtils;
    @Autowired
    SocialSecurityInfoDao socialSecurityInfoDao;
    /**
     * 患者更换手机号
@ -339,7 +339,7 @@ public class PatientInfoService extends BaseService {
        Patient p = patientDao.findByCode(patient);
        JSONObject json = new JSONObject();
        com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
        json.put("ARCHIVE_TIME", DateUtil.getStringDateShort());//建档时间
        json.put("ARCHIVE_STATUS","3");//档案状态【1.未管理 2.死亡 3.正常 4.高危】
        json.put("SICK_NAME",p.getName());//姓名
@ -353,14 +353,44 @@ public class PatientInfoService extends BaseService {
        json.put("ORG_ID","0");//新增默认传0
        json.put("RESIDENCE","1");//户籍【1.户籍 2.非户籍】
        json.put("NATIONAL",nation);//民族【NATION_DICT】
        json.put("ORIGO","3502030502");//户口所在地【ZONE_DICT】
        json.put("ORIGO","350200");//户口所在地【ZONE_DICT】
        json.put("BLOOD",blood);//血型【1.A型 2.3.O型4.AB型 5.不详】
        json.put("BLOOD_RH","1");//RH阴性【1.否 2.是 3.不详】
        json.put("MARRIAGE",marry);//婚姻状况【10.未婚 20.已婚 30.丧偶 40.离婚 90.未说明的婚姻状况】
        //补充参数
        json.put("ALLERGIC_WITHOUT","1");//药物过敏史--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("TRAUMA","0");// "TRAUMA":"既往史--外伤--【0 无 1 有】(同一类别,新增时,默认选无)",
        json.put("TRANSFUSION","0");//   "TRANSFUSION":"既往史--输血--【0 无 1 有】(同一类别,新增时,默认选无)",
        json.put("SURGERY","0");// "SURGERY":"既往史--手术--【0 无 1 有】(同一类别,新增时,默认选无)",
        json.put("EXPOSE_WITHOUT","1");//"EXPOSE_WITHOUT":"暴露史--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("FAMILY_FATHER_NONE","1");// "FAMILY_FATHER_NONE":"家族史--父亲--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("FAMILY_MOTHER_NONE","1");// "FAMILY_MOTHER_NONE":"家族史--母亲--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("FAMILY_BROTHERS_NONE","1");//  "FAMILY_BROTHERS_NONE":"家族史--兄弟姐妹--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("FAMILY_CHILDREN_NONE","1");//  "FAMILY_CHILDREN_NONE":"家族史--子女--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("GENETIC","0");//  "GENETIC":"遗传病史【0 无 1 有】(同一类别,新增时,默认选无)",
        json.put("DISABILITY_WITHOUT","1");//  "DISABILITY_WITHOUT":"有无残疾--无残疾【0不勾选 1勾选】(同一类别,新增时,默认勾选)",
        json.put("PAST_NONE","1");//  既往史--疾病--无【0不勾选 1勾选】(同一类别,新增时,默认勾选)
        String doctor = doctorCode;
        String response = jwArchivesService.saveSickArchiveRecord(json.toString(),doctor);
        String response = jwArchivesService.saveSickArchiveRecord(com.alibaba.fastjson.JSONObject.toJSONString(json, SerializerFeature.WriteMapNullValue),doctor);
        if("0".equals(response)){
            return -1;
        }
        //保存建档记录
        SocialSecurityInfo info = new SocialSecurityInfo();
        info.setXming0(p.getName());
        info.setXbie00(p.getSex()+"");
        info.setSfzh18(p.getIdcard());
        info.setId0000(p.getIdcard());
        info.setCardno(p.getSsc());
        info.setCard16(p.getSsc());
        info.setCsrqi0(brithday.replace("-",""));
        info.setGrsfen("8");
        info.setGzztai("01");
        socialSecurityInfoDao.save(info);
        return 1;
    }
@ -383,4 +413,93 @@ public class PatientInfoService extends BaseService {
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql,new Object[]{name});
        return rs;
    }
    public JSONObject checkPatientArchives(String icCard)throws Exception{
        String rs = jwArchivesService.getSickArchiveFlag(icCard);
        SignFamily signFamily =  signFamilyDao.findByIdcard(icCard);
        JSONObject r = new JSONObject();
        int state = 1;
        if("0".equals(rs)){
            //未建档
            state = -1;
            if(signFamily==null){
                state = -3;
                r.put("state",state);
                r.put("mes","未建档且未签约");
                return r;
            }
            r.put("state",state);
            r.put("mes","未建档且已经签约");
            return r;
        }else{
            if(signFamily==null){
                state = -2;
                r.put("state",state);
                r.put("mes","已建档且未签约");
                return r;
            }else{
                r.put("state",state);
                r.put("mes","已建档已签约");
                return r;
            }
        }
    }
    public JSONObject createProfileAndSign(String doctorCode,
                                           String idcard,
                                           String ssc,
                                           String name,
                                           String mobile,
                                           String brithday,
                                           String jwCountryCode,
                                           String nation,
                                           String blood,
                                           String marry,
                                           String adress)throws Exception{
        JSONObject rs = new  JSONObject();
        // 解密身份证号
        rsaUtils.setBaseService(patientService);
        idcard = rsaUtils.decryptString(idcard);
        idcard = URLDecoder.decode(idcard, "UTF-8");
        idcard = StringUtils.reverse(idcard);
        // 校验身份证号
        IdcardValidator validator = new IdcardValidator();
        if (validator.isValidatedAllIdcard(idcard)) {
            if (idcard.length() == 15) {
                idcard = validator.convertIdcarBy15bit(idcard);
                if (StringUtils.isEmpty(idcard)) {
                    rs.put("code","-1");
                    rs.put("mes","身份证格式不正确!") ;
                    return rs;
                }
            }
        } else {
            rs.put("code","-1");
            rs.put("mes","身份证格式不正确!") ;
            return rs;
        }
        if(mobile.length()!=11){
            rs.put("code","-2");
            rs.put("mes","手机格式不正确!") ;
            return rs;
        }
        String salt = UUID.randomUUID().toString().replace("-", "");
        String password = idcard.substring(idcard.length()-6,idcard.length());
        password = MD5.GetMD5Code(password + salt);
        Patient p = patientService.registerAPPBydoctor(idcard,ssc,name,mobile,password,salt,salt,3);
        createProfile(doctorCode,p.getCode(), brithday, jwCountryCode, nation, blood, marry,adress);
        rs.put("code","1");
        rs.put("mes","操作成功!") ;
        return rs;
    }
}

+ 72 - 64
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -4506,85 +4506,93 @@ public class SignPatientLabelInfoService extends BaseService {
        //1.清空居民标签
        String delSql = " DELETE FROM wlyy_sign_patient_label_info WHERE patient ='"+patient+"'";
        jdbcTemplate.execute(delSql);
        //2.新增健康情况标签
        String healths[] = health.split(",");
        //获取所有健康情况标签
        List<Map<String,Object>> healthList = getLabelsByType("2");
        //减低循环层级
        Map<String,Map<String,Object>> healthMap = new HashedMap();
        for(Map<String,Object> map : healthList){
            String code = (String)map.get("code");
            healthMap.put(code,map);
        }
        if(healths!=null&&healths.length>0){
            for(int i=0;i<healths.length;i++){
                SignPatientLabelInfo info = new SignPatientLabelInfo();
                info.setCzrq(new Date());
                info.setLabelType("2");
                info.setPatient(patient);
                info.setPname(p.getName());
                info.setLabel(healths[i]);
                info.setStatus(1);
                String name = (String)healthMap.get(healths[i]).get("name");
                info.setLabelName(name);
                signPatientLabelInfoDao.save(info);
        //2.新增健康情况标签
        if(StringUtils.isNotBlank(health)){
            String healths[] = health.split(",");
            //获取所有健康情况标签
            List<Map<String,Object>> healthList = getLabelsByType("2");
            //减低循环层级
            Map<String,Map<String,Object>> healthMap = new HashedMap();
            for(Map<String,Object> map : healthList){
                String code = (String)map.get("code");
                healthMap.put(code,map);
            }
            if(healths!=null&&healths.length>0){
                for(int i=0;i<healths.length;i++){
                    SignPatientLabelInfo info = new SignPatientLabelInfo();
                    info.setCzrq(new Date());
                    info.setLabelType("2");
                    info.setPatient(patient);
                    info.setPname(p.getName());
                    info.setLabel(healths[i]);
                    info.setStatus(1);
                    String name = (String)healthMap.get(healths[i]).get("name");
                    info.setLabelName(name);
                    signPatientLabelInfoDao.save(info);
                }
            }
        }
        //2.新增疾病标签
        String diseases[] = disease.split(",");
        //获取所有健康情况标签
        List<Map<String,Object>> diseaseList = getLabelsByType("3");
        //减低循环层级
        Map<String,Map<String,Object>> diseaseMap = new HashedMap();
        for(Map<String,Object> map : diseaseList){
            String code = (String)map.get("code");
            diseaseMap.put(code,map);
        }
        if(StringUtils.isNotBlank(disease)){
            String diseases[] = disease.split(",");
            //获取所有健康情况标签
            List<Map<String,Object>> diseaseList = getLabelsByType("3");
            //减低循环层级
            Map<String,Map<String,Object>> diseaseMap = new HashedMap();
            for(Map<String,Object> map : diseaseList){
                String code = (String)map.get("code");
                diseaseMap.put(code,map);
            }
        if(diseases!=null&&diseases.length>0){
            for(int i=0;i<diseases.length;i++){
                SignPatientLabelInfo info = new SignPatientLabelInfo();
                info.setCzrq(new Date());
                info.setLabelType("3");
                info.setPatient(patient);
                info.setPname(p.getName());
                info.setLabel(diseases[i]);
                String name = (String)diseaseMap.get(diseases[i]).get("name");
                info.setLabelName(name);
                info.setStatus(1);
                signPatientLabelInfoDao.save(info);
            if(diseases!=null&&diseases.length>0){
                for(int i=0;i<diseases.length;i++){
                    SignPatientLabelInfo info = new SignPatientLabelInfo();
                    info.setCzrq(new Date());
                    info.setLabelType("3");
                    info.setPatient(patient);
                    info.setPname(p.getName());
                    info.setLabel(diseases[i]);
                    String name = (String)diseaseMap.get(diseases[i]).get("name");
                    info.setLabelName(name);
                    info.setStatus(1);
                    signPatientLabelInfoDao.save(info);
                }
            }
        }
        //3.新增自定义标签
        String customs[] = custom.split(",");
        //获取所有健康情况标签
        List<Map<String,Object>> customList = getLabelsByType("4");
        //减低循环层级
        Map<String,Map<String,Object>> customMap = new HashedMap();
        for(Map<String,Object> map : customList){
            String code = (String)map.get("code");
            customMap.put(code,map);
        }
        if(StringUtils.isNotBlank(custom)){
            String customs[] = custom.split(",");
            //获取所有健康情况标签
            List<Map<String,Object>> customList = getLabelsByType("4");
            //减低循环层级
            Map<String,Map<String,Object>> customMap = new HashedMap();
            for(Map<String,Object> map : customList){
                String code = (String)map.get("code");
                customMap.put(code,map);
            }
        if(customs!=null&&customs.length>0){
            for(int i=0;i<customs.length;i++){
                SignPatientLabelInfo info = new SignPatientLabelInfo();
                info.setCzrq(new Date());
                info.setLabelType("4");
                info.setPatient(patient);
                info.setPname(p.getName());
                info.setLabel(customs[i]);
                String name = (String)customMap.get(customs[i]).get("name");
                info.setLabelName(name);
                info.setStatus(1);
                signPatientLabelInfoDao.save(info);
            if(customs!=null&&customs.length>0){
                for(int i=0;i<customs.length;i++){
                    SignPatientLabelInfo info = new SignPatientLabelInfo();
                    info.setCzrq(new Date());
                    info.setLabelType("4");
                    info.setPatient(patient);
                    info.setPname(p.getName());
                    info.setLabel(customs[i]);
                    String name = (String)customMap.get(customs[i]).get("name");
                    info.setLabelName(name);
                    info.setStatus(1);
                    signPatientLabelInfoDao.save(info);
                }
            }
        }
        return 1;
    }

+ 16 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -35,7 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
 * Created  Trick on 2017/7/25.
 * Created  Trick on 2017/7/25..
 */
@Service
@Transactional
@ -661,8 +661,8 @@ public class PrescriptionInfoService extends BaseService {
    public void setSQL(StringBuffer pre_sql, List<Object> params, Integer teamCode, String state, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
        if (teamCode != null && teamCode > 0) {
            pre_sql.append(" AND pr.admin_team_id =?");
            params.add(teamCode);
        }
        params.add(teamCode);
        if (StringUtils.isNotBlank(state)) {
            pre_sql.append(" AND pr.status IN (" + state + ") ");
@ -805,6 +805,20 @@ public class PrescriptionInfoService extends BaseService {
            PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
            if ("1".equals(state)) {
                if(StringUtils.isNotBlank(dept)){
                    String sql = "SELECT t.dept_name AS deptName FROM zy_iv_dept_dict t WHERE t.dept_code = '"+dept+"'" ;
                    List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
                    if(list!=null&&list.size()>0){
                        String name = (String)list.get(0).get("deptName");
                        p.setDeptName(name);
                        p.setDept(dept);
                    }else{
                        throw new RuntimeException("科室不能为空");
                    }
                }else{
                    throw new RuntimeException("科室不能为空");
                }
                //审核通过,前往智业开方
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.adding.getValue());
                p.setReviewedTime(new Date());

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

@ -130,6 +130,8 @@ public class FamilyContractService extends BaseService {
    private SignFamilyMappingDao signFamilyMappingDao;
    @Autowired
    private JwArchivesService jwArchivesService;
    @Autowired
    private FamilyContractService familyContractService;
    @Autowired
    private ImUtill ImUtill;
@ -887,7 +889,7 @@ public class FamilyContractService extends BaseService {
     * @return
     * @throws Exception
     */
    synchronized public SignFamily agent(String access_token, String name,
    synchronized public String agent(String access_token, String name,
                                         String doctor, String doctorName,
                                         String doctorHealth, String doctorHealthName,
                                         String hospital, String hospitalName,
@ -902,14 +904,13 @@ public class FamilyContractService extends BaseService {
        if (sc != null) {
            throw new Exception("已签约了家庭医生!");
        }
        //判断是否有三师签约 并且判断全科医生一致
        //屏蔽三师签约判断
//        SignFamily sssignFamily = signFamilyDao.findSSByIdcard(idcard);
//        if (sssignFamily != null && !doctor.equals(sssignFamily.getDoctor())) {
//            throw new Exception("全科医生不一致!");
//        }
        //1.3.7.2  判断是否建档---------------------------
        String rp = familyContractService.checkSickArchiveFlag(idcard);
        if("0".equals(rp)){
            return "-1";
        }
        //1.3.7.2  end------------------------------------
//        List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
        Calendar cal = Calendar.getInstance();
        int m = cal.get(Calendar.MONTH) + 1;
        String signYear = "";
@ -975,6 +976,7 @@ public class FamilyContractService extends BaseService {
        if (StringUtils.isNotBlank(sevId)) {
            signWebService.setSevId(sf, sevId);
        }
        // 查询该患者是否已注册
        Patient patient = patientDao.findByIdcard(idcard);
        if (patient == null) {
@ -1192,9 +1194,9 @@ public class FamilyContractService extends BaseService {
        }
        BusinessLogs.info(BusinessLogs.BusinessType.sign, signDoctorCode, sf.getPatient(), new JSONObject(sf));
        //签约成功之后给患者新增标签
        String openId = sf.getOpenid();
        hospital = sf.getHospital();
        return temp;
//        String openId = sf.getOpenid();
//        hospital = sf.getHospital();
        return "1";
    }
    /**
@ -4080,4 +4082,11 @@ public class FamilyContractService extends BaseService {
        return rs;
    }
    public String checkSickArchiveFlag(String idCard)throws Exception{
        String rs = jwArchivesService.getSickArchiveFlag(idCard);
        return rs ;
    }
}

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

@ -1885,7 +1885,7 @@ public class SignWebService extends BaseService {
     */
    public JSONObject getOverDuePatients(String year, Long teamCode, String doctor, Integer page, Integer pageSize) {
        StringBuffer sql = new StringBuffer("SELECT IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') age," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid," +
                "t.patient code,t.idcard,t.name,t.mobile,t.openid,p.photo," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                " FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +

+ 137 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java

@ -19,6 +19,7 @@ import com.yihu.wlyy.repository.statistics.WlyyQuotaResultDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -936,6 +937,59 @@ public class StatisticsAllService extends BaseService {
        return resultList;
    }
    /**
     * 获取过去某个日期某个区域一级指标的下级统计(单条记录)
     *
     * @param date
     * @param area
     * @param level
     * @param index
     * @return
     */
    public Map<String, Object> getTodayBeforeLowLevelTotalSingle(String date, String area, int level, String index) throws Exception {
        Map<String, Object> map = new HashedMap();
        List<Map<String, Object>> resultList = new ArrayList<>();
        String areaField = "";
        String lowLevelField = "";
        String lowLevelName = "";
        if (level == 4) {
            // 市级别
            areaField = "city";
            lowLevelField = "city";
            lowLevelName = "city_name";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
            lowLevelField = "town";
            lowLevelName = "town_name";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
            lowLevelField = "org_code";
            lowLevelName = "org_name";
        } else if (level == 1) {
            throw new Exception("param level error");
        }
        // 查询语句
        String sql = " select " +
                "     ifnull(" + lowLevelField + ",'') code " +
                "     ,ifnull(" + lowLevelName + ",'') 'name' " +
                "     ,ifnull(result,'0') amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '" + index + "' " +
                "   and level1_type = ? and del = '1'" +
                "   and quota_date = ? " +
                "   and " + areaField + " = ? ";
        resultList = jdbcTemplate.queryForList(sql,level, date, area);
        return resultList.get(0);
    }
    /**
     * 获取今天及以后某个区域一级指标的下级统计
@ -1027,6 +1081,38 @@ public class StatisticsAllService extends BaseService {
        return resultList;
    }
    /**
     * 获取今天某个区域一级指标的下级统计(单条记录)
     *
     * @param area
     * @param level
     * @param index
     * @return
     */
    public Map<String, Object> getTodayLowLevelTotalSingle(String area, int level, String index) throws Exception {
        Map<String, Object> data = new HashMap<>();
        String redisData = "";
        try {
            redisData = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area  + ":" + getQuotaTimeStamp());
        } catch (Exception e) {
            redisData = "";
        }
        if (!StringUtils.isEmpty(redisData)) {
                JSONObject json = new JSONObject(redisData);
                data.put("code", String.valueOf(json.get("code")));
                data.put("name", String.valueOf(json.get("name")));
                data.put("amount", Long.valueOf(String.valueOf(json.get("num"))));
        } else {
            Calendar today = Calendar.getInstance();
            today.add(Calendar.DATE, -1);
            String preDate = new SimpleDateFormat("yyyy-MM-dd").format(today.getTime());
            data = getTodayBeforeLowLevelTotalSingle(preDate, area, level, index);
        }
        return data;
    }
    /**
     * 获取今天某个区域一级指标的下级统计
     *
@ -2455,6 +2541,36 @@ public class StatisticsAllService extends BaseService {
        }
    }
    /**
     * 查询某个级别的某个指标到达量(单条记录)
     *
     * @param date
     * @param area
     * @param level
     * @return
     * @throws Exception
     */
    public JSONObject getLowLevelTotalSingle2(String date, String area, int level) throws Exception {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        //获取微信关注的未交费
        Map<String, Object> expenseStatus0 = getByIndexSingle(date, area, level, "49",dateFormat);
        //获取微信关注的已交费
        Map<String, Object> expenseStatus1 = getByIndexSingle(date, area, level, "50",dateFormat);
        //获取已缴费的签约数
        Map<String, Object> expenseStatus1Sigjn = getByIndexSingle(date, area, level, "1",dateFormat);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name", expenseStatus1Sigjn.get("name"));
        jsonObject.put("code", area);
        Long  weChatAmount0 =  (Long) expenseStatus0.get("amount");
        Long  weChatAmount1 =  (Long) expenseStatus1.get("amount");
        jsonObject.put("weChatAmount0", weChatAmount0);//微信关注未交费数
        jsonObject.put("weChatAmount1", weChatAmount1);//微信关注已交费数
        jsonObject.put("bindRate", getRangeDouuble(weChatAmount0.intValue(), weChatAmount1.intValue(), 2));//微信关注率
        return jsonObject;
    }
    /**
     * 获取某个指标某一天某一level的值   到达量
     *
@ -2484,6 +2600,27 @@ public class StatisticsAllService extends BaseService {
        return returnMap;
    }
    /**
     * 获取某个指标某一天某一level的值 到达量(单条记录)
     *
     * @param date
     * @param area
     * @param level
     * @param index
     * @param dateFormat
     * @return
     * @throws Exception
     */
    private Map<String,Object> getByIndexSingle(String date, String area, int level, String index, SimpleDateFormat dateFormat) throws Exception {
        Map<String,Object> map ;
        if (date.compareTo(dateFormat.format(new Date())) >= 0) {
            map = getTodayLowLevelTotalSingle(area, level, index);
        } else {
            map = getTodayBeforeLowLevelTotalSingle(date, area, level, index);
        }
        return map;
    }
    /**
     * 查询签约人数
     *

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

@ -244,6 +244,72 @@ public class PatientService extends TokenService {
        return null;
    }
    public JSONObject registerAPP(String idcard, String ssc, String name, String mobile
            , String password, String salt, String imei, int platform) throws Exception {
        IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard);
        String code = getCode();
        String sql = "insert wlyy_patient(code,idcard,name,ssc,mobile,password,salt,openid" +
                ",status,birthday,sex,czrq,openid_time,disease,disease_condition,record_amount,points)" +
                " 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});
        Patient temp = patientDao.findByIdcard(idcard);
        if (temp != null) {
            // 更新openid
            updatePatient(temp, imei);
            // 生成登录tokey
            Token token = newToken(temp.getCode(), imei, platform);
            if (token != null) {
                // 生成登录信息成功
                JSONObject json = new JSONObject();
                json.put("id", temp.getId());
                json.put("uid", temp.getCode());
                json.put("token", token.getToken());
                json.put("name", temp.getName());
                json.put("photo", temp.getPhoto());
                json.put("brithday", ie.getBirthday());
                //new Thread(new SignSsGetTask(patient.getIdcard())).start();
                return json;
            }
        }
        return null;
    }
    public Patient registerAPPBydoctor(String idcard, String ssc, String name, String mobile
            , String password, String salt, String imei, int platform) throws Exception {
        IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard);
        Patient temp = patientDao.findByIdcard(idcard);
        if (temp != null) {
            return temp;
        }else{
            //新建记录code,idcard,name,ssc,mobile,password,salt,
            // openid,status,birthday,sex,czrq,openid_time,
            // disease,disease_condition,record_amount,points
            Patient newP = new Patient();
            String code = getCode();
            newP.setCode(code);
            newP.setIdcard(idcard);
            newP.setName(name);
            newP.setSsc(ssc);
            newP.setMobile(mobile);
            newP.setPassword(password);
            newP.setSalt(salt);
            newP.setStatus(1);
            newP.setBirthday(ie.getBirthday());
            newP.setSex(ie.getGender());
            newP.setCzrq(clock.getCurrentDate());
            newP.setDisease(0);
            newP.setDiseaseCondition(0);
            newP.setRecordAmount(0);
            patientDao.save(newP);
            return newP;
        }
    }
    /**
     * 建立三师团队与患者的关系
     *

+ 1 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java

@ -148,7 +148,7 @@ public class DoctorGuidanceTempService extends BaseService {
        } else {
            String[] images = imagesUrl.split(",");
            for (String image : images) {
                if (image.contains("http://")) {
                if (image.contains("group1")) {
                    imageUrls += image + ",";
                } else {
                    try {
@ -158,7 +158,6 @@ public class DoctorGuidanceTempService extends BaseService {
                    }
                }
            }
            imagesUrl = imageUrls + imageRow;
            imagesUrl = imagesUrl.substring(0, imagesUrl.length() - 1);
        }

+ 4 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -308,7 +308,8 @@ public class LoginController extends BaseController {
            if (type == 2) {
                // 医生端
                Doctor doctor = doctorService.findDoctorByMobile(mobile);
                String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                rsaUtils.setBaseService(doctorService);
                String password = rsaUtils.decryptString(newpwd);
                password = StringUtils.reverse(password);
                password = MD5.GetMD5Code(password + doctor.getSalt());
                doctor.setPassword(password);
@ -320,7 +321,8 @@ public class LoginController extends BaseController {
                if (patientTemp == null) {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    rsaUtils.setBaseService(doctorService);
                    String password = rsaUtils.decryptString(newpwd);
                    password = StringUtils.reverse(password);
                    password = MD5.GetMD5Code(password + patientTemp.getSalt());
                    patientTemp.setPassword(password);

+ 10 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -129,7 +129,10 @@ public class WechatController extends WeixinBaseController {
            //    return error(-1, "该手机号已被注册");
            //}
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            //idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            rsaUtils.setBaseService(patientService);
            idcard =rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
@ -167,6 +170,7 @@ public class WechatController extends WeixinBaseController {
            }
            return write(200, "验证成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "验证失败");
        }
    }
@ -219,7 +223,8 @@ public class WechatController extends WeixinBaseController {
//				return error(-1, "该微信号已绑定其他手机号!");
//			}
            // 解密身份证号
            idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            rsaUtils.setBaseService(patientService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
@ -267,7 +272,8 @@ public class WechatController extends WeixinBaseController {
            //增加密码
            String salt = UUID.randomUUID().toString().replace("-", "");
            patient.setSalt(salt);
            password = RSAUtils.getInstance(patientService).decryptString(password);
            rsaUtils.setBaseService(patientService);
            password = rsaUtils.decryptString(password);
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
@ -276,7 +282,7 @@ public class WechatController extends WeixinBaseController {
                patient.setOpenidTime(new Date());
            }
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    , salt, openid, 3);
                    ,salt,openid,3);
            if (json != null) {
                try {
                    Patient p = patientDao.findByIdcard(idcard);

+ 11 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -94,6 +94,8 @@ public class DoctorController extends BaseController {
    SignPatientLabelDao labelDao;
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private RSAUtils rsaUtils;
    /**
@ -473,11 +475,11 @@ public class DoctorController extends BaseController {
            int page,
            int pagesize) {
        try {
            JSONArray array = new JSONArray();
            com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray();
            List<Doctor> list = doctorInfoService.findFamousDoctorList(key, type, page, pagesize, level);
            if (list != null) {
                for (Doctor doctor : list) {
                    JSONObject json = new JSONObject();
                    com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
                    json.put("id", doctor.getId());
                    json.put("code", doctor.getCode());
                    json.put("name", doctor.getName());
@ -501,7 +503,7 @@ public class DoctorController extends BaseController {
                    json.put("deptName", doctor.getDeptName());
                    json.put("expertise", doctor.getExpertise());
                    json.put("isworking", 1);
                    array.put(json);
                    array.add(json);
                }
            }
            return write(200, "获取名医列表成功!", "list", array);
@ -1284,10 +1286,10 @@ public class DoctorController extends BaseController {
                    return error(-1, "身份证号与姓名不一致,请检查后重新输入");
                }
                if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0 && ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
                    return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
                    return error(-1, "您的社保卡不支持线上签约,请到社区卫生服务中心办理线下签约");
                }
            } else {
                return error(-1, "对不起,暂不支持16年6月份之后办理的医保卡注册");
                return error(-1, "您的社保卡不支持线上签约,请到社区卫生服务中心办理线下签约");
            }
            return write(200, "查询成功!");
        } catch (Exception ex) {
@ -1654,9 +1656,10 @@ public class DoctorController extends BaseController {
                                 String oldPassword,
                                 String doctorCode) {
        try {
            newPassword1 = RSAUtils.getInstance(doctorInfoService).decryptString(newPassword1);
            newPassword2 = RSAUtils.getInstance(doctorInfoService).decryptString(newPassword2);
            oldPassword = RSAUtils.getInstance(doctorInfoService).decryptString(oldPassword);
            rsaUtils.setBaseService(doctorInfoService);
            newPassword1 = rsaUtils.decryptString(newPassword1);
            newPassword2 = rsaUtils.decryptString(newPassword2);
            oldPassword = rsaUtils.decryptString(oldPassword);
            newPassword1 = StringUtils.reverse(newPassword1);
            newPassword2 = StringUtils.reverse(newPassword2);
            oldPassword = StringUtils.reverse(oldPassword);

+ 237 - 16
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -1,38 +1,32 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.account.DoctorPatientGroupService;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.team.DrHealthTeamService;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.IdcardValidator;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.net.URLDecoder;
import java.util.UUID;
/**
 * 医生端:患者分组管理
@ -46,6 +40,14 @@ public class PatientInfoController extends BaseController {
    @Autowired
    private PatientInfoService patientInfoService;
    @Autowired
    private RSAUtils rsaUtils;
    @Autowired
    private PatientService patientService;
    @Autowired
    private SocialSecurityInfoDao socialSecurityInfoDao;
    @Autowired
    private PatientDao patientDao;
    /**
     * 获取患者基本信息
     *
@ -139,4 +141,223 @@ public class PatientInfoController extends BaseController {
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "checkPatientArchives",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("判断居民建档状态和签约状态")
    public String checkPatientArchives(@ApiParam(value = "居民身份证", name = "icCard") @RequestParam(required = true)String icCard){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.checkPatientArchives(icCard));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    /**
     * 注册信息验证
     *
     * @param name   姓名
     * @param idcard 身份证号
     * @param ssc    社保卡号
     * @param mobile 手机号
     * @return
     */
    @RequestMapping(value = "/check_regist_info", method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("注册信息验证")
    public String checkRegistInfo(@ApiParam(value = "居民姓名", name = "name") @RequestParam(required = true)String name,
                                  @ApiParam(value = "居民身份证", name = "idcard") @RequestParam(required = true)String idcard,
                                  @ApiParam(value = "居民社保卡", name = "ssc") @RequestParam(required = true)String ssc,
                                  @ApiParam(value = "居民手机", name = "mobile") @RequestParam(required = true)String mobile) {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "姓名不允许为空");
            }
            if (StringUtils.isEmpty(idcard)) {
                return error(-1, "身份证号不允许为空");
            }
            if (StringUtils.isEmpty(ssc)) {
                return error(-1, "社保卡号不允许为空");
            }
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "手机号不允许为空");
            }
            //if (patientService.findByMobile(mobile) != null) {
            //    return error(-1, "该手机号已被注册");
            //}
            // 解密身份证号
            //idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
            rsaUtils.setBaseService(patientService);
            idcard =rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号");
            }
//            SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
//
//            if (socialSecurityInfo != null) {
//                if (name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0) {
//                    return error(-1, "身份证号与姓名不一致,请检查后重新输入");
//                }
//                if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0 && ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
//                    return error(-1, "身份证号与医保卡号不一致,请检查后重新输入");
//                }
//            } else {
//                return error(-1, "未查询到建档记录");
//            }
            Patient patient = patientDao.findByIdcard(idcard);
//            if (patient != null) {
//                if (!StringUtils.isEmpty(patient.getMobile())) {
//                    return error(-2, "该身份证已被注册");
//                }
//            }
            return write(200, "验证成功");
        } catch (Exception e) {
            error(e);
            return error(-1, "验证失败");
        }
    }
    @RequestMapping(value = "createProfileAndSign",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("居民注册与建档")
    public String createProfileAndSign(String idcard,
                                       String ssc,
                                       String name,
                                       String mobile,
                                       String brithday,
                                       String jwCountryCode,
                                       String nation,
                                       String blood,
                                       String marry,
                                       String adress){
        try {
            // 获取医生下的患者
            return write(200, "请求成功", "data",patientInfoService.createProfileAndSign(getUID(),idcard,ssc,name,mobile,brithday,jwCountryCode,nation,blood,marry,adress));
        } catch (Exception e) {
            error(e);
            return error( -1, "建档失败!");
        }
    }
    /**
     * 患者注册
     *
     * @param idcard  身份證號
     * @param mobile  登录手机号
     * @return
     */
    @RequestMapping(value = "regist", method = RequestMethod.POST)
    @ResponseBody
    public String regist(@ApiParam(value = "姓名", name = "name") @RequestParam(required = true) String name,
                         @ApiParam(value = "身份证", name = "idcard") @RequestParam(required = true)String idcard,
                         @ApiParam(value = "社保卡", name = "ssc") @RequestParam(required = true) String ssc,
                         @ApiParam(value = "手机", name = "mobile") @RequestParam(required = true) String mobile) {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "姓名不允许为空!");
            }
            if (StringUtils.isEmpty(idcard)) {
                return error(-1, "身份证号不允许为空!");
            }
            if (StringUtils.isEmpty(ssc)) {
                return error(-1, "社保卡号不允许为空!");
            }
            if (StringUtils.isEmpty(mobile)) {
                return error(-1, "手机号不允许为空!");
            }
            // 解密身份证号
            rsaUtils.setBaseService(patientService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
            IdcardValidator validator = new IdcardValidator();
            if (validator.isValidatedAllIdcard(idcard)) {
                if (idcard.length() == 15) {
                    idcard = validator.convertIdcarBy15bit(idcard);
                    if (StringUtils.isEmpty(idcard)) {
                        return error(-1, "请输入正确的身份证号!");
                    }
                }
            } else {
                return error(-1, "请输入正确的身份证号!");
            }
            SocialSecurityInfo socialSecurityInfo = socialSecurityInfoDao.findBySfzh18Max(idcard);
            if (socialSecurityInfo != null) {
                if (name.compareTo(socialSecurityInfo.getXming0() == null ? "" : socialSecurityInfo.getXming0()) != 0) {
                    return error(-1, "身份证号与姓名不一致<br/>请检查后重新输入");
                }
                if (ssc.compareTo(socialSecurityInfo.getCardno() == null ? "" : socialSecurityInfo.getCardno()) != 0) {
                    if (ssc.compareTo(socialSecurityInfo.getCard16() == null ? "" : socialSecurityInfo.getCard16()) != 0) {
                        return error(-1, "您的社保卡不支持线上签约,请到社区卫生服务中心办理线下签约");
                    } else {
                        ssc = socialSecurityInfo.getCardno();//统一只存英文字母开头的医保卡
                    }
                }
            } else {
                return error(-1, "您的社保卡不支持线上签约,请到社区卫生服务中心办理线下签约");
            }
            Patient patient = patientDao.findByIdcard(idcard);
            if (patient == null) {
                patient = new Patient();
            } else {
                if (!StringUtils.isEmpty(patient.getMobile())) {
                    return error(-2, "该身份证已被注册!");
                }
            }
            patient.setName(name);
            patient.setIdcard(idcard);
            patient.setMobile(mobile);
            //增加密码
            String salt = UUID.randomUUID().toString().replace("-", "");
            patient.setSalt(salt);
            rsaUtils.setBaseService(patientService);
            String password = mobile.substring(5,10);
            password = rsaUtils.decryptString(password);
            password = StringUtils.reverse(password);
            patient.setPassword(MD5.GetMD5Code(password + salt));
            patient.setSsc(ssc);
            JSONObject json = patientService.register(idcard, ssc, name, mobile, MD5.GetMD5Code(password + salt)
                    ,salt,salt,3);
            if (json != null) {
                try {
                    Patient p = patientDao.findByIdcard(idcard);
                    BusinessLogs.info(BusinessLogs.BusinessType.register, p.getCode(), p.getCode(), new JSONObject(p));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                // 注册成功
                return write(200, "注册成功!", "data", json);
            } else {
                // 注册失败
                return error(-1, "注册失败!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "注册失败!");
        }
    }
}

+ 3 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -861,10 +861,9 @@ public class SignPatientLabelInfoController extends BaseController {
    @RequestMapping(value = "/resetPatientLabels", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String resetPatientLabels(@RequestParam(required = true)String patient,
                                     @RequestParam(required = true)String health,
                                     @RequestParam(required = true)String disease,
                                     @RequestParam(required = true)String custom,
                                     @RequestParam(required = true)String doctor){
                                     @RequestParam(required = false)String health,
                                     @RequestParam(required = false)String disease,
                                     @RequestParam(required = false)String custom){
        try {
            return write(200, "保存成功", "data", signPatientLabelService.resetPatientLabels(patient,health,disease,custom));
        } catch (Exception e) {

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

@ -80,6 +80,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
    private HttpUtil HttpUtil;
    @Value("${sign.check_upload}")
    private String sign_check_upload;
    @Autowired
    private RSAUtils rsaUtils;
    /**
     * 根据姓名、地址、身份证搜索已分配的居民
@ -361,7 +363,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            }
            JSONObject json = new JSONObject();
            // 解密身份证号
            idcard = RSAUtils.getInstance(familyContractService).decryptString(idcard);
            rsaUtils.setBaseService(familyContractService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            if (StringUtils.isEmpty(idcard)) {
@ -441,7 +444,8 @@ public class DoctorFamilyContractController extends WeixinBaseController {
                return error(-1, "请选择健康管理师!");
            }
            // 解密身份证号
            idcard = RSAUtils.getInstance(familyContractService).decryptString(idcard);
            rsaUtils.setBaseService(familyContractService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号
@ -489,11 +493,11 @@ public class DoctorFamilyContractController extends WeixinBaseController {
            /**end**/
            Doctor cDoctor = doctorService.findDoctorByCode(getUID());
            //1.3.5 新增居委会字段countryCode
            SignFamily sf = familyContractService.agent(getAccessToken(), name, doctor, doctorName,
            String sf = familyContractService.agent(getAccessToken(), name, doctor, doctorName,
                    healthDoctor, healthDoctorName, cDoctor.getHospital(), cDoctor.getHospitalName(),
                    idcard, ssc, mobile, emerMobile, images, healthLabel, customLabel, disease, expenses, signDoctorCode, signDoctorName, signDoctorLevel, adminTeamCode, sevId, countryCode);
            if (sf == null) {
                return error(-1, "代理签约失败!");
            if ("-1".equals(sf)) {
                return error(-2, "居民未建档!");
            } else {
                try {
                    Patient p = patientService.findByIdcard(idcard);

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

@ -230,8 +230,7 @@ public class DoctorSignController extends WeixinBaseController {
            @RequestParam(required = false)Integer doctorType,
            @RequestParam(required = false)Integer page,
            @RequestParam(required = false)Integer pageSize) {
        try {
            page = page > 0 ? page -1 : 0;
        try {page = page > 0 ? page -1 : 0;
            List<Map<String, Object>> listSign = signWebService.getSignWebByDoctor(getUID(), status, page, pageSize);
            JSONObject data = new JSONObject();

+ 8 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -74,6 +74,8 @@ public class PatientController extends WeixinBaseController {
    private SignFamilyServerDao signFamilyServerDao;
    @Autowired
    private WeiXinTagUtil weiXinTagUtil;
    @Autowired
    private RSAUtils rsaUtils;
    /**
     * 患者基本信息查询接口
@ -859,9 +861,10 @@ public class PatientController extends WeixinBaseController {
                                 String newPassword2,
                                 String oldPassword) {
        try {
            newPassword1 = RSAUtils.getInstance(doctorService).decryptString(newPassword1);
            newPassword2 = RSAUtils.getInstance(doctorService).decryptString(newPassword2);
            oldPassword = RSAUtils.getInstance(doctorService).decryptString(oldPassword);
            rsaUtils.setBaseService(doctorService);
            newPassword1 = rsaUtils.decryptString(newPassword1);
            newPassword2 = rsaUtils.decryptString(newPassword2);
            oldPassword = rsaUtils.decryptString(oldPassword);
            newPassword1 = StringUtils.reverse(newPassword1);
            newPassword2 = StringUtils.reverse(newPassword2);
            oldPassword = StringUtils.reverse(oldPassword);
@ -981,4 +984,6 @@ public class PatientController extends WeixinBaseController {
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
}

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

@ -57,6 +57,8 @@ public class FamilyContractController extends BaseController {
    private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
    @Autowired
    private SignWebService signWebService;
    @Autowired
    private RSAUtils rsaUtils;
    /**
     * 得到患者的签约的医生的信息
     *
@ -346,7 +348,8 @@ public class FamilyContractController extends BaseController {
                return error(-1, "请输入身份证号!");
            }
            // 解密身份证号
            idcard = RSAUtils.getInstance(familyContractService).decryptString(idcard);
            rsaUtils.setBaseService(familyContractService);
            idcard = rsaUtils.decryptString(idcard);
            idcard = URLDecoder.decode(idcard, "UTF-8");
            idcard = StringUtils.reverse(idcard);
            // 校验身份证号

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ValueComparator;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -1565,4 +1566,17 @@ public class StatisticsController extends BaseController {
            return error(-1, "查询失败");
         }
    }
    @RequestMapping("/getLevelTotalSingle")
    @ResponseBody
    public String getLevelTotalSingle(@ApiParam(name="date", value="日期标识") @RequestParam(required = true)String date,
                                      @ApiParam(name="area", value="区域code") @RequestParam(required = true)String area,
                                      @ApiParam(name="level", value="级别") @RequestParam(required = true)int level){
        try{
            return write(200, "查询成功", "data", statisticsAllService.getLowLevelTotalSingle2(date,area,level));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}

+ 5 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/GcLoginController.java

@ -63,8 +63,9 @@ public class GcLoginController extends WeixinBaseController {
    @ApiOperation("获取公钥")
    public ResultOneModel publicKey() {
        try {
            String modulus = RSAUtils.getInstance(smsService).getModulus();
            String exponent = RSAUtils.getInstance(smsService).getExponent();
            rsaUtils.setBaseService(smsService);
            String modulus = rsaUtils.getModulus();
            String exponent = rsaUtils.getExponent();
            if (StringUtils.isEmpty(modulus) || StringUtils.isEmpty(exponent)) {
                return new ResultOneModel(BaseResultModel.statusEm.login_publickey_error.getCode(), BaseResultModel.statusEm.login_publickey_error.getMessage());
            } else {
@ -113,7 +114,8 @@ public class GcLoginController extends WeixinBaseController {
            }
            //身份证登录
            if (StringUtils.isNoneEmpty(account) && StringUtils.isNoneEmpty(password)) {
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                rsaUtils.setBaseService(doctorService);
                password = rsaUtils.decryptString(password);
                password = StringUtils.reverse(password);
                //根据电话号码找
                Doctor doctor = doctorService.findDoctorByMobile(account);

+ 98 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.NetworkUtil;
@ -14,12 +15,15 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutionException;
@ -40,6 +44,13 @@ public class GcMessageController {
    private PatientService patientService;
    @Autowired
    private SMSService smsService;
    @Autowired
    private PatientDao patientDao;
    @Value("${wechat.message.template_consult_notice}")
    private String templateId;
    @Value("${server.server_url}")
    private String server_url;
    @RequestMapping(value = "/sendWXTemplate", method = RequestMethod.POST)
    @ApiOperation("给患者发送微信模板消息")
@ -102,10 +113,93 @@ public class GcMessageController {
        }
    }
    @RequestMapping(value = "/sendEduArticle", method = RequestMethod.POST)
    @ApiOperation("给手机号码发送短信消息")
    public ResultBatchModel sendEduArticle(){
    /**
     * 健康宣教微信模板消息通知
     *
     * @param title    指导标题
     * @param hospitalName  指导机构名称
     * @param doctorName    指导医生姓名
     * @param patients 发送居民对象 多个以逗号分隔
     * @param content  指导内容
     * @return
     */
    @RequestMapping(value = "/sendWechatMessage", method = RequestMethod.POST)
    @ApiOperation("健康宣教微信模板消息通知")
    public ResultBatchModel sendWechatMessage(
            @ApiParam(name = "title", value = "消息标题", required = true) @RequestParam(value = "title", required = true) String title,
            @ApiParam(name = "hospitalName", value = "指导机构名称", required = true) @RequestParam(value = "hospitalName", required = true) String hospitalName,
            @ApiParam(name = "doctorName", value = "指导医生姓名", required = true) @RequestParam(value = "doctorName", required = true) String doctorName,
            @ApiParam(name = "patients", value = "指导对象", required = true) @RequestParam(value = "patients", required = true) String patients,
            @ApiParam(name = "content", value = "指导内容", required = true) @RequestParam(value = "content", required = true) String content) {
        Integer success = 0;
        Integer error = 0;
        String remark = "为了您和家人更健康,请仔细阅读健康指导内容,谢谢。";
        List<String> errorLiust = new ArrayList<>();
        try {
            String url = server_url + "wx_doctor/html/home/html/jumpApp.html";
            String[] codeArr = patients.split(",");
            for (String people : codeArr) {
                try {
                    Patient patient = patientDao.findByCode(people);
                    String openId = patient.getOpenid();
                    String name = patient.getName();
                    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
                    JSONObject sendJson = weiXinTempMsgSendUtils.packageTemplate(title, remark, dateFormat.format(new Date()),hospitalName,doctorName,name,content );
                    Boolean flag = weiXinTempMsgSendUtils.sendTemplateMessage(templateId, openId, url, sendJson);
                    logger.info("send wechat message param : title "+title+" hospitalName "+hospitalName+" doctorName "+doctorName+" patients "+patients+" content "+content);
                    logger.info("send wechat message retuen : " + flag + " =======> " + flag);
                    success++;
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("patient " + people + " send Template error:" + e.getMessage());
                    error++;
                    errorLiust.add(people);
                }
            }
            return new ResultBatchModel(success, error, errorLiust);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultBatchModel(-1, "发送失败!", success, error, errorLiust);
        }
    }
        return null;
    /**
     * 健康宣教短信消息通知
     *
     * @param mobiles 手机号.多个用逗号分隔
     * @param content
     * @return
     */
    @RequestMapping(value = "/sendEduArticle", method = RequestMethod.POST)
    @ApiOperation("健康宣教微信短信消息通知")
    public ResultBatchModel sendEduArticle(
            @ApiParam(name = "mobiles", value = "手机号(批量逗号分割)", required = true) @RequestParam(value = "mobiles", required = true) String mobiles,
            @ApiParam(name = "content", value = "消息内容", required = true) @RequestParam(value = "content", required = true) String content) {
        Integer success = 0;
        Integer error = 0;
        List<String> errorLiust = new ArrayList<>();
        content = "【健康之路】" +content+
                "社区的医生,给您发送了发送了健康教育文章,请点击以下网址查看www.yihu.com.xxxxx.xxx,关注【小薇社区】公众号,获取更多健康资讯。";
        try {
            String[] codeArr = mobiles.split(",");
            for (String mobile : codeArr) {
                try {
                    JSONObject result = smsService.sendMsg(mobile, content);
                    logger.info("send mobile message param : " + mobile + " ====> " + content);
                    logger.info("send mobile message return : " + result);
                    success++;
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("mobile " + mobile + " send message error:" + e.getMessage());
                    error++;
                    errorLiust.add(mobile);
                }
            }
            return new ResultBatchModel(success, error, errorLiust);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultBatchModel(-1, "发送失败!", success, error, errorLiust);
        }
    }
}

+ 32 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinTempMsgSendUtils.java

@ -6,6 +6,9 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by lyr on 2016/08/22.
 */
@ -65,4 +68,33 @@ public class WeiXinTempMsgSendUtils {
            return false;
        }
    }
    /**
     * 构建微信模板内容消息体 默认字体黑色
     *
     * @param first    消息头
     * @param remark   备注
     * @param keywords 消息体
     * @return
     */
    public JSONObject packageTemplate(String first, String remark, String... keywords) throws Exception{
        JSONObject data = new JSONObject();
        Map keywordFirst = new HashMap();
        keywordFirst.put("color", "#000000");
        keywordFirst.put("value", first);
        Map keywordRemark = new HashMap();
        keywordRemark.put("color", "#000000");
        keywordRemark.put("value", remark);
        data.put("first", keywordFirst);
        data.put("remark", keywordRemark);
        for (int i = 0; i < keywords.length; i++) {
            Map keyword1 = new HashMap();
            keyword1.put("color", "#000000");
            keyword1.put("value", keywords[i]);
            data.put("keyword" + (i + 1), keyword1);
        }
        return data;
    }
}