Pārlūkot izejas kodu

医保签约号

wujunjie 7 gadi atpakaļ
vecāks
revīzija
0fe4cb6623
79 mainītis faili ar 3918 papildinājumiem un 354 dzēšanām
  1. 53 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/httpLog/HttpLogDetail.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java
  3. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlan.java
  4. 108 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPreCard.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  6. 2 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java
  7. 5 3
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrenatalInspectorController.java
  8. 14 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  9. 3 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java
  10. 2 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionLog.java
  11. 5 3
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/VO/PrescriptionExpressageVO.java
  12. 17 5
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/LogService.java
  13. 2 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftMaternalService.java
  14. 50 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  15. 11 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/HttpLogDetailDao.java
  16. 53 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/entity/HttpLogDetail.java
  17. 24 6
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/LogService.java
  18. 122 3
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/service/template/DoctorFeldsherTemplateService.java
  19. 4 0
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/util/RSAUtils.java
  20. 2 1
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  21. 2 2
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  22. 1 1
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorFeldsherTemplateController.java
  23. 22 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/RenewSignDataFilter.java
  24. 32 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/model/RenewCacheModel.java
  25. 243 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java
  26. 416 83
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  27. 1 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignServerTypeJob.java
  28. 1 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/WechatCountJob.java
  29. 116 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignOrgOutServerJob.java
  30. 115 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignOrgServerJob.java
  31. 115 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignServerJob.java
  32. 114 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTeamOutServerJob.java
  33. 113 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTeamServerJob.java
  34. 113 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTownOutServerJob.java
  35. 113 0
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/signServer/RenewSignTownServerJob.java
  36. 1 1
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/QuartzJobLog.java
  37. 5 5
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  38. 2 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  39. 10 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  40. 2 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionExecuteSickSettleJob.java
  41. 4 4
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SFExpressJob.java
  42. 36 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignFamilyPayResultJob.java
  43. 3 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java
  44. 610 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/ZyDictService.java
  45. 72 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/ZyDictController.java
  46. 17 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  47. 2 2
      patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml
  48. 5 2
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  49. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/httplog/HttpLogDetailDao.java
  50. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java
  51. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanLibraryDao.java
  52. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  53. 132 13
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  54. 72 64
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  55. 88 30
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  56. 16 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  57. 33 16
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  58. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignFamilyServiceService.java
  59. 9 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  60. 137 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java
  61. 66 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  62. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorGuidanceTempService.java
  63. 24 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/httplog/LogService.java
  64. 4 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  65. 10 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  66. 14 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  67. 237 16
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  68. 3 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  69. 71 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prenatalInspector/PrenatalController.java
  70. 9 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorFamilyContractController.java
  71. 1 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  72. 8 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  73. 15 20
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/PrenatalInspectorContoller.java
  74. 23 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java
  75. 4 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  76. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  77. 5 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/GcLoginController.java
  78. 98 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java
  79. 32 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/util/WeiXinTempMsgSendUtils.java

+ 53 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/httpLog/HttpLogDetail.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.entity.httpLog;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2017/9/26.
 */
@Entity
@Table(name = "wlyy_http_log_detail")
public class HttpLogDetail extends IdEntity {
    private Long code;//关联code和ZyPushLog表的id
    private String response;//'返回结果',
    private String error;//'报错信息',
    private Date createTime;// '创建时间',
    public Long getCode() {
        return code;
    }
    public void setCode(Long code) {
        this.code = code;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java

@ -50,7 +50,7 @@ public class SignFamily extends IdEntity {
    private String signType;//1 用户自己申请  2医生手工带签  3.医生发起邀请
    private String familyCode;//签约code
    private Double expenses;//签约费用
    private String expensesStatus;//扣费状态【0未扣费 1已扣费 2已退费】
    private String expensesStatus;//扣费状态【0未扣费 1已扣费 2已退费 3医保取消】
    private String signSource;// 签约来源【1 社区签约 2 移动签约】
    private String signDoctorCode;//簽約人code
    private String signDoctorName;//簽約人銘

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPlan.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.entity.patient.prenatal;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@ -53,6 +55,8 @@ public class PrenatalInspectorPlan extends IdEntity implements Serializable {
        this.name = name;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "inspection_time")
    public Date getInspectionTime() {
        return inspectionTime;
    }
@ -61,6 +65,8 @@ public class PrenatalInspectorPlan extends IdEntity implements Serializable {
        this.inspectionTime = inspectionTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "inspection_start_time")
    public Date getInspectionStartTime() {
        return inspectionStartTime;
    }
@ -69,6 +75,8 @@ public class PrenatalInspectorPlan extends IdEntity implements Serializable {
        this.inspectionStartTime = inspectionStartTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "inspection_end_time")
    public Date getInspectionEndTime() {
        return inspectionEndTime;
    }
@ -125,6 +133,8 @@ public class PrenatalInspectorPlan extends IdEntity implements Serializable {
        this.signHospital = signHospital;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "czrq")
    public Date getCzrq() {
        return czrq;
    }

+ 108 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorPreCard.java

@ -19,8 +19,12 @@ public class PrenatalInspectorPreCard extends IdEntity implements Serializable{
    private String patient;//居民code
    private String name;//居民姓名
    private String ssc;//医保卡号
    private String idcard;//身份证号
    private Date birthday;//出生日期
    private String mobile;//手机号码
    private String doctor;//团队长
    private String doctorName;//医生名称
    private String jwDoctor;//基位医生code
    private Date lastMenstrualDate;//末次月经时间
    private String allergyHistory;//过敏史
    private String maritalStatus;//婚姻情况(1未婚,2已婚,3再婚,4丧偶,5离婚,6分居)
@ -51,6 +55,12 @@ public class PrenatalInspectorPreCard extends IdEntity implements Serializable{
    private Integer menstrualCycle;//周期(天)
    private String diseaseHistory;//疾病史
    private String operationHistory;//手术史
    private String hypertensionHistory;//'高血压',
    private String diabetesHistory;//'糖尿病',
    private String mentalDiseaseHistory;//'精神病',
    private String hyperthroidismHistory;//'甲亢',
    private String bloodDiseaseHistory;//'血液病',
    private String epilepsiaHistory;//'癫痫',
    private String otherInformation;//其他
    private String effective;//是否有效(1有效,0无效)
    private String status;//状态
@ -62,7 +72,8 @@ public class PrenatalInspectorPreCard extends IdEntity implements Serializable{
    private String inspectionPhase;//检查阶段(1社区检查,2医院检查)
    private String del;//是否删除(1正常,0废弃)
    private Date czrq;//创建日期
    private String uploadStatus;// '上传状态(0未上传,1上传成功,2上传失败)',
    private String uploadMsg; //上传记录\'',
    public String getCode() {
        return code;
@ -439,4 +450,100 @@ public class PrenatalInspectorPreCard extends IdEntity implements Serializable{
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getUploadStatus() {
        return uploadStatus;
    }
    public void setUploadStatus(String uploadStatus) {
        this.uploadStatus = uploadStatus;
    }
    public String getUploadMsg() {
        return uploadMsg;
    }
    public void setUploadMsg(String uploadMsg) {
        this.uploadMsg = uploadMsg;
    }
    public String getHypertensionHistory() {
        return hypertensionHistory;
    }
    public void setHypertensionHistory(String hypertensionHistory) {
        this.hypertensionHistory = hypertensionHistory;
    }
    public String getDiabetesHistory() {
        return diabetesHistory;
    }
    public void setDiabetesHistory(String diabetesHistory) {
        this.diabetesHistory = diabetesHistory;
    }
    public String getMentalDiseaseHistory() {
        return mentalDiseaseHistory;
    }
    public void setMentalDiseaseHistory(String mentalDiseaseHistory) {
        this.mentalDiseaseHistory = mentalDiseaseHistory;
    }
    public String getHyperthroidismHistory() {
        return hyperthroidismHistory;
    }
    public void setHyperthroidismHistory(String hyperthroidismHistory) {
        this.hyperthroidismHistory = hyperthroidismHistory;
    }
    public String getBloodDiseaseHistory() {
        return bloodDiseaseHistory;
    }
    public void setBloodDiseaseHistory(String bloodDiseaseHistory) {
        this.bloodDiseaseHistory = bloodDiseaseHistory;
    }
    public String getEpilepsiaHistory() {
        return epilepsiaHistory;
    }
    public void setEpilepsiaHistory(String epilepsiaHistory) {
        this.epilepsiaHistory = epilepsiaHistory;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getJwDoctor() {
        return jwDoctor;
    }
    public void setJwDoctor(String jwDoctor) {
        this.jwDoctor = jwDoctor;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -37,7 +37,7 @@ public class Prescription extends IdEntity {
    private String patientName;             //患者名称
    private String ssc;//社保卡号
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //(-3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
    private Integer status;                  //(-4线下退费 -3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
    // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
    // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
    // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,

+ 2 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java

@ -55,6 +55,7 @@ public class PrescriptionLog extends IdEntity {
    //状态枚举
    public enum PrescriptionLogStatus {
        pay_refund("线下退费",-4),
        //续方取消
        pay_outtime("支付超时", -3),
        patient_canel("患者自己取消", -2),
@ -124,7 +125,7 @@ public class PrescriptionLog extends IdEntity {
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
    private Integer status;                 //状态 (-4线下退费 -3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
                                               // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
                                            // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
                                            // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,

+ 5 - 3
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrenatalInspectorController.java

@ -25,14 +25,16 @@ public class PrenatalInspectorController extends BaseController{
    @RequestMapping(value = "getEhrMaternalFirstExamRecord",method = RequestMethod.POST)
    @ApiOperation("获取孕妇建卡信息")
    public Result getEhrMaternalFirstExamRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122,350204197512284026,222406198209202228")
    public Result getEhrMaternalFirstExamRecord(@ApiParam(name="idcard",value="身份证号",defaultValue = "352124761015122,350204197512284026,222406198209202228,35062719831211252X")
                                                @RequestParam(value = "idcard",required = true) String idcard,
                                                @ApiParam(name="hospital",value="医院code",defaultValue = "3502030500")
                                                @RequestParam(value = "hospital",required = false) String hospital) throws Exception
                                                @RequestParam(value = "hospital",required = false) String hospital,
                                                @ApiParam(name="pregnancyNo",value="产检号")
                                                @RequestParam(value = "pregnancyNo",required = false) String pregnancyNo) throws Exception
    {
        try {
            String re = maternalService.getEhrMaternalFirstExamRecord(idcard,hospital);
            String re = maternalService.getEhrMaternalFirstExamRecord(idcard,hospital,pregnancyNo);
            return Result.success("获取孕妇建卡信息成功!",re);
        } catch (Exception ex) {

+ 14 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java

@ -99,6 +99,20 @@ public class PrescriptionController extends BaseController{
		}
	}
	
	
	@RequestMapping(value = "cancelPrescription",method = RequestMethod.POST)
	@ApiOperation("接收订单退费消息")
	public Result cancelPrescription(@ApiParam(name="data",value="json串",defaultValue = "{}")
	                                 @RequestParam(value = "data",required = true) String data){
		try {
			
			return prescriptionService.cancelPrescription(data);
		}catch (Exception e){
			e.printStackTrace();
			return Result.error(e.getMessage());
		}
	}
	/***************************************获取im消息*****************************************************/
	@RequestMapping(value = "getLoglist",method = RequestMethod.GET)

+ 3 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java

@ -34,4 +34,7 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Modifying
    @Query("update Prescription p set p.jwPayStatus=1 where p.code=?1")
    void updatejwPayStatus(String prescriptionCode);
    
    @Query("from Prescription p where p.visitNo=?1")
    Prescription findByVisitNo(String visitNo);
}

+ 2 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionLog.java

@ -53,6 +53,7 @@ public class PrescriptionLog extends IdEntity {
    //状态枚举
    public enum PrescriptionLogStatus {
        //续方取消
        pay_refund("线下退费",-4),
        pay_outtime("支付超时", -3),
        patient_canel("患者自己取消", -2),
@ -121,7 +122,7 @@ public class PrescriptionLog extends IdEntity {
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
    private Integer status;                 //状态 (-4线下退费,-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
    private Integer type;                   //类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
    private String userCode;                  //医生或者患者code

+ 5 - 3
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/VO/PrescriptionExpressageVO.java

@ -48,10 +48,12 @@ public class PrescriptionExpressageVO extends Result {
    //付款方式:1:寄方付,2:收方付 3:第三方付
    private Integer pay_method;
    private String receive_time;//收件时间
    
    private Integer dispensaryType;//取药类型:1 自取 2快递配送 3健管师配送
    //收件时间
    private String receive_time;
    
    //取药类型:1 自取 2快递配送 3健管师配送
    private Integer dispensaryType;
    //订单的药品详情
    private List<PrescriptionInfo> infos = new ArrayList<>();

+ 17 - 5
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/LogService.java

@ -146,14 +146,26 @@ public class LogService {
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
//                if(response.length()>10652261){
//                    log.setResponse("超过longtext限制");
//                }else {
//                    log.setResponse(response);
//                }
//                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                //明细表
                HttpLogDetail detail = new HttpLogDetail();
                detail.setCode(log.getId());
                detail.setCreateTime(new Date());
                if(response.length()>10652261){
                    log.setResponse("超过longtext限制");
                    detail.setResponse("超过longtext限制");
                }else {
                    log.setResponse(response);
                    detail.setResponse(response);
                }
                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                detail.setError(error);
                httpLogDetailDao.save(detail);
            }
        }
        catch (Exception ex)

+ 2 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftMaternalService.java

@ -30,7 +30,7 @@ public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.32获取孕妇建卡信息(妇幼保健)
     */
    public String getEhrMaternalFirstExamRecord(String idcard,String hospitalCode) throws Exception
    public String getEhrMaternalFirstExamRecord(String idcard,String hospitalCode,String pregnancyNo) throws Exception
    {
        String[] hospitalMapping = getHospitalMapping(hospitalCode); //获取机构映射
        String hospital = hospitalMapping[0];
@ -43,6 +43,7 @@ public class ZysoftMaternalService extends ZysoftBaseService{
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("PREGNANCY_NO",pregnancyNo);
        String response = postSecond("getEhrMaternalFirstExamRecord","获取孕妇建卡信息",params,null,header,false,1,"3");

+ 50 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -1087,6 +1087,56 @@ public class PrescriptionService extends ZysoftBaseService{
        return Result.success("查询成功",vo);
    }
    
    
    /*********************************************智业请求顺丰快递接口数据 END**************************************************/
    public Result cancelPrescription(String data) {
        String error = null;
        String status = "1";
        String errMsg = null;
        try{
            JSONObject json = JSONObject.parseObject(data);
            Integer code = json.getInteger("CODE");
            if(code==1){
                String visit_no = json.getString("ORDER_NO");//挂号编号
                String msg = json.getString("MSG");//退费原因
            
                Prescription prescription = prescriptionDao.findByVisitNo(visit_no);
    
                prescription.setStatus(-4);//线下退费
    
                prescriptionDao.save(prescription);
    
                //新增log表
                PrescriptionLog log = new PrescriptionLog();
                log.setPrescriptionCode(prescription.getCode());
                log.setCode(getCode());
                log.setCreateTime(new Date());
                log.setType(PrescriptionLog.PrescriptionLogType.zy.getValue());
                log.setUserType(2);
                log.setHospital(prescription.getHospital());
                log.setHospitalName(prescription.getHospitalName());
                log.setUserName(prescription.getDoctorName());
                log.setFlag(1);
                log.setRemark("退费成功");
                log.setUserCode(prescription.getDoctor());
                log.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_refund.getValue());
                prescriptionLogDao.save(log);
            }
        
        }catch (JSONException ex){
            ex.printStackTrace();
            error = ex.getMessage();
            errMsg = ex.getMessage();
            status = "0";
        }catch (Exception e){
            e.printStackTrace();
            error = e.getMessage();
            status = "0";
        }
        //添加日志
        return addZyPushLog(data,"cancelPrescription","接收订单退费消息",error,"POST",status,"1",errMsg);
    }
}

+ 11 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/HttpLogDetailDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.sign.dao;
import com.yihu.wlyy.sign.entity.HttpLogDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/9/26.
 */
public interface HttpLogDetailDao extends PagingAndSortingRepository<HttpLogDetail, Long>, JpaSpecificationExecutor<HttpLogDetail> {
}

+ 53 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/entity/HttpLogDetail.java

@ -0,0 +1,53 @@
package com.yihu.wlyy.sign.entity;
import com.yihu.wlyy.sign.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2017/9/26.
 */
@Entity
@Table(name = "wlyy_http_log_detail")
public class HttpLogDetail extends IdEntity {
    private Long code;//关联code和ZyPushLog表的id
    private String response;//'返回结果',
    private String error;//'报错信息',
    private Date createTime;// '创建时间',
    public Long getCode() {
        return code;
    }
    public void setCode(Long code) {
        this.code = code;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 24 - 6
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/LogService.java

@ -2,8 +2,10 @@ package com.yihu.wlyy.sign.service;
import com.yihu.wlyy.sign.common.util.StringUtil;
import com.yihu.wlyy.sign.dao.HttpLogDao;
import com.yihu.wlyy.sign.dao.HttpLogDetailDao;
import com.yihu.wlyy.sign.dao.SignFamilyLogDao;
import com.yihu.wlyy.sign.entity.HttpLog;
import com.yihu.wlyy.sign.entity.HttpLogDetail;
import com.yihu.wlyy.sign.entity.SignFamilyLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -19,10 +21,10 @@ public class LogService {
    @Autowired
    private HttpLogDao httpLogDao;
    @Autowired
    private HttpLogDetailDao httpLogDetailDao;
    @Autowired
    private SignFamilyLogDao signFamilyLogDao;
    @Autowired
    private SystemDictService systemDictService;
@ -40,10 +42,18 @@ public class LogService {
            log.setParams(params);
            log.setCreateTime(new Date());
            log.setCreateTime(new Date());
            log.setResponse(response);
            log.setError(error);
//            log.setResponse(response);
//            log.setError(error);
            log.setStatus(isSuccess?"1":"0");
            httpLogDao.save(log);
            //明细表
            HttpLogDetail detail = new HttpLogDetail();
            detail.setCode(log.getId());
            detail.setCreateTime(new Date());
            detail.setResponse(response);
            detail.setError(error);
            httpLogDetailDao.save(detail);
        }
        catch (Exception ex)
        {
@ -76,10 +86,18 @@ public class LogService {
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
                log.setResponse(response);
                log.setError(error);
//                log.setResponse(response);
//                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                //明细表
                HttpLogDetail detail = new HttpLogDetail();
                detail.setCode(log.getId());
                detail.setCreateTime(new Date());
                detail.setResponse(response);
                detail.setError(error);
                httpLogDetailDao.save(detail);
            }
        }
        catch (Exception ex)

+ 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();
        }
    }
}

+ 1 - 1
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/model/job/QuartzJobLog.java

@ -81,7 +81,7 @@ public class QuartzJobLog implements java.io.Serializable {
	}
	public void setJobContent(String jobContent) {
		this.jobContent = jobContent;
		this.jobContent = "";
	}
	@Column(name = "job_type", length = 1)

+ 5 - 5
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -164,7 +164,7 @@ public class JobService {
                params.put("yesterday", getYesterday(0 - i));
                if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                    quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                    Thread.sleep(30000L);
                    Thread.sleep(60000L);
                }
            }
        }
@ -206,7 +206,7 @@ public class JobService {
            params.put("yesterday", yesterday);
            if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(30000L);
                Thread.sleep(60000L);
            }
        }
@ -252,7 +252,7 @@ public class JobService {
        params.put("yesterday", yesterday);
        if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
            quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            Thread.sleep(30000L);
            Thread.sleep(60000L);
        }
    }
@ -283,7 +283,7 @@ public class JobService {
            params.put("yesterday", getYesterday(0 - i));
            if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(30000L);
                Thread.sleep(60000L);
            }
        }
    }
@ -418,7 +418,7 @@ public class JobService {
        params.put("now", yesterday);
        params.put("yesterday", day);
        quartzHelper.startNow(HealthMessageJob.class, HealthMessageJob.jobKey + UUID.randomUUID().toString().replace("-", ""), params);
        Thread.sleep(30000L);
        Thread.sleep(60000L);
    }
    public void productHealthDataByDayToDay(String start, String end) throws Exception {

+ 2 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -101,7 +101,8 @@ public class SwaggerConfig {
                        regex("/login/.*"),
                        regex("/qrcode/.*"),
                        regex("/onepay/.*"),
                        regex("/wlyy_service/.*")
                        regex("/wlyy_service/.*"),
                        regex("/zydict/.*")
                ))
                .build()
                .apiInfo(otherApiInfo());

+ 10 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -84,7 +84,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            //同步智业字典 每晚1点同步
            if (!quartzHelper.isExistJob("zy_dict_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("zy_dict_job");
                quartzHelper.addJob(ZyDictJob.class, trigger, "zy_dict_job", new HashMap<String, Object>());
               // quartzHelper.addJob(ZyDictJob.class, trigger, "zy_dict_job", new HashMap<String, Object>());
                logger.info("zy_dict_job job success");
            } else {
                logger.info("zy_dict_job job exist");
@ -133,6 +133,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("patient_disease_contion_syn_job  job exist");
            }
            //查询家庭签约支付结果,补更新医保签约号,3分钟跑一次
            if (!quartzHelper.isExistJob("sign_family_pay_result_migisterno_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("sign_family_pay_result_migisterno_job");
                quartzHelper.addJob(SignFamilyPayResultJob.class, trigger, "sign_family_pay_result_migisterno_job", new HashMap<String, Object>());
                logger.info("sign_family_pay_result_migisterno_job  job success");
            } else {
                logger.info("sign_family_pay_result_migisterno_job  job exist");
            }
            //处理家庭签约当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
            if (!quartzHelper.isExistJob("onepay_query_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("onepay_query_job");

+ 2 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionExecuteSickSettleJob.java

@ -28,7 +28,7 @@ public class PrescriptionExecuteSickSettleJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("START=====开始执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
//        logger.info("START=====开始执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
        try {
            //获取支付完成,院内结算失败的 处方CODE 集合
            List<String> prescriptionCodeList = prescriptionService.findCodesByPayStautsAndExecuteSickStatus();
@ -43,7 +43,7 @@ public class PrescriptionExecuteSickSettleJob implements Job {
                    }
                }
            }
        logger.info("END========执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
//        logger.info("END========执行长处方支付成功,院内结算失败,重新执行院内结算的JOB");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("END===ERROE===执行长处方支付成功,院内结算失败,重新执行院内结算的JOB,message:"+e.getMessage());

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

@ -38,15 +38,15 @@ public class SFExpressJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            logger.info("顺丰快递JOB开始:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
//            logger.info("顺丰快递JOB开始:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
            List<PrescriptionExpressage> expresslist = prescriptionExpressageService.findByPrescriptionPaidExpressOrderFail();
            if(!expresslist.isEmpty()){
                logger.info("顺丰快递JOB:找到"+expresslist.size()+"条下单失败记录,开始重新下单"+ DateUtil.getNowDate());
//                logger.info("顺丰快递JOB:找到"+expresslist.size()+"条下单失败记录,开始重新下单"+ DateUtil.getNowDate());
                sfexpressService.reOrderExpress(expresslist);
            }else{
                logger.info("顺丰快递JOB:未找到下单失败的处方快递记录"+ DateUtil.getNowDate());
//                logger.info("顺丰快递JOB:未找到下单失败的处方快递记录"+ DateUtil.getNowDate());
            }
            logger.info("顺丰快递JOB结束:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
//            logger.info("顺丰快递JOB结束:搜索已支付成功,但是顺丰快递下单失败的处方物流记录,重新下单---------时间:"+ DateUtil.getNowDate());
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("顺丰快递JOB执行出错:错误信息"+ e.getMessage());

+ 36 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/SignFamilyPayResultJob.java

@ -0,0 +1,36 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
/**
 * 遍历没有医保签约号的家庭签约支付记录,
 * 查询家庭签约支付结果,补更新医保签约号
 * @author huangwenjie
 * @date 2017/9/29 11:04
 */
public class SignFamilyPayResultJob implements Job {
	private static final Logger logger = LoggerFactory.getLogger(SignFamilyPayResultJob.class);
	
	@Autowired
	private PatientPrescriptionPayService payService;
	
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		try {
			//根据起止时间查询家签慢病患者定标情况,并同步到本地数据库
			payService.getSignFamilyPayResultJob(new Date(),DateUtil.getNextMin(new Date(),-(60*24)));
		}catch (Exception e){
			e.printStackTrace();
			logger.info("END===ERROE==遍历没有医保签约号的家庭签约支付记录JOB,message:"+e.getMessage());
		}
	}
}

+ 3 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java

@ -60,6 +60,9 @@ public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>,
    List<WlyyCharge> findByPatient(String patient, Pageable pageRequest);
    @Query(value = "select * from wlyy_charge where trade_status = ?1 AND (mi_register_no IS null OR mi_register_no = '') AND update_time BETWEEN ?2  and ?3",nativeQuery = true)
    List<WlyyCharge> findByTradeStatusAndMiRegisterNoAndUpdateTime(int tradestatus, Date enddate, Date startdate);
    //   查询当天支付,页面回调及异步回调均失败的支付 tradeStatus为空
    @Query(value = "SELECT t.`code` FROM wlyy_charge t WHERE t.trade_status is null AND t.create_time >= date(now()) AND t.create_time < DATE_ADD(date(now()), INTERVAL 1 DAY)", nativeQuery = true)
    List<String> findTodayUnpay();

+ 610 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/ZyDictService.java

@ -0,0 +1,610 @@
package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.entity.zydict.*;
import com.yihu.wlyy.repository.zydict.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * Created by chenweida on 2017/9/30.
 */
@Service
public class ZyDictService {
    public Logger logger = LoggerFactory.getLogger(ZyDictService.class);
    @Autowired
    public ZyCommonDictDao zyCommonDictDao;
    @Autowired
    public ZyIvDeptDictDao zyIvDeptDictDao;
    @Autowired
    public ZyIvDeptStaffAllotDictDao zyIvDeptStaffAllotDictDao;
    @Autowired
    public ZyIvDiagnoseClassDictDao zyIvDiagnoseClassDictDao;
    @Autowired
    public ZyIvDiagnoseDictDao zyIvDiagnoseDictDao;
    @Autowired
    public ZyIvOrgPhysicAllotDictDao zyIvOrgPhysicAllotDictDao;
    @Autowired
    public ZyIvPhysicDictDao zyIvPhysicDictDao;
    @Autowired
    public ZyIvStaffDictDao zyIvStaffDictDao;
    @Autowired
    public ZyIvStaffRegTypeAllotDictDao zyIvStaffRegTypeAllotDictDao;
    @Autowired
    public ZyIvSubjectClassDictDao zyIvSubjectClassDictDao;
    @Autowired
    public JwPrescriptionService jwPrescriptionService;
    public void synchronizeZy_iv_diagnose_dict() {
        logger.info("synchronized zy_iv_diagnose_dict start");
        String dictName = this.IV_DIAGNOSE_DICT;
        List<ZyIvDiagnoseDict> zyIvDiagnoseDicts = new ArrayList<>();
        //得到list
        zyIvDiagnoseDicts = commonGetOneDict(ZyIvDiagnoseDict.class, dictName);
        if (zyIvDiagnoseDicts != null && zyIvDiagnoseDicts.size() > 0) {
            //清空表
            zyIvDiagnoseDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_dict  ,size:" + zyIvDiagnoseDicts.size());
            List<ZyIvDiagnoseDict> zyIvDiagnoseDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvDiagnoseDicts.size(); i++) {
                zyIvDiagnoseDictTemp.add(zyIvDiagnoseDicts.get(i));
                //批量提交
                if (((zyIvDiagnoseDictTemp.size() % 2000) == 0) || (zyIvDiagnoseDictTemp.size() == i)) {
                    saveZy_iv_diagnose_dict(zyIvDiagnoseDictTemp);
                    zyIvDiagnoseDictTemp = new ArrayList<>();
                }
            }
        }
        logger.info("synchronized zy_iv_diagnose_dict end");
    }
    @Transactional
    private void saveZy_iv_diagnose_dict(List<ZyIvDiagnoseDict> zyIvDiagnoseDictTemp) {
        zyIvDiagnoseDictDao.save(zyIvDiagnoseDictTemp);
    }
    public void synchronizeZy_iv_subject_class_dict() {
        logger.info("synchronized zy_iv_subject_class_dict start");
        String dictName = this.IV_SUBJECT_CLASS_DICT;
        List<ZyIvSubjectClassDict> zyIvSubjectClassDicts = new ArrayList<>();
        //得到list
        zyIvSubjectClassDicts = commonGetOneDict(ZyIvSubjectClassDict.class, dictName);
        if (zyIvSubjectClassDicts.size() > 0) {
            //清空表
            zyIvSubjectClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_subject_class_dict  ,size:" + zyIvSubjectClassDicts.size());
            List<ZyIvSubjectClassDict> zyIvSubjectClassDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvSubjectClassDicts.size(); i++) {
                zyIvSubjectClassDictTemp.add(zyIvSubjectClassDicts.get(i));
                //批量提交
                if (((zyIvSubjectClassDictTemp.size() % 2000) == 0) || (zyIvSubjectClassDictTemp.size() == i)) {
                    saveZy_iv_subject_class_dict(zyIvSubjectClassDictTemp);
                    zyIvSubjectClassDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_subject_class_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_subject_class_dict(List<ZyIvSubjectClassDict> zyIvSubjectClassDictTemp) {
        zyIvSubjectClassDictDao.save(zyIvSubjectClassDictTemp);
    }
    public void synchronizeZy_iv_staff_reg_type_allot_dict() {
        logger.info("synchronized zy_iv_staff_reg_type_allot_dict start");
        String dictName = this.IV_STAFF_REG_TYPE_ALLOT_DICT;
        List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDicts = new ArrayList<>();
        //得到list
        zyIvStaffRegTypeAllotDicts = commonGetOneDict(ZyIvStaffRegTypeAllotDict.class, dictName);
        if (zyIvStaffRegTypeAllotDicts != null && zyIvStaffRegTypeAllotDicts.size() > 0) {
            //清空表
            zyIvStaffRegTypeAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_reg_type_allot_dict  ,size:" + zyIvStaffRegTypeAllotDicts.size());
            List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvStaffRegTypeAllotDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zyIvStaffRegTypeAllotDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_staff_reg_type_allot_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_staff_reg_type_allot_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_staff_reg_type_allot_dict(List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDictTemp) {
        zyIvStaffRegTypeAllotDictDao.save(zyIvStaffRegTypeAllotDictTemp);
    }
    @Transactional
    public void synchronizeZ_iv_staff_dict() {
        logger.info("synchronized zy_iv_staff_dict start");
        String dictName = this.IV_STAFF_DICT;
        List<ZyIvStaffDict> zyIvStaffDicts = new ArrayList<>();
        //得到list
        zyIvStaffDicts = commonGetOneDict(ZyIvStaffDict.class, dictName);
        //清空表
        if (zyIvStaffDicts != null && zyIvStaffDicts.size() > 0) {
            zyIvStaffDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_dict  ,size:" + zyIvStaffDicts.size());
            zyIvStaffDictDao.save(zyIvStaffDicts);
            logger.info("synchronized zy_iv_staff_dict end");
        }
    }
    public void synchronizeZy_iv_physic_dict() {
        logger.info("synchronized zy_iv_physic_dict start");
        String dictName = this.IV_PHYSIC_DICT;
        List<ZyIvPhysicDict> zyIvPhysicDicts = new ArrayList<>();
        //得到list
        zyIvPhysicDicts = commonGetOneDict(ZyIvPhysicDict.class, dictName);
        if (zyIvPhysicDicts != null && zyIvPhysicDicts.size() > 0) {
            //清空表
            zyIvPhysicDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_physic_dict  ,size:" + zyIvPhysicDicts.size());
            List<ZyIvPhysicDict> zyIvPhysicDictsTemp = new ArrayList<>();
            for (int i = 0; i < zyIvPhysicDicts.size(); i++) {
                zyIvPhysicDictsTemp.add(zyIvPhysicDicts.get(i));
                //批量提交
                if (((zyIvPhysicDictsTemp.size() % 2000) == 0) || (zyIvPhysicDictsTemp.size() == i)) {
                    saveObPhysicDict(zyIvPhysicDictsTemp);
                    zyIvPhysicDictsTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_physic_dict end");
        }
    }
    @Transactional
    private void saveObPhysicDict(List<ZyIvPhysicDict> zyIvPhysicDictsTemp) {
        zyIvPhysicDictDao.save(zyIvPhysicDictsTemp);
    }
    @Transactional
    public void synchronizeZy_iv_org_physic_allot_dict() {
        logger.info("synchronized zy_iv_org_physic_allot_dict start");
        String dictName = this.IV_ORG_PHYSIC_ALLOT_DICT;
        List<ZyIvOrgPhysicAllotDict> zyIvOrgPhysicAllotDicts = new ArrayList<>();
        //得到list
        zyIvOrgPhysicAllotDicts = commonGetOneDict(ZyIvOrgPhysicAllotDict.class, dictName);
        if (zyIvOrgPhysicAllotDicts != null && zyIvOrgPhysicAllotDicts.size() > 0) {
            //清空表
            zyIvOrgPhysicAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_org_physic_allot_dict  ,size:" + zyIvOrgPhysicAllotDicts.size());
            List<ZyIvOrgPhysicAllotDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvOrgPhysicAllotDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zyIvOrgPhysicAllotDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_org_physic_allot_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_org_physic_allot_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_org_physic_allot_dict(List<ZyIvOrgPhysicAllotDict> zyIvOrgPhysicAllotDicts) {
        zyIvOrgPhysicAllotDictDao.save(zyIvOrgPhysicAllotDicts);
    }
    public void synchronizeZy_iv_diagnose_class_dict() {
        logger.info("synchronized zy_iv_diagnose_class_dict start");
        String dictName = this.IV_DIAGNOSE_CLASS_DICT;
        List<ZyIvDiagnoseClassDict> zIvDiagnoseClassDicts = new ArrayList<>();
        //得到list
        zIvDiagnoseClassDicts = commonGetOneDict(ZyIvDiagnoseClassDict.class, dictName);
        if (zIvDiagnoseClassDicts != null && zIvDiagnoseClassDicts.size() > 0) {
            //清空表
            zyIvDiagnoseClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_class_dict  ,size:" + zIvDiagnoseClassDicts.size());
            List<ZyIvDiagnoseClassDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zIvDiagnoseClassDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zIvDiagnoseClassDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_diagnose_class_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_diagnose_class_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_diagnose_class_dict(List<ZyIvDiagnoseClassDict> zIvDiagnoseClassDicts) {
        zyIvDiagnoseClassDictDao.save(zIvDiagnoseClassDicts);
    }
    @Transactional
    public void synchronizeZy_iv_dept_staff_allot_dict() {
        logger.info("synchronized zy_iv_dept_staff_allot_dict start");
        String dictName = this.IV_DEPT_STAFF_ALLOT_DICT;
        List<ZyIvDeptStaffAllotDict> syIvDeptStaffAllotDictz = new ArrayList<>();
        //得到list
        syIvDeptStaffAllotDictz = commonGetOneDict(ZyIvDeptStaffAllotDict.class, dictName);
        if (syIvDeptStaffAllotDictz != null && syIvDeptStaffAllotDictz.size() > 0) {
            //清空表
            zyIvDeptStaffAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_staff_allot_dict  ,size:" + syIvDeptStaffAllotDictz.size());
            List<ZyIvDeptStaffAllotDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < syIvDeptStaffAllotDictz.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(syIvDeptStaffAllotDictz.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_dept_staff_allot_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_dept_staff_allot_dict end");
        }
    }
    private void saveZy_iv_dept_staff_allot_dict(List<ZyIvDeptStaffAllotDict> syIvDeptStaffAllotDictz) {
        zyIvDeptStaffAllotDictDao.save(syIvDeptStaffAllotDictz);
    }
    public void synchronizeZyCommonDict() {
        logger.info("synchronized zy_common_dict start");
        String[] dictNames = new String[]{
                this.IV_PHYSIC_FORM_DICT, this.IV_PHYSIC_INJECT_PLACE_DICT, this.IV_PHYSIC_SKIN_TEST_DICT,
                this.IV_RATE_TYPE_DICT, this.IV_RECIPE_FREQUENCY_DICT, this.IV_RECIPE_USAGE_DICT,
                this.IV_SEX_DICT, this.IV_PHYSIC_TOXICOLOGY_TYPE_DICT, this.IV_MEASURE_UNIT_DICT,
                this.IV_DEPT_TYPE_DICT};
        List<ZyCommonDict> zyCommonDictz = new ArrayList<>();
        Boolean isFlush = true;
        for (String dictName : dictNames) {
            String json = null;
            try {
                //调用智业的接口得到字典
                json = jwPrescriptionService.getDictForI(dictName);
                JSONObject returnJson = JSONObject.fromObject(json);
                if (returnJson.getInt("status") != 200) {
                    throw new Exception("zy dict error status not 200");
                }
                if (returnJson.containsKey("data")) {
                    String dataString = returnJson.getString("data");
                    JSONArray dataJSONArray = JSONObject.fromObject(dataString).getJSONArray("returnData");
                    if (dataJSONArray.size() == 0) {
                        logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                        continue;
                    }
                    //下划线转驼峰
                    JSONArray newJA = new JSONArray();
                    JSONArray jsonArrayTemp = dataJSONArray.getJSONArray(0);
                    logger.info("zy dict data size " + jsonArrayTemp.size() + ",dictname:" + dictName);
                    for (int i = 0; i < jsonArrayTemp.size(); i++) {
                        JSONObject jo = jsonArrayTemp.getJSONObject(i);
                        JSONObject newJO = new JSONObject();
                        jo.keySet().stream().forEach(key -> {
                            Object value = jo.get(key);
                            String newKey = Tool.lineToHump(key.toString());
                            newJO.put(newKey, value);
                        });
                        newJA.add(newJO);
                    }
                    ZyCommonDict[] zyCommonDictArrays = (ZyCommonDict[]) JSONArray.toArray(newJA, ZyCommonDict.class);
                    zyCommonDictz.addAll(Arrays.asList(zyCommonDictArrays));
                } else {
                    throw new Exception("zy dict error no contain data");
                }
            } catch (Exception e) {
                e.printStackTrace();
                isFlush = false; //设置状态不能更新
                logger.error("dictName:" + dictName);
                logger.error("returnJson:" + json);
                logger.error(e.getMessage());
            }
        }
        //判断是否可以更新
        if (isFlush) {
            // 判断返回的数据是否大于0
            if (zyCommonDictz.size() > 0) {
                //清空表
                zyCommonDictDao.deleteAll();
                //新增数据
                logger.info("save table zy_common_dict  ,size:" + zyCommonDictz.size());
                List<ZyCommonDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                for (int i = 0; i < zyCommonDictz.size(); i++) {
                    zyIvStaffRegTypeAllotDictTemp.add(zyCommonDictz.get(i));
                    //批量提交
                    if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                        saveZyCommonDict(zyIvStaffRegTypeAllotDictTemp);
                        zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                    }
                }
                logger.info("synchronized zy_common_dict end");
            }
        }
    }
    @Transactional
    private void saveZyCommonDict(List<ZyCommonDict> zyCommonDictz) {
        zyCommonDictDao.save(zyCommonDictz);
    }
    public void synchronizeZy_iv_dept_dict() {
        logger.info("synchronized zy_iv_dept_dict start");
        String dictName = this.IV_DEPT_DICT;
        List<ZyIvDeptDict> zyIvDeptDicts = new ArrayList<>();
        //得到list
        zyIvDeptDicts = commonGetOneDict(ZyIvDeptDict.class, dictName);
        if (zyIvDeptDicts != null && zyIvDeptDicts.size() > 0) {
            //清空表
            zyIvDeptDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_dict  ,size:" + zyIvDeptDicts.size());
            List<ZyIvDeptDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvDeptDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zyIvDeptDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_dept_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_dept_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_dept_dict(List<ZyIvDeptDict> zyIvDeptDicts) {
        zyIvDeptDictDao.save(zyIvDeptDicts);
    }
    /**
     * 得到单个字典
     *
     * @param clazz    class
     * @param dictName 字典名称
     */
    public List commonGetOneDict(Class clazz, String dictName) {
        String json = null;
        try {
            //调用智业的接口得到字典
            json = jwPrescriptionService.getDictForI(dictName);
            JSONObject returnJson = JSONObject.fromObject(json);
            if (returnJson.getInt("status") != 200) {
                throw new Exception("zy dict error status not 200");
            }
            if (returnJson.containsKey("data")) {
                String dataJSONStr = returnJson.getString("data");
                JSONObject joTemp = JSONObject.fromObject(dataJSONStr);
                JSONArray dataJSONArray = joTemp.getJSONArray("returnData");
                if (dataJSONArray.size() == 0) {
                    logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                    return null;
                } else {
                    dataJSONArray = dataJSONArray.getJSONArray(0);
                }
                logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                //下划线转驼峰
                JSONArray newJA = new JSONArray();
                for (int i = 0; i < dataJSONArray.size(); i++) {
                    JSONObject jo = dataJSONArray.getJSONObject(i);
                    JSONObject newJO = new JSONObject();
                    jo.keySet().stream().forEach(key -> {
                        Object value = jo.get(key);
                        String newKey = Tool.lineToHump(key.toString());
                        newJO.put(newKey, value);
                    });
                    newJA.add(newJO);
                }
                return (List) JSONArray.toCollection(newJA, clazz);
            } else {
                throw new Exception("zy dict error no contain data");
            }
        } catch (Exception e) {
            logger.error("dictName:" + dictName);
            logger.error("returnJson:" + json);
            logger.error(e.getMessage());
        }
        return null;
    }
    /**
     * 智业的字典
     */
    public static final String IV_MEASURE_UNIT_DICT = "IV_MEASURE_UNIT_DICT";//("计量单位字典", "IV_MEASURE_UNIT_DICT"),
    public static final String IV_PHYSIC_FORM_DICT = "IV_PHYSIC_FORM_DICT";//("药品剂型字典", "IV_PHYSIC_FORM_DICT"),
    public static final String IV_PHYSIC_INJECT_PLACE_DICT = "IV_PHYSIC_INJECT_PLACE_DICT";//"计量单位字典", "IV_PHYSIC_INJECT_PLACE_DICT"),
    public static final String IV_PHYSIC_SKIN_TEST_DICT = "IV_PHYSIC_SKIN_TEST_DICT";//("皮试类型字典", "IV_PHYSIC_SKIN_TEST_DICT"),
    public static final String IV_RATE_TYPE_DICT = "IV_RATE_TYPE_DICT";//("费别字典", "IV_RATE_TYPE_DICT"),
    public static final String IV_RECIPE_FREQUENCY_DICT = "IV_RECIPE_FREQUENCY_DICT";//("频次字典", "IV_RECIPE_FREQUENCY_DICT"),
    public static final String IV_RECIPE_USAGE_DICT = "IV_RECIPE_USAGE_DICT";//("用药方法字典", "IV_RECIPE_USAGE_DICT"),
    public static final String IV_SEX_DICT = "IV_SEX_DICT";//("性别字典", "IV_SEX_DICT"),
    public static final String IV_PHYSIC_DICT = "IV_PHYSIC_DICT";//("药品字典", "IV_PHYSIC_DICT"),
    public static final String IV_ORG_PHYSIC_ALLOT_DICT = "IV_ORG_PHYSIC_ALLOT_DICT";//("机构药品分发字典", "IV_ORG_PHYSIC_ALLOT_DICT "),
    public static final String IV_SUBJECT_CLASS_DICT = "IV_SUBJECT_CLASS_DICT";//("科目类别字典", "IV_SUBJECT_CLASS_DICT"),
    public static final String IV_PHYSIC_TOXICOLOGY_TYPE_DICT = "IV_PHYSIC_TOXICOLOGY_TYPE_DICT";//("药品毒理分类字典", "IV_PHYSIC_TOXICOLOGY_TYPE_DICT"),
    public static final String IV_DEPT_DICT = "IV_DEPT_DICT";//("科室字典", "IV_DEPT_DICT"),
    public static final String IV_DEPT_TYPE_DICT = "IV_DEPT_TYPE_DICT";//("科室类型字典", "IV_DEPT_TYPE_DICT"),
    public static final String IV_DIAGNOSE_DICT = "IV_DIAGNOSE_DICT";//("诊断字典", "IV_DIAGNOSE_DICT"),
    public static final String IV_DIAGNOSE_CLASS_DICT = "IV_DIAGNOSE_CLASS_DICT";//("诊断类别字典", "IV_DIAGNOSE_CLASS_DICT"),
    public static final String IV_STAFF_DICT = "IV_STAFF_DICT";//("员工字典", "IV_STAFF_DICT"),
    public static final String IV_STAFF_REG_TYPE_ALLOT_DICT = "IV_STAFF_REG_TYPE_ALLOT_DICT";//("员工挂号类型配置字典", "IV_STAFF_REG_TYPE_ALLOT_DICT"),
    public static final String IV_DEPT_STAFF_ALLOT_DICT = "IV_DEPT_STAFF_ALLOT_DICT";//("科室员工配置字典", "IV_DEPT_STAFF_ALLOT_DICT");
    /**
     * 字典表的枚举类
     */
    public enum TableName {
        zy_common_dict("通用字典", "zy_common_dict"),
        zy_iv_dept_dict("科室字典", "zy_iv_dept_dict"),
        zy_iv_dept_staff_allot_dict("科室员工配置字典", "zy_iv_dept_staff_allot_dict"),
        zy_iv_diagnose_class_dict("诊断类别字典", "zy_iv_diagnose_class_dict"),
        zy_iv_diagnose_dict("诊断字典表", "zy_iv_diagnose_dict"),
        zy_iv_org_physic_allot_dict("机构药品分发字典", "zy_iv_org_physic_allot_dict"),
        zy_iv_physic_dict("药品字典", "zy_iv_physic_dict"),
        zy_iv_staff_dict("员工字典", "zy_iv_staff_dict"),
        zy_iv_staff_reg_type_allot_dict("员工挂号类型配置字典", "zy_iv_staff_reg_type_allot_dict"),
        zy_iv_subject_class_dict("科目类别字典", "zy_iv_subject_class_dict");
        TableName(String name, String dict) {
            this.name = name;
            this.dict = dict;
        }
        public String name;
        public String dict;
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String getDict() {
            return dict;
        }
        public void setDict(String dict) {
            this.dict = dict;
        }
    }
    /**
     * 根据字典获取表名
     *
     * @param dictName
     * @return
     */
    public String getTableName(String dictName) {
        switch (dictName) {
            case IV_PHYSIC_FORM_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_INJECT_PLACE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_SKIN_TEST_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_RATE_TYPE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_RECIPE_FREQUENCY_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_RECIPE_USAGE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_SEX_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_TOXICOLOGY_TYPE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_MEASURE_UNIT_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_DEPT_TYPE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_DICT: {
                return TableName.zy_iv_physic_dict.getDict();
            }
            case IV_ORG_PHYSIC_ALLOT_DICT: {
                return TableName.zy_iv_org_physic_allot_dict.getDict();
            }
            case IV_SUBJECT_CLASS_DICT: {
                return TableName.zy_iv_subject_class_dict.getDict();
            }
            case IV_DIAGNOSE_DICT: {
                return TableName.zy_iv_diagnose_dict.getDict();
            }
            case IV_DIAGNOSE_CLASS_DICT: {
                return TableName.zy_iv_diagnose_class_dict.getDict();
            }
            case IV_STAFF_DICT: {
                return TableName.zy_iv_staff_dict.getDict();
            }
            case IV_STAFF_REG_TYPE_ALLOT_DICT: {
                return TableName.zy_iv_staff_reg_type_allot_dict.getDict();
            }
            case IV_DEPT_STAFF_ALLOT_DICT: {
                return TableName.zy_iv_dept_staff_allot_dict.getDict();
            }
            case IV_DEPT_DICT: {
                return TableName.zy_iv_dept_dict.getDict();
            }
        }
        return "";
    }
    public static class Tool {
        public static Pattern linePattern = Pattern.compile("_(\\w)");
        /**
         * 下划线转驼峰
         */
        public static String lineToHump(String str) {
            str = str.toLowerCase();
            Matcher matcher = linePattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
        /**
         * 驼峰转下划线(简单写法,效率低于{@link #humpToLine2(String)})
         */
        public static String humpToLine(String str) {
            return str.replaceAll("[A-Z]", "_$0").toLowerCase();
        }
        public static Pattern humpPattern = Pattern.compile("[A-Z]");
        /**
         * 驼峰转下划线,效率比上面高
         */
        public static String humpToLine2(String str) {
            Matcher matcher = humpPattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
    }
}

+ 72 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/ZyDictController.java

@ -0,0 +1,72 @@
package com.yihu.wlyy.web;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
 * Created by chenweida on 2017/9/30.
 */
@Controller
@RequestMapping(value = "/zydict/")
@Api(description = "同步智业字典")
public class ZyDictController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(ZyDictController.class);
    @Autowired
    private ZyDictService zyDictService;
    @ApiOperation("同步智业字典")
    @RequestMapping(value = "/synchronousDict", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String synchronousDict(
            @ApiParam(name = "dictName", value = "字典名称", defaultValue = "") @RequestParam(value = "dictName", required = true) String dictName) {
        try {
            if (ZyDictService.TableName.zy_common_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_common_dict");
                zyDictService.synchronizeZyCommonDict();
            } else if (ZyDictService.TableName.zy_iv_dept_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_dept_dict");
                zyDictService.synchronizeZy_iv_dept_dict();
            } else if (ZyDictService.TableName.zy_iv_dept_staff_allot_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_dept_staff_allot_dict");
                zyDictService.synchronizeZy_iv_dept_staff_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_diagnose_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_diagnose_dict");
                zyDictService.synchronizeZy_iv_diagnose_dict();
            } else if (ZyDictService.TableName.zy_iv_diagnose_class_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_diagnose_class_dict");
                zyDictService.synchronizeZy_iv_diagnose_class_dict();
            } else if (ZyDictService.TableName.zy_iv_org_physic_allot_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_org_physic_allot_dict");
                zyDictService.synchronizeZy_iv_org_physic_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_physic_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_physic_dict");
                zyDictService.synchronizeZy_iv_physic_dict();
            } else if (ZyDictService.TableName.zy_iv_staff_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_staff_dict");
                zyDictService.synchronizeZ_iv_staff_dict();  //birthday    Date(529084800000+0800) 无法解析
            } else if (ZyDictService.TableName.zy_iv_staff_reg_type_allot_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_staff_reg_type_allot_dict");
                zyDictService.synchronizeZy_iv_staff_reg_type_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_subject_class_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_subject_class_dict");
                zyDictService.synchronizeZy_iv_subject_class_dict();
            }
            return success("同步成功");
        } catch (Exception e) {
            logger.error(e.getMessage());
            return invalidUserException(e, -1, "同步失败");
        }
    }
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -538,4 +538,21 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /**
     *立即执行:查询家庭签约支付结果,补更新医保签约号
     *@author huangwenjie
     *@date 2017/9/29 13:37
     */
    @RequestMapping(value = "/executeSignFamilyPayResultJob", method = RequestMethod.POST)
    @ApiOperation("立即执行查询家庭签约支付结果,补更新医保签约号")
    public String executeSignFamilyPayResultJob() {
        try {
            quartzHelper.startNow(SignFamilyPayResultJob.class, "SIGN_FAMILY_PAY_RESULT_MIRESISTERNO_JOB", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 2 - 2
patient-co/patient-co-wlyy-job/src/main/resources/application-prod.yml

@ -20,8 +20,8 @@ spring:
channel:
  redis:
    host: 10.95.22.142 # Redis server host.
    port: 6380 # Redis server port.
    host: 59.61.92.90 # Redis server host.
    port: 9054 # Redis server port.
    password: jkzlehr
server:

+ 5 - 2
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -87,8 +87,8 @@ sfexpress_reorder_job=0 0/10 * * * ?
#同步智业字典
zy_dict_job=0 0 1 * * ?
#遍历支付成功,院内结算失败的的记录,重新结算,10分钟跑一次
zy_execute_sick_settle_job=0 0/10 * * * ?
#遍历支付成功,院内结算失败的的记录,重新结算,3分钟跑一次
zy_execute_sick_settle_job=0 0/3 * * * ?
#处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
prescription_pay_query_job=0 0/3 * * * ?
@ -101,6 +101,9 @@ doctor_feldsher_template_job=0 0/29 * * * ?
# 病患者定标情况同步JOB (每天2点一次)
patient_disease_contion_syn_job=0 0 2 * * ?
#查询家庭签约支付结果,补更新医保签约号,3分钟跑一次
sign_family_pay_result_migisterno_job=0 0/3 * * * ?
# 家庭签约支付回调失败,每3分钟一次去主动查询并保存
onepay_query_job=0 0/3 * * * ?

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/httplog/HttpLogDetailDao.java

@ -0,0 +1,11 @@
package com.yihu.wlyy.repository.httplog;
import com.yihu.wlyy.entity.httpLog.HttpLogDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/9/26.
 */
public interface HttpLogDetailDao extends PagingAndSortingRepository<HttpLogDetail, Long>, JpaSpecificationExecutor<HttpLogDetail> {
}

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

@ -12,7 +12,7 @@ import java.util.List;
 */
public interface PrenatalInspectorPlanDao extends PagingAndSortingRepository<PrenatalInspectorPlan, Long>{
    @Query("select a from PrenatalInspectorPlan a where a.inspectionCode = ?1 and a.status = '0' order by a.inspectionStartTime desc")
    @Query("select a from PrenatalInspectorPlan a where a.inspectionCode = ?1 and a.status = '0' order by a.inspectionStartTime asc")
    List<PrenatalInspectorPlan> findByCode(String inspectionCode);
    @Query("select a from PrenatalInspectorPlan a where a.inspectionTime is not null and a.status = '0' and ( TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=7 or TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=1 ) ")

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

@ -14,7 +14,7 @@ import java.util.List;
public interface PrenatalInspectorPlanLibraryDao extends PagingAndSortingRepository<PrenatalInspectorPlanLibrary, Long>{
    @Query("select a from PrenatalInspectorPlanLibrary a where a.endDay >= ?1 order by a.endDay desc ")
    @Query("select a from PrenatalInspectorPlanLibrary a where a.endDay >= ?1 order by a.endDay asc ")
    List<PrenatalInspectorPlanLibrary> findByDays(Long endDay);
}

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

@ -415,4 +415,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query(" select a from SignFamily a where a.patient = ?1 ")
    SignFamily findPatientExpensesStatus(String patient);
    // 查询团队已签约的总数
    @Query("select count(1) from SignFamily a where  a.adminTeamId = ?1 and (a.status = 1 or a.status = 2) and a.type = 2")
    int countAmountSignedByAdminTeam(Long id);
}

+ 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;
    }

+ 88 - 30
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -2,15 +2,18 @@ package com.yihu.wlyy.service.app.prenatalInspector;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlanLibrary;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPreCard;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.third.jw.JwMaternalChildService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2017/6/6.
@ -48,6 +52,10 @@ public class PrenatalInspectorPreCardService extends BaseService {
    private JwMaternalChildService jwMaternalChildService;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private ZyDictService zyDictService;
//    public
@ -95,8 +103,11 @@ public class PrenatalInspectorPreCardService extends BaseService {
        try{
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(),hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = json.getJSONArray("DATA");
            if(data.size()>0){
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                for (int i=0;i<data.size();i++) {
                    JSONObject planJson = new JSONObject();
                    JSONObject pregnancy = data.getJSONObject(i);
@ -126,6 +137,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
                            Date lastMenstrualDate = DateUtil.strToDate(MENSES_LAST);
                            Long days = DateUtil.getDays(date,lastMenstrualDate);
                            days = days>365?0:days;//老早前的测试数据处理
                            List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
                            plans = new ArrayList<>();
                            PrenatalInspectorPlan plan = null;
@ -175,8 +187,11 @@ public class PrenatalInspectorPreCardService extends BaseService {
                        try {
                            String bedRecode = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(patient.getIdcard(),hospital);
                            JSONObject bedJson = JSONObject.parseObject(bedRecode);
                            JSONArray bedData = bedJson.getJSONArray("DATA");
                            if(bedData.size()>0){
                            JSONArray bedData = null;
                            if(bedJson.getInteger("status")==200){
                                bedData = json.getJSONObject("data").getJSONArray("DATA");
                            }
                            if(bedData!=null&&bedData.size()>0){
                                JSONObject exam = data.getJSONObject(data.size()-1);
                                precontract_org_name = exam.getString("PRECONTRACT_ORG_NAME");
                            }
@ -185,6 +200,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
                        }
                        planJson.put("precontractOrgName",precontract_org_name);//产床医院
                    }
                    re.add(planJson);
                }
            }
@ -200,7 +216,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
     * @param patientCode
     * @return
     */
    public JSONObject firstExam(String patientCode){
    public JSONObject firstExam(String patientCode,String pregnancyNo){
        JSONObject re = new JSONObject();
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
@ -212,8 +228,17 @@ public class PrenatalInspectorPreCardService extends BaseService {
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(),hospital);
            JSONObject json = JSONObject.parseObject(response);
            if(json.getJSONArray("DATA").size()>0){
                re = json.getJSONArray("DATA").getJSONObject(0);
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                for (int i=0;i<data.size();i++){
                    if(pregnancyNo.equals(data.getJSONObject(i).getString("PREGNANCY_NO"))){//判断是否同一个产检
                        re = data.getJSONObject(i);
                        return re;
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
@ -226,8 +251,8 @@ public class PrenatalInspectorPreCardService extends BaseService {
     * @param patientCode
     * @return
     */
    public JSONArray reExamRecode(String patientCode,String pregnancyNo){
        JSONArray re = new JSONArray();
    public String reExamRecode(String patientCode,String pregnancyNo){
        String re = "";
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String hospital = null;
@ -237,8 +262,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
            Patient patient = patientDao.findByCode(patientCode);
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(patient.getIdcard(),hospital,pregnancyNo);
            JSONObject json = JSONObject.parseObject(response);
            re = json.getJSONArray("DATA");
            return response;
        }catch (Exception e){
            e.printStackTrace();
        }
@ -256,8 +280,11 @@ public class PrenatalInspectorPreCardService extends BaseService {
        try {
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(idcard,hospital,pregnancyNo);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = json.getJSONArray("DATA");
            if(data.size()>0){
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                JSONObject exam = data.getJSONObject(data.size()-1);
                String PREGNANCY_WEEK = exam.getString("PREGNANCY_WEEK");//检查孕周
                String examTime = exam.getString("EXAM_TIME");//产检日期
@ -280,8 +307,11 @@ public class PrenatalInspectorPreCardService extends BaseService {
        try {
            String response = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(idcard,hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = json.getJSONArray("DATA");
            if(data.size()>0){
            JSONArray data = null;
            if(json.getInteger("status")==200){
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                JSONObject exam = data.getJSONObject(data.size()-1);
                String PREGNANCY_WEEK = exam.getString("PREGNANCY_WEEK");//检查孕周
                String examTime = exam.getString("EXAM_TIME");//产检日期
@ -348,13 +378,44 @@ public class PrenatalInspectorPreCardService extends BaseService {
        return day%7;
    }
    /**
     * 上传预建卡
     * @param code
     */
    public void uploadPreExam(String code){
        try {
            //上传预建卡
            jwMaternalChildService.SaveEhrMaternalPreFirstExamRecord(code);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    /**
     * 新建产检预建卡
     */
    public void addPrenatalInspectorPreCard(PrenatalInspectorPreCard preCard){
    @Transactional
    public String addPrenatalInspectorPreCard(PrenatalInspectorPreCard preCard,String patientcCode){
        SignFamily signFamily = signFamilyDao.findByPatient(patientcCode);
        if(signFamily==null){
            return "-1";
        }
        //获取团队长
        Doctor doctor = doctorDao.findByAdminTeamId(signFamily.getAdminTeamId());
        preCard.setDoctor(doctor.getCode());
        preCard.setDoctorName(doctor.getName());
        //保存智业的医生信息
        Map<String,Object> map = zyDictService.findJwDoctorByDoctor(doctor.getCode());
        if(map!=null){
            preCard.setJwDoctor(map.get("jw_doctor").toString());
        }
        String re = "";
        //1、保存预建卡
        Date date = new Date();
        Date lastMenstrualDate = preCard.getLastMenstrualDate();
//        Date lastMenstrualDate = preCard.getLastMenstrualDate();
        preCard.setDel("1");
        preCard.setCode(getCode());
        preCard.setCzrq(date);
@ -362,16 +423,18 @@ public class PrenatalInspectorPreCardService extends BaseService {
        preCard.setStatus("0");
        preCard.setEffective("");
        preCard.setInspectionPhase("1");//检查阶段
        preCard.setUploadStatus("0");//未上传
        prenatalInspectorPreCardDao.save(preCard);
//        String patient = preCard.getPatient();
        try {
            //上传预建卡
        }catch (Exception e){
            e.printStackTrace();
        }
        //2.更新居民信息
//        Patient p = patientDao.findByCode(patient);
//        p.setName(preCard.getName());
//        p.setSsc(preCard.getSsc());
//        p.setBirthday(preCard.getBirthday());
//        p.setMobile(preCard.getMobile());
        String patient = preCard.getPatient();
        return preCard.getCode();
        //2、生成待产检计划(待产检计划由获取健康信息接口生成,关联产检计划)
//        Long days = DateUtil.getDays(date,lastMenstrualDate);
@ -405,12 +468,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
//            prenatalInspectorPlanDao.save(plans);
//        }
        //3.更新居民信息
//        Patient p = patientDao.findByCode(patient);
//        p.setName(preCard.getName());
//        p.setSsc(preCard.getSsc());
//        p.setBirthday(preCard.getBirthday());
//        p.setMobile(preCard.getMobile());
    }

+ 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());

+ 33 - 16
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;
@ -345,8 +347,9 @@ public class FamilyContractService extends BaseService {
        json.put("services", services);
        //是否签约上限
        int signLimit = signWebService.getSickFamilyDoctorSignLimit(doctor);
        json.put("signLimit", signLimit);
        JSONObject signLimit = signWebService.getSickFamilyDoctorSignLimit(doctor);
        json.put("signTotal",signLimit.getInt("signTotal"));//签约总数
        json.put("limitTotal",signLimit.getInt("limitTotal"));//限制总数
        return json;
    }
@ -886,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,
@ -901,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 = "";
@ -974,6 +976,7 @@ public class FamilyContractService extends BaseService {
        if (StringUtils.isNotBlank(sevId)) {
            signWebService.setSevId(sf, sevId);
        }
        // 查询该患者是否已注册
        Patient patient = patientDao.findByIdcard(idcard);
        if (patient == null) {
@ -1191,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";
    }
    /**
@ -1719,7 +1722,14 @@ public class FamilyContractService extends BaseService {
     * @return
     */
    public int countAmountSigned(String doctor) {
        return signFamilyDao.countAmountSignedByDoctor(doctor);
        AdminTeam adminTeam = doctorAdminTeamDao.findByLeaderCode(doctor);
        if(adminTeam!=null){
            //团队长只显示实际有签约关系的数量
            return signFamilyDao.countAmountSignedByAdminTeam(adminTeam.getId());
        }else{
            //不是团队长显示所有有服务关系的数量
            return signFamilyDao.countAmountSignedByDoctor(doctor);
        }
    }
    /**
@ -4051,7 +4061,7 @@ public class FamilyContractService extends BaseService {
                "  a.patient=p.`code` " +
                " AND a.`status` IN (1, 2) ");
        List params = new ArrayList<>();
        if (teamCode!=null&&teamCode>0) {
        if (teamCode != null && teamCode > 0) {
            sb.append(" AND a.admin_team_code =?  ");
            params.add(teamCode);
        }
@ -4064,12 +4074,19 @@ public class FamilyContractService extends BaseService {
        return patients;
    }
    public String getSickArchiveFlag(String patient)throws Exception{
    public String getSickArchiveFlag(String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        String rs = jwArchivesService.getSickArchiveFlag(p.getIdcard());
        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/SignFamilyServiceService.java

@ -169,7 +169,7 @@ public class SignFamilyServiceService {
                "   wlyy_service_item s, " +
                "   wlyy_sign_family_service_item si " +
                " WHERE " +
                "   s.`code` = si.service_item_code and si.del=1 ");
                "   s.`code` = si.service_item_code and si.del=1 and s.del=1");
        if (!StringUtils.isEmpty(patient)) {
            sql.append(" and si.patient = '" + patient + "'");
        }

+ 9 - 10
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 " +
@ -2621,13 +2621,15 @@ public class SignWebService extends BaseService {
     * @param doctorCode
     * @return
     */
    public Integer getSickFamilyDoctorSignLimit(String doctorCode){
        Integer re = 0;//0未达上线 1 已达上限
    public JSONObject getSickFamilyDoctorSignLimit(String doctorCode){
        JSONObject re = new JSONObject();//0未达上线 1 已达上限
        Integer signTotal = 0;
        Integer limitTotal = 0;
        List<AdminTeam> adminTeams = doctorAdminTeamMemberDao.findDoctorTeams(doctorCode);
        int limitNum = 0;
        for(AdminTeam one:adminTeams){
            //获取团队签约数
            Integer signCount = signFamilyDao.findByAdminTeamIdAndStatus(one.getId(),0);
            signTotal+=signCount;
            //获取智业团队签约上线
            String jwCode = one.getMappingCode();//智业服务团队的code
            try{
@ -2637,18 +2639,15 @@ public class SignWebService extends BaseService {
                    com.alibaba.fastjson.JSONObject data = json.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        int sign_limit_number = data.getJSONArray("DATA").getJSONObject(0).getInteger("SIGN_LIMIT_NUMBER");//签约上线
                        if(signCount>=sign_limit_number){
                            limitNum++;
                        }
                        limitTotal+=sign_limit_number;
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if(adminTeams.size()==limitNum){
            re = 1;
        }
        re.put("signTotal",signTotal);
        re.put("limitTotal",limitTotal);
        return re;
    }

+ 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);
        }

+ 24 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/httplog/LogService.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.service.third.httplog;
import com.yihu.wlyy.entity.httpLog.HttpLog;
import com.yihu.wlyy.entity.httpLog.HttpLogDetail;
import com.yihu.wlyy.repository.httplog.HttpLogDao;
import com.yihu.wlyy.repository.httplog.HttpLogDetailDao;
import com.yihu.wlyy.service.system.SystemDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -17,7 +19,8 @@ public class LogService {
    @Autowired
    private HttpLogDao httpLogDao;
    @Autowired
    private HttpLogDetailDao httpLogDetailDao;
    @Autowired
    private SystemDictService systemDictService;
@ -42,11 +45,18 @@ public class LogService {
            log.setMethod(method);
            log.setParams(params);
            log.setCreateTime(new Date());
            log.setCreateTime(new Date());
            log.setResponse(response);
            log.setError(error);
//            log.setResponse(response);
//            log.setError(error);
            log.setStatus(isSuccess?"1":"0");
            httpLogDao.save(log);
            //明细表
            HttpLogDetail detail = new HttpLogDetail();
            detail.setCode(log.getId());
            detail.setCreateTime(new Date());
            detail.setResponse(response);
            detail.setError(error);
            httpLogDetailDao.save(detail);
        }
        catch (Exception ex)
        {
@ -73,10 +83,18 @@ public class LogService {
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
                log.setResponse(response);
                log.setError(error);
//                log.setResponse(response);
//                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                httpLogDao.save(log);
                //明细表
                HttpLogDetail detail = new HttpLogDetail();
                detail.setCode(log.getId());
                detail.setCreateTime(new Date());
                detail.setResponse(response);
                detail.setError(error);
                httpLogDetailDao.save(detail);
            }
        }
        catch (Exception ex)

+ 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);

+ 14 - 11
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);
@ -576,11 +578,11 @@ public class DoctorController extends BaseController {
                // 二维码地址
                json.put("qrcode", temp.getQrcode());
                // 审核总数
                json.put("signed_amount", familyContractService.countAmountSigned(getUID()));
                json.put("signed_amount", familyContractService.countAmountSigned(code));
                // 等审核总数
                json.put("unsign_amount", familyContractService.countAmountUnsign(getUID()));
                json.put("unsign_amount", familyContractService.countAmountUnsign(code));
                // 咨询统计
                Map<String, Long> consultCount = consultTeamService.getAllCount(getUID());
                Map<String, Long> consultCount = consultTeamService.getAllCount(code);
                // 咨询总数
                json.put("consultAmount", consultCount.get("all"));
                // 当天咨询数
@ -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) {

+ 71 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prenatalInspector/PrenatalController.java

@ -0,0 +1,71 @@
package com.yihu.wlyy.web.doctor.prenatalInspector;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.app.prenatalInspector.PrenatalInspectorPreCardService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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.RestController;
/**
 * Created by yeshijie on 2017/9/27.
 */
@RestController
@RequestMapping(value = "/doctor/prenatalnspector", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "居民端-产检")
public class PrenatalController extends BaseController{
    @Autowired
    private PrenatalInspectorPreCardService preCardService;
    @ApiOperation("建卡列表-孕检计划")
    @RequestMapping(value = "prenatalInspectorList", method = RequestMethod.POST)
    public String prenatalInspectorList(@ApiParam(name = "patient", value = "居民code", defaultValue = "d9de442323324a759ac82857c4692184")
                                        @RequestParam(value = "patient", required = true) String patient){
        try {
            JSONArray jsonArray = preCardService.getEhrMaternalFirstExamRecord(patient);
            return write(200, "查询成功!", "list", jsonArray);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("初检检查")
    @RequestMapping(value = "getEhrMaternalFirstExamRecord", method = RequestMethod.GET)
    public String getEhrMaternalFirstExamRecord(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
                                                @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo,
                                                @ApiParam(name = "patient", value = "居民code", defaultValue = "d9de442323324a759ac82857c4692184")
                                                @RequestParam(value = "patient", required = true) String patient){
        try {
            JSONObject jsonObject = preCardService.firstExam(patient,pregnancyNo);
            return write(200, "查询成功!", "data", jsonObject);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    @ApiOperation("复检检查记录")
    @RequestMapping(value = "getEhrMaternalReExamRecord", method = RequestMethod.GET)
    public String getEhrMaternalReExamRecord(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
                                             @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo,
                                             @ApiParam(name = "patient", value = "居民code", defaultValue = "d9de442323324a759ac82857c4692184")
                                             @RequestParam(value = "patient", required = true) String patient){
        try {
            String response = preCardService.reExamRecode(patient,pregnancyNo);
            return response;
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
}

+ 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, "获取字典信息失败!");
        }
    }
}

+ 15 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/PrenatalInspectorContoller.java

@ -36,7 +36,12 @@ public class PrenatalInspectorContoller extends BaseController{
        try {
            PrenatalInspectorPreCard preCard = objectMapper.readValue(json,PrenatalInspectorPreCard.class);
            preCardService.addPrenatalInspectorPreCard(preCard);
            String code = preCardService.addPrenatalInspectorPreCard(preCard,getRepUID());
            if("-1".equals(code)){
                return error(-1,"居民未签约,无法添加预建卡信息");
            }
            preCardService.uploadPreExam(code);
            return success("预建卡保存成功!");
        }catch (Exception e){
            error(e);
@ -48,8 +53,8 @@ public class PrenatalInspectorContoller extends BaseController{
    @RequestMapping(value = "prenatalInspectorList", method = RequestMethod.POST)
    public String prenatalInspectorList(){
        try {
//            JSONArray jsonArray = preCardService.getEhrMaternalFirstExamRecord(getUID());
            JSONArray jsonArray = preCardService.getEhrMaternalFirstExamRecord("915cca0a-5b1d-11e6-8344-fa163e8aee56");
            JSONArray jsonArray = preCardService.getEhrMaternalFirstExamRecord(getUID());
//            JSONArray jsonArray = preCardService.getEhrMaternalFirstExamRecord("d9de442323324a759ac82857c4692184");
            return write(200, "查询成功!", "list", jsonArray);
        }catch (Exception e){
            error(e);
@ -59,10 +64,11 @@ public class PrenatalInspectorContoller extends BaseController{
    @ApiOperation("初检检查")
    @RequestMapping(value = "getEhrMaternalFirstExamRecord", method = RequestMethod.GET)
    public String getEhrMaternalFirstExamRecord(){
    public String getEhrMaternalFirstExamRecord(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
                                                @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo){
        try {
//            JSONObject jsonObject = preCardService.firstExam(getUID());
            JSONObject jsonObject = preCardService.firstExam("915cca0a-5b1d-11e6-8344-fa163e8aee56");
            JSONObject jsonObject = preCardService.firstExam(getUID(),pregnancyNo);
//            JSONObject jsonObject = preCardService.firstExam("d9de442323324a759ac82857c4692184",pregnancyNo);
            return write(200, "查询成功!", "data", jsonObject);
        }catch (Exception e){
            error(e);
@ -75,9 +81,9 @@ public class PrenatalInspectorContoller extends BaseController{
    public String getEhrMaternalReExamRecord(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
                                             @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo){
        try {
//            JSONArray jsonArray = preCardService.reExamRecode(getUID(),pregnancyNo);
            JSONArray jsonArray = preCardService.reExamRecode("915cca0a-5b1d-11e6-8344-fa163e8aee56",pregnancyNo);
            return write(200, "查询成功!", "list", jsonArray);
            String response = preCardService.reExamRecode(getUID(),pregnancyNo);
//            String response = preCardService.reExamRecode("d9de442323324a759ac82857c4692184",pregnancyNo);
            return response;
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
@ -85,17 +91,6 @@ public class PrenatalInspectorContoller extends BaseController{
    }
    @ApiOperation("预建卡列表-孕检计划")
    @RequestMapping(value = "preCardList", method = RequestMethod.GET)
    public String preCardList(){

+ 23 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionPayController.java

@ -117,6 +117,29 @@ public class PatientPrescriptionPayController extends WeixinBaseController {
            return error(-1, "获取失败!");
        }
    }
    
    /**
     * 查询家庭签约支付结果
     * @return
     */
    @RequestMapping(value = "/getSignFamilyPayResult", method = RequestMethod.GET)
    @ApiOperation(value = "查询家庭签约支付结果")
    public String getSignFamilyPayResult(
            @RequestParam(required = true)
            @ApiParam(value = "支付应用流水号", name = "outChargeNo") String outChargeNo,
            @RequestParam(required = true)
            @ApiParam(value = "易联众appid", name = "appId") String appId,
            @RequestParam(required = true)
            @ApiParam(value = "易联众app secret", name = "appSecret") String appSecret) throws Exception {
        try {
            String accessToken = getAccessToken();
            String result = payService.getSignFamilyPayResult(outChargeNo, accessToken,appId,appSecret);
            return write(200, "获取成功!", "data", result);
        } catch (Exception e) {
            error(e);
            return error(-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;
    }
}