浏览代码

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

trick9191 7 年之前
父节点
当前提交
5b53042eb1
共有 50 个文件被更改,包括 3884 次插入448 次删除
  1. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java
  2. 94 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorRecord.java
  3. 2 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/SpringSecurityConfig.java
  4. 147 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/datastatic/PrescriptionStaticController.java
  5. 86 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/device/WlyyDeviceController.java
  6. 767 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/prescription/Prescription.java
  7. 323 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/prescription/PrescriptionInfo.java
  8. 101 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/prescription/PrescriptionVO.java
  9. 35 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java
  10. 22 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyDeviceService.java
  11. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/user/UserService.java
  12. 197 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/prescription/PrescriptionService.java
  13. 16 3
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_list.jsp
  14. 30 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_list_js.jsp
  15. 28 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/main.jsp
  16. 65 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/prescription/prescription_list.jsp
  17. 459 0
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/prescription/prescription_list_js.jsp
  18. 4 0
      patient-co-manage/wlyy-manage/src/main/webapp/static/js/menu.js
  19. 9 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  20. 37 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorPrenatalInspectorJob.java
  21. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java
  22. 11 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java
  23. 22 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorRecordDao.java
  24. 146 20
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  25. 3 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  26. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  27. 12 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java
  28. 20 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorRecordDao.java
  29. 31 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  30. 20 21
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/express/SFExpressService.java
  31. 146 41
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  32. 23 22
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java
  33. 409 186
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  34. 165 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  35. 3 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  36. 5 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  37. 2 53
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  38. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  39. 106 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/ylz/ThirdEHCService.java
  40. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  41. 61 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  42. 33 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  43. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultMoviController.java
  44. 23 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/DoctorPatientGroupController.java
  45. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  46. 45 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prenatalInspector/PrenatalController.java
  47. 102 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  48. 2 60
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  49. 49 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdEHCController.java
  50. 6 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

文件差异内容过多而无法显示
+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/message/Message.java


+ 94 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prenatal/PrenatalInspectorRecord.java

@ -0,0 +1,94 @@
package com.yihu.wlyy.entity.patient.prenatal;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
@Entity
@Table(name = "wlyy_prenatal_inspector_record")
public class PrenatalInspectorRecord extends IdEntity implements Serializable {
  private String relation;
  private String sender;
  private String receiver;
  private int type;
  private String name;
  private String openid;
  private String content;
  private Integer times;
  private Date sendTime;
  public String getRelation() {
    return relation;
  }
  public void setRelation(String relation) {
    this.relation = relation;
  }
  public String getSender() {
    return sender;
  }
  public void setSender(String sender) {
    this.sender = sender;
  }
  public String getReceiver() {
    return receiver;
  }
  public void setReceiver(String receiver) {
    this.receiver = receiver;
  }
  public int getType() {
    return type;
  }
  public void setType(int type) {
    this.type = type;
  }
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }
  public String getOpenid() {
    return openid;
  }
  public void setOpenid(String openid) {
    this.openid = openid;
  }
  public String getContent() {
    return content;
  }
  public void setContent(String content) {
    this.content = content;
  }
  public Integer getTimes() {
    return times;
  }
  public void setTimes(Integer times) {
    this.times = times;
  }
  public Date getSendTime() {
    return sendTime;
  }
  public void setSendTime(Date sendTime) {
    this.sendTime = sendTime;
  }
}

+ 2 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/config/SpringSecurityConfig.java

@ -35,6 +35,8 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
                "/admin/team/importData",
                "/admin/hos/importData",
                "/admin/hos/doctor/toExcel",
                "/admin/device/toExcel",
                "/admin/static/prescription/toExcel",
                "/admin/basedata/importData",
                "/admin/wlyyUserRole/importData",
                "/WEB—INF/views/**"

+ 147 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/datastatic/PrescriptionStaticController.java

@ -0,0 +1,147 @@
package com.yihu.wlyy.controller.manager.datastatic;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.device.entity.WlyyDevice;
import com.yihu.wlyy.entity.SignFamily;
import com.yihu.wlyy.entity.prescription.Prescription;
import com.yihu.wlyy.entity.prescription.PrescriptionVO;
import com.yihu.wlyy.service.prescription.PrescriptionService;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
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 javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
/**
 * 长处方统计
 * @author huangwenjie
 * @date 2017/12/8 08:54
 */
@Controller
@RequestMapping(value="/admin/static/prescription")
public class PrescriptionStaticController extends BaseController {
	
	@Autowired
	private PrescriptionService prescriptionService;
	
	//长处方统计管理*******************************
	@RequestMapping(value = "initial", method = RequestMethod.GET)
	public String listInit(){
		return "prescription/prescription_list";
	}
	
	@RequestMapping(value = "list")
	@ResponseBody
	public String searchPatientList(
			@RequestParam(value = "town",required = false)String town,
			@RequestParam(value = "hospital",required = false)String hospital,
			@RequestParam(value = "disease",required = false)String disease,
			@RequestParam(value = "dispensarytype",required = false)String dispensarytype,
			@RequestParam(value = "status",required = false)String status,
			@RequestParam(value = "beginDate",required = false)String beginDate,
			@RequestParam(value = "endDate",required = false)String endDate,
			@RequestParam(value = "page",required = true)Integer page,
			@RequestParam(value = "rows",required = true)Integer pageSize
	){
		try {
			List<PrescriptionVO> datalist = prescriptionService.getPrescriptionList(hospital,disease,dispensarytype,status,beginDate,endDate,page,pageSize,true);
			Long totalcount = prescriptionService.getPrescriptionListCount(hospital,disease,dispensarytype,status,beginDate,endDate);
			return write(200,"操作成功",page,pageSize,totalcount,datalist);
		}catch (Exception ex){
			error(ex);
			return error(-1, "操作失败!");
		}
	}
	
	//导出设备报表
	@RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
	public void exportList(
			@RequestParam(value = "town",required = false)String town,
			@RequestParam(value = "hospital",required = false)String hospital,
			@RequestParam(value = "disease",required = false)String disease,
			@RequestParam(value = "dispensarytype",required = false)String dispensarytype,
			@RequestParam(value = "status",required = false)String status,
			@RequestParam(value = "beginDate",required = false)String beginDate,
			@RequestParam(value = "endDate",required = false)String endDate,
			HttpServletResponse response){
		try {
			ObjectMapper objectMapper = new ObjectMapper();
			JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, WlyyDevice.class);
			List<PrescriptionVO> datalist = prescriptionService.getPrescriptionList(hospital,disease,dispensarytype,status,beginDate,endDate,0,0,false);
			response.setContentType("octets/stream");
			response.setHeader("Content-Disposition", "attachment; filename="+ new String( "prescriptionDataList.xls"));
			OutputStream os = response.getOutputStream();
			this.write(os,datalist);
		}catch (Exception ex){
			error(ex);
		}
	}
	
	
	public void addHeader(WritableSheet ws) throws WriteException {
		String[] header = {"姓名","身份证","电话","社区", "申请时间","开方医生", "诊断", "取药方式", "状态","更新时间"};
		int i = 0;
		for (String h : header) {
			addCell(ws, 0, i, h);//表名,行,列,header
			i++;
		}
	}
	
	public void write(WritableWorkbook wwb, List ls) throws Exception {
		try {
			WritableSheet ws;
			ws = wwb.createSheet("sheet",1);
			addHeader(ws);
			int i = 1;
			for (PrescriptionVO m : (List<PrescriptionVO>) ls) {
				addCell(ws, i, 0, m.getPatient_name()+"","");
				addCell(ws, i, 1, m.getIdcard(),"");
				addCell(ws, i, 2, m.getMobile(),"");
				addCell(ws, i, 3, m.getHospital_name(),"");
				addCell(ws, i, 4, m.getCreate_time(),"");
				addCell(ws, i, 5, m.getDoctor_name(),"");
				addCell(ws, i, 6, m.getHealth_problem_name(),"");
				addCell(ws, i, 7, m.getPay(),"");
				addCell(ws, i, 8, m.getStatusName(),"");
				addCell(ws, i, 9, m.getCreate_time(),"");
				i++;
			}
			wwb.write();
			wwb.close();
		} catch (IOException e) {
			e.printStackTrace();
			if (wwb != null) wwb.close();
			throw e;
		}
	}
	public void write(OutputStream os, List ls) throws Exception{
		write(Workbook.createWorkbook(os), ls);
	}
	//添加单元格内容
	public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
		Label label = new Label(column ,row, data);
		ws.addCell(label);
	}
	//添加单元格内容
	public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
		Label label = new Label(column ,row, data);
		if(!org.springframework.util.StringUtils.isEmpty(memo)){
			WritableCellFeatures cellFeatures = new WritableCellFeatures();
			cellFeatures.setComment(memo);
			label.setCellFeatures(cellFeatures);
		}
		ws.addCell(label);
	}
}

+ 86 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/device/WlyyDeviceController.java

@ -1,9 +1,12 @@
package com.yihu.wlyy.controller.manager.device;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.device.entity.WlyyDevice;
import com.yihu.wlyy.service.manager.device.WlyyDeviceService;
import jxl.Workbook;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
@ -12,6 +15,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by yww on 2016/12/2.
 * 设备管理
@ -131,4 +140,81 @@ public class WlyyDeviceController extends BaseController {
    public String isCodeExist(String deviceCode) {
        return deviceService.existDeviceCode(deviceCode);
    }
    
    
    //导出设备报表
    @RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(
            @RequestParam(value = "deviceName",required = false)String deviceName,
            @RequestParam(value = "deviceCode",required = false) String deviceCode,
            @RequestParam(value = "orgName",required = false)String orgName,
            @RequestParam(value = "linkman",required = false) String linkman,
            HttpServletResponse response){
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, WlyyDevice.class);
            List<WlyyDevice> wlyyDevices = deviceService.exporthDeviceList(deviceName,deviceCode,orgName,linkman);
            response.setContentType("octets/stream");
            response.setHeader("Content-Disposition", "attachment; filename="+ new String( "deviceDataList.xls"));
            OutputStream os = response.getOutputStream();
            this.write(os,wlyyDevices);
        }catch (Exception ex){
            error(ex);
        }
    }
    
    public void addHeader(WritableSheet ws) throws WriteException {
        
        String[] header = {"ID","设备名称","型号","SN码", "SIM卡号","机构名称", "联系人", "联系电话", "厂家名称"};
        int i = 0;
        for (String h : header) {
            addCell(ws, 0, i, h);//表名,行,列,header
            i++;
        }
    }
    
    public void write(WritableWorkbook wwb, List ls) throws Exception {
        try {
            WritableSheet ws;
            ws = wwb.createSheet("sheet",1);
            addHeader(ws);
            int i = 1;
            for (WlyyDevice m : (List<WlyyDevice>) ls) {
                addCell(ws, i, 0, m.getId()+"","");
                addCell(ws, i, 1, m.getDeviceName(),"");
                addCell(ws, i, 2, m.getDeviceModel(),"");
                addCell(ws, i, 3, m.getDeviceCode(),"");
                addCell(ws, i, 4, m.getSim()+"","");
                addCell(ws, i, 5, m.getOrgName(),"");
                addCell(ws, i, 6, m.getLinkman(),"");
                addCell(ws, i, 7, m.getTel(),"");
                addCell(ws, i, 8, m.getManufacturer(),"");
                i++;
            }
            wwb.write();
            wwb.close();
        } catch (IOException e) {
            e.printStackTrace();
            if (wwb != null) wwb.close();
            throw e;
        }
    }
    public void write(OutputStream os, List ls) throws Exception{
        write(Workbook.createWorkbook(os), ls);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column,  String data) throws WriteException {
        Label label = new Label(column ,row, data);
        ws.addCell(label);
    }
    //添加单元格内容
    public void addCell(WritableSheet ws, int row, int column, String data, String memo) throws WriteException {
        Label label = new Label(column ,row, data);
        if(!org.springframework.util.StringUtils.isEmpty(memo)){
            WritableCellFeatures cellFeatures = new WritableCellFeatures();
            cellFeatures.setComment(memo);
            label.setCellFeatures(cellFeatures);
        }
        ws.addCell(label);
    }
}

+ 767 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/prescription/Prescription.java

@ -0,0 +1,767 @@
package com.yihu.wlyy.entity.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import org.springframework.util.StringUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/**
 * Created by Administrator on 2017/7/21.
 * 处方
 */
@Entity
@Table(name = "wlyy_prescription")
public class Prescription extends IdEntity {
    private String code;                    //业务主键
    private String jwCode;                  //基卫的历史处方code
    private String visitNo;                  //基卫的挂号code(调用基位开方接口后回调给我们后才有值)
    private String recipeNo;                  //基卫的处方code(调用基位开方接口后回调给我们后才有值)
    private String parentCode;             //如果是续方 那就是处方的code
    private Date createTime;               //处方创建时间
    private Date reviewedTime;             //审核时间
    private Date payTime;                   //支付时间
    private Date failTime;                  //基位 开方失败时间
    private String failReason;                  //基位 开方失败原因
    private Date dosageTime;                //配药完成时间
    private Date dispatchingTime;          //配送员领药时间
    private Date expressageTime;            //配送员到服务站的时间
    private Date finishTime;                //配送员确认送达或居民确认取药的时间
    private String patient;                  //关联 wlyy_patient code
    private String patientName;             //患者名称
    private String ssc;//社保卡号
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //(-5线下取消 -4线下退费 -3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
    // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
    // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
    // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,
    // (61配送失败62分配健管师 65配送中,69配送到服务站)配送中,(100配送到患者手中/已完成)已完成',
    private String doctor;                   //开处方的医生code 关联 wlyy_doctor
    private String doctorName;               //医生名称
    private Long adminTeamId;             //患者签约的行政团队
    private String hospital;                  //医院 关联 dm_hospital code
    private String hospitalName;              //医院 关联 dm_hospital name
    private String dept;                       //科室code
    private String deptName;                   //科室名称
    private String diagnosisCode;             //诊断的病种code
    private String diagnosis;                  //诊断名称
    private String consult;                    //咨询id 1对1
    //    private String dispensary_code;           //取药编码  关联wlyy_prescription_dispensary_code  code
//    private String dispensaryAddress;         //取药地址
    private Integer dispensaryType;            //取药类型:1 自取 2快递配送 3健管师配送
    private String caCertData;                  //ca加密信息(签名证书主题数据)
    //    private String expressNum;                  //快递单号
//    private String expressCompanyName;         //快递公司名称
    private String caMessage;                   //ca指纹信息(签名值)
    private String remark;                     //处方备注
    private String reason;                      //续方原因
    //    private Double ybCost;                      //医保费用
//    private Double myCost;                      //自己付费
    private Integer prescriptionType;          //处方类型:1、门诊处方,2、住院处方
    private String cancelReason;
    private String adjustReason;
    private String statusName; //
    private String digitalSignNo;//CA数字签名唯一流水号
    private String originalDataAbstract;//原文的MD5摘要
    private String strOriginalData; //CA原文数据
    private List<PrescriptionInfo> prescriptionInfo;
    private String reviewedState;
    private String jwDeptCode;  //基卫-开处方的科室编码
    private String jwHospital;  //基卫-开处方的医院编码
    private String jwDoctorCode; //基卫-开方医生的编码
    private String jwGisterTypeCode;//基卫-挂号类型编码
    private String jwRateTypeCode;//基卫-费别类型编码
    private String jwRegisterFee; //基卫-诊金
    private String prescribeReason; //开方失败/成功原因
    private Date prescribeTime;//开方失败、成功时间
    //用于药品用药情况排序
    private Integer minDrugDay; //药品最小用药天数
    private Date presCreateTime; //处方建立时间
    private String dispensaryTypeName; //类型翻译
    private Integer jwPayStatus;//处方结算状态,0为未结算,1为结算成功,默认为0
    private Integer zyCancelState; //智业同步取消表示:0 位同步取消 1已经同步取消
    //1.4.0新增字段
    private Integer drugDeliveryFlag;   //是否异常出药0为正常 1为异常
    private String drugDeliveryReasonCode; //原因字典对应Code
    private String drugDeliveryReasonValue; //原因字典对应Name
    private String drugDeliveryReason; //详细原因
    private String drugDeliveryOperator; //操作人员code
    private String drugDeliveryOperatorName; //操作人员名字
    private Date drugDeliveryTime; //异常出药时间
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "parent_code")
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "reviewed_time")
    public Date getReviewedTime() {
        return reviewedTime;
    }
    public void setReviewedTime(Date reviewedTime) {
        this.reviewedTime = reviewedTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "pay_time")
    public Date getPayTime() {
        return payTime;
    }
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "dosage_time")
    public Date getDosageTime() {
        return dosageTime;
    }
    public void setDosageTime(Date dosageTime) {
        this.dosageTime = dosageTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "dispatching_time")
    public Date getDispatchingTime() {
        return dispatchingTime;
    }
    public void setDispatchingTime(Date dispatchingTime) {
        this.dispatchingTime = dispatchingTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "finish_time")
    public Date getFinishTime() {
        return finishTime;
    }
    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "admin_team_id")
    public Long getAdminTeamId() {
        return adminTeamId;
    }
    public void setAdminTeamId(Long adminTeamId) {
        this.adminTeamId = adminTeamId;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "diagnosis_code")
    public String getDiagnosisCode() {
        return diagnosisCode;
    }
    public void setDiagnosisCode(String diagnosisCode) {
        this.diagnosisCode = diagnosisCode;
    }
    @Column(name = "diagnosis")
    public String getDiagnosis() {
        return diagnosis;
    }
    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }
    @Column(name = "consult")
    public String getConsult() {
        return consult;
    }
    public void setConsult(String consult) {
        this.consult = consult;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "dispensary_type")
    public Integer getDispensaryType() {
        return dispensaryType;
    }
    public void setDispensaryType(Integer dispensaryType) {
        this.dispensaryType = dispensaryType;
    }
    @Column(name = "ca_message")
    public String getCaMessage() {
        return caMessage;
    }
    public void setCaMessage(String caMessage) {
        this.caMessage = caMessage;
    }
    public String getJwCode() {
        return jwCode;
    }
    public void setJwCode(String jwCode) {
        this.jwCode = jwCode;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public String getCaCertData() {
        return caCertData;
    }
    public void setCaCertData(String caCertData) {
        this.caCertData = caCertData;
    }
    public Integer getPrescriptionType() {
        return prescriptionType;
    }
    public void setPrescriptionType(Integer prescriptionType) {
        this.prescriptionType = prescriptionType;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = getStatusName(status, null, null);
    }
    public Date getExpressageTime() {
        return expressageTime;
    }
    public void setExpressageTime(Date expressageTime) {
        this.expressageTime = expressageTime;
    }
    @Transient
    public static String getStatusName(Integer status, String hospitalName, String userName) {
        /**
         *  no_reviewed("审核不通过", -1),
         revieweding("待审核", 0),
         changeing("调整中",2),
         reviewed_success("审核通过/开方中", 10),
         wait_pay("开方完成/待支付", 20),
         pay_error("支付失败", 21),
         wait_expressage("配药成功/待配送", 40),
         expressageing_error("配送失败", 41),
         expressageJGS("分配健管师", 42),
         expressageing("配送中", 45),
         pay_success("支付成功/待配药", 50),
         expressage2hospital("配送到服务站", 49),
         finish("配送到患者手中/已完成", 100);
         */
        //-1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成
        switch (status) {
            case -3: {
                return "支付超时";
            }
            case -2: {
                return "患者自己取消";
            }
            case -1: {
                return "审核不通过";
            }
            case 0: {
                return "待审核";
            }
            case 2: {
                return "调整处方中";
            }
            case 3: {
                return "调整成功";
            }
            case 4: {
                return "调整失败";
            }
            case 21: {
                return "药师审核失败";
            }
            case 31: {
                return "开方失败";
            }
            case 10: {
                return "开方中";
            }
            case 20: {
                return "药师审核中";
            }
            case 30: {
                return "开方中/药师审核成功";
            }
            case 40: {
                return "开方完成/待支付 ";
            }
            case 41: {
                return "支付失败";
            }
            case 50: {
                return " 订单已支付";
            }
            case 60: {
                return "配药完成";
            }
            case 61: {
                return "配送失败";
            }
            case 62: {
                return "分配健管师 ";
            }
            case 65: {
                return "配送中 ";
            }
            case 69: {
                if (StringUtils.isEmpty(hospitalName) || StringUtils.isEmpty(userName)) {
                    return "配送到服务站";
                }
                {
                    return "配送到" + hospitalName + ",接收人:" + userName;
                }
            }
            case 100: {
                if (StringUtils.isEmpty(userName)) {
                    return "续方完成";
                } else {
                    return "续方完成,确认人:" + userName;
                }
            }
        }
        return "未知";
    }
    public String getCancelReason() {
        return cancelReason;
    }
    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }
    public String getAdjustReason() {
        return adjustReason;
    }
    public void setAdjustReason(String adjustReason) {
        this.adjustReason = adjustReason;
    }
    public String getVisitNo() {
        return visitNo;
    }
    public void setVisitNo(String visitNo) {
        this.visitNo = visitNo;
    }
    public String getRecipeNo() {
        return recipeNo;
    }
    public void setRecipeNo(String recipeNo) {
        this.recipeNo = recipeNo;
    }
    public Date getFailTime() {
        return failTime;
    }
    public void setFailTime(Date failTime) {
        this.failTime = failTime;
    }
    public String getFailReason() {
        return failReason;
    }
    public void setFailReason(String failReason) {
        this.failReason = failReason;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public String getOriginalDataAbstract() {
        return originalDataAbstract;
    }
    public void setOriginalDataAbstract(String originalDataAbstract) {
        this.originalDataAbstract = originalDataAbstract;
    }
    public String getDigitalSignNo() {
        return digitalSignNo;
    }
    public void setDigitalSignNo(String digitalSignNo) {
        this.digitalSignNo = digitalSignNo;
    }
    public String getStrOriginalData() {
        return strOriginalData;
    }
    public void setStrOriginalData(String strOriginalData) {
        this.strOriginalData = strOriginalData;
    }
    @Transient
    public List<PrescriptionInfo> getPrescriptionInfo() {
        return prescriptionInfo;
    }
    public void setPrescriptionInfo(List<PrescriptionInfo> prescriptionInfo) {
        this.prescriptionInfo = prescriptionInfo;
    }
    @Transient
    public String getReviewedState() {
        return reviewedState;
    }
    public void setReviewedState(String reviewedState) {
        this.reviewedState = reviewedState;
    }
    public String getJwDeptCode() {
        return jwDeptCode;
    }
    public void setJwDeptCode(String jwDeptCode) {
        this.jwDeptCode = jwDeptCode;
    }
    public String getJwDoctorCode() {
        return jwDoctorCode;
    }
    public void setJwDoctorCode(String jwDoctorCode) {
        this.jwDoctorCode = jwDoctorCode;
    }
    public String getJwGisterTypeCode() {
        return jwGisterTypeCode;
    }
    public void setJwGisterTypeCode(String jwGisterTypeCode) {
        this.jwGisterTypeCode = jwGisterTypeCode;
    }
    public String getJwRateTypeCode() {
        return jwRateTypeCode;
    }
    public void setJwRateTypeCode(String jwRateTypeCode) {
        this.jwRateTypeCode = jwRateTypeCode;
    }
    public String getJwHospital() {
        return jwHospital;
    }
    public void setJwHospital(String jwHospital) {
        this.jwHospital = jwHospital;
    }
    public String getJwRegisterFee() {
        return jwRegisterFee;
    }
    public void setJwRegisterFee(String jwRegisterFee) {
        this.jwRegisterFee = jwRegisterFee;
    }
    @Transient
    public String getDispensaryTypeName() {
        if (dispensaryType != null) {
            switch (this.dispensaryType) {
                case 1: {
                    return "自取";
                }
                case 2: {
                    return "快递配送";
                }
                case 3: {
                    return "健管师配送";
                }
            }
        }
        return "";
    }
    public String getPrescribeReason() {
        return prescribeReason;
    }
    public void setPrescribeReason(String prescribeReason) {
        this.prescribeReason = prescribeReason;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getPrescribeTime() {
        return prescribeTime;
    }
    public void setPrescribeTime(Date prescribeTime) {
        this.prescribeTime = prescribeTime;
    }
    public void setDispensaryTypeName(String dispensaryTypeName) {
        this.dispensaryTypeName = dispensaryTypeName;
    }
    public Integer getJwPayStatus() {
        return jwPayStatus;
    }
    public void setJwPayStatus(Integer jwPayStatus) {
        this.jwPayStatus = jwPayStatus;
    }
    public Integer getMinDrugDay() {
        return minDrugDay;
    }
    public void setMinDrugDay(Integer minDrugDay) {
        this.minDrugDay = minDrugDay;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getPresCreateTime() {
        return presCreateTime;
    }
    public void setPresCreateTime(Date presCreateTime) {
        this.presCreateTime = presCreateTime;
    }
    public Integer getZyCancelState() {
        return zyCancelState;
    }
    public void setZyCancelState(Integer zyCancelState) {
        this.zyCancelState = zyCancelState;
    }
    public Integer getDrugDeliveryFlag() {
        return drugDeliveryFlag;
    }
    public void setDrugDeliveryFlag(Integer drugDeliveryFlag) {
        this.drugDeliveryFlag = drugDeliveryFlag;
    }
    public String getDrugDeliveryReasonCode() {
        return drugDeliveryReasonCode;
    }
    public void setDrugDeliveryReasonCode(String drugDeliveryReasonCode) {
        this.drugDeliveryReasonCode = drugDeliveryReasonCode;
    }
    public String getDrugDeliveryReasonValue() {
        return drugDeliveryReasonValue;
    }
    public void setDrugDeliveryReasonValue(String drugDeliveryReasonValue) {
        this.drugDeliveryReasonValue = drugDeliveryReasonValue;
    }
    public String getDrugDeliveryReason() {
        return drugDeliveryReason;
    }
    public void setDrugDeliveryReason(String drugDeliveryReason) {
        this.drugDeliveryReason = drugDeliveryReason;
    }
    public String getDrugDeliveryOperator() {
        return drugDeliveryOperator;
    }
    public void setDrugDeliveryOperator(String drugDeliveryOperator) {
        this.drugDeliveryOperator = drugDeliveryOperator;
    }
    public String getDrugDeliveryOperatorName() {
        return drugDeliveryOperatorName;
    }
    public void setDrugDeliveryOperatorName(String drugDeliveryOperatorName) {
        this.drugDeliveryOperatorName = drugDeliveryOperatorName;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getDrugDeliveryTime() {
        return drugDeliveryTime;
    }
    public void setDrugDeliveryTime(Date drugDeliveryTime) {
        this.drugDeliveryTime = drugDeliveryTime;
    }
}

+ 323 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/prescription/PrescriptionInfo.java

@ -0,0 +1,323 @@
package com.yihu.wlyy.entity.prescription;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Administrator on 2017/7/21.
 * 处方详细
 */
@Entity
@Table(name = "wlyy_prescription_info")
public class PrescriptionInfo extends IdEntity{
    //drugRate(频率:一天用次数)*dayCount(天数)*physicDose(单次用量)
    //
    private String code;                    //业务主键
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private String drugCode;               //药品code
    private String drugName;               //药品名称
    private String subjectClass;               //科目类别编码
    private String drugRate;               //吃药频率
    private String drugRateName;          //用药频次名称
    private String drugFormat;             //药品规格
    private Integer num;                    //药品总量(用来计算价格)
    private Integer isRefrigerate;         //是否冷藏 1是 0否
    private String direction;               //药品用法
    private Integer price;                    //药品单价 单位是分
    private Integer del;               //1可用 0删除 不填数据库默认是1
    private String jwSubCode;//智业子处方号
    private String drugNumUnit;//数量单位编码
    private String drugNumUnitName;//数量单位名称
    private Integer cost;//计算总额(num*price) 单位是分
    private Integer charge;//自付 单位是分
    private String bindFlag;//成组标志, 0.非成组,1.成组
    private Integer dayCount;//用药天数
    private String drugUsage;//用药方法编码
    private String usageName;//用药方法名称
    private String physicDose;//用药剂量
    private String physicDoseUnit;//剂量单位编码
    private String physicDoseUnitName;//剂量单位名称
    private String physicAmount;//用药总量(实际用药量)
    private String physicAmountUnit;//总量单位编码
    private String physicAmountUnitName;//总量单位名称
    private String physicInjectPlace;//注射地点编码
    private String physicInjectPlaceName;//注射地点名称
    private String physicSkinTest;//注射地点名称
    private String physicSkinTestName;//皮试类型名称
    private String remark;//备注
    @Column(name = "code",unique = true , nullable=false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "prescription_code")
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @Column(name = "drug_code")
    public String getDrugCode() {
        return drugCode;
    }
    public void setDrugCode(String drugCode) {
        this.drugCode = drugCode;
    }
    @Column(name = "drug_name")
    public String getDrugName() {
        return drugName;
    }
    public void setDrugName(String drugName) {
        this.drugName = drugName;
    }
    public String getDrugRate() {
        return drugRate;
    }
    public void setDrugRate(String drugRate) {
        this.drugRate = drugRate;
    }
    public String getDrugFormat() {
        return drugFormat;
    }
    public void setDrugFormat(String drugFormat) {
        this.drugFormat = drugFormat;
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public Integer getIsRefrigerate() {
        return isRefrigerate;
    }
    public void setIsRefrigerate(Integer isRefrigerate) {
        this.isRefrigerate = isRefrigerate;
    }
    public String getDirection() {
        return direction;
    }
    public void setDirection(String direction) {
        this.direction = direction;
    }
    public Integer getPrice() {
        return price;
    }
    public void setPrice(Integer price) {
        this.price = price;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getJwSubCode() {
        return jwSubCode;
    }
    public void setJwSubCode(String jwSubCode) {
        this.jwSubCode = jwSubCode;
    }
    public String getDrugNumUnit() {
        return drugNumUnit;
    }
    public void setDrugNumUnit(String drugNumUnit) {
        this.drugNumUnit = drugNumUnit;
    }
    public String getDrugNumUnitName() {
        return drugNumUnitName;
    }
    public void setDrugNumUnitName(String drugNumUnitName) {
        this.drugNumUnitName = drugNumUnitName;
    }
    public Integer getCost() {
        return cost;
    }
    public void setCost(Integer cost) {
        this.cost = cost;
    }
    public Integer getCharge() {
        return charge;
    }
    public void setCharge(Integer charge) {
        this.charge = charge;
    }
    @Column(name = "bind_flag")
    public String getBindFlag() {
        return bindFlag;
    }
    public void setBindFlag(String bindFlag) {
        this.bindFlag = bindFlag;
    }
    @Column(name = "day_count")
    public Integer getDayCount() {
        return dayCount;
    }
    public void setDayCount(Integer dayCount) {
        this.dayCount = dayCount;
    }
    public String getDrugUsage() {
        return drugUsage;
    }
    public void setDrugUsage(String drugUsage) {
        this.drugUsage = drugUsage;
    }
    @Column(name = "usage_name")
    public String getUsageName() {
        return usageName;
    }
    public void setUsageName(String usageName) {
        this.usageName = usageName;
    }
    @Column(name = "physic_dose")
    public String getPhysicDose() {
        return physicDose;
    }
    public void setPhysicDose(String physicDose) {
        this.physicDose = physicDose;
    }
    public String getPhysicDoseUnit() {
        return physicDoseUnit;
    }
    public void setPhysicDoseUnit(String physicDoseUnit) {
        this.physicDoseUnit = physicDoseUnit;
    }
    public String getPhysicDoseUnitName() {
        return physicDoseUnitName;
    }
    public void setPhysicDoseUnitName(String physicDoseUnitName) {
        this.physicDoseUnitName = physicDoseUnitName;
    }
    public String getPhysicAmount() {
        return physicAmount;
    }
    public void setPhysicAmount(String physicAmount) {
        this.physicAmount = physicAmount;
    }
    public String getPhysicAmountUnit() {
        return physicAmountUnit;
    }
    public void setPhysicAmountUnit(String physicAmountUnit) {
        this.physicAmountUnit = physicAmountUnit;
    }
    public String getPhysicAmountUnitName() {
        return physicAmountUnitName;
    }
    public void setPhysicAmountUnitName(String physicAmountUnitName) {
        this.physicAmountUnitName = physicAmountUnitName;
    }
    public String getPhysicInjectPlace() {
        return physicInjectPlace;
    }
    public void setPhysicInjectPlace(String physicInjectPlace) {
        this.physicInjectPlace = physicInjectPlace;
    }
    public String getPhysicInjectPlaceName() {
        return physicInjectPlaceName;
    }
    public void setPhysicInjectPlaceName(String physicInjectPlaceName) {
        this.physicInjectPlaceName = physicInjectPlaceName;
    }
    public String getPhysicSkinTest() {
        return physicSkinTest;
    }
    public void setPhysicSkinTest(String physicSkinTest) {
        this.physicSkinTest = physicSkinTest;
    }
    public String getPhysicSkinTestName() {
        return physicSkinTestName;
    }
    public void setPhysicSkinTestName(String physicSkinTestName) {
        this.physicSkinTestName = physicSkinTestName;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getDrugRateName() {
        return drugRateName;
    }
    public void setDrugRateName(String drugRateName) {
        this.drugRateName = drugRateName;
    }
    public String getSubjectClass() {
        return subjectClass;
    }
    public void setSubjectClass(String subjectClass) {
        this.subjectClass = subjectClass;
    }
}

+ 101 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/prescription/PrescriptionVO.java

@ -0,0 +1,101 @@
package com.yihu.wlyy.entity.prescription;
/**
 * 长处方VO类
 * @author huangwenjie
 * @date 2017/12/8 09:21
 */
public class PrescriptionVO {
	
	private String prescription_code;
	private String patient_name;
	private String idcard;
	private String mobile;
	private String hospital_name;
	private String create_time;
	private String doctor_name;
	private String health_problem_name;
	private String pay;
	private String statusName;
	
	public String getPrescription_code() {
		return prescription_code;
	}
	
	public void setPrescription_code(String prescription_code) {
		this.prescription_code = prescription_code;
	}
	
	public String getPatient_name() {
		return patient_name;
	}
	
	public void setPatient_name(String patient_name) {
		this.patient_name = patient_name;
	}
	
	public String getIdcard() {
		return idcard;
	}
	
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public String getHospital_name() {
		return hospital_name;
	}
	
	public void setHospital_name(String hospital_name) {
		this.hospital_name = hospital_name;
	}
	
	public String getCreate_time() {
		return create_time;
	}
	
	public void setCreate_time(String create_time) {
		this.create_time = create_time;
	}
	
	public String getDoctor_name() {
		return doctor_name;
	}
	
	public void setDoctor_name(String doctor_name) {
		this.doctor_name = doctor_name;
	}
	
	public String getHealth_problem_name() {
		return health_problem_name;
	}
	
	public void setHealth_problem_name(String health_problem_name) {
		this.health_problem_name = health_problem_name;
	}
	
	public String getPay() {
		return pay;
	}
	
	public void setPay(String pay) {
		this.pay = pay;
	}
	
	public String getStatusName() {
		return statusName;
	}
	
	public void setStatusName(String statusName) {
		this.statusName = statusName;
	}
}

+ 35 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -0,0 +1,35 @@
package com.yihu.wlyy.repository.prescription;
import com.yihu.wlyy.entity.prescription.Prescription;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionDao extends PagingAndSortingRepository<Prescription, Long>, JpaSpecificationExecutor<Prescription> {
    @Query("from Prescription p where p.code=?1")
    Prescription findByCode(String prescriptionCode);
    @Modifying
    @Query("update Prescription p set p.status=?2 where p.code=?1")
    void updateStatus(String prescriptionCode, Integer status);
    @Query("select p from Prescription p where p.jwCode=?1 and p.status=?2 and p.patient=?3 ")
    List<Prescription> fingdByJwCodeAndStatus(String jwcode, Integer status, String patient);
//    //根据处方code得到患者信息
//    @Query("select p from Prescription pt,Patient p where p.code=pt.patient  and pt.code=?1")
//    Patient findPatientByPrescriptionCode(String prescriptionCode);
    @Query("from Prescription p where p.visitNo=?1 and p.recipeNo=?2 ")
    Prescription findByVisitNoAndRecipeNo(String visitNo, String recipeNo);
    @Modifying
    @Query("update Prescription p set p.jwPayStatus=1 where p.code=?1")
    void updatejwPayStatus(String prescriptionCode);
}

+ 22 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/WlyyDeviceService.java

@ -15,6 +15,7 @@ package com.yihu.wlyy.service.manager.device;
        import javax.persistence.EntityManager;
        import java.util.Date;
        import java.util.HashMap;
        import java.util.List;
        import java.util.Map;
/**
@ -99,4 +100,25 @@ public class WlyyDeviceService {
        if(device == null){return "false";}
        return "true";
    }
    
    
    public List<WlyyDevice> exporthDeviceList(String deviceName, String deviceCode, String orgName, String linkman){
        
        Map<String,SearchFilter> filter = new HashMap<>();
        
        if(!StringUtils.isEmpty(orgName)){
            filter.put("orgName",new SearchFilter("orgName", SearchFilter.Operator.LIKE,orgName));
        }
        if(!StringUtils.isEmpty(deviceCode)){
            filter.put("deviceCode",new SearchFilter("deviceCode",SearchFilter.Operator.EQ,deviceCode));
        }
        if(!StringUtils.isEmpty(deviceName)){
            filter.put("deviceName",new SearchFilter("deviceName",SearchFilter.Operator.LIKE,deviceName));
        }
        if(!StringUtils.isEmpty(linkman)){
            filter.put("linkman",new SearchFilter("linkman",SearchFilter.Operator.EQ,linkman));
        }
        Specification<WlyyDevice> spec = DynamicSpecifications.bySearchFilter(filter.values(), WlyyDevice.class);
        return deviceDao.findAll(spec);
    }
}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/user/UserService.java

@ -196,7 +196,7 @@ public class UserService extends BaseJpaService<User,UserDao> {
            String[] codes = code.split(",");
            List<ManageDictEntry> manageDictEntries = manageDictEntryDao.findByDictIdAndCodes(dictId, codes);
            if (null != manageDictEntries && manageDictEntries.size() > 0) {
                return manageDictEntries.get(0).getValue();
                return "http://localhost:8180/admin/main";
            }
        }
        return null;

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

@ -0,0 +1,197 @@
package com.yihu.wlyy.service.prescription;
import com.yihu.wlyy.entity.prescription.PrescriptionVO;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * @author huangwenjie
 * @date 2017/12/8 09:00
 */
@Service
public class PrescriptionService extends BaseService {
	
	@Autowired
	JdbcTemplate jdbcTemplate;
	
	@Autowired
	private PrescriptionDao prescriptionDao;
	
	private static Logger logger = LoggerFactory.getLogger(PrescriptionService.class);
	
	public List<PrescriptionVO> getPrescriptionList(String hospital,
	                                                String disease,
	                                                String dispensarytype,
	                                                String status,
	                                                String beginDate,
	                                                String endDate,
	                                                Integer page,
	                                                Integer pageSize,
	                                                boolean ispage) throws Exception{
		
		List<PrescriptionVO> list = new ArrayList<>();
		String prescriptionsql = "SELECT " +
				"p.code as prescription_code,"+
				"p.patient_name," +
				"CONCAT(LEFT (p.idcard,6),'**********',RIGHT (p.idcard,2)) idcard," +
				"p.mobile," +
				"p.hospital_name," +
				"p.create_time," +
				"p.doctor_name," +
				"p.health_problem_name," +
				"p.pay," +
				"CASE p.STATUS " +
					"WHEN 31 THEN '开方失败' " +
					"WHEN 40 THEN '开方完成/待支付' " +
					"WHEN 50 THEN '支付成功/待配药' " +
					"WHEN 60 THEN '配药成功/待配送' " +
					"WHEN 65 THEN '配送中' " +
					"WHEN 100 THEN '配送到患者手中/已完成' " +
					"WHEN-4 THEN '线下退费' " +
					"WHEN-3 THEN '支付超时' " +
					"WHEN-2 THEN '患者自己取消' " +
					"WHEN-1 THEN '审核不通过' " +
					"WHEN 0 THEN '待审核' " +
					"WHEN 2 THEN '调整中' " +
				"END statusName,(" +
				"SELECT max(create_time) FROM wlyy_prescription_log l WHERE p.CODE=l.prescription_code) FROM (" +
					"SELECT " +
							"p1.CODE," +
							"p1.patient_name," +
							"p2.idcard," +
							"p2.mobile," +
							"p1.hospital_name," +
							"p1.create_time," +
							"p1.doctor_name," +
							"d.health_problem_name," +
							"CASE p1.dispensary_type " +
								"WHEN 1 THEN '自取' " +
								"WHEN 2 THEN '快递配送' " +
								"WHEN 3 THEN '健管师配送' " +
							"END pay,p1.STATUS " +
					"FROM wlyy_prescription p1," +
					"wlyy_patient p2,(" +
				    "SELECT prescription_code," +
						"GROUP_CONCAT(health_problem_name) health_problem_name " +
						"FROM wlyy_prescription_diagnosis ";
		
			//疾病
			if (StringUtils.isNotBlank(disease)) {
				prescriptionsql = prescriptionsql + " where health_problem = '" + disease+"' ";
			}
				prescriptionsql = prescriptionsql +	" GROUP BY prescription_code) d " +
				    "WHERE p1.patient=p2.CODE AND p1.CODE=d.prescription_code ";
						
//					"WHERE p.patient_name NOT IN ('谭仁祝','林美美','曾丽玉','陈新梅','罗金水','陈友财') " +
		//社区
		if (StringUtils.isNotBlank(hospital)) {
			prescriptionsql = prescriptionsql + " and p1.hospital = '" + hospital+"' ";
		}
		
		//取药方式
		if (StringUtils.isNotBlank(dispensarytype)) {
			prescriptionsql = prescriptionsql + " and p1.dispensary_type = '" + dispensarytype+"' ";
		}
		
		//状态
		if (StringUtils.isNotBlank(status)) {
			prescriptionsql = prescriptionsql + " and p1.status = '" + status+"' ";
		}
		
		//开始时间
		if (StringUtils.isNotBlank(beginDate) && !" 00:00:00".equals(beginDate)) {
			prescriptionsql = prescriptionsql + " and  p1.create_time <= '" + beginDate+"' ";
		}
		
		//结束时间
		if (StringUtils.isNotBlank(endDate) && !" 23:59:59".equals(endDate)) {
			prescriptionsql = prescriptionsql + " and  p1.create_time >= '" + endDate+"' ";
		}
		
		prescriptionsql = prescriptionsql+ ") p ORDER BY p.create_time DESC";
		
		if(ispage){
			if(1 == page){
				page = page-1;
			}
			prescriptionsql = prescriptionsql +" limit " + page+", "+pageSize;
		}
		
		list =  jdbcTemplate.query(prescriptionsql,new BeanPropertyRowMapper(PrescriptionVO.class));
		
		return list ;
	}
	
	public Long getPrescriptionListCount(String hospital, String disease, String dispensarytype, String status, String beginDate, String endDate) {
		
		String prescriptionsql = "SELECT count(p.code) FROM (" +
				"SELECT " +
				"p1.CODE," +
				"p1.patient_name," +
				"p2.idcard," +
				"p2.mobile," +
				"p1.hospital_name," +
				"p1.create_time," +
				"p1.doctor_name," +
				"d.health_problem_name," +
				"CASE p1.dispensary_type " +
				"WHEN 1 THEN '自取' " +
				"WHEN 2 THEN '快递配送' " +
				"WHEN 3 THEN '健管师配送' " +
				"END pay,p1.STATUS " +
				"FROM wlyy_prescription p1," +
				"wlyy_patient p2,(" +
				"SELECT prescription_code," +
				"GROUP_CONCAT(health_problem_name) health_problem_name " +
				"FROM wlyy_prescription_diagnosis ";
		
		//疾病
		if (StringUtils.isNotBlank(disease)) {
			prescriptionsql = prescriptionsql + " where health_problem = '" + disease+"' ";
		}
		prescriptionsql = prescriptionsql +	" GROUP BY prescription_code) d " +
				"WHERE p1.patient=p2.CODE AND p1.CODE=d.prescription_code";
//					"WHERE p.patient_name NOT IN ('谭仁祝','林美美','曾丽玉','陈新梅','罗金水','陈友财') " +
		//社区
		if (StringUtils.isNotBlank(hospital)) {
			prescriptionsql = prescriptionsql + " and p1.hospital = '" + hospital+"' ";
		}
		
		//取药方式
		if (StringUtils.isNotBlank(dispensarytype)) {
			prescriptionsql = prescriptionsql + " and p1.dispensary_type = '" + dispensarytype+"' ";
		}
		
		//状态
		if (StringUtils.isNotBlank(status)) {
			prescriptionsql = prescriptionsql + " and p1.status = '" + status+"' ";
		}
		
		//开始时间
		if (StringUtils.isNotBlank(beginDate) && !" 00:00:00".equals(beginDate)) {
			prescriptionsql = prescriptionsql + " and p1.create_time <= '" + beginDate+"' ";
		}
		
		//结束时间
		if (StringUtils.isNotBlank(endDate) && !" 23:59:59".equals(endDate)) {
			prescriptionsql = prescriptionsql + " and p1.create_time >= '" + endDate+"' ";
		}
		
		prescriptionsql = prescriptionsql + ") p ";
		
		Long total = jdbcTemplate.queryForObject(prescriptionsql, Long.class);
		
		return total ;
	}
}

+ 16 - 3
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_list.jsp

@ -26,20 +26,32 @@
			<%--<div class="m-form-control f-ml15">--%>
				<%--<input type="text" id="inp_device_model" placeholder="请输入设备型号" class="f-ml10" data-attr-scan="deviceModel"/>--%>
			<%--</div>--%>
			<div id="div_error_list_grid">
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_device_code" placeholder="请输入设备SN码" class="f-ml10" data-attr-scan="deviceCode"/>
				<input type="text" id="inp_device_code" name="inp_device_code" placeholder="请输入设备SN码" class="f-ml10" data-attr-scan="deviceCode"/>
			</div>
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_org_name" placeholder="请输入机构名称" class="f-ml10" data-attr-scan="orgName"/>
				<input type="text" id="inp_org_name" name="inp_org_name" placeholder="请输入机构名称" class="f-ml10" data-attr-scan="orgName"/>
			</div>
			<div class="m-form-control f-ml15">
				<input type="text" id="inp_linkman" placeholder="请输入机构联系人" class="f-ml10" data-attr-scan="linkman"/>
				<input type="text" id="inp_linkman" name="inp_linkman" placeholder="请输入机构联系人" class="f-ml10" data-attr-scan="linkman"/>
			</div>
			<sec:authorize url="/admin/device/deviceList">
			<div id="btn_search" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
				<span>查询</span>
			</div>
			</sec:authorize>
			<sec:authorize url="/admin/device/toExcel">
			<div class="m-form-control m-form-control-fr">
				<div id="btn_export" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam">
					<span>导出</span>
				</div>
			</div>
			</sec:authorize>
			<sec:authorize url="/admin/device/create">
			<div class="m-form-control m-form-control-fr">
				<div id="btn_add" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam" style="margin-right: 20px;">
@ -48,6 +60,7 @@
			</div>
			</sec:authorize>
		</div>
	</div>
	<!-- 列表 -->

+ 30 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_list_js.jsp

@ -29,6 +29,7 @@
				$element: $('.m-retrieve-area'),
				$searchBtn: $('#btn_search'),
				$addBtn: $('#btn_add'),
                $exportBtn: $('#btn_export'),
				$deviceName: $("#inp_device_name"),//设备名称
				$deviceCode: $("#inp_device_code"),
@ -53,6 +54,35 @@
					self.$addBtn.click(function () {
						$.publish("device:info:create", [0]);
					});
					//导出
                    //生成Excel表
                    self.$exportBtn.click(function () {
                        //定义一个form表单
                        var myform = $("<form></form>");
                        myform.attr('method','post')
                        myform.attr('action',ctx + '/admin/device/toExcel');
                        //设备名称
                        var deviceName = $("<input type='hidden' name='deviceName' />")
                        deviceName.attr('value',$("#inp_device_name").val());
                        //设备编号
                        var deviceCode = $("<input type='hidden' name='deviceCode' />")
                        deviceName.attr('value',$("#deviceCode").val());
                        //社区名称
                        var orgName = $("<input type='hidden' name='orgName' />")
                        deviceName.attr('value',$("#orgName").val());
                        //联系人
                        var orgName = $("<input type='hidden' name='linkman' />")
                        deviceName.attr('value',$("#linkman").val());
                        myform.append(deviceName);
                        myform.append(deviceCode);
                        myform.append(orgName);
                        myform.appendTo('body').submit(); //must add this line for higher html spec
                    })
				}
			};
			master = {

+ 28 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/main.jsp

@ -117,6 +117,33 @@
				</div>
				</sec:authorize>
				<%-- 数据统计--%>
				<sec:authorize url="/admin/static/center">
				<div class="a-divider"></div>
				<div class="a-menu">
					<div class="a-menu-tit"><i class="icons icons-aside-2 icons-24 mr15"></i>数据统计</div>
					<div class="a-menu-list c-hide">
						<ul>
							</sec:authorize>
							<sec:authorize url="/admin/static/prescription/initial">
								<li><a href="javascript:locationMenu('staticPrescription');">长处方数据统计</a></li>
							</sec:authorize>
							<sec:authorize url="/admin/static/wechat/initial">
								<li><a href="javascript:locationMenu('staticWechat');">微信统计报表</a></li>
							</sec:authorize>
							<sec:authorize url="/admin/static/sign/initial">
								<li><a href="javascript:locationMenu('staticSign');">签约统计报表</a></li>
							</sec:authorize>
							<sec:authorize url="/admin/static/device/initial">
								<li><a href="javascript:locationMenu('staticDevice');">设备统计报表</a></li>
							</sec:authorize>
							<sec:authorize url="/admin/static/static/center">
						</ul>
					</div>
				</div>
				</sec:authorize>
				<%-- 问卷调查管理中心--%>
				<sec:authorize url="/admin/survey/center">
				<div class="a-divider"></div>
@ -228,6 +255,7 @@
					</div>
					</sec:authorize>
                <!-- 原有先注释 20160901  ********-->
                <!-- <div class="a-divider"></div>
                <div class="a-menu">

+ 65 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/prescription/prescription_list.jsp

@ -0,0 +1,65 @@
<%--
  Created by IntelliJ IDEA.
  User: huangwenjie
  Date: 2017/12/8
  Time: 10:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@ include file="../head/page_head.jsp" %>
    <title>长处方统计</title>
</head>
<body>
<div id="div_wrapper">
    <!-- 检索条件 -->
    <div class="m-retrieve-area f-h50 f-dn f-pr m-form-inline" data-role-form style='display: block;'>
        <div class="m-form-group f-mt10">
            <div class="m-form-group f-mt10">
                <div class="m-form-control f-ml15" style="display: none">
                    <input type="text" id="inp_device_name" placeholder="请选择城市" class="f-ml10"/>
                </div>
                <div class="m-form-control f-ml15">
                    <input type="text" id="inp_categoryCode" placeholder="请选择市区" class="f-ml10"/>
                </div>
                <div class="m-form-control f-ml15">
                    <input type="text" id="inp_hos" placeholder="请选择机构" class="f-ml10"/>
                </div>
                <div class="m-form-control f-ml15" style="display: none">
                    <input type="text" id="inp_team" placeholder="请选择团队" class="f-ml10"/>
                </div>
                <div class="m-form-control f-ml15">
                    <input type="text" id="inp_star_date" placeholder="开始日期" class="f-ml10" data-attr-scan="beginDate"/>
                </div>
                <div class="m-form-control f-ml15">
                    <input type="text" id="inp_end_date" placeholder="结束日期" class="f-ml10" data-attr-scan="endDate"/>
                </div>
                <div class="m-form-control f-ml15">
                    <input type="text" id="inp_disease" placeholder="请选择病种" class="f-ml10" data-attr-scan="disease"/>
                </div>
                <div class="m-form-control f-ml15">
                    <input type="text" id="inp_dispensarytype" placeholder="请选择取药方式" class="f-ml10" data-attr-scan="dispensarytype"/>
                </div>
                <div class="m-form-control f-ml15">
                    <input type="text" id="inp_status" placeholder="请选择状态" class="f-ml10" data-attr-scan="status"/>
                </div>
                <div id="btn_search" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
                    <span>查询</span>
                </div>
                <div id="btn_export" class="l-button u-btn u-btn-primary u-btn-small f-ib f-vam  f-ml10" >
                    <span>导出</span>
                </div>
            </div>
        </div>
    </div>
    <!-- 列表 -->
    <div id="div_prescription_list">
    </div>
</div>
</body>
<%@ include file="../head/page_foot.jsp" %>
<%@ include file="prescription_list_js.jsp" %>
</html>

+ 459 - 0
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/prescription/prescription_list_js.jsp

@ -0,0 +1,459 @@
<%--
  Created by IntelliJ IDEA.
  User: Mewtwo
  Date: 2017/12/8
  Time: 11:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<script>
    (function ( $, win) {
        $(function () {
            /* ************************** 变量定义 ******************************** */
            // 通用工具类库
            var Util = $.Util;
            var retrieve = null;
            var inpStarDate = null,inpEndDate = null;
            var now = new Date(); //当前日期
            var nowDayOfWeek = now.getDay(); //今天本周的第几天
            var nowDay = now.getDate(); //当前日
            var nowMonth = now.getMonth(); //当前月
            var nowYear = now.getYear(); //当前年
            nowYear += (nowYear < 2000) ? 1900 : 0;
            retrieve = {
                $element: $('.m-retrieve-area'),
                patientInfoDialog: null,
                remindInfoDialog:null,
                $noReply: $('#noReply'),
                $count: $('#count'),
                $rate: $('#rate'),
                grid: null,
                url: {
                    //接口链接
                    /*
                    列表
                    */
                    list: '/admin/static/prescription/list',
                    /*
                    * 省,市,区
                    * */
                    district: '/common/district',
                    /*
                    *获取医院列表
                    * */
                    hospitalsByType: '/admin/hos/hospitalsByType',
                    /*
                    * 获取社区的团队
                    * */
                    team: '/admin/team/list'
                },
                $inpDeviceName: $('#inp_device_name'),//城市
                $inpCategoryCode: $('#inp_categoryCode'),//区
                $inpHos: $('#inp_hos'),//机构
                $inpTeam: $('#inp_team'),//团队
                $inpDisease:$('#inp_disease'),//病种
                $inpDispensarytype:$('#inp_dispensarytype'),//取药方式
                $inpStatus:$('#inp_status'),//状态
                dnc: null,
                ccc: null,
                hc: null,
                tc: null,
                $inpNotReturn: $('#inp_not_return'),
                $inpDocName: $('#inp_doc_name'),
                $inpStarDate: $('#inp_star_date'),
                $inpEndDate: $('#inp_end_date'),
                $btnSearch: $('#btn_search'),
                $btnExport: $('#btn_export'),
                init: function () {
                    this.initComboBox();
                    inpStarDate = this.$inpStarDate.ligerDateEditor({
                        format: "yyyy-MM-dd",
                        showTime: false,
                        labelWidth: 100,
                        labelAlign: 'center',
                        cancelable: true
                    });
                    inpEndDate = this.$inpEndDate.ligerDateEditor({
                        format: "yyyy-MM-dd",
                        showTime: false,
                        labelWidth: 100,
                        labelAlign: 'center',
                        cancelable: true
                    });
                    this.$inpNotReturn.ligerTextBox({width: 200});
                    this.$inpDocName.ligerTextBox({width: 200});
                    this.getList(this);
                    this.bindEvents();
                    //疾病下拉框
                    retrieve.diseaseBox = $("#inp_disease").ligerComboBox({
                        width: 150,
                        data: [
                            {text: '高血压病', statusId: 'HP0093'},
                            {text: '糖尿病', statusId: 'HP0047'}
                        ],
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                    //请选择取药方式拉框
                    retrieve.dispensarytypeBox = $("#inp_dispensarytype").ligerComboBox({
                        width: 150,
                        data: [
                            {text: '自取', statusId: '1'},
                            {text: '快递配送', statusId: '2'},
                            {text: '健管师配送', statusId: '3'}
                        ],
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                    //状态拉框
                    retrieve.statusBox = $("#inp_status").ligerComboBox({
                        width: 150,
                        data: [
                            {text: '开方失败', statusId: '31'},
                            {text: '开方完成/待支付', statusId: '40'},
                            {text: '支付成功/待配药', statusId: '50'},
                            {text: '配药成功/待配送', statusId: '60'},
                            {text: '配送中', statusId: '65'},
                            {text: '配送到患者手中/已完成', statusId: '100'},
                            {text: '线下退费', statusId: '-4'},
                            {text: '支付超时', statusId: '-3'},
                            {text: '患者自己取消', statusId: '-2'},
                            {text: '审核不通过', statusId: '-1'},
                            {text: '待审核', statusId: '0'},
                            {text: '调整中', statusId: '2'},
                        ],
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                    //查询
                    me.$btnSearch.on('click',function () {
                        me.reloadGrid(me);
                    });
                },
                //初始化市区下拉框
                initComboBox: function () {
                    this.dnc = this.$inpDeviceName.ligerComboBox({
                        width: 150,
                        data: [
                            {text: '厦门市', statusId: '350200'}
                        ],
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                    this.dnc.selectValue('350200');//默认选中厦门市
                    this.setCityFun(this);
                    this.initInpCat( [], this);
                    this.initHc( [], this);
                    this.initTc( [], this);
                },
                //区
                initInpCat: function ( d, me) {
                    me.ccc = me.$inpCategoryCode.ligerComboBox({
                        width: 150,
                        data: d,
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                },
                //机构
                initHc: function ( d, me) {
                    me.hc = me.$inpHos.ligerComboBox({
                        width: 250,
                        data: d,
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                },
                //团队
                initTc: function ( d, me) {
                    me.tc = me.$inpTeam.ligerComboBox({
                        width: 200,
                        data: d,
                        initIsTriggerEvent: false,
                        valueField: 'statusId',
                    });
                },
                //获取列表
                getList: function (me) {
                    me.$element.attrScan();
                    var values = me.$element.Fields.getValues();
                    values.beginDate = values.beginDate + ' 00:00:00';
                    values.endDate = values.endDate + ' 23:59:59';
                    values.city = me.dnc.getValue();
                    values.town = me.ccc.getValue();
                    values.hospital = me.hc.getValue();
                    values.teamCode = me.tc.getValue();
                    console.log(values);
                    me.grid = $("#div_prescription_list").ligerGrid($.LigerGridEx.config({
                        url: ctx + me.url.list,
                        parms: {
                            "town": values.town,
                            "hospital": values.hospital,
                            "disease": values.disease,
                            "dispensarytype": values.dispensarytype,
                            "status":values.status,
                            "beginDate":values.beginDate,
                            "endDate":values.endDate,
                        },
                        ajaxHeader: ajaxHeaderName,
                        ajaxHeaderValue: ajaxHeaderValue,
                        columns: [
                            {display: 'code', name: 'prescription_code', hide: true},
                            {display: '姓名', name: 'patient_name', width: '5%', align: "center"},
                            {display: '身份证号', name: 'idcard', width: '12%', align: "left"},
                            {display: '手机号码', name: 'mobile', width: '10%', align: "center"},
                            {display: '签约医院', name: 'hospital_name', width: '17%', align: "left"},
                            {display: '医生', name: 'doctor_name', width: '10%', align: "center"},
                            {display: '疾病', name: 'health_problem_name', align: "center"},
                            {display: '状态', name: 'statusName', align: "center"},
                            {display: '配送方式', name: 'pay', align: "center"},
                            {display: '时间', name: 'create_time', width: '12%', align: "center"},
                            {
                                display: '操作', name: 'operator', width: '10%', align: "center", isSort: false,
                                <%--render: function (row) {--%>
                                <%--var html = '';--%>
                                <%--html += '<a  href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "sign:info:view", row.id) + '">明细</a>';--%>
                                <%--//html += '<a  style="margin-left:10px;"href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}'])", "patient:info:edit", row.id) + '">编辑</a>';--%>
                                <%--//html += '<a  style="margin-left:10px;" title="删除" href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}'])", "patient:info:del", row.id,row.code) + '">删除</a>';--%>
                                <%--if (row.adminTeamId) {--%>
                                <%--<sec:authorize url="/admin/sign/memberList">--%>
                                <%--html += '<a style="margin-left:10px;" href="' + ctx + '/admin/team/signTeamInfo/' + row.adminTeamId + '" target="centerFrame">行政团队</a>';--%>
                                <%--</sec:authorize>--%>
                                <%--}--%>
                                <%--return html;--%>
                                <%--}--%>
                            }
                        ],
                    }));
                    // 自适应宽度
                    me.grid.adjustToWidth();
                },
                setCityFun: function (me) {
                    var v = me.dnc.getValue();
                    if (v != '') {
                        me.rAjax( me.url.district, {
                            type: 3,
                            code: v
                        }, function (data) {
                            var d = [];
                            for (var i = 0; i < data.list.length; i++) {
                                d.push({
                                    text: data.list[i].name,
                                    statusId: data.list[i].code
                                });
                            }
                            //区
                            me.initInpCat( d, me);
                        })
                    } else {
                        me.initInpCat( [], me);
                        me.initHc( [], me);
                        me.initTc( [], me);
                    }
                },
                setAreaFun: function (me) {
                    var v = me.ccc.getValue();
                    if (v != '') {
                        me.rAjax( me.url.hospitalsByType, {
                            type: 2,
                            code: v
                        }, function (data) {
                            var d = [];
                            for (var i = 0; i < data.list.length; i++) {
                                d.push({
                                    text: data.list[i].name,
                                    statusId: data.list[i].code
                                });
                            }
                            //机构
                            me.initHc( d, me);
                        })
                    } else {
                        me.initHc( [], me);
                        me.initTc( [], me);
                    }
                },
                setJgFun: function (me) {
                    var v = me.hc.getValue();
                    if (v != '') {
                        me.rAjax( me.url.team, {
                            orgCode: v
                        }, function (data) {
                            var d = [];
                            for (var i = 0; i < data.list.length; i++) {
                                d.push({
                                    text: data.list[i].name,
                                    statusId: data.list[i].id
                                });
                            }
                            //tuandui
                            me.initTc( d, me);
                        })
                    } else {
                        me.initTc( [], me);
                    }
                },
                bindEvents: function () {
                    var me = this;
                    //城市下拉
                    me.$inpDeviceName.on( 'change', function () {
                        me.setCityFun(me);
                    });
                    //区下拉
                    me.$inpCategoryCode.on( 'change', function () {
                        me.setAreaFun(me);
                        me.hc.setValue('');
                        me.tc.setValue('');
                    });
                    //机构
                    me.$inpHos.on( 'change', function () {
                        me.setJgFun(me);
                        me.tc.setValue('');
                    });
                    //查询
                    me.$btnSearch.on('click',function () {
                        me.reloadGrid(me);
                    });
                    //导出
                    me.$btnExport.on('click',function () {
                        //定义一个form表单
                        var myform = $("<form></form>");
                        myform.attr('method','post')
                        myform.attr('action',ctx + '/admin/static/prescription/toExcel');
                        me.$element.attrScan();
                        var values = me.$element.Fields.getValues();
                        values.beginDate = values.beginDate + ' 00:00:00';
                        values.endDate = values.endDate + ' 23:59:59';
                        values.city = me.dnc.getValue();
                        values.town = me.ccc.getValue();
                        values.hospital = me.hc.getValue();
                        values.teamCode = me.tc.getValue();
                        //疾病
                        var disease = $("<input type='hidden' name='disease' />")
                        disease.attr('value',$("#inp_disease_val").val());
                        //取药方式
                        var dispensarytype = $("<input type='hidden' name='dispensarytype' />")
                        dispensarytype.attr('value',$("#inp_dispensarytype_val").val());
                        //状态
                        var status = $("<input type='hidden' name='status' />")
                        status.attr('value',$("#inp_status_val").val());
                        //区
                        var town = $("<input type='hidden' name='town' />")
                        town.attr('value',values.town);
                        //社区医院
                        var hospital = $("<input type='hidden' name='hospital' />")
                        hospital.attr('value',values.hospital);
                        //开始时间
                        var beginDate = $("<input type='hidden' name='beginDate' />")
                        beginDate.attr('value',values.beginDate);
                        //结束时间
                        var endDate = $("<input type='hidden' name='endDate' />")
                        endDate.attr('value',values.endDate);
                        myform.append(disease);
                        myform.append(dispensarytype);
                        myform.append(status);
                        myform.append(town);
                        myform.append(hospital);
                        myform.append(beginDate);
                        myform.append(endDate);
                        myform.appendTo('body').submit(); //must add this line for higher html spec
                    });
                },
                reloadGrid: function (me) {
                    me.$element.attrScan();
                    var values = me.$element.Fields.getValues();
                    values.beginDate = values.beginDate + ' 00:00:00';
                    values.endDate = values.endDate + ' 23:59:59';
                    values.city = me.dnc.getValue();
                    values.town = me.ccc.getValue();
                    values.hospital = me.hc.getValue();
                    values.teamCode = me.tc.getValue();
                    values.disease = $('#inp_disease_val').val();
                    values.dispensarytype = $('#inp_dispensarytype_val').val();
                    values.status = $('#inp_status_val').val();
                    console.log(values);
                    me.selReloadGrid.call(me, values);
                },
                selReloadGrid: function (params) {
                    this.grid.options.newPage = 1;
                    this.grid.setOptions({parms: params});
                    this.grid.loadData(true);
                },
                rAjax: function ( url, d, cb) {
                    $.ajax({
                        url: ctx + url,
                        data: d,
                        type: 'POST',
                        dataType: 'json',
                        success: function (data) {
                            if (data.status == 200) {
                                cb && cb.call( this, data);
                            } else {
                                $.Notice.error(data.msg);
                            }
                        }
                    });
                },
                formatDate:function (date) {//格式化日期
                    var myyear = date.getFullYear();
                    var mymonth = date.getMonth()+1;
                    var myweekday = date.getDate();
                    if(mymonth < 10){
                        mymonth = "0" + mymonth;
                    }
                    if(myweekday < 10){
                        myweekday = "0" + myweekday;
                    }
                    return (myyear+"-"+mymonth + "-" + myweekday);
                },
                getNowDay:function(){
                    var me = this;
                    var nowDate = new Date(nowYear, nowMonth, nowDay);
                    return me.formatDate(nowDate);
                },
                getWeekStartDate:function () {//获得本周的开始日期
                    var me = this;
                    var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + 1);
                    return me.formatDate(weekStartDate);
                },
                getMonthStartDate:function(){ //获得本月的开始日期
                    var me = this;
                    var monthStartDate = new Date(nowYear, nowMonth, 1);
                    return me.formatDate(monthStartDate);
                }
            };
            win.reloadMasterUpdateGrid = function () {
                retrieve.reloadGrid(retrieve);
            };
            retrieve.init();
        });
    })( jQuery, window);
</script>

+ 4 - 0
patient-co-manage/wlyy-manage/src/main/webapp/static/js/menu.js

@ -21,6 +21,10 @@ var menu = {
    "deviceHealthIndex": "/admin/healthIndex/initial",//健康体征数据查询页面
    "patientDevice": "/admin/patientDevice/initial",//居民设备查询页面
    //数据统计
    "static": "/admin/static/center",//数据统计
    "staticPrescription": "/admin/static/prescription/initial",//长处方数据统计
    //安全管理
    "user": "/admin/user/initial",//人员管理界面
    "roles": "/admin/roles/initial",//用户角色管理界面

+ 9 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -160,6 +160,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("prenatal_inspector_job exist");
            }
            //医生端产检系统提醒 每个工作日上午10:00执行一次
            if (!quartzHelper.isExistJob("doctor_prenatal_inspector_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("doctor_prenatal_inspector_job");
                quartzHelper.addJob(DoctorPrenatalInspectorJob.class, trigger, "doctor_prenatal_inspector_job", new HashMap<String, Object>());
                logger.info("doctor_prenatal_inspector_job success");
            } else {
                logger.info("doctor_prenatal_inspector_job exist");
            }
    
            //老年人体检记录同步,每天凌晨1点执行一次
            if (!quartzHelper.isExistJob("old_people_tijian_syb_job")) {

+ 37 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/DoctorPrenatalInspectorJob.java

@ -0,0 +1,37 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.app.prenatalInspector.PrenatalInspectorPreCardService;
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 org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
/**
 * 医生端产检系统消息提醒
 * Created by Reece on 2017/12/7.
 */
public class DoctorPrenatalInspectorJob implements Job{
    private static Logger logger = LoggerFactory.getLogger(DoctorPrenatalInspectorJob.class);
    @Autowired
    private PrenatalInspectorPreCardService preCardService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            logger.info("doctor prenatal inspector message sending start...");
            preCardService.sendMessagePrenatal();
            logger.info("doctor prenatal inspector message sending end...");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

@ -64,6 +64,6 @@ public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>,
    List<WlyyCharge> findByTradeStatusAndMiRegisterNoAndUpdateTime(int tradestatus, Date enddate, Date startdate);
    //   查询当天支付,页面回调及异步回调均失败的支付 tradeStatus为空
    @Query(value = "SELECT t.`code` FROM wlyy_charge t WHERE t.trade_status != '0' AND t.create_time >= date(now()) AND t.create_time < DATE_ADD(date(now()), INTERVAL 1 DAY) ", nativeQuery = true)
    @Query(value = "SELECT t.`code` FROM wlyy_charge t WHERE ((t.trade_status = '1') OR (t.trade_status is NULL)) AND t.create_time >= timestamp(adddate(date(sysdate()),0)) AND t.create_time < timestamp(adddate(date(sysdate()),1)) ", nativeQuery = true)
    List<String> findTodayUnpay();
}

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

@ -10,11 +10,21 @@ import java.util.List;
/**
 * Created by yeshijie on 2017/6/6.
 */
public interface PrenatalInspectorPlanDao extends PagingAndSortingRepository<PrenatalInspectorPlan, Long>{
public interface PrenatalInspectorPlanDao extends PagingAndSortingRepository<PrenatalInspectorPlan, Long> {
    @Query("select a from PrenatalInspectorPlan a where a.inspectionCode = ?1 and a.status = '0' ")
    List<PrenatalInspectorPlan> findByCode(String inspectionCode);
    @Query("select a from PrenatalInspectorPlan a where a.inspectionTime is not null and a.status = '0' and a.del ='1' and ( TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=7 or TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=1 ) ")
    List<PrenatalInspectorPlan> findWxTipList();
    //获取当前时间在应产检时间往后7天以上
    @Query("select a from PrenatalInspectorPlan a where a.inspectionTime is not null and a.status = '0' and a.del ='1' and TO_DAYS(NOW()) - TO_DAYS(a.inspectionTime) > 7 ")
    List<PrenatalInspectorPlan> findByTime();
    //应产检时间前14天后14天待产检计划(不包括应产检当天)
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a, (SELECT t.* from wlyy_prenatal_inspector_plan t where t.id = ?1 )b  " +
            " WHERE a.inspection_time >= DATE_ADD(b.inspection_time,INTERVAL -14 DAY) and a.inspection_time <= DATE_ADD(b.inspection_time,INTERVAL 14 DAY) " +
            "and a.inspection_time != b.inspection_time ORDER BY a.inspection_time DESC ", nativeQuery = true)
    List<PrenatalInspectorPlan> getScopeById(Long prenatalId);
}

+ 22 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorRecordDao.java

@ -0,0 +1,22 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorRecord;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Reece on 2017/12/5.
 */
public interface PrenatalInspectorRecordDao extends PagingAndSortingRepository<PrenatalInspectorRecord, Long>{
    //根据孕检ID及type获取发送记录
    @Query("select a from PrenatalInspectorRecord a where a.relation = ?1 and a.type= ?2 ")
    PrenatalInspectorRecord findByRelationAndType(String relation,int type);
    //根据孕检ID及type和接收者code获取发送给医生的系统提醒
    @Query("select a from PrenatalInspectorRecord a where a.relation = ?1 and a.receiver= ?2 and a.type= 2 ")
    PrenatalInspectorRecord getMessageByRelation(String relation,String receiver);
}

+ 146 - 20
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java

@ -1,9 +1,17 @@
package com.yihu.wlyy.service.app.prenatalInspector;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorRecord;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PrenatalInspectorPlanDao;
import com.yihu.wlyy.repository.patient.PrenatalInspectorRecordDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.task.PushMsgTask;
@ -15,6 +23,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
@ -31,9 +41,15 @@ public class PrenatalInspectorPreCardService extends BaseService {
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private FamilyContractService familyContractService;
    private MessageDao messageDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PrenatalInspectorRecordDao recordDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
    private DoctorDao doctorDao;
    /**
@ -41,40 +57,59 @@ public class PrenatalInspectorPreCardService extends BaseService {
     * 1、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前7天(保证居民可自行预约),发出产检预约提醒通知。点击该消息,进入预约页面
     * 2、当居民已有经医生确认过的下一次产检时间,则距离下一次产检前1天,发出产检就诊提醒,提醒居民就诊。点击该消息,进入预约记录页面
     */
    public void sendPrenatalInspectorRemind(){
    public void sendPrenatalInspectorRemind() {
        System.out.println("产检计划---running");
        List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findWxTipList();
        for (PrenatalInspectorPlan plan:planList){
        for (PrenatalInspectorPlan plan : planList) {
            try {
                String relation = plan.getId().toString();
                Patient patient = patientDao.findByCode(plan.getPatient());
                String openId = patient.getOpenid();
                String name = patient.getName();
                String patientCode = patient.getCode();
                if(StringUtils.isNotBlank(openId)){
                    Long day = DateUtil.getDays(plan.getInspectionTime(),DateUtil.getNowDateShort());
                plan.getId();
                if (StringUtils.isNotBlank(openId)) {
                    Long day = DateUtil.getDays(plan.getInspectionTime(), DateUtil.getNowDateShort());
                    JSONObject json = new JSONObject();
                    if(day==7){
                    PrenatalInspectorRecord record = recordDao.findByRelationAndType(relation, 0);
                    if (record == null) {
                        record = new PrenatalInspectorRecord();
                        record.setTimes(1);
                    } else {
                        record.setTimes(record.getTimes() + 1);
                    }
                    record.setRelation(relation);
                    record.setSender("PrenatalInspectorJob");
                    record.setReceiver(patientCode);
                    record.setType(0);
                    record.setName(name);
                    record.setOpenid(openId);
                    record.setContent(plan.getCheckItem());
                    record.setSendTime(new Date());
                    if (day == 7) {
                        //产检提醒
                        json.put("remark","产检内容以医生实际检查为准。点击进行预约");
                        json.put("first",name+",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略");
                        json.put("url","wdyy/html/appointment-register.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
                        json.put("remark", "产检内容以医生实际检查为准。点击进行预约");
                        json.put("first", name + ",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略");
                        json.put("url", "wdyy/html/appointment-register.html?openid=" + openId + "&toUser=" + patientCode + "&toName=" + name);
                        json.put("keyword1","产检提醒");
                        String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
                        json.put("keyword2",keyword2);
                        json.put("keyword1", "产检提醒");
                        String keyword2 = DateUtil.getStringDateShort() + "\n产检内容:" + plan.getCheckItem();
                        json.put("keyword2", keyword2);
                        pushMsgTask.sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                    }else if(day==1){
                        recordDao.save(record);
                    } else if (day == 1) {
                        //产检就诊提醒
                        json.put("remark","产检内容以医生实际检查为准。点击查看预约记录");
                        json.put("first",name+",您好!您和您的宝宝即将进行产检啦~请按时就诊,如已就诊,请忽略");
                        json.put("url","wdyy/html/my-appointment.html?openid="+openId+"&toUser="+patientCode+"&toName="+name);
                        json.put("keyword1","产检就诊提醒");
                        String keyword2 = DateUtil.getStringDateShort()+"\n产检内容:"+plan.getCheckItem();
                        json.put("keyword2",keyword2);
                        json.put("remark", "产检内容以医生实际检查为准。点击查看预约记录");
                        json.put("first", name + ",您好!您和您的宝宝即将进行产检啦~请按时就诊,如已就诊,请忽略");
                        json.put("url", "wdyy/html/my-appointment.html?openid=" + openId + "&toUser=" + patientCode + "&toName=" + name);
                        json.put("keyword1", "产检就诊提醒");
                        String keyword2 = DateUtil.getStringDateShort() + "\n产检内容:" + plan.getCheckItem();
                        json.put("keyword2", keyword2);
                        pushMsgTask.sendWeixinMessage(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                        recordDao.save(record);
                    }
                }
            }catch (Exception e){
            } catch (Exception e) {
                System.out.println("微信提醒发送失败");
                e.printStackTrace();
            }
@ -82,4 +117,95 @@ public class PrenatalInspectorPreCardService extends BaseService {
    }
    /**
     * 向医生发出产检系统消息
     */
    public void sendMessagePrenatal() throws Exception {
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findByTime();
            for (PrenatalInspectorPlan plan : planList) {
                String code = plan.getPatient();
                Patient patient = patientDao.findByCode(code);
                String content = "您的签约居民" + patient.getName() + "超期未进行孕检,原计划孕检时间" + format.format(plan.getInspectionTime());
                List<PrenatalInspectorPlan> plans = prenatalInspectorPlanDao.getScopeById(plan.getId());
                if (plans == null || plans.size() == 0) {
                    SignFamily signFamily = signFamilyDao.findByPatient(code);
                    String doctor = signFamily.getDoctor();
                    String doctorHealth = signFamily.getDoctorHealth();
                    if (StringUtils.isNotEmpty(doctor)) {
                        saveMessageRecord(plan.getId().toString(), doctor, content);
                    }
                    if (StringUtils.isNotEmpty(doctorHealth)) {
                        saveMessageRecord(plan.getId().toString(), doctorHealth, content);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 保存系统消息及发送记录
     *
     * @param prenatalId
     * @param doctor
     * @param content
     * @throws Exception
     */
    public void saveMessageRecord(String prenatalId, String doctor, String content) throws Exception {
        try {
            Doctor doc = doctorDao.findByCode(doctor);
            String doctorName = doc.getName();
            String doctorOpenId = doc.getOpenid();
            PrenatalInspectorRecord record = recordDao.getMessageByRelation(prenatalId, doctor);
            if (record != null) {
                if (record.getTimes() < 3 && record.getTimes() > 0) {
//                    每次间隔2天发送(已发送过1-2次)
                    if (DateUtil.getDays(new Date(), record.getSendTime()) == 3) {
                        record.setTimes(record.getTimes() + 1);
                    }else {
                        return;
                    }
                } else if (record.getTimes() >= 3) {
                    return;
                }
            } else {
                record = new PrenatalInspectorRecord();
                record.setTimes(1);
            }
            record.setRelation(prenatalId);
            record.setSender("SYSTEM");
            record.setReceiver(doctor);
            record.setType(2);
            record.setName(doctorName);
            record.setOpenid(doctorOpenId);
            record.setContent(content);
            record.setSendTime(new Date());
            recordDao.save(record);
            Message message = new Message();
            message.setCzrq(new Date());
            message.setCreateTime(new Date());
            message.setRead(1);
            message.setOver("1");
            message.setReceiver(doctor);
            message.setSender("SYSTEM");
            message.setCode(getCode());
            message.setTitle("孕检提醒");
            message.setContent(content);
            message.setType(2);
            messageDao.save(message);
            // 推送消息给医生
            pushMsgTask.put(doctor, "13", "孕检提醒", content, "");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 3 - 0
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -125,6 +125,9 @@ patient_physical_examination_job=0 0 8 * * ?
# 电子社保卡绑定状态查询,每隔6小时执行一次
sicard_query_job=0 0 6,12,18,23 * * ?
#医生端产检系统提醒(每个工作日10点执行一次)
doctor_prenatal_inspector_job=0 0 10 ? * MON-FRI
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html
#统一支付平台支付接口地址

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -62,6 +62,10 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    @Query("select p from Patient p where p.status = 1 and p.openid = ?1 order by p.czrq desc")
    Page<Patient> findPatientByOpenid(String openid, Pageable pageable);
    //根据openID获取居民
    @Query("select p from Patient p where p.status = 1 and p.openid = ?1 order by p.czrq desc")
    List<Patient> findPatientByOpenid(String openid);
    //获取所有的openid并排重
    @Query("select distinct p.openid from Patient p where p.openid is not null and p.openid <> '' ")
    List<String> findOpenids();

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

@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -15,9 +16,19 @@ public interface PrenatalInspectorPlanDao extends PagingAndSortingRepository<Pre
    @Query("select a from PrenatalInspectorPlan a where a.inspectionCode = ?1 and a.status = '0' and a.del='1' order by a.inspectionTime asc")
    List<PrenatalInspectorPlan> findByCode(String inspectionCode);
    @Query("select a from PrenatalInspectorPlan a where a.patient = ?1 and a.status = '0' and a.del='1' and NOW()<=a.inspectionTime order by a.inspectionTime asc")
    //查询最近15天数据
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a WHERE a.patient = ?1 AND a. STATUS = '0' AND a.del = '1' " +
            " AND DATE_ADD(CURDATE(),INTERVAL -14 DAY) <= a.inspection_time " +
            " AND a.inspection_time <= CURDATE() ORDER BY a.inspection_time DESC ",nativeQuery = true)
    List<PrenatalInspectorPlan> findByPatient(String patient);
    //应产检时间前14天后14天待产检计划(不包括应产检当天)
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a, (SELECT t.* from wlyy_prenatal_inspector_plan t where t.id = ?1 )b  " +
            " WHERE a.inspection_time >= DATE_ADD(b.inspection_time,INTERVAL -14 DAY) and a.inspection_time <= DATE_ADD(b.inspection_time,INTERVAL 14 DAY) " +
            "and a.inspection_time != b.inspection_time ORDER BY a.inspection_time DESC ",nativeQuery = true)
    List<PrenatalInspectorPlan> getScopeById(Long prenatalId);
    @Query("select a from PrenatalInspectorPlan a where a.status = '0' and a.del='1' and ( TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=7 or TO_DAYS(a.inspectionTime)- TO_DAYS(NOW())=1 ) ")
    List<PrenatalInspectorPlan> findWxTipList();

+ 20 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorRecordDao.java

@ -0,0 +1,20 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorPlan;
import com.yihu.wlyy.entity.patient.prenatal.PrenatalInspectorRecord;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Reece on 2017/12/5.
 */
public interface PrenatalInspectorRecordDao extends PagingAndSortingRepository<PrenatalInspectorRecord, Long>{
    //根据孕检ID及type获取发送记录
    @Query("select a from PrenatalInspectorRecord a where a.relation = ?1 and a.type= ?2 ")
    PrenatalInspectorRecord findByRelationAndType(String relation,int type);
}

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

@ -13,6 +13,7 @@ import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
import com.yihu.wlyy.entity.patient.vo.PatientArchivesDto;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.address.*;
import com.yihu.wlyy.repository.demographic.TblBasicDao;
@ -34,6 +35,7 @@ import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.objenesis.ObjenesisBase;
import org.springframework.stereotype.Component;
@ -1288,4 +1290,33 @@ public class PatientInfoService extends BaseService {
        return rs;
    }
    
    
    /**
     *根据居民CODE获取居民VO对象
     *@author huangwenjie
     *@date 2017/12/6 08:40
     */
    public PatientVO getPatientVOByCode(String code){
        PatientVO p = new PatientVO();
        List<PatientVO> plist = new ArrayList<>();
        if(StringUtils.isNotBlank(code)){
            String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                    "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                    "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                    " and patient = '"+code+"' GROUP BY patient) c on a.code = c.patient" +
                    " where a.status =1 and a.code = '"+code+"'";
            
            plist = jdbcTemplate.query(patientsql,new BeanPropertyRowMapper(PatientVO.class));
            
            if(plist.isEmpty()){
                return null;
            }else{
                p = plist.get(0);
                return p;
            }
        }else{
            return null;
        }
    }
}

+ 20 - 21
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/express/SFExpressService.java

@ -252,27 +252,26 @@ public class SFExpressService extends BaseService {
        Document doc = DocumentHelper.parseText(re);
        String headvalue = doc.selectSingleNode("/Response/Head").getText();
        if(StringUtils.isNotBlank(headvalue) && "OK".equals(headvalue)) {
        }
        Element root = doc.getRootElement();
        if (root.element("Body") != null)     //取报文根节点
        {
            root = root.element("Body");
        }
        List<?> child = root.elements();
        String mailno = "";
        Map<String,List<PrescriptionExpressageLog>> wayroutlsit = new HashMap<>();
        for (Object o : child) {
            Element e = (Element) o;
            mailno = e.attributeValue("mailno");
            //判断快递单号不为空,且和我们本地的一致
            if(StringUtils.isNotBlank(mailno) &&
                    sfexpress_obj.getMailno().equals(mailno)){
                //解析报文,结合本地数据返回最终的日志结果
                return this.xmltologlist(e,sfexpresslogList,sfexpress_obj);
            }else{
                continue;
            Element root = doc.getRootElement();
            if (root.element("Body") != null)     //取报文根节点
            {
                root = root.element("Body");
            }
            List<?> child = root.elements();
            String mailno = "";
            Map<String,List<PrescriptionExpressageLog>> wayroutlsit = new HashMap<>();
            for (Object o : child) {
                Element e = (Element) o;
                mailno = e.attributeValue("mailno");
                //判断快递单号不为空,且和我们本地的一致
                if(StringUtils.isNotBlank(mailno) &&
                        sfexpress_obj.getMailno().equals(mailno)){
            
                    //解析报文,结合本地数据返回最终的日志结果
                    return this.xmltologlist(e,sfexpresslogList,sfexpress_obj);
                }else{
                    continue;
                }
            }
        }
        return null;

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

@ -18,6 +18,7 @@ import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.account.PatientInfoService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
@ -74,6 +75,8 @@ public class SignPatientLabelInfoService extends BaseService {
    SignFamilyRenewDao signFamilyRenewDao;
    @Autowired
    SignPatientLabelInfoDao signPatientLabelInfoDao;
    @Autowired
    PatientInfoService patientInfoService;
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
@ -86,7 +89,8 @@ public class SignPatientLabelInfoService extends BaseService {
     */
    public JSONObject getPatient(String patient) throws Exception {
        JSONObject json = new JSONObject();
        Patient p = patientDao.findByCode(patient);
//        Patient p = patientDao.findByCode(patient);
        PatientVO p = patientInfoService.getPatientVOByCode(patient);
        if (p == null) {
            throw new Exception("patient info can not find");
@ -119,6 +123,15 @@ public class SignPatientLabelInfoService extends BaseService {
        json.put("address", p.getAddress());
        // 社保号
        json.put("ssc", p.getSsc());
    
        //病情类型:0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
        json.put("disease",p.getDisease());
        // 病情:0绿标,1黄标,2红标,
        json.put("diseaseCondition",p.getDiseaseCondition());
        //预警状态
        json.put("standardStatus",p.getStandardStatus());
        //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
        json.put("deviceType",p.getDeviceType());
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily familySign = signFamilyDao.findSignByPatient(patient, 2);
@ -267,10 +280,12 @@ public class SignPatientLabelInfoService extends BaseService {
            Calendar today = Calendar.getInstance();
            Calendar startDate = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            sql = "select * " +
            sql = "select DISTINCT * " +
                    " from " +
                    "     wlyy_sign_family " +
                    " where (doctor = ? or doctor_health = ?) and status > 0 and admin_team_code = ? ";
                    "     wlyy_sign_family t1" +
                    "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                    "  LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = 3 and t2.status=1 "+
                    " where (t1.doctor = ? or t1.doctor_health = ?) and t1.status > 0 and t1.admin_team_code = ? ";
            if (labelCode.equals("1")) {
                int week = today.get(Calendar.DAY_OF_WEEK) - 2;
@ -279,53 +294,43 @@ public class SignPatientLabelInfoService extends BaseService {
                    week = 6;
                }
                startDate.add(Calendar.DATE, -week);
                sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                sql += " and t1.apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("2")) {
                startDate.set(Calendar.DATE, 1);
                sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                sql += " and t1.apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("3")) {
                startDate.add(Calendar.DATE, 30);
                sql += " and end between '" + (df.format(today.getTime()) + " 00:00:00")
                sql += " and t1.end between '" + (df.format(today.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(startDate.getTime()) + " 23:59:59'");
            } else {
                throw new Exception("label is not exist");
            }
            sql += " order by openid desc,convert(name using gbk) ";
            sql += " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
            args = new Object[]{doctor, doctor, teamCode};
        }else if("1".equals(labelType)){
            sql = "SELECT " +
                    " f.* " +
                    "FROM " +
                    " wlyy_sign_family_server s ,( " +
                    "  SELECT " +
                    "   t1.*, p.openid AS ptOpenid " +
            sql ="  SELECT " +
                    "  DISTINCT t1.* " +
                    "  FROM " +
                    "   wlyy_sign_family t1, " +
                    "   wlyy_patient p " +
                    "  WHERE " +
                    "  p. CODE = t1.patient " +
                    "  AND ( " +
                    "   wlyy_sign_family t1 " +
                    "   LEFT JOIN wlyy_patient p on p. CODE = t1.patient " +
                    "   LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient and t2.label_type = 3 and t2.status=1 "+
                    "   LEFT JOIN wlyy_sign_family_server s on s.sign_code = t1.code and s.server_type = '"+labelCode+"' "+
                    "  WHERE ( " +
                    "   t1.doctor = ? " +
                    "   OR t1.doctor_health = ? " +
                    "  ) " +
                    "  AND t1. STATUS > 0  AND t1.admin_team_code = ?";
            if(isSlowDisease){
                sql = sql + "  AND p.disease >0 " ;
            }
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.disease_condition ="+diseaseCondition;
            }
            sql = sql +" ) f " +
                    "WHERE " +
                    " f. CODE = s.sign_code " +
                    " AND s.server_type ='"+labelCode+"'  ORDER BY f.ptOpenid DESC";
            sql = sql +" order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk) ";
            args = new Object[]{doctor, doctor, teamCode};
        }else if("3".equals(labelType) && isSlowDisease){
            //慢病管理
            sql = "SELECT " +
                    "    DISTINCT t1.* " +
                    "  DISTINCT t1.* " +
                    "  FROM  wlyy_sign_family t1 " +
                    "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                    "  RIGHT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient ";
@ -355,11 +360,12 @@ public class SignPatientLabelInfoService extends BaseService {
                        " left join " +
                        "    (select l.patient,l.label,l.label_type,l.label_name from wlyy_sign_family f left join wlyy_sign_patient_label_info l on f.patient = l.patient where (f.doctor = '" + doctor + "' or f.doctor_health = '" + doctor + "') and f.status > 0 and l.label_type = ? and l.status = 1) t2 " +
                        " on t1.patient = t2.patient " +
                        " left join wlyy_patient p on p.code = t1.patient "+
                        " WHERE " +
                        "    t2.patient is null " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?) " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
                        "    AND t1.admin_team_code = ? order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC ,convert(t1.name using gbk)";
                args = new Object[]{labelType, doctor, doctor, teamCode};
            }else {
@ -368,6 +374,7 @@ public class SignPatientLabelInfoService extends BaseService {
                        " FROM " +
                        "    wlyy_sign_family t1, " +
                        "    wlyy_sign_patient_label_info t2 " +
                        "    wlyy_patient p "+
                        " WHERE " +
                        "    t2.label = ? " +
                        "    AND t2.label_type = ? " +
@ -375,7 +382,7 @@ public class SignPatientLabelInfoService extends BaseService {
                        "    AND t1.patient = t2.patient " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? order by t1.openid desc,convert(t1.name using gbk) ";
                        "    AND t1.admin_team_code = ? order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,p.openid DESC ,convert(t1.name using gbk)";
                args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
            }
@ -2299,9 +2306,23 @@ public class SignPatientLabelInfoService extends BaseService {
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                PatientVO p = new PatientVO();
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
                    plist = jdbcTemplate.query(patientsql,new BeanPropertyRowMapper(PatientVO.class));
        
                    if(plist.isEmpty()){
                        continue;
                    }else{
                        p = plist.get(0);
                    }
                }else{
                    continue;
                }
@ -2425,6 +2446,17 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
    
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease", p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition", p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                
                
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -2552,9 +2584,23 @@ public class SignPatientLabelInfoService extends BaseService {
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                PatientVO p = new PatientVO();
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
                    plist = jdbcTemplate.query(patientsql,new BeanPropertyRowMapper(PatientVO.class));
        
                    if(plist.isEmpty()){
                        continue;
                    }else{
                        p = plist.get(0);
                    }
                }else{
                    continue;
                }
@ -2678,6 +2724,16 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
    
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease", p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition", p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -3342,6 +3398,7 @@ public class SignPatientLabelInfoService extends BaseService {
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                (isIdcard ? ",wlyy_patient p " : "") +
                " WHERE " +
                (isIdcard ? " t1.patient = p.code  and " : "") +
@ -3355,9 +3412,23 @@ public class SignPatientLabelInfoService extends BaseService {
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                PatientVO p = new PatientVO();
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
                    plist = jdbcTemplate.query(patientsql,new BeanPropertyRowMapper(PatientVO.class));
        
                    if(plist.isEmpty()){
                        continue;
                    }else{
                        p = plist.get(0);
                    }
                }else{
                    continue;
                }
@ -3465,6 +3536,16 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease", p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition", p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
@ -3520,9 +3601,23 @@ public class SignPatientLabelInfoService extends BaseService {
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                PatientVO p = new PatientVO();
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
                    plist = jdbcTemplate.query(patientsql,new BeanPropertyRowMapper(PatientVO.class));
        
                    if(plist.isEmpty()){
                        continue;
                    }else{
                        p = plist.get(0);
                    }
                }else{
                    continue;
                }
@ -3630,6 +3725,16 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
    
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease", p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition", p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",p.getDeviceType());
                
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());

+ 23 - 22
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientRemindRecords;
import com.yihu.wlyy.entity.patient.PatientTeamRemindRecord;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientRemindRecordsDao;
@ -23,6 +24,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -157,7 +159,6 @@ public class PhysicalExaminationRemindService extends BaseService {
        Map<String, JSONObject> result = new TreeMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        Map<String, Object> patientDeviceTypeMap = new HashMap<>();//用于存储患者设备绑定情况
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
@ -167,6 +168,8 @@ public class PhysicalExaminationRemindService extends BaseService {
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                "  LEFT JOIN wlyy_patient p on p.code = t1.patient  "+
                "  LEFT JOIN wlyy_sign_patient_label_info t2 on t2.patient = t1.patient "+
                " WHERE " +
                "     t1.status > 0 " +
                "    AND t1.admin_team_code = ? " +
@ -178,29 +181,32 @@ public class PhysicalExaminationRemindService extends BaseService {
                "                wlyy_old_people_physical_examination o" +
                "           WHERE s.admin_team_code=? and s.`status`>0 and s.idcard = o.id_card " +
                "                 and o.medical_time>?)" +
                " order by t1.openid desc,convert(t1.name using gbk) ";
                " order by p.standard_status DESC ,p.disease_condition DESC,t2.label DESC,t1.openid DESC";
        args = new Object[]{teamCode,doctor,doctor, teamCode, DateUtil.getLastYear()};
        sql = sql + " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        //查询患者设备绑定情况
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<Map<String, Object>> patientCodeDeviceTypes = jdbcTemplate.queryForList(_pdsql);
        if (!patientCodeDeviceTypes.isEmpty()) {
            for (Map<String, Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                patientDeviceTypeMap.put(user, sum);
            }
        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                PatientVO p = new PatientVO();
                List<PatientVO> plist = new ArrayList<>();
                if(sign.get("patient") != null){
                    String patientsql = "select a.*,b.deviceType as deviceType,c.disease as disease from wlyy_patient a" +
                            "  left join (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on a.code = b.user" +
                            "  left join (select patient,group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 " +
                            " and (label = 1 or label = 2) and patient = '"+sign.get("patient").toString()+"' GROUP BY patient) c on a.code = c.patient" +
                            " where a.status =1 and a.code = '"+sign.get("patient").toString()+"'";
        
                    plist = jdbcTemplate.query(patientsql,new BeanPropertyRowMapper(PatientVO.class));
        
                    if(plist.isEmpty()){
                        continue;
                    }else{
                        p = plist.get(0);
                    }
                }else{
                    continue;
                }
@ -265,12 +271,7 @@ public class PhysicalExaminationRemindService extends BaseService {
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                String deviceType = "";
                if (!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())) {
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType", deviceType);
                json.put("deviceType",p.getDeviceType());
                boolean epTime = false;
                try {

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

@ -9,17 +9,20 @@ 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.entity.patient.prenatal.PrenatalInspectorRecord;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
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.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.common.SMSService;
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;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -64,24 +68,31 @@ public class PrenatalInspectorPreCardService extends BaseService {
    private PatientHealthIndexService healthIndexService;
    @Autowired
    private DevicePatientHealthIndexDao healthIndexDao;
    @Autowired
    private PrenatalInspectorRecordDao recordDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private SMSService smsService;
//    public
    /**
     * 待产检计划
     *
     * @param code
     * @return
     */
    public JSONArray planList(String code){
    public JSONArray planList(String code) {
        JSONArray jsonArray = new JSONArray();
        List<PrenatalInspectorPlan> planList = prenatalInspectorPlanDao.findByCode(code);
        for (PrenatalInspectorPlan plan:planList){
        for (PrenatalInspectorPlan plan : planList) {
            JSONObject json = new JSONObject();
            json.put("checkItem",plan.getCheckItem());
            json.put("name",plan.getName());
            json.put("thisFoucs",plan.getThisFocus());
            json.put("thisNote",plan.getThisNote());
            json.put("inspectionTime",DateUtil.dateToStrShort(plan.getInspectionTime()));
            json.put("checkItem", plan.getCheckItem());
            json.put("name", plan.getName());
            json.put("thisFoucs", plan.getThisFocus());
            json.put("thisNote", plan.getThisNote());
            json.put("inspectionTime", DateUtil.dateToStrShort(plan.getInspectionTime()));
            jsonArray.add(json);
        }
@ -91,28 +102,29 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 获取产检列表
     *
     * @param patientCode
     * @return
     */
    public JSONArray getEhrMaternalFirstExamRecord(String patientCode){
    public JSONArray getEhrMaternalFirstExamRecord(String patientCode) {
        JSONArray re = new JSONArray();
        SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
        String hospital = null;
        if(signFamily!=null){
        if (signFamily != null) {
            hospital = signFamily.getHospital();
        }
        Patient patient = patientDao.findByCode(patientCode);
        try{
        try {
            boolean checkFlag = true;//是否查询预建卡接口。有建卡记录且建卡记录有结束妊娠才查询预建卡
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(),hospital);
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(), hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
            if (json.getInteger("status") == 200) {
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            Map<String,String> map = new HashMap<>();//存储产检号,用于去除预建卡信息中重复记录
            if(data!=null&&data.size()>0){//有建卡信息
                for (int i=0;i<data.size();i++) {
            Map<String, String> map = new HashMap<>();//存储产检号,用于去除预建卡信息中重复记录
            if (data != null && data.size() > 0) {//有建卡信息
                for (int i = 0; i < data.size(); i++) {
                    JSONObject planJson = new JSONObject();
                    JSONObject pregnancy = data.getJSONObject(i);
                    String PREGNANCY_NO = pregnancy.getString("PREGNANCY_NO");//智业产检号
@ -124,103 +136,112 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    String DELIVERY_WAY = pregnancy.getString("DELIVERY_WAY");//分娩方式
                    String DELIVERY_TIME = pregnancy.getString("DELIVERY_TIME");//分娩方式时间
                    String EXAM_TIME = pregnancy.getString("EXAM_TIME");//检查日期
                    planJson.put("pregnancyNo",PREGNANCY_NO);
                    planJson.put("pregnancyStatus",PREGNANCY_STATUS);
                    planJson.put("endManner",END_MANNER);
                    planJson.put("endTime",END_TIME);
                    planJson.put("mensesLast",MENSES_LAST);
                    planJson.put("expectedTime",EXPECTED_TIME);
                    planJson.put("pregnancyNo", PREGNANCY_NO);
                    planJson.put("pregnancyStatus", PREGNANCY_STATUS);
                    planJson.put("endManner", END_MANNER);
                    planJson.put("endTime", END_TIME);
                    planJson.put("mensesLast", MENSES_LAST);
                    planJson.put("expectedTime", EXPECTED_TIME);
                    Date date = new Date();
                    map.put("PREGNANCY_NO","PREGNANCY_NO");
                    if(StringUtils.isBlank(END_TIME)){
                        checkFlag = checkFlag?false:checkFlag;
                    map.put("PREGNANCY_NO", "PREGNANCY_NO");
                    if (StringUtils.isBlank(END_TIME)) {
                        checkFlag = checkFlag ? false : checkFlag;
                        //未结束妊娠,生成待产检计划
                        List<PrenatalInspectorPlan> plans = prenatalInspectorPlanDao.findByPatient(patientCode);
                        boolean flag = false;
                        if(plans==null||plans.size()==0){
                        if (plans == null || plans.size() == 0) {
                            flag = true;
                        }else {
                        } else {
                            String inspectionCode = plans.get(0).getInspectionCode();
                            if(StringUtils.isBlank(inspectionCode)){//有待产检计划,但是产检号为空,说明是预建卡生成的产检记录
                            if (StringUtils.isBlank(inspectionCode)) {//有待产检计划,但是产检号为空,说明是预建卡生成的产检记录
                                flag = true;
                                //更新居民待产检计划,需要重新生成
                                prenatalInspectorPlanDao.updateStatus(patientCode);
                            }
                        }
                        if(flag){//判断是否已经生成产检记录
                        if (flag) {//判断是否已经生成产检记录
                            Date dueDay = DateUtil.strToDate(EXPECTED_TIME);
                            Long days = DateUtil.getDays(dueDay,date);
                            Long days = DateUtil.getDays(dueDay, date);
                            List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
                            plans = new ArrayList<>();
                            PrenatalInspectorPlan plan = null;
                            for (PrenatalInspectorPlanLibrary library:libraries){
                                plan = new PrenatalInspectorPlan();
                                plan.setInspectionPhase(library.getInspectionPhase());
                                plan.setStatus("0");
                                plan.setPatient(patientCode);
                                plan.setCzrq(date);
                                plan.setDel("1");
                                plan.setInspectionCode(PREGNANCY_NO);//产检号
                                plan.setCheckItem(library.getCheckItem());
                                plan.setInspectionTime(DateUtil.getPrenatalInspectorDate(dueDay,-library.getEndDay().intValue()));
                                plan.setName(library.getName());
                                plan.setThisFocus(library.getThisFocus());
                                plan.setThisNote(library.getThisNote());
                                plans.add(plan);
                            for (PrenatalInspectorPlanLibrary library : libraries) {
                                //                                    只取最近15天数据
                                Date inspectorDate = DateUtil.getPrenatalInspectorDate(dueDay, -library.getEndDay().intValue());
                                if (DateUtil.getDays(date, inspectorDate) <= 15 && DateUtil.getDays(date, inspectorDate) >= 0) {
                                    plan = new PrenatalInspectorPlan();
                                    plan.setInspectionPhase(library.getInspectionPhase());
                                    plan.setStatus("0");
                                    plan.setPatient(patientCode);
                                    plan.setCzrq(date);
                                    plan.setDel("1");
                                    plan.setInspectionCode(PREGNANCY_NO);//产检号
                                    plan.setCheckItem(library.getCheckItem());
                                    plan.setInspectionTime(DateUtil.getPrenatalInspectorDate(dueDay, -library.getEndDay().intValue()));
                                    plan.setName(library.getName());
                                    plan.setThisFocus(library.getThisFocus());
                                    plan.setThisNote(library.getThisNote());
                                    plans.add(plan);
                                }
                            }
                            if (plans.size()>0){
                            if (plans.size() > 0) {
                                prenatalInspectorPlanDao.save(plans);
                            }
                        }
                        //计算距离下次产检时间
                        Long nextExamDay = 0l;
                        for (PrenatalInspectorPlan plan:plans) {
                            Long temp = DateUtil.getDays(plan.getInspectionTime(),date);
                            if(nextExamDay==0||nextExamDay>temp){
                        for (PrenatalInspectorPlan plan : plans) {
                            Long temp = DateUtil.getDays(plan.getInspectionTime(), date);
                            if (nextExamDay == 0 || nextExamDay > temp) {
                                nextExamDay = temp;
                            }
                        }
                        planJson.put("plans",plans);//待产检列表
                        planJson.put("nextExamDay",nextExamDay);//距离下次产检天数
                        planJson.put("plans", plans);//待产检列表
                        if (plans != null && plans.size()>0) {
                            PrenatalInspectorPlan prenatalInspectorPlan = plans.get(0);
                            JSONObject status = getPrenatalStatus(prenatalInspectorPlan.getId());
                            planJson.put("inspectStatus", status);//最近一条状态
                        }
                        planJson.put("nextExamDay", nextExamDay);//距离下次产检天数
                        //产床预约信息
                        String precontract_org_name = "";//产床医院
                        try {
                            String bedRecode = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(patient.getIdcard(),hospital);
                            String bedRecode = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(patient.getIdcard(), hospital);
                            JSONObject bedJson = JSONObject.parseObject(bedRecode);
                            JSONArray bedData = null;
                            if(bedJson.getInteger("status")==200){
                            if (bedJson.getInteger("status") == 200) {
                                bedData = bedJson.getJSONObject("data").getJSONArray("DATA");
                            }
                            if(bedData!=null&&bedData.size()>0){
                                JSONObject exam = bedData.getJSONObject(bedData.size()-1);
                            if (bedData != null && bedData.size() > 0) {
                                JSONObject exam = bedData.getJSONObject(bedData.size() - 1);
                                precontract_org_name = exam.getString("PRECONTRACT_ORG_NAME");
                            }
                        }catch (Exception e){
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        planJson.put("precontractOrgName",precontract_org_name);//产床医院
                        planJson.put("precontractOrgName", precontract_org_name);//产床医院
                    }
                    re.add(planJson);
                }
            }
            //请求预建卡接口
            if(checkFlag){
                String resp = jwMaternalChildService.getEhrMaternalPreFirstExamRecord(patient.getIdcard(),hospital);
            if (checkFlag) {
                String resp = jwMaternalChildService.getEhrMaternalPreFirstExamRecord(patient.getIdcard(), hospital);
                JSONObject preJson = JSONObject.parseObject(resp);
                JSONArray preData = null;
                if(preJson.getInteger("status")==200){
                if (preJson.getInteger("status") == 200) {
                    preData = preJson.getJSONObject("data").getJSONArray("DATA");
                    if(preData!=null&&preData.size()>0){
                    if (preData != null && preData.size() > 0) {
                        JSONArray rep = new JSONArray();
                        for (int i=0;i<preData.size();i++){
                        for (int i = 0; i < preData.size(); i++) {
                            JSONObject planJson = new JSONObject();
                            JSONObject pregnancy = preData.getJSONObject(i);
                            String PREGNANCY_NO = pregnancy.getString("PREGNANCY_NO");//智业产检号
                            if(map.containsKey(PREGNANCY_NO)){
                            if (map.containsKey(PREGNANCY_NO)) {
                                continue;//去重
                            }
@ -228,58 +249,67 @@ public class PrenatalInspectorPreCardService extends BaseService {
                            String END_TIME = pregnancy.getString("END_TIME");//结束妊娠
                            String MENSES_LAST = pregnancy.getString("MENSES_LAST");//末次月经
                            Date dueday = DateUtil.getDueDate(DateUtil.strToDateLong(MENSES_LAST));//预产期
                            planJson.put("pregnancyNo",PREGNANCY_NO);
                            planJson.put("pregnancyStatus","0");
                            planJson.put("endManner",END_MANNER);
                            planJson.put("endTime",END_TIME);
                            planJson.put("mensesLast",MENSES_LAST);
                            planJson.put("expectedTime",DateUtil.dateToStrLong(dueday));
                            planJson.put("pregnancyNo", PREGNANCY_NO);
                            planJson.put("pregnancyStatus", "0");
                            planJson.put("endManner", END_MANNER);
                            planJson.put("endTime", END_TIME);
                            planJson.put("mensesLast", MENSES_LAST);
                            planJson.put("expectedTime", DateUtil.dateToStrLong(dueday));
                            Date date = new Date();
                            List<PrenatalInspectorPlan> plans = prenatalInspectorPlanDao.findByPatient(patientCode);
                            if(plans==null||plans.size()==0){//判断是否已经生成产检记录
                            if (plans == null || plans.size() == 0) {//判断是否已经生成产检记录
                                //预建卡还没产检,有产检就会生成产检记录,建卡接口就会有数据
                                Long days = DateUtil.getDays(dueday,date);
                                Long days = DateUtil.getDays(dueday, date);
                                List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
                                plans = new ArrayList<>();
                                PrenatalInspectorPlan plan = null;
                                for (PrenatalInspectorPlanLibrary library:libraries){
                                    plan = new PrenatalInspectorPlan();
                                    plan.setInspectionPhase(library.getInspectionPhase());
                                    plan.setStatus("0");
                                    plan.setPatient(patientCode);
                                    plan.setCzrq(date);
                                    plan.setDel("1");
                                    plan.setCheckItem(library.getCheckItem());
                                    plan.setInspectionTime(DateUtil.getPrenatalInspectorDate(dueday,-library.getEndDay().intValue()));
                                    plan.setName(library.getName());
                                    plan.setThisFocus(library.getThisFocus());
                                    plan.setThisNote(library.getThisNote());
                                    plans.add(plan);
                                for (PrenatalInspectorPlanLibrary library : libraries) {
//                                    只取最近15天数据
                                    Date inspectorDate = DateUtil.getPrenatalInspectorDate(dueday, -library.getEndDay().intValue());
                                    if (DateUtil.getDays(date, inspectorDate) <= 15 && DateUtil.getDays(date, inspectorDate) >= 0) {
                                        plan = new PrenatalInspectorPlan();
                                        plan.setInspectionPhase(library.getInspectionPhase());
                                        plan.setStatus("0");
                                        plan.setPatient(patientCode);
                                        plan.setCzrq(date);
                                        plan.setDel("1");
                                        plan.setCheckItem(library.getCheckItem());
                                        plan.setInspectionTime(inspectorDate);
                                        plan.setName(library.getName());
                                        plan.setThisFocus(library.getThisFocus());
                                        plan.setThisNote(library.getThisNote());
                                        plans.add(plan);
                                    }
                                }
                                if (plans.size()>0){
                                if (plans.size() > 0) {
                                    prenatalInspectorPlanDao.save(plans);
                                }
                            }
                            //计算距离下次产检时间
                            Long nextExamDay = 0l;
                            for (PrenatalInspectorPlan plan:plans) {
                                Long temp = DateUtil.getDays(plan.getInspectionTime(),date);
                                if(nextExamDay==0||nextExamDay>temp){
                            for (PrenatalInspectorPlan plan : plans) {
                                Long temp = DateUtil.getDays(plan.getInspectionTime(), date);
                                if (nextExamDay == 0 || nextExamDay > temp) {
                                    nextExamDay = temp;
                                }
                            }
                            planJson.put("plans",plans);//待产检列表
                            planJson.put("nextExamDay",nextExamDay);//距离下次产检天数
                            planJson.put("precontractOrgName",null);//产床医院
                            planJson.put("plans", plans);//待产检列表
                            if (plans != null && plans.size()>0) {
                                PrenatalInspectorPlan prenatalInspectorPlan = plans.get(0);
                                JSONObject status = getPrenatalStatus(prenatalInspectorPlan.getId());
                                planJson.put("inspectStatus", status);//最近一条状态
                            }
                            planJson.put("nextExamDay", nextExamDay);//距离下次产检天数
                            planJson.put("precontractOrgName", null);//产床医院
                            rep.add(planJson);
                        }
                        //重新排序
                        if(rep.size()>0){
                            for (int i=0;i<re.size();i++){
                        if (rep.size() > 0) {
                            for (int i = 0; i < re.size(); i++) {
                                rep.add(re.getJSONObject(i));
                            }
                            return rep;
@ -288,7 +318,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
                }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
@ -297,28 +327,29 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 初检
     *
     * @param patientCode
     * @return
     */
    public JSONObject firstExam(String patientCode,String pregnancyNo){
    public JSONObject firstExam(String patientCode, String pregnancyNo) {
        JSONObject re = new JSONObject();
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String hospital = null;
            if(signFamily!=null){
            if (signFamily != null) {
                hospital = signFamily.getHospital();
            }
            Patient patient = patientDao.findByCode(patientCode);
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(),hospital);
            String response = jwMaternalChildService.getEhrMaternalFirstExamRecord(patient.getIdcard(), hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
            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"))){//判断是否同一个产检
            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);
                        String SICK_PROVINCE = re.getString("SICK_PROVINCE");//省
                        String SICK_CITY = re.getString("SICK_CITY");//市
@ -332,42 +363,42 @@ public class PrenatalInspectorPreCardService extends BaseService {
                        String SICK_HOUSEHOLD_COUNTRY = re.getString("SICK_HOUSEHOLD_COUNTRY");//户籍街道
                        String SICK_HOUSEHOLD_VILLAGE = re.getString("SICK_HOUSEHOLD_VILLAGE");//户籍居委会
                        if(StringUtils.isNotBlank(SICK_PROVINCE)){
                            re.put("SICK_PROVINCE",zyDictService.findZoneName(SICK_PROVINCE));
                        if (StringUtils.isNotBlank(SICK_PROVINCE)) {
                            re.put("SICK_PROVINCE", zyDictService.findZoneName(SICK_PROVINCE));
                        }
                        if(StringUtils.isNotBlank(SICK_CITY)){
                            re.put("SICK_CITY",zyDictService.findZoneName(SICK_CITY));
                        if (StringUtils.isNotBlank(SICK_CITY)) {
                            re.put("SICK_CITY", zyDictService.findZoneName(SICK_CITY));
                        }
                        if(StringUtils.isNotBlank(SICK_COUNTY)){
                            re.put("SICK_COUNTY",zyDictService.findZoneName(SICK_COUNTY));
                        if (StringUtils.isNotBlank(SICK_COUNTY)) {
                            re.put("SICK_COUNTY", zyDictService.findZoneName(SICK_COUNTY));
                        }
                        if(StringUtils.isNotBlank(SICK_COUNTRY)){
                            re.put("SICK_COUNTRY",zyDictService.findZoneName(SICK_COUNTRY));
                        if (StringUtils.isNotBlank(SICK_COUNTRY)) {
                            re.put("SICK_COUNTRY", zyDictService.findZoneName(SICK_COUNTRY));
                        }
                        if(StringUtils.isNotBlank(SICK_VILLAGE)){
                            re.put("SICK_VILLAGE",zyDictService.findZoneName(SICK_VILLAGE));
                        if (StringUtils.isNotBlank(SICK_VILLAGE)) {
                            re.put("SICK_VILLAGE", zyDictService.findZoneName(SICK_VILLAGE));
                        }
                        if(StringUtils.isNotBlank(SICK_HOUSEHOLD_PROVINCE)){
                            re.put("SICK_HOUSEHOLD_PROVINCE",zyDictService.findZoneName(SICK_HOUSEHOLD_PROVINCE));
                        if (StringUtils.isNotBlank(SICK_HOUSEHOLD_PROVINCE)) {
                            re.put("SICK_HOUSEHOLD_PROVINCE", zyDictService.findZoneName(SICK_HOUSEHOLD_PROVINCE));
                        }
                        if(StringUtils.isNotBlank(SICK_HOUSEHOLD_CITY)){
                            re.put("SICK_HOUSEHOLD_CITY",zyDictService.findZoneName(SICK_HOUSEHOLD_CITY));
                        if (StringUtils.isNotBlank(SICK_HOUSEHOLD_CITY)) {
                            re.put("SICK_HOUSEHOLD_CITY", zyDictService.findZoneName(SICK_HOUSEHOLD_CITY));
                        }
                        if(StringUtils.isNotBlank(SICK_HOUSEHOLD_COUNTY)){
                            re.put("SICK_HOUSEHOLD_COUNTY",zyDictService.findZoneName(SICK_HOUSEHOLD_COUNTY));
                        if (StringUtils.isNotBlank(SICK_HOUSEHOLD_COUNTY)) {
                            re.put("SICK_HOUSEHOLD_COUNTY", zyDictService.findZoneName(SICK_HOUSEHOLD_COUNTY));
                        }
                        if(StringUtils.isNotBlank(SICK_HOUSEHOLD_COUNTRY)){
                            re.put("SICK_HOUSEHOLD_COUNTRY",zyDictService.findZoneName(SICK_HOUSEHOLD_COUNTRY));
                        if (StringUtils.isNotBlank(SICK_HOUSEHOLD_COUNTRY)) {
                            re.put("SICK_HOUSEHOLD_COUNTRY", zyDictService.findZoneName(SICK_HOUSEHOLD_COUNTRY));
                        }
                        if(StringUtils.isNotBlank(SICK_HOUSEHOLD_VILLAGE)){
                            re.put("SICK_HOUSEHOLD_VILLAGE",zyDictService.findZoneName(SICK_HOUSEHOLD_VILLAGE));
                        if (StringUtils.isNotBlank(SICK_HOUSEHOLD_VILLAGE)) {
                            re.put("SICK_HOUSEHOLD_VILLAGE", zyDictService.findZoneName(SICK_HOUSEHOLD_VILLAGE));
                        }
                        return re;
                    }
                }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return re;
@ -375,30 +406,31 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 复检记录
     *
     * @param patientCode
     * @return
     */
    public JSONArray reExamRecode(String patientCode,String pregnancyNo){
    public JSONArray reExamRecode(String patientCode, String pregnancyNo) {
        JSONArray re = new JSONArray();
        try {
            SignFamily signFamily = signFamilyDao.findByPatient(patientCode);
            String hospital = null;
            if(signFamily!=null){
            if (signFamily != null) {
                hospital = signFamily.getHospital();
            }
            Patient patient = patientDao.findByCode(patientCode);
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(patient.getIdcard(),hospital,pregnancyNo);
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(patient.getIdcard(), hospital, pregnancyNo);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
            if (json.getInteger("status") == 200) {
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
            if (data != null && data.size() > 0) {
                return data;
            }
            return re;
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return re;
@ -406,26 +438,27 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 获取最后一次产检时间
     *
     * @param idcard
     * @param hospital
     * @return
     */
    public String getLastExamTime(String idcard,String hospital,String pregnancyNo){
    public String getLastExamTime(String idcard, String hospital, String pregnancyNo) {
        String re = "";
        try {
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(idcard,hospital,pregnancyNo);
            String response = jwMaternalChildService.getEhrMaternalReExamRecord(idcard, hospital, pregnancyNo);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
            if (json.getInteger("status") == 200) {
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                JSONObject exam = data.getJSONObject(data.size()-1);
            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");//产检日期
                re = examTime;
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return re;
@ -433,26 +466,27 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 产床预约信息
     *
     * @param idcard
     * @param hospital
     * @return
     */
    public String getEhrMaternalBedPrecontractRecord(String idcard,String hospital){
    public String getEhrMaternalBedPrecontractRecord(String idcard, String hospital) {
        String re = "";
        try {
            String response = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(idcard,hospital);
            String response = jwMaternalChildService.getEhrMaternalBedPrecontractRecord(idcard, hospital);
            JSONObject json = JSONObject.parseObject(response);
            JSONArray data = null;
            if(json.getInteger("status")==200){
            if (json.getInteger("status") == 200) {
                data = json.getJSONObject("data").getJSONArray("DATA");
            }
            if(data!=null&&data.size()>0){
                JSONObject exam = data.getJSONObject(data.size()-1);
            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");//产检日期
                re = examTime;
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return re;
@ -460,34 +494,35 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 预建卡列表-孕检计划
     *
     * @param patient
     * @return
     */
    public JSONArray preCardList(String patient){
    public JSONArray preCardList(String patient) {
        JSONArray jsonArray = new JSONArray();
        List<PrenatalInspectorPreCard> preCards = prenatalInspectorPreCardDao.findByPatient(patient);
        for (PrenatalInspectorPreCard preCard:preCards){
        for (PrenatalInspectorPreCard preCard : preCards) {
            JSONObject json = new JSONObject();
            json.put("code",preCard.getCode());
            json.put("dueDate",DateUtil.dateToStrShort(preCard.getDueDate()));//预产期
            json.put("code", preCard.getCode());
            json.put("dueDate", DateUtil.dateToStrShort(preCard.getDueDate()));//预产期
            Date date = new Date();
            Long dueDateDay = DateUtil.getDays(preCard.getDueDate(),date);
            if(dueDateDay>0){
                json.put("dueDateWeek",getWeek(dueDateDay.intValue()));//距离预产期周数
                json.put("dueDateDay",getDay(dueDateDay.intValue()));//距离预产期周数的余数
                Long pregnancyDay = DateUtil.getDays(date,preCard.getLastMenstrualDate());
            Long dueDateDay = DateUtil.getDays(preCard.getDueDate(), date);
            if (dueDateDay > 0) {
                json.put("dueDateWeek", getWeek(dueDateDay.intValue()));//距离预产期周数
                json.put("dueDateDay", getDay(dueDateDay.intValue()));//距离预产期周数的余数
                Long pregnancyDay = DateUtil.getDays(date, preCard.getLastMenstrualDate());
                int week = getWeek(pregnancyDay.intValue());
                int day = getDay(pregnancyDay.intValue());
                String preDay = day==0?(week+"周"):(week+"周"+day+"天");//怀孕时间
                json.put("status",preDay);
            }else {
                json.put("dueDateWeek",0);//距离预产期周数
                json.put("dueDateDay",0);//距离预产期周数的余数
                json.put("status",preCard.getStatus());
                String preDay = day == 0 ? (week + "周") : (week + "周" + day + "天");//怀孕时间
                json.put("status", preDay);
            } else {
                json.put("dueDateWeek", 0);//距离预产期周数
                json.put("dueDateDay", 0);//距离预产期周数的余数
                json.put("status", preCard.getStatus());
            }
            json.put("hospitalName",preCard.getHospitalName());//预约床位医院
            json.put("orderBedTime",preCard.getOrderBedTime());//预约床位时间
            json.put("hospitalName", preCard.getHospitalName());//预约床位医院
            json.put("orderBedTime", preCard.getOrderBedTime());//预约床位时间
            jsonArray.add(json);
        }
@ -497,47 +532,50 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 把天数换算成周数
     *
     * @param day
     * @return
     */
    private int getWeek(Integer day){
        return day/7;
    private int getWeek(Integer day) {
        return day / 7;
    }
    /**
     * 把天数换算成周数的余数
     *
     * @param day
     * @return
     */
    private int getDay(Integer day){
        return day%7;
    private int getDay(Integer day) {
        return day % 7;
    }
    /**
     * 上传预建卡
     *
     * @param code
     */
    public String uploadPreExam(String code){
    public String uploadPreExam(String code) {
        String re = "";
        try {
            //上传预建卡
            String response = jwMaternalChildService.SaveEhrMaternalPreFirstExamRecord(code);
            JSONObject preJson = JSONObject.parseObject(response);
            if(preJson.getInteger("status")!=200){
            if (preJson.getInteger("status") != 200) {
                re = preJson.getString("msg");
            }else {
            } else {
                JSONObject json = preJson.getJSONObject("data");
                if("0".equals(json.getString("code"))){
                if ("0".equals(json.getString("code"))) {
                    re = json.getString("MESSAGE");
                }
            }
            if(re.contains("身份证为空,请检查")){
            if (re.contains("身份证为空,请检查")) {
                re = "身份证为空,请检查";
            }else if(re.contains("操作员为空,请检查")){
            } else if (re.contains("操作员为空,请检查")) {
                re = "操作员为空,请检查";
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return re;
@ -557,12 +595,12 @@ public class PrenatalInspectorPreCardService extends BaseService {
        //判断是否有预建卡
        try {
            String resp = jwMaternalChildService.getEhrMaternalPreFirstExamRecord(preCard.getIdcard(),signFamily.getHospital());
            String resp = jwMaternalChildService.getEhrMaternalPreFirstExamRecord(preCard.getIdcard(), signFamily.getHospital());
            JSONObject preJson = JSONObject.parseObject(resp);
            JSONArray preData = null;
            if(preJson.getInteger("status")==200){
            if (preJson.getInteger("status") == 200) {
                preData = preJson.getJSONObject("data").getJSONArray("DATA");
                if(preData!=null&&preData.size()>0){
                if (preData != null && preData.size() > 0) {
                    JSONObject temp = preData.getJSONObject(0);
                    String END_MANNER = temp.getString("END_MANNER");//妊娠终止方式
                    if(StringUtils.isBlank(END_MANNER)){
@ -571,7 +609,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    }
                }
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
            json.put("code","-3");
            return json;
@ -583,8 +621,8 @@ public class PrenatalInspectorPreCardService extends BaseService {
        preCard.setDoctorName(doctor.getName());
        //保存智业的医生信息
        Map<String,Object> map = zyDictService.findJwDoctorByDoctor(doctor.getCode());
        if(map!=null){
        Map<String, Object> map = zyDictService.findJwDoctorByDoctor(doctor.getCode());
        if (map != null) {
            preCard.setJwDoctor(map.get("jw_doctor").toString());
        }
@ -612,11 +650,11 @@ public class PrenatalInspectorPreCardService extends BaseService {
//        p.setMobile(preCard.getMobile());
        //2、生成待产检计划(待产检计划由获取健康信息接口生成,关联产检计划)
        Long days = DateUtil.getDays(dueDate,date);
        Long days = DateUtil.getDays(dueDate, date);
        List<PrenatalInspectorPlanLibrary> libraries = prenatalInspectorPlanLibraryDao.findByDays(days);
        List<PrenatalInspectorPlan> plans = new ArrayList<>();
        PrenatalInspectorPlan plan = null;
        for (PrenatalInspectorPlanLibrary library:libraries){
        for (PrenatalInspectorPlanLibrary library : libraries) {
            plan = new PrenatalInspectorPlan();
            plan.setInspectionPhase(library.getInspectionPhase());
            plan.setStatus("0");
@ -625,7 +663,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
            plan.setDel("1");
            plan.setCheckItem(library.getCheckItem());
//            plan.setInspectionCode(preCard.getCode());
            plan.setInspectionTime(DateUtil.getPrenatalInspectorDate(dueDate,-library.getEndDay().intValue()));
            plan.setInspectionTime(DateUtil.getPrenatalInspectorDate(dueDate, -library.getEndDay().intValue()));
            plan.setName(library.getName());
            plan.setThisFocus(library.getThisFocus());
            plan.setThisNote(library.getThisNote());
@ -639,7 +677,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
            plans.add(plan);
        }
        if (plans.size()>0){
        if (plans.size() > 0) {
            prenatalInspectorPlanDao.save(plans);
        }
        json.put("code",preCard.getCode());
@ -649,28 +687,29 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 保存体征数据 有保存体征数据才更新
     *
     * @param preCard
     * @param patientCode
     */
    public void saveHealthIndex(PrenatalInspectorPreCard preCard,String patientCode){
        if(StringUtils.isNotBlank(preCard.getHeight())&&StringUtils.isNotBlank(preCard.getWeight())){
    public void saveHealthIndex(PrenatalInspectorPreCard preCard, String patientCode) {
        if (StringUtils.isNotBlank(preCard.getHeight()) && StringUtils.isNotBlank(preCard.getWeight())) {
            //先判断体征数据是否变更
            DevicePatientHealthIndex index = healthIndexDao.findLastData(patientCode, 3);
            String height = null;
            String weight = null;
            if(index!=null){
            if (index != null) {
                height = index.getValue2();
                weight = index.getValue1();
            }
            if(!preCard.getHeight().equals(height)||!preCard.getWeight().equals(weight)){
            if (!preCard.getHeight().equals(height) || !preCard.getWeight().equals(weight)) {
                //更新体征数据
                JSONObject json = new JSONObject();
                json.put("time",DateUtil.dateToStrLong(preCard.getCzrq()));
                json.put("height",preCard.getHeight());
                json.put("weight",preCard.getWeight());
                json.put("time", DateUtil.dateToStrLong(preCard.getCzrq()));
                json.put("height", preCard.getHeight());
                json.put("weight", preCard.getWeight());
                try {
                    healthIndexService.addPatientHealthIndex(json.toString(), "3", patientCode, null);
                }catch (Exception e){
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("预建卡时 保存体征数据失败。。。");
                }
@ -678,4 +717,188 @@ public class PrenatalInspectorPreCardService extends BaseService {
        }
    }
    /**
     * 根据待产检ID查询最近一条待产检计划状态
     *
     * @param prenatalId
     */
    public JSONObject getPrenatalStatus(Long prenatalId) throws Exception {
        JSONObject json = new JSONObject();
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            PrenatalInspectorPlan plan = prenatalInspectorPlanDao.findOne(prenatalId);
            Date planTime = plan.getInspectionTime();
            Boolean flag = getSendStatus(prenatalId);
            Long days = DateUtil.getDays(new Date(), planTime);
            if (days > 0) {
//                当前时间在应产检之后
                List<PrenatalInspectorPlan> plans = prenatalInspectorPlanDao.getScopeById(prenatalId);
                if (plans == null || plans.size() == 0) {
                    String str = "当前时间在应产检7天后";
                    if (days > 7) {
                        System.out.println("超期未检");
                        json.put("renatalStatus", "3");
                        json.put("sendStatus", flag == true ? "1" : "0");
                    }else {
                        PrenatalInspectorRecord record = recordDao.findByRelationAndType(prenatalId.toString(), 0);
                        if (record == null) {
                            System.out.println("未提醒");
                            json.put("renatalStatus", "1");
                            if (days < -7) {
                                json.put("reason", "未到提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
                            }
                        } else {
                            PrenatalInspectorRecord docRecord = recordDao.findByRelationAndType(prenatalId.toString(), 1);
                            System.out.println("已提醒");
                            json.put("renatalStatus", "2");
                            json.put("sendStatus", flag == true ? "1" : "0");
                            if (docRecord == null) {
                                json.put("sendTime", format.format(record.getSendTime()));
                            } else {
                                json.put("sendTime", format.format(docRecord.getSendTime()));
                            }
                        }
                    }
                } else {
                    System.out.println("已产检");
                    json.put("renatalStatus", "4");
                }
            } else {
                PrenatalInspectorRecord record = recordDao.findByRelationAndType(prenatalId.toString(), 0);
                if (record == null) {
                    System.out.println("未提醒");
                    json.put("renatalStatus", "1");
                    if (days < -7) {
                        json.put("reason", "未到提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
                    }
                } else {
                    PrenatalInspectorRecord docRecord = recordDao.findByRelationAndType(prenatalId.toString(), 1);
                    System.out.println("已提醒");
                    json.put("renatalStatus", "2");
                    json.put("sendStatus", flag == true ? "1" : "0");
                    if (docRecord == null) {
                        json.put("sendTime", format.format(record.getSendTime()));
                    } else {
                        json.put("sendTime", format.format(docRecord.getSendTime()));
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        json.put("prenatalId", prenatalId);
        return json;
    }
    /**
     * 提醒居民(每24小时可提醒一次)
     *
     * @param prenatalId
     * @param code       居民code
     * @param doc        医生code
     */
    public Boolean sendPrenatal(Long prenatalId, String code, String doc) throws Exception {
        Boolean flag = false;
        try {
            String relation = prenatalId.toString();
            Patient patient = patientDao.findByCode(code);
            String name = patient.getName();
            String openId = patient.getOpenid();
            String mobile = patient.getMobile();
            String first = name + ",您好!您和您的宝宝需要进行产检啦~请及时预约产检,如已预约,请忽略";
            String url = "wdyy/html/appointment-register.html?openid=" + openId + "&toUser=" + code + "&toName=" + name;
            PrenatalInspectorPlan plan = prenatalInspectorPlanDao.findOne(prenatalId);
            org.json.JSONObject json = new org.json.JSONObject();
            //产检提醒
            json.put("remark", "产检内容以医生实际检查为准。点击进行预约");
            json.put("first", first);
            json.put("url", url);
            json.put("keyword1", "产检提醒");
            String keyword2 = DateUtil.getStringDateShort() + "\n产检内容:" + plan.getCheckItem();
            json.put("keyword2", keyword2);
            if (StringUtils.isNotEmpty(openId) && !("undefined".equals(openId))) {
                pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 18, openId, name, json);
                flag = true;
            } else {
                //发送代理人
                org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(code, openId);
                if (jsonArray != null && jsonArray.length() > 0) {
                    for (int i = 0; i < jsonArray.length(); i++) {
                        org.json.JSONObject j = jsonArray.getJSONObject(i);
                        Patient member = (Patient) j.get("member");
                        org.json.JSONObject data = json;
                        data.remove("first");
                        data.remove("url");
                        data.put("url", url + "&represented=" + member.getCode());
                        data.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), name) + first);
                        if (StringUtils.isNotEmpty(member.getOpenid()) && !("undefined".equals(member.getOpenid()))) {
                            pushMsgTask.putWxMsg(accessTokenUtils.getAccessToken(), 18, member.getOpenid(), name, data);
                            flag = true;
                        }
                    }
                }
            }
            if (!flag && StringUtils.isNotEmpty(mobile)) {
//                发送短信消息
                org.json.JSONObject resultJson = smsService.sendMsg(mobile, ":张三,您好!您的家庭医生李四提醒你,您和您的宝宝需要进行产检啦~" +
                        " 您可微信搜索公众号:厦门i健康,关注公众号预约产检时间/查看孕检计划及历史检查记录,更可及时获取产检提醒哟~");
                if (resultJson != null && resultJson.getInt("result") == 0) {
                    flag = true;
                }
            }
            if (flag) {
                PrenatalInspectorRecord record = recordDao.findByRelationAndType(relation, 1);
                if (record == null) {
                    record = new PrenatalInspectorRecord();
                    record.setTimes(1);
                } else {
                    record.setTimes(record.getTimes() + 1);
                }
                record.setRelation(relation);
                record.setSender(doc);
                record.setReceiver(code);
                record.setType(1);
                record.setName(name);
                record.setOpenid(openId);
                record.setContent(plan.getCheckItem());
                record.setSendTime(new Date());
                recordDao.save(record);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
    /**
     * 查询该产检记录是否可提醒(是否过24小时)
     *
     * @param prenatalId
     * @return boolean 是否可提醒
     * @throws Exception true 可再次提醒 flase 不可提醒
     */
    public Boolean getSendStatus(Long prenatalId) throws Exception {
        Boolean flag = false;
        try {
            String relation = prenatalId.toString();
            PrenatalInspectorRecord record = recordDao.findByRelationAndType(relation, 1);
            if (record != null) {
                float hours = DateUtil.getHours(new Date(), record.getSendTime());
                if (hours > 24) {
                    flag = true;
                }
            } else {
                flag = true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
}

+ 165 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -24,12 +24,15 @@ import com.yihu.wlyy.service.app.message.MessageService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.CommonUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MessageType;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
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.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
@ -37,10 +40,7 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by chenweida on 2017/7/27.
@ -80,6 +80,12 @@ public class PrescriptionService extends BaseService {
    private FollowUpDao followUpDao;
    @Autowired
    private MessageService messageService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    //健康问题 高血压
    private static final String gxy = "HP0093";
    //健康问题 糖尿病
    private static final String tnb = "HP0047";
    /**
     *  获取处方信息
@ -390,4 +396,159 @@ public class PrescriptionService extends BaseService {
        }
        return statusObj;
    }
    /**
     * 长处方统计-点击柱状图获取详情
     * @param interval
     * @param date
     * @param disease
     * @param type
     * @return
     */
    public List<Map<String,Object>> getPrescriptionTotalDetailTime(int interval,String date,String disease,String type){
        //如果是日就是按一天,周就是从本周一到本周日,月就是本月第一天到本月最后一天
        String startTime = "";
        String endTime = "";
        if (interval==1){
            startTime = date+" 00:00:00";
            endTime = " 23:59:59";
        }else if (interval==2){
            startTime = DateUtil.getMondayOfThisDate(DateUtil.strToDate(date));
            endTime = DateUtil.getSundayOfThisDate(DateUtil.strToDate(date));
            startTime += " 00:00:00";
            endTime += "23:59:59";
        }else if (interval==3){
            startTime = DateUtil.getFristDayOfMonthThisDate(DateUtil.strToDate(date+"-01"));
            endTime = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(date+"-01"));
            startTime += " 00:00:00";
            endTime += " 23:59:59";
        }
        String sql = "SELECT * FROM wlyy_prescription p ";
        if(StringUtils.isNotBlank(disease)){
            sql += " JOIN wlyy_prescription_diagnosis d ON  d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            sql +=" WHERE 1=1 ";
        }
        if ("2".equals(type)){//已完成
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.finish.getValue() ;
        }else if ("3".equals(type)){//居民取消
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue() ;
        }else if ("4".equals(type)){//审核不通过
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue() ;
        }else if ("5".equals(type)){//进行中
            sql += " AND  p.`status` < " + PrescriptionLog.PrescriptionLogStatus.finish.getValue() +
                    " AND p.`status`>= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() ;
        }else if ("6".equals(type)){//其他原因取消
            sql += " AND p.`status` <= "+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue() ;
        }
        sql += " AND p.create_time <= ? " +
                " AND p.create_time >= ? ";
        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql,new Object[]{endTime,startTime});
        return resultList;
    }
    /**
     * 长处方统计--长处方记录筛选
     * @param level
     * @param area
     * @param disease
     * @param status
     * @param type
     * @param startTime
     * @param endTime
     * @return
     */
    public List<Map<String,Object>> getPrescriptionByCondition(String level, String area, String disease, String status, String type, String startTime,String endTime){
        String sql = "SELECT * FROM wlyy_prescription p ";
        //判断疾病
        if(StringUtils.isNotBlank(disease)){
            if ("1".equals(disease)){
                disease = gxy;
            }else if ("2".equals(disease)){
                disease = tnb;
            }
            sql += " JOIN wlyy_prescription_diagnosis d ON  d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            sql +=" WHERE 1=1 ";
        }
        //判断状态
        if ("2".equals(status)){//已完成
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.finish.getValue() ;
        }else if ("3".equals(status)){//居民取消
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue() ;
        }else if ("4".equals(status)){//审核不通过
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue() ;
        }else if ("5".equals(status)){//进行中
            sql += " AND  p.`status` < " + PrescriptionLog.PrescriptionLogStatus.finish.getValue() +
                    " AND p.`status`>= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() ;
        }else if ("6".equals(status)){//其他原因取消
            sql += " AND p.`status` <= "+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue() ;
        }
        //判断取药方式
        if (StringUtils.isNotBlank(type)){
            //类型1.自取,2.快递配送,3.健管师配送
            if("1".equals(type)){
                sql +=" AND p.dispensary_type ="+type;
            }else if("2".equals(type)){
                sql +=" AND p.dispensary_type ="+type;
            }else if("3".equals(type)){
                sql +=" AND p.dispensary_type ="+type;
            }
        }
        //市区
        if("4".equals(level)){
            //市区无过滤
            //区级
        }else if("3".equals(level)){
            sql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
            //机构
        }else if("2".equals(level)){
            sql += "AND p.hospital = '"+area+"' ";
        }
        List<Map<String,Object>> resultList = new ArrayList<>();
        if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){
            startTime += " 00:00:00";
            endTime += " 23:59:59";
            sql += " AND p.create_time <= ? " +
                    " AND p.create_time >= ? ";
            resultList = jdbcTemplate.queryForList(sql,new Object[]{endTime,startTime});
        }else{
            resultList = jdbcTemplate.queryForList(sql);
        }
        return resultList;
    }
    /**
     * 长处方统计--上方模糊搜索
     * @param keyWord
     * @return
     */
    public List<Map<String,Object>> getPrescriptionByKeyWord(String keyWord){
        String sql = "SELECT * FROM wlyy_prescription p where 1=1";
        //判断关键字
        if (StringUtils.isNotBlank(keyWord)){
            sql += " AND (p.patient_name like '%"+keyWord+"%' or p.doctor_name like '%"+keyWord+"%')";
        }
        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql);
        return resultList;
    }
    /**
     * 长处方统计--点击查看详情
     * @param code
     * @return
     */
    public Map<String,Object> getPrescriptionByCode(String code){
        Map<String,Object> rsMap = new HashedMap();
        String sql ="SELECT p.code,p.patient_name,p.doctor_name,p.hospital_name,p.dispensary_type,d.health_problem " +
                "FROM wlyy_prescription p LEFT JOIN wlyy_prescription_diagnosis d ON  d.prescription_code = p.code " +
                "WHERE p.code=? ";
        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql,new Object[]{code});
        if (resultList!=null && resultList.size()>0){
            rsMap = resultList.get(0);
        }
        return rsMap;
    }
}

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

@ -1886,10 +1886,11 @@ 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,p.photo," +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus " +
                "t.ssc,t.type signType,p.sex ,t.expenses_status expensesStatus,c.disease " +
                " FROM wlyy_sign_family t " +
                " LEFT JOIN wlyy_patient p ON t.patient = p.code " +
                " WHERE t.doctor ='" + doctor + "' AND t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 LIMIT " + page * pageSize + "," + pageSize);
                " LEFT JOIN (select patient,group_concat(label) disease,sum(label) lablesum from wlyy_sign_patient_label_info where label_type = 3 and status=1 GROUP BY patient) c on t.patient = c.patient " +
                " WHERE t.doctor ='" + doctor + "' AND t.admin_team_code =" + teamCode + " AND t.sign_year ='" + year + "' AND t.status =-4 order by p.standard_status DESC ,p.disease_condition DESC,c.lablesum DESC,p.openid DESC LIMIT " + page * pageSize + "," + pageSize);
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql.toString());
        JSONObject json = new JSONObject();
        json.put("result", rs);

+ 5 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -5142,12 +5142,13 @@ public class StatisticsService extends BaseService {
            startTime = DateUtil.dateToStr(startDate, "YYYY-MM-dd HH:mm:ss");
            endTime = DateUtil.dateToStr(endDate, "YYYY-MM-dd HH:mm:ss");
        }else if (interval==3){
            sql = "SELECT count(1) AS count,LEFT(p.create_time,7) AS month  FROM wlyy_prescription p ";
            sql = "SELECT count(1) AS count,LEFT(p.create_time,7) AS date  FROM wlyy_prescription p ";
            //String monthNumber = dd.get(Calendar.MONTH);
            for (int i = 1; i < 7; i++) {
                Map<String, Object> mc = new HashedMap();
                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
                String date = sdf2.format(dd.getTime());
                mc.put("month", date);
                mc.put("date", date);
                mc.put("count", 0.0D);
                dd.add(Calendar.MONTH, -1);
                rs.add(mc);
@ -5205,13 +5206,8 @@ public class StatisticsService extends BaseService {
            String keyDb = "";
            while (iterator.hasNext()){
                Map<String,Object> ml = ( Map<String,Object>)iterator.next();
                if (interval!=3){
                    key = (String)m.get("date");
                    keyDb = (String)ml.get("date");
                }else{
                    key = (String)m.get("month");
                    keyDb = (String)ml.get("month");
                }
                key = (String)m.get("date");
                keyDb = (String)ml.get("date");
                if(key.equals(keyDb)){
                    m.put("count",ml.get("count"));

+ 2 - 53
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -3962,7 +3962,7 @@ public class StatisticsESService {
                Map<String, Object> mc = new HashedMap();
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
                String date = sdf.format(dd.getTime());
                mc.put("month", date);
                mc.put("date", date);
                mc.put("count", 0.0D);
                dd.add(Calendar.MONTH, -1);
                rs.add(mc);
@ -3985,11 +3985,10 @@ public class StatisticsESService {
                if (saveModel.getQuotaDate() != null) {
                    String key = "";
                    String EsKey ="";
                    key=String.valueOf(m.get("date"));
                    if (interval != 3){
                        key=String.valueOf(m.get("date"));
                        EsKey = DateUtil.dateToStr(saveModel.getQuotaDate(),"yyyy-MM-dd");
                    }else {
                        key=String.valueOf(m.get("month"));
                        EsKey = DateUtil.changeQuotaDate(saveModel.getQuotaDate());
                    }
                    if (key.equals(EsKey)) {
@ -4777,56 +4776,6 @@ public class StatisticsESService {
        }
    }
    /**
     * 订单统计-点击柱状图获取详情
     * @param interval
     * @param date
     * @param disease
     * @param type
     * @return
     */
    public List<Map<String,Object>> getPrescriptionTotalDetailTime(int interval,String date,String disease,String type){
        //如果是日就是按一天,周就是从本周一到本周日,月就是本月第一天到本月最后一天
        String startTime = "";
        String endTime = "";
        if (interval==1){
            startTime = date+" 00:00:00";
            endTime = " 23:59:59";
        }else if (interval==2){
            startTime = DateUtil.getMondayOfThisDate(DateUtil.strToDate(date));
            endTime = DateUtil.getSundayOfThisDate(DateUtil.strToDate(date));
            startTime += " 00:00:00";
            endTime += "23:59:59";
        }else if (interval==3){
            startTime = DateUtil.getFristDayOfMonthThisDate(DateUtil.strToDate(date+"-01"));
            endTime = DateUtil.getLastDayOfMonthThisDate(DateUtil.strToDate(date+"-01"));
            startTime += " 00:00:00";
            endTime += " 23:59:59";
        }
        String sql = "SELECT * FROM wlyy_prescription p ";
        if(StringUtils.isNotBlank(disease)){
            sql += " JOIN wlyy_prescription_diagnosis d ON  d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            sql +=" WHERE 1=1 ";
        }
        if ("2".equals(type)){//已完成
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.finish.getValue() ;
        }else if ("3".equals(type)){//居民取消
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue() ;
        }else if ("4".equals(type)){//审核不通过
            sql += " AND p.`status` = "+PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue() ;
        }else if ("5".equals(type)){//进行中
            sql += " AND  p.`status` < " + PrescriptionLog.PrescriptionLogStatus.finish.getValue() +
                    " AND p.`status`>= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() ;
        }else if ("6".equals(type)){//其他原因取消
            sql += " AND p.`status` <= "+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue() ;
        }
        sql += " AND p.create_time <= ? " +
                " AND p.create_time >= ? ";
        List<Map<String,Object>> resultList = jdbcTemplate.queryForList(sql,new Object[]{endTime,startTime});
        return resultList;
    }
    /**
     * 长处方记录筛选
     * @param level

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

@ -12,6 +12,7 @@ import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.ServerLabelTree;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -30,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -1097,4 +1099,5 @@ public class PatientService extends TokenService {
        }
        return true;
    }
}

+ 106 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/ylz/ThirdEHCService.java

@ -0,0 +1,106 @@
package com.yihu.wlyy.service.third.ylz;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.ylz.PayLog;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.ylz.PayLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.procedure.spi.ParameterRegistrationImplementor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * Created by Reece on 2017/9/20.
 * 日志服务
 */
@Service
public class ThirdEHCService extends BaseService {
    private static Logger logger = LoggerFactory.getLogger(ThirdEHCService.class);
    @Autowired
    private PayLogDao payLogDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientDao patientDao;
    /**
     *公众号消息推送接口
     */
    public String pushMessage(JSONObject json) {
        String flag = "0000";
        try {
            logger.info("push message "+ json);
            org.json.JSONObject model = new org.json.JSONObject();
            String url = null;
            model.put("remark", "产检内容以医生实际检查为准。点击进行预约");
            model.put("first", "电子健康卡提醒");
            model.put("url",url);
            model.put("keyword1", "电子健康卡提醒");
            json.put("keyword2", "电子健康卡推送");
            String messageType = json.containsKey("message_type") ? json.getString("message_type") : null;
            JSONObject messageContent = json.containsKey("message_content") ? json.getJSONObject("message_content") : null;
            String idType = json.containsKey("id_type") ? json.getString("id_type") : null;
            String idNo = json.containsKey("id_no") ? json.getString("id_no") : null;
            String openId = json.containsKey("open_id") ? json.getString("open_id") : null;
            if (idNo == null && openId ==null) {
                return "0001";
            }
            if (idNo != null) {
                Patient patient = patientDao.findByIdcard(idNo);
                pushMsgTask.putAgentWxMsg(patient.getCode(), 18, model);
            }
            if (StringUtils.isNotEmpty(openId) && !"undefined".equals(openId)) {
                List<Patient> patients = patientDao.findPatientByOpenid(openId);
                for (Patient patient : patients) {
                    Patient patient1 = patientDao.findByCode(patient.getCode());
                    pushMsgTask.putAgentWxMsg(patient1.getCode(), 18, model);
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            flag = "1000";
        }
        return flag;
    }
    /**
     * 保存http调用日志  type 0家庭签约支付 1续方支付
     */
    public void saveHttpLog(Boolean isSuccess, String url, String content, String method, String header, String params, String response, String error, String type) {
        try {
            //新增日志
            PayLog log = new PayLog();
            log.setType(type);
            log.setApi(url);
            log.setContent(content);
            log.setMethod(method);
            log.setHeader(header);
            log.setParams(params);
            log.setCreateTime(new Date());
            log.setResponse(response);
            log.setError(error);
            log.setStatus(isSuccess ? "1" : "0");
            payLogDao.save(log);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -718,9 +718,9 @@ public class OnePayService {
                //保存到患者表
                Patient p = patientDao.findByCode(patient);
                if(!"undefined".equals(openid)&&StringUtils.isNotBlank(openid)){
                    p.setOpenid(openid);
                }
//                if(!"undefined".equals(openid)&&StringUtils.isNotBlank(openid)){
//                    p.setOpenid(openid);
//                }
//            增加绑定电子社保卡信息
                if (p.getSicardStatus()!=null && p.getSicardStatus()!=1){
                    p.setSicardTime(new Date());

+ 61 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -1,11 +1,15 @@
package com.yihu.wlyy.task;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatPushLog;
import com.yihu.wlyy.entity.wechat.WechatTemplate;
import com.yihu.wlyy.entity.wechat.WechatTemplateData;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatPushLogDao;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -69,6 +73,12 @@ public class PushMsgTask {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private WechatPushLogDao wechatPushLogDao;
    @Autowired
    private WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private PatientDao patientDao;
    /**
     * 添加一条推送消息
@ -110,12 +120,12 @@ public class PushMsgTask {
            json.put("name", name);
            json.put("data", data);
            //如果是内网推送到redis,如果是外网推送到内存队列
            if(putMesMethod.equals("1")){
            if (putMesMethod.equals("1")) {
                JSONObject mes = new JSONObject();
                mes.put("title",putMesType);
                mes.put("value",json.toString());
                redisTemplate.opsForList().leftPush(redisQueue,mes.toString());
            }else{
                mes.put("title", putMesType);
                mes.put("value", json.toString());
                redisTemplate.opsForList().leftPush(redisQueue, mes.toString());
            } else {
                queue.put(json);
            }
@ -249,7 +259,7 @@ public class PushMsgTask {
                log.setCreateTime(new Date());
                log.setName(name);
                log.setOpenid(openid);
                if(!json.isNull("toUser")){
                if (!json.isNull("toUser")) {
                    log.setPatient(json.getString("toUser"));
                }
                log.setRequest(json.toString());
@ -495,7 +505,7 @@ public class PushMsgTask {
            } else if (type == 10) {
                if (json.has("url")) {
                    temp.setUrl(url + json.getString("url"));
                }else {
                } else {
                    temp.setUrl(url + "qygl/html/signing-doctors.html?openid=" + openid + "&state=" + openid + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                }
                temp.setTemplate_id(template_doctor_change);
@ -672,4 +682,48 @@ public class PushMsgTask {
        }
    }
    /**
     * 添加含发送代理人微信消息
     *
     * @param code 居民code
     * @param type 模板类型
     * @param json 模板消息体加上跳转URL
     * @return
     */
    public Boolean putAgentWxMsg(String code, int type, JSONObject json) {
        Boolean flag = false;
        try {
            String url = json.has("url") ? json.getString("url") : null;
            String first = json.has("first") ? json.getString("first") : "";
            Patient patient = patientDao.findByCode(code);
            String name = patient.getName();
            String openId = patient.getOpenid();
            if (StringUtils.isNotEmpty(openId) && !("undefined".equals(openId))) {
                putWxMsg(accessTokenUtils.getAccessToken(), type, openId, name, json);
                flag = true;
            } else {
                //发送代理人
                org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(code, openId);
                if (jsonArray != null && jsonArray.length() > 0) {
                    for (int i = 0; i < jsonArray.length(); i++) {
                        org.json.JSONObject j = jsonArray.getJSONObject(i);
                        Patient member = (Patient) j.get("member");
                        org.json.JSONObject data = json;
                        data.remove("first");
                        data.remove("url");
                        data.put("url", url + "&represented=" + member.getCode());
                        data.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), name) + first);
                        if (StringUtils.isNotEmpty(member.getOpenid()) && !("undefined".equals(member.getOpenid()))) {
                            putWxMsg(accessTokenUtils.getAccessToken(), type, member.getOpenid(), name, data);
                            flag = true;
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return flag;
    }
}

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

@ -3,6 +3,7 @@ package com.yihu.wlyy.util;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
@ -367,6 +368,23 @@ public class DateUtil {
		return mydate1;
	}
	/**
	 * 时间前推或后推天数(负数前推正数后推)
	 * date 基准时间
	 */
	public static Date getPreDays(Date date, int days) {
		Date day = null;
		try {
			Calendar c = Calendar.getInstance();
			c.setTime(date);
			c.add(Calendar.DATE, days);
			day = c.getTime();
		} catch (Exception e) {
		}
		return day;
	}
	/**
	 * 得到一个时间延后或前移几分钟的时间,nowdate为时间,delay为前移或后延的分钟数
	 */
@ -660,6 +678,21 @@ public class DateUtil {
		return day;
	}
	/**
	 * 返回两个日期相差的小时数(保留2位小数)
	 * @param date1
	 * @param date2
	 * @return
	 */
	public static float getHours(Date date1, Date date2) {
		if (date1 == null || date2 == null)
			return 0;
		float hours = (date1.getTime() - date2.getTime()) / (float)(60 * 60 * 1000);
		BigDecimal decimal = new BigDecimal(hours);
		float hour = decimal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
		return hour;
	}
	/**
	 * 形成如下的日历 , 根据传入的一个时间返回一个结构 星期日 星期一 星期二 星期三 星期四 星期五 星期六 下面是当月的各个时间
	 * 此函数返回该日历第一行星期日所在的日期

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultMoviController.java

@ -148,7 +148,7 @@ public class DoctorConsultMoviController extends BaseController {
	/**
	 * 结束视频咨询
	 * @param consult 咨询标识
	 * @param movi_finish 咨询标识
	 * @return
	 */
	@ApiOperation("结束视频咨询")

+ 23 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/DoctorPatientGroupController.java

@ -7,6 +7,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
@ -605,7 +606,9 @@ public class DoctorPatientGroupController extends BaseController {
    @ApiOperation("患者信息查询接口")
    public String patient(String code, String jyStatus) {
        try {
            Patient temp = patientInfoService.findByCode(code);
        
//            Patient temp = patientInfoService.findByCode(code);
            PatientVO temp = patientInfoService.getPatientVOByCode(code);
            if (temp != null) {
                JSONObject json = new JSONObject();
                // 设置患者标识
@ -620,9 +623,9 @@ public class DoctorPatientGroupController extends BaseController {
                json.put("sex", temp.getSex());
                // 设置患者病情:0绿标,1黄标,2红标
                json.put("diseaseLevel", temp.getDiseaseCondition());
                // 疾病类型名称,0健康,1高血压,2糖尿病,3高血压+糖尿病
                // 疾病类型名称,0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
                json.put("diseaseName", getDiseaseName(temp.getDisease()));
                // 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
                // 疾病类型,0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
                json.put("disease", temp.getDisease());
                // 设置患者身份证号
                json.put("idCard", temp.getIdcard());
@ -692,6 +695,15 @@ public class DoctorPatientGroupController extends BaseController {
                } else {
                    json.put("ssSign", "");
                }
    
                //病情类型:0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
                json.put("disease",temp.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition",temp.getDiseaseCondition());
                //预警状态
                json.put("standardStatus",temp.getStandardStatus());
                //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                json.put("deviceType",temp.getDeviceType());
                return write(200, "患者信息查询成功!", "data", json);
            } else {
@ -1131,21 +1143,23 @@ public class DoctorPatientGroupController extends BaseController {
    }
    /**
     * 根据patient表的disease字段转换成相应的疾病类型 疾病类型,0健康,1高血压,2糖尿病,3高血压+糖尿病
     * 根据patient表的disease字段转换成相应的疾病类型 疾病类型,0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
     *
     * @return string
     */
    private String getDiseaseName(Integer disease) {
    private String getDiseaseName(String disease) {
        if (disease != null) {
            switch (disease) {
                case 0:
                case "0":
                    return "健康";
                case 1:
                case "1":
                    return "高血压";
                case 2:
                case "2":
                    return "糖尿病";
                case 3:
                case "1,2":
                    return "高血压+糖尿病";
                case "2,1":
                    return "高血压+糖尿病";
                default:

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SocialSecurityInfo;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
@ -71,7 +72,8 @@ public class PatientInfoController extends BaseController {
    public String getPatient(String patient) {
        try {
            // 获取医生下的患者
            Patient temp = patientInfoService.findByCode(patient);
//            Patient temp = patientInfoService.findByCode(patient);
            PatientVO temp = patientInfoService.getPatientVOByCode(patient);
            return write(200, "获取患者信息成功!", "data", temp);
        } catch (Exception e) {
            error(e);

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

@ -72,4 +72,49 @@ public class PrenatalController extends BaseController{
        }
    }
    /**
     * 根据待产检ID查询最近一条待产检计划状态
     * @param prenatalId
     * @return 1未提醒 2已提醒 3超期未检 4已产检
     */
    @ApiOperation("获取产检计划状态")
    @RequestMapping(value = "/getPrenatalStatus", method = RequestMethod.GET)
    public String getPrenatalStatus(@ApiParam(name = "prenatalId", value = "产检号", defaultValue = "")
                                             @RequestParam(value = "prenatalId", required = true) Long prenatalId){
        try {
            JSONObject response = preCardService.getPrenatalStatus(prenatalId);
            return write(200, "查询成功!", "data", response);
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
    /**
     * 提醒居民(每24小时可提醒一次)
     * @param prenatalId
     * @param patient
     * @return
     */
    @ObserverRequired
    @ApiOperation("提醒居民")
    @RequestMapping(value = "/sendPrenatal", method = RequestMethod.POST)
    public String sendPrenatal(@ApiParam(name = "prenatalId", value = "产检号", defaultValue = "")
                                    @RequestParam(value = "prenatalId", required = true) Long prenatalId,
                                    @ApiParam(name = "patient", value = "提醒居民", defaultValue = "")
                                    @RequestParam(value = "patient", required = true) String patient,
                                    @ApiParam(name = "doctor", value = "医生", defaultValue = "")
                                    @RequestParam(value = "doctor", required = true) String doctor){
        try {
            Boolean response = preCardService.sendPrenatal(prenatalId,patient,doctor);
            if (response){
                return write(200, "提醒成功!");
            }
            return error(-1,"提醒失败");
        }catch (Exception e){
            error(e);
            return error(-1,"提醒失败");
        }
    }
}

+ 102 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -17,13 +17,17 @@ import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.util.DateUtil;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.jmx.DataEndpointMBean;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
@ -616,4 +620,102 @@ public class PrescriptionInfoController extends BaseController {
        }
    }
    /**
     *长处方统计-点击柱状图获取详情
     * @Author zhangdan
     * @param interval
     * @param date
     * @param disease
     * @param type
     * @return
     */
    @RequestMapping(value = "/getPrescriptionTotalDetailTime", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("长处方统计-点击柱状图获取详情")
    public String getPrescriptionTotalDetailTime(
            @RequestParam(required = true)int interval,
            @RequestParam(required = true)String date,
            @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease,
            @ApiParam(name="type", value="类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消") @RequestParam(required = true)String type){
        try{
            return write(200, "查询成功", "data", prescriptionService.getPrescriptionTotalDetailTime(interval,date,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 长处方统计--长处方记录筛选
     * @Author zhangdan
     * @param level 地区级别
     * @param area 地区编号
     * @param disease 疾病 高血压1 糖尿病2
     * @param status 状态 1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消(没有选择的情况传1)
     * @param type 取药方式 1.自取,2快递配送,3健管师配送
     * @param startTime 开始日期
     * @param endTime 结束日期
     * @return
     */
    @RequestMapping(value = "/getPrescriptionByCondition", method = RequestMethod.GET)
    @ResponseBody
    public String getPrescriptionByCondition(
            @RequestParam(required = true)String level,
            @RequestParam(required = true)String area,
            @RequestParam(required = false)String disease,
            @RequestParam(required = false,defaultValue = "1")String status,
            @RequestParam(required = false)String type,
            @RequestParam(required = false)String startTime,
            @RequestParam(required = false)String endTime){
        try{
            if (StringUtils.isNotBlank(startTime)){
                if (StringUtils.isNotBlank(endTime)){
                    Date startDate = DateUtil.strToDate(startTime,"yyyy-MM-dd");
                    Date endDate = DateUtil.strToDate(endTime,"yyyy-MM-dd");
                    if (startDate.after(endDate)){
                        return  error(-2,"参数错误");
                    }
                }
            }
            return write(200, "查询成功", "data", prescriptionService.getPrescriptionByCondition(level,area,disease,status,type,startTime,endTime));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 长处方统计--上方模糊搜索
     * @Author zhangdan
     * @param keyWord 模糊搜索关键字
     * @return
     */
    @RequestMapping(value = "/getPrescriptionByKeyWord", method = RequestMethod.GET)
    @ResponseBody
    public String getPrescriptionByKeyWord(
            @RequestParam(required = true)String keyWord){
        try{
            return write(200, "查询成功", "data", prescriptionService.getPrescriptionByKeyWord(keyWord));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 长处方统计--点击查看详情
     * @param code
     * @return
     */
    @RequestMapping(value = "/getPrescriptionByCode", method = RequestMethod.GET)
    @ResponseBody
    public String getPrescriptionByCode(@RequestParam(required = true)String code){
        try{
            return write(200, "查询成功", "data", prescriptionService.getPrescriptionByCode(code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}

+ 2 - 60
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -1737,7 +1737,7 @@ public class EsStatisticsController extends BaseController {
                                                @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                                @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease,
                                                @ApiParam(name="type", value="类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消") @RequestParam(required = true)String type,
                                                @ApiParam(name="interval",value ="时间类型:1日2周3月")@RequestParam(required = false,defaultValue = "1")int interval){
                                                @ApiParam(name="interval",value ="时间类型:1日2周3月")@RequestParam(required = true)int interval){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionTotalHistogram(level,area,disease,type,interval));
@ -1842,7 +1842,7 @@ public class EsStatisticsController extends BaseController {
                                                      @ApiParam(name="area", value="级别编码") @RequestParam(required = true)String area,
                                                      @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease,
                                                      @ApiParam(name="type", value="1.自取,2.快递配送,3.健管师配送") @RequestParam(required = true)String type,
                                                      @ApiParam(name="interval",value ="时间类型:1日2周3月")@RequestParam(required = false,defaultValue = "1")int interval){
                                                      @ApiParam(name="interval",value ="时间类型:1日2周3月")@RequestParam(required = true)int interval){
        try{
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionDispatchingHistogram(elasticsearchUtil.changeLevel(Integer.valueOf(level)),area,disease,type,interval));
        } catch (Exception e) {
@ -2064,63 +2064,5 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     *订单统计-点击柱状图获取详情
     * @param interval
     * @param date
     * @param disease
     * @param type
     * @return
     */
    @RequestMapping("/getPrescriptionTotalDetailTime")
    @ResponseBody
    @ApiOperation("订单统计-点击柱状图获取详情")
    public String getPrescriptionTotalDetailTime(
            @RequestParam(required = true)int interval,
            @RequestParam(required = true)String date,
            @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease,
            @ApiParam(name="type", value="类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消") @RequestParam(required = true)String type){
        try{
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionTotalDetailTime(interval,date,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 长处方记录筛选
     * @param level 地区级别
     * @param area 地区编号
     * @param disease 疾病
     * @param status 状态 1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消(没有选择的情况传1)
     * @param type 取药方式 1.自取,2快递配送,3健管师配送
     * @param startTime 开始日期
     * @param endTime 结束日期
     * @return
     */
    @RequestMapping("/getPrescriptionByCondition")
    @ResponseBody
    public String getPrescriptionByCondition(
            @RequestParam(required = false)String keyWord,
            @RequestParam(required = true)String level,
            @RequestParam(required = true)String area,
            @RequestParam(required = false)String disease,
            @RequestParam(required = false,defaultValue = "1")String status,
            @RequestParam(required = false)String type,
            @RequestParam(required = false)String startTime,
            @RequestParam(required = false)String endTime){
        try{
            if (StringUtils.isNotBlank(startTime)){
            }
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionByCondition(keyWord,level,area,disease,status,type,startTime,endTime));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /*==================================版本1.4.1统计优化结束 end=====================================*/
}

+ 49 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdEHCController.java

@ -0,0 +1,49 @@
package com.yihu.wlyy.web.third.ylzpay;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.service.app.health.HealthEduArticleService;
import com.yihu.wlyy.service.third.ylz.ThirdEHCService;
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.web.bind.annotation.*;
/**
 * 提供给易联众电子健康卡功能
 * Created by Reece on 2017/12/7
 *
 */
@RestController
@RequestMapping("/wlyygc/ehc/")
@Api(description = "易联众电子健康卡")
public class ThirdEHCController extends BaseController {
	
	@Autowired
	private ThirdEHCService thirdEHCService;
	/**
	 *公众号消息推送接口
	 * @param data
	 * @return
	 */
	@ApiOperation("公众号推送接口")
	@RequestMapping(value = "/pushMessage",method = RequestMethod.POST)
	@ResponseBody
	public JSON pushMessage(@ApiParam(name="data",value="推送json串",defaultValue = "{\"message_type\":\"01\",\"message_content\":{\"content\":\"尊敬的用户,您已成功在中山医院注册居民电子健康卡,请点击领取使用。\"},\"id_type\":\"01\",\"id_no\":\"350322199008207716\",\"open_id\":\"14552525252\"}")
								@RequestParam(value="data",required = true) String data) {
		JSONObject response = new JSONObject();
		try {
			String res = thirdEHCService.pushMessage(JSON.parseObject(data));
			response.put("ret_code",res);
			response.put("ret_msg","操作成功");
		} catch (Exception ex) {
			error(ex);
			response.put("ret_code","0001");
			response.put("ret_msg","操作失败");
		}
		return response;
	}
}

+ 6 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -100,10 +100,10 @@ public class OnePayController extends WeixinBaseController {
            JSONObject json = new JSONObject();
            String msg = null;
            String uid = getUID();
            String openid = getOpenid();
            String repUid = getRepUID();
            Patient people = patientDao.findByCode(uid);
            String openid = people.getOpenid();
            String ssc = people.getSsc();
            String createType = "sicard";
            if (!repUid.equals(uid)) {
@ -111,6 +111,11 @@ public class OnePayController extends WeixinBaseController {
                people = patientDao.findByCode(repUid);
                ssc = people.getSsc();
            }
            if("undefined".equals(openid)||StringUtils.isEmpty(openid)){
                people.setOpenid(null);
                patientDao.save(people);
                return write(-1, "用户微信信息格式不正确!");
            }
//            BindCard bindCard = pay.bindCard(patient, openid);
            List<BindCard> bindCard = pay.bindCardList(openid);