Переглянути джерело

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

huangwenjie 7 роки тому
батько
коміт
6ec7484cac
18 змінених файлів з 414 додано та 118 видалено
  1. 1 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/util/DateUtil.java
  2. 101 0
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/controller/DeviceController.java
  3. 127 58
      patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java
  4. 4 30
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  5. 4 3
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java
  6. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  7. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/manage/UserDao.java
  8. 7 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PrenatalInspectorPlanDao.java
  9. 10 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  10. 22 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/PrenatalInspectorPreCardService.java
  11. 6 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java
  12. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java
  13. 13 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  14. 9 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java
  15. 3 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  16. 100 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java
  17. 4 2
      patient-co/patient-co-wlyy/src/main/resources/system.properties
  18. BIN
      patient-co/patient-co-wlyy/src/main/webapp/images/wifi.png

+ 1 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/util/DateUtil.java

@ -44,6 +44,7 @@ public class DateUtil {
    public final static String DEFAULT_YMDHMSDATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
    public static final String DEFAULT_NOW_STRING_FORMAT = "yyyyMMddHHmmssSSS";
    public static final String yyyyMMddHHmmss = "yyyyMMddHHmmss";
    public static final String DATE_MDY_FORMAT = "MMddyyyy";
    public static final String DATE_MY_FORMAT = "MMyyyy";
    public static final String DATE_WORLD_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";

+ 101 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/controller/DeviceController.java

@ -7,6 +7,7 @@ import com.yihu.hos.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -64,6 +65,106 @@ public class DeviceController {
        }
    }
    /**
     * imei=865328025053108&tel=15911017043&iccid=10011003100403120073&imsi=012345678901234&user=1&sys=125&dia=85&pul=65&ano=0&time="2017-11-30/15:20:12"
     * @param imei
     * @param tel
     * @param iccid
     * @param imsi
     * @param user
     * @param sys
     * @param dia
     * @param pul
     * @param ano
     * @param time
     * @return
     */
    @ApiOperation("三诺血压设备数据上传接口(标准协议)")
    @RequestMapping(value = "/threeNodUploadXY", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public Result threeNodUploadXY(@ApiParam(value="设备号",defaultValue = "865328025053108")
                                    @RequestParam(value = "imei", required = true) String imei,
                                    @ApiParam(value="电话",defaultValue = "15911017043")
                                    @RequestParam(value = "tel", required = false) String tel,
                                    @ApiParam(value="iccid",defaultValue = "10011003100403120073")
                                    @RequestParam(value = "iccid", required = false) String iccid,
                                    @ApiParam(value="imsi",defaultValue = "012345678901234")
                                    @RequestParam(value = "imsi", required = false) String imsi,
                                    @ApiParam(value="用户 1爸爸 2妈妈",defaultValue = "1")
                                    @RequestParam(value = "user", required = true) String user,
                                    @ApiParam(value="高压",defaultValue = "125")
                                    @RequestParam(value = "sys", required = true) String sys,
                                    @ApiParam(value="低压",defaultValue = "85")
                                    @RequestParam(value = "dia", required = true) String dia,
                                    @ApiParam(value="心跳次数/分钟",defaultValue = "65")
                                    @RequestParam(value = "pul", required = false) String pul,
                                    @ApiParam(value="心率 齐0 不齐1",defaultValue = "0")
                                    @RequestParam(value = "ano", required = false) String ano,
                                    @ApiParam(value="时间",defaultValue = "2017-11-30/15:20:12")
                                    @RequestParam(value = "time", required = true) String time){
        try{
            JSONObject json = new JSONObject();
            json.put("imei",imei);
            json.put("tel",tel);
            json.put("iccid",iccid);
            json.put("imsi",imsi);
            json.put("user",user);
            json.put("sys",sys);
            json.put("dia",dia);
            json.put("pul",pul);
            json.put("ano",ano);
            json.put("time",time);
            return deviceService.threeNodeUpload("2",json);
        }
        catch (Exception ex)
        {
            return Result.error("Device data incoming failure!"+ex.getMessage());
        }
    }
    /**
     * act=bloodGlu&devid=1234123&bloodGlu=4.9&bgState=2&testTime=20171116091015&tempTur=23.4&codeNum=019
     * @param act
     * @param devid
     * @param bloodGlu
     * @param bgState
     * @param testTime
     * @param tempTur
     * @param codenum
     * @return
     */
    @ApiOperation("三诺血糖设备数据上传接口(标准协议)")
    @RequestMapping(value = "/threeNodUploadXT", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public Result threeNodUploadXT(@ApiParam(value="标识为血糖数据",defaultValue = "bloodGlu")
                                    @RequestParam(value = "act", required = false) String act ,
                                    @ApiParam(value="设备id",defaultValue = "1234123")
                                    @RequestParam(value = "devid", required = true) String devid ,
                                    @ApiParam(value="血糖值",defaultValue = "4.9")
                                    @RequestParam(value = "bloodGlu", required = true) String bloodGlu ,
                                    @ApiParam(value="1饭后,2饭前",defaultValue = "2")
                                    @RequestParam(value = "bgState", required = false) String bgState ,
                                    @ApiParam(value="测量时间",defaultValue = "20171116091015")
                                    @RequestParam(value = "testTime", required = true) String testTime ,
                                    @ApiParam(value="温度值",defaultValue = "23.4")
                                    @RequestParam(value = "tempTur", required = false) String tempTur ,
                                    @ApiParam(value="codenum",defaultValue = "019")
                                    @RequestParam(value = "codenum", required = false) String codenum){
        try{
            JSONObject json = new JSONObject();
            json.put("act",act);
            json.put("devid",devid);
            json.put("bloodGlu",bloodGlu);
            json.put("bgState",bgState);
            json.put("testTime",testTime);
            json.put("tempTur",tempTur);
            json.put("codenum",codenum);
            return deviceService.threeNodeUpload("1",json);
        }
        catch (Exception ex)
        {
            return Result.error("Device data incoming failure!"+ex.getMessage());
        }
    }
    @ApiOperation("设备数据查询接口")
    @RequestMapping(value = "/data", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public Result getData(

+ 127 - 58
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -337,6 +337,67 @@ public class DeviceService {
        return response.getBody();
    }
    /**
     * 三诺设备数据上传
     * @param type //设备类型2:血压 1:血糖
     * @param json
     * @return
     */
    public Result threeNodeUpload(String type,JSONObject json){
        try {
            String deviceSn = "";//设备唯一码
            String data = "";//体征值(血糖:data=血糖值   血压:data=收缩压,舒张压,脉搏)
            String uploadTime = "";//体征上传时间yyyy-MM-dd HH:mm:ss
            String userType = "";//按键号 即 userType
            if ("1".equals(type)) {
                userType = "-1";
                deviceSn = json.getString("devid");//设备唯一码
                data = json.getString("bloodGlu");//体征值(血糖:data=血糖值   血压:data=收缩压,舒张压,脉搏)
                uploadTime = json.getString("testTime");//体征上传时间yyyy-MM-dd HH:mm:ss
                uploadTime = DateUtil.formatDate(DateUtil.formatCharDateYMD(uploadTime,DateUtil.yyyyMMddHHmmss),DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
            }else {
                userType = json.getString("user");
                deviceSn = json.getString("imei");//设备唯一码
                data = json.getString("sys")+","+json.getString("dia");//体征值(血糖:data=血糖值   血压:data=收缩压,舒张压,脉搏)
                if(json.get("pul")==null){
                    data += ","+json.getString("pul");
                }
                if(json.get("ano")==null){
                    data += ","+json.getString("ano");
                }
                uploadTime = json.getString("time").replace("/"," ");//体征上传时间yyyy-MM-dd HH:mm:ss
            }
            PatientHealthIndex result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json);
            if (result == null) {
                throw new Exception("This device is not relate patient!");
            } else {
                //患者信息
                String patientCode = result.getUser();
                Patient patient = patientDao.findByCode(patientCode);
                //血糖、血压数据需校验,如果超标,需要发送消息给医生
                verifyHealthIndex(result);
                //发送华三demo推送
                //判断是否有未结束的续方咨询,发送消息给对应的医生----huangwenjie--2017.11.06
                sendPrescriptionHealthIndexMsgresult(result,patient);
                //指标数据上传基卫
                uploadHealthIndex(result);
                System.out.println(result);
                yujing(patientCode,patient);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return Result.success("Device data incoming success");
    }
    /**
     * 福州设备数据上传接口(标准协议)
     *
@ -382,19 +443,14 @@ public class DeviceService {
                userType = "-1";
            }
            PatientHealthIndex result = savePatientDeviceData(deviceSn, type, data, uploadTime, manufacturerCode, manufacturerName, unit, sendTime, userType, json);
            PatientHealthIndex result = savePatientDeviceData(deviceSn, type, data, uploadTime, userType, json);
            if (result == null) {
                throw new Exception("This device is not relate patient!");
            } else {
	
	            //患者信息
	            String patientCode = result.getUser();
	            Patient patient = patientDao.findByCode(patientCode);
	
	            String patientsql = "select group_concat(label) disease from wlyy.wlyy_sign_patient_label_info where label_type = 3 and status=1 and (label = 1 or label = 2) and patient = '"+patient.getCode()+"' GROUP BY patient";
	
	            String patientdisease = jdbcTemplate.queryForObject(patientsql,String.class);
	
	            //血糖、血压数据需校验,如果超标,需要发送消息给医生
	            if (1 == deviceType || 2 == deviceType) {
		            verifyHealthIndex(result);
@ -410,79 +466,92 @@ public class DeviceService {
                System.out.println(result);
                yujing(patientCode,patient);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
                //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
        return Result.success("Device data incoming success");
    }
                int bloodPressureBbnormalCount = 0;//血压异常次数
                int bloodSuggurBbnormalCount = 0;//血糖异常次数
    /**
     * 预警
     * @param patientCode
     * @param patient
     */
    public void yujing(String patientCode,Patient patient){
        try{
            String patientsql = "select group_concat(label) disease from wlyy.wlyy_sign_patient_label_info where label_type = 3 and status=1 and (label = 1 or label = 2) and patient = '"+patient.getCode()+"' GROUP BY patient";
                List<PatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
                List<PatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
            String patientdisease = jdbcTemplate.queryForObject(patientsql,String.class);
                bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
                bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
            //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
                for (PatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
                    if(index1.getStatus() != null && 1 == index1.getStatus()){
                        bloodPressureBbnormalCount++;
                    }
                }
            int bloodPressureBbnormalCount = 0;//血压异常次数
            int bloodSuggurBbnormalCount = 0;//血糖异常次数
                for (PatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
                    if(index2.getStatus() != null && 1 == index2.getStatus()){
                        bloodSuggurBbnormalCount++;
                    }
                }
            List<PatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
            List<PatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
            bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
            bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
                //连续3次异常,修改用户为预警状态
                if( (bloodPressureBbnormalCount >=3 || bloodSuggurBbnormalCount >=3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())){
            for (PatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
                if(index1.getStatus() != null && 1 == index1.getStatus()){
                    bloodPressureBbnormalCount++;
                }
            }
            for (PatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
                if(index2.getStatus() != null && 1 == index2.getStatus()){
                    bloodSuggurBbnormalCount++;
                }
            }
            //连续3次异常,修改用户为预警状态
            if( (bloodPressureBbnormalCount >=3 || bloodSuggurBbnormalCount >=3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())){
                patient.setStandardStatus(1);
            }else{
                Date end = new Date();
                Date start = DateUtil.setDateTime(end,-7);
                //计算血糖或者血压一周内的异常记录数量
                int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
                if(errorCount >= 5){//超过5次,记为预警状态
                    patient.setStandardStatus(1);
                }else{
                    Date end = new Date();
                    Date start = DateUtil.setDateTime(end,-7);
                    //计算血糖或者血压一周内的异常记录数量
                    int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
                    if(errorCount >= 5){//超过5次,记为预警状态
                        patient.setStandardStatus(1);
                    }
                }
    
                //连续5次正常,修改用户为非预警状态
                if(StringUtils.isNotBlank(patientdisease)){
                    if("1".equals(patientdisease)){
                        if(0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
                    }else if("2".equals(patientdisease)){
                        if(0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
                    }else if( "1,2".equals(patientdisease) || "2,1".equals(patientdisease)){
                        if( 0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
            }
            //连续5次正常,修改用户为非预警状态
            if(StringUtils.isNotBlank(patientdisease)){
                if("1".equals(patientdisease)){
                    if(0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                    }
                }else if("2".equals(patientdisease)){
                    if(0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                    }
                }else if( "1,2".equals(patientdisease) || "2,1".equals(patientdisease)){
                    if( 0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                        patient.setStandardStatus(0);
                    }
                }else{
                    patient.setStandardStatus(0);
                }
                patientDao.save(patient);
                //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
            }else{
                patient.setStandardStatus(0);
            }
        } catch (Exception e) {
            patientDao.save(patient);
            //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.success("Device data incoming success");
    }
    
    /**
     * 保存设备数据
     */
    public PatientHealthIndex savePatientDeviceData(String deviceSn, String type, String data, String uploadTime, String manufacturerCode
            , String manufacturerName, String unit, String sendTime, String userType, JSONObject json) throws Exception {
    public PatientHealthIndex savePatientDeviceData(String deviceSn, String type, String data, String uploadTime, String userType, JSONObject json) throws Exception {
        Date currentTime = DateUtil.getSysDateTime();
        Date time = currentTime;
        if (!StringUtil.isEmpty(uploadTime)) {

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

@ -22,6 +22,8 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -58,6 +60,8 @@ public class PrenatalInspectorPreCardService extends BaseService {
    @Autowired
    private JwMaternalChildService jwMaternalChildService;
    Logger logger = LoggerFactory.getLogger(PrenatalInspectorPreCardService.class);
    /**
     * 产检提醒(1预约提醒,2就诊提醒)
@ -124,36 +128,6 @@ public class PrenatalInspectorPreCardService extends BaseService {
    }
    /**
     * 向医生发出产检系统消息
     */
    public void sendMessagePrenatalBak() 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,code, content);
                    }
                    if (StringUtils.isNotEmpty(doctorHealth)) {
                        saveMessageRecord(plan.getId().toString(), doctorHealth,code, content);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 向医生发出产检系统消息

+ 4 - 3
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -603,11 +603,12 @@ public class DateUtil {
	 */
	public static int getDutyDays(Date startDate, Date endDate) {
		int result = 0;
		while (startDate.compareTo(endDate) <= 0) {
			if (startDate.getDay() != 6 && startDate.getDay() != 0) {
        Date  startTime = new Date(startDate.getTime());
		while (startTime.compareTo(endDate) <= 0) {
			if (startTime.getDay() != 6 && startTime.getDay() != 0) {
				result++;
			}
			startDate.setDate(startDate.getDate() + 1);
            startTime.setDate(startTime.getDate() + 1);
		}
		return result;
	}

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

@ -176,6 +176,7 @@ public class SwaggerConfig {
                        regex("/nofilter/.*"),
                        regex("/idc10/.*"),
                        regex("/im_new/.*"),
                        regex("/dataHandling/.*"),
                        regex("/version/.*"),
                        regex("/express/.*"),
                        regex("/doctorFeedback/.*"),

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

@ -9,7 +9,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/12/26.
 */
public interface UserDao  extends PagingAndSortingRepository<User, Integer>,JpaSpecificationExecutor<User> {
public interface UserDao  extends PagingAndSortingRepository<User, Long>,JpaSpecificationExecutor<User> {
    @Query("from User where code=?1")
    User findByCode(String code);
}

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

@ -22,11 +22,17 @@ public interface PrenatalInspectorPlanDao extends PagingAndSortingRepository<Pre
    List<PrenatalInspectorPlan> findByPatient(String patient);
    //查询当前时间14天前之后所有产检计划中距当前时间最近的记录
    @Query(value = "SELECT a.id,a.inspection_time FROM wlyy_prenatal_inspector_plan a WHERE a.patient = ?1 " +
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a WHERE a.patient = ?1 " +
            " AND a. STATUS = '0' AND a.del = '1' AND a.inspection_time >= DATE_ADD(CURDATE(),INTERVAL -14 DAY) " +
            " ORDER BY ABS(DATEDIFF(NOW(),inspection_time)) ASC LIMIT 0,1 ",nativeQuery = true)
    PrenatalInspectorPlan findByPatientlateliest(String patient);
    //查询当前时间14天前之前所有产检计划中距当前时间最近的记录
    @Query(value = "SELECT a.* FROM wlyy_prenatal_inspector_plan a WHERE a.patient = ?1 " +
            " AND a. STATUS = '0' AND a.del = '1' AND a.inspection_time < DATE_ADD(CURDATE(), INTERVAL - 14 DAY) " +
            " ORDER BY ABS( DATEDIFF(NOW(), inspection_time) ) ASC LIMIT 0,1 ",nativeQuery = true)
    PrenatalInspectorPlan findByPatientBeforeList(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) " +

+ 10 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -1551,7 +1551,13 @@ public class DoctorInfoService extends BaseService {
    }
    public List<Map<String,Object>>  getDoctorManagerRole(String code) {
    /**
     *
     * @param code 医生code
     * @param authenCode 权限code
     * @return
     */
    public List<Map<String,Object>>  getDoctorManagerRole(String code,String authenCode) {
        //获取医生在后台管理系统的权限  wlly_user的code是wlyy_doctor的code
        String sql=" select f.url url,f.code code from " +
                " wlyy_user u," +
@ -1563,6 +1569,9 @@ public class DoctorInfoService extends BaseService {
                " ru.role_id=rf.role_id and" +
                " rf.feature_id=f.id and" +
                " u.`code`='"+code+"'";
        if(StringUtils.isNotEmpty(authenCode)){
            sql+=" and f.code='"+authenCode+"'";
        }
        return jdbcTemplate.queryForList(sql);
    }
}

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

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.app.prenatalInspector;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.device.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
@ -831,7 +832,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
    /**
     * 根据待产检ID查询最近一条待产检计划状态
     *
     * 及列表范围之外最近一条待产检计划状态
     * @param prenatalId
     */
    public JSONObject getPrenatalStatus(Long prenatalId) throws Exception {
@ -850,6 +851,7 @@ public class PrenatalInspectorPreCardService extends BaseService {
            if (StringUtils.isNotEmpty(pregnancyNo) && (pregnancyNo != null)){
                Map<String,String> exams = getExamStatus(patient,pregnancyNo,begin,end);
                String examStatus = exams.get("status");
                Object beforePlan = exams.containsKey("plan")?exams.get("plan"):null;
                if ("1".equals(examStatus)){
                    String examTime = exams.get("examTime");
                    json.put("renatalStatus", "4");
@ -858,10 +860,14 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    if (days > 7) {
                        json.put("renatalStatus", "3");
                        json.put("sendStatus", flag == true ? "1" : "0");
                        json.put("plan", plan);
                    }else{
                        PrenatalInspectorRecord record = recordDao.findByRelationAndType(prenatalId.toString(), 0);
                        if (record == null) {
                            json.put("renatalStatus", "1");
                            if (beforePlan !=null){
                                json.put("plan", beforePlan);
                            }
                            if (days < -7) {
                                json.put("reason", "未到提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
                            }else {
@ -871,6 +877,9 @@ public class PrenatalInspectorPreCardService extends BaseService {
                            PrenatalInspectorRecord docRecord = recordDao.findByRelationAndType(prenatalId.toString(), 1);
                            json.put("renatalStatus", "2");
                            json.put("sendStatus", flag == true ? "1" : "0");
                            if (beforePlan !=null){
                                json.put("plan", beforePlan);
                            }
                            if (docRecord == null) {
                                json.put("sendTime", format.format(record.getSendTime()));
                            } else {
@ -1029,10 +1038,11 @@ public class PrenatalInspectorPreCardService extends BaseService {
     * @throws Exception
     */
    public Map getExamStatus(String patient,String pregnancyNo,Date begin,Date end) throws Exception {
        Map<String,String> respose = new HashMap();
        Map<String,Object> respose = new HashMap();
        respose.put("status","0");
        try {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                PrenatalInspectorPlan plan = prenatalInspectorPlanDao.findByPatientBeforeList(patient);
                JSONArray natals = reExamRecode(patient,pregnancyNo);
                for (Object natal : natals) {
                    JSONObject examRecord = JSON.parseObject(natal.toString());
@ -1041,8 +1051,17 @@ public class PrenatalInspectorPreCardService extends BaseService {
                    if ((examTime.getTime()<= end.getTime()) && (examTime.getTime() >= begin.getTime())){
                        respose.put("status","1");
                        respose.put("examTime",exam_time);
                        return respose;
                    }
                    if ((plan != null) && (StringUtils.isNotEmpty(plan.getInspectionCode()))){
                        Date planTime = plan.getInspectionTime();
                        Date beginTime = DateUtil.getPreDays(planTime,-14);
                        Date endTime = DateUtil.getPreDays(planTime,14);
                        respose.put("plan",plan);
                        if ((examTime.getTime()<= beginTime.getTime()) && (examTime.getTime() >= endTime.getTime())){
                            respose.remove("plan");
                        }
                    }
                }
        } catch (Exception e) {
            e.printStackTrace();

+ 6 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/jimeiJkEdu/JMJkEduArticleService.java

@ -13,6 +13,7 @@ import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.common.account.RoleService;
@ -64,6 +65,8 @@ public class JMJkEduArticleService extends BaseService {
    private CommonUtil commonUtil;
    @Autowired
    private SignPatientLabelInfoService signPatientLabelInfoService;
    @Autowired
    private DoctorInfoService doctorInfoService;
    /**
     *
@ -971,8 +974,9 @@ public class JMJkEduArticleService extends BaseService {
        //当管理员具有审核权限时,添加文章不需认证,添加后自动认证,
        Doctor doctor = doctorDao.findByCode(userCode);
        if(doctor.getLevel()==10){
            List<RoleWithAuthorityCheck> list = doctorDao.findEduAuthority(userCode,operatorRoleCode);
            if(list.size()>0){
//            List<RoleWithAuthorityCheck> list = doctorDao.findEduAuthority(userCode,operatorRoleCode);
            List<Map<String, Object>> list = doctorInfoService.getDoctorManagerRole(userCode,"Manage_Article_Authentication");
            if(list.size()>0&&!StringUtils.isEmpty(list.get(0).get("code"))){
                isAuthentication = 1;
            }
        }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -112,7 +112,7 @@ public class FileUploadController extends BaseController {
     * @throws IOException
     * @throws IllegalStateException
     */
    @RequestMapping(value = "image", method = RequestMethod.POST/* , headers = "Accept=image/png" */)
    @RequestMapping(value = "image", method = RequestMethod.POST  /*,headers = "Accept=image/png"*/ )
    @ResponseBody
    public String image(HttpServletRequest request, HttpServletResponse response) {
        if (isneiwang) {

+ 13 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -66,13 +66,12 @@ public class DataHandingService {
        doctorDao.save(doctors);
        return "更新患者(默认身份证后六位):"+patientCount+",有身份证异常的患者:"+patientErrorCount+",更新医生(默认电话后六位):"+doctorCount+",有电话号码异常的医生:"+doctorErrorCount;
    }
    @Transactional
    public String initWLyyDoctorTable2WLyyUserTable() {
        JSONObject returnjo = new JSONObject();
        List<Doctor> doctors = doctorDao.findAllDoctors();
        List<String> errorCodes = new ArrayList<>();
        Integer success = 0;
        Integer error = 0;
        Integer success = 0;
        Integer exsit = 0;
        for (Doctor doctor : doctors) {
            try {
@ -82,13 +81,7 @@ public class DataHandingService {
                    exsit++;
                    continue;
                }
                User userTemp = new User();
                user.setCode(doctor.getCode());
                user.setMobile(doctor.getMobile());
                user.setName(doctor.getName());
                user.setCzrq(new Date());
                user.setType(2); //医生
                userDao.save(userTemp);
                saveUser(doctor);
                success++;
            } catch (Exception e) {
                error++;
@ -101,4 +94,15 @@ public class DataHandingService {
        returnjo.put("errorCode", errorCodes);//转移失败的医生code
        return returnjo.toString();
    }
    @Transactional
    private void saveUser(Doctor doctor) {
        User userTemp = new User();
        userTemp.setCode(doctor.getCode());
        userTemp.setMobile(doctor.getMobile());
        userTemp.setName(doctor.getName());
        userTemp.setCzrq(new Date());
        userTemp.setType(2); //医生
        userDao.save(userTemp);
    }
}

+ 9 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -4,6 +4,8 @@ import com.yihu.wlyy.entity.organization.HospitalDept;
import com.yihu.wlyy.service.app.consult.ConsultTeamService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,7 +22,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
 * 修改历史数据处理控制器
 */
@Controller
@RequestMapping(value = "/dataHandling", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@Api(description = "修改历史数据处理控制器")
@RequestMapping(value = "/dataHandling", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DataHandlingController extends BaseController {
    @Autowired
@ -32,7 +35,7 @@ public class DataHandlingController extends BaseController {
    /**
     * 生成签约表中的行政团队的code
     */
    @RequestMapping(value = "produceSignAdminTeamCode")
    @RequestMapping(value = "produceSignAdminTeamCode",method =RequestMethod.GET)
    @ResponseBody
    public String produceSignAdminTeamCode() {
        try {
@ -47,7 +50,7 @@ public class DataHandlingController extends BaseController {
     * 生成咨询表中中的行政团队的code
     * @return
     */
    @RequestMapping(value = "produceConsultAdminTeamCode")
    @RequestMapping(value = "produceConsultAdminTeamCode",method =RequestMethod.GET)
    @ResponseBody
    public String produceConsultAdminTeamCode() {
        try {
@ -62,7 +65,8 @@ public class DataHandlingController extends BaseController {
     * 生成医生和患者表中有身份的用户的密码
     * @return
     */
    @RequestMapping(value = "producePatientAndDoctorPassword")
    @ApiOperation("生成医生和患者表中有身份的用户的密码")
    @RequestMapping(value = "producePatientAndDoctorPassword",method =RequestMethod.GET)
    @ResponseBody
    public String producePatientAndDoctorPasswor() {
        try {
@ -76,6 +80,7 @@ public class DataHandlingController extends BaseController {
     * 初始化wlyy_doctor的数据到wlyy_user
     * @return
     */
    @ApiOperation("初始化wlyy_doctor的数据到wlyy_user")
    @RequestMapping(value = "initWLyyDoctorTable2WLyyUserTable",method = RequestMethod.GET)
    @ResponseBody
    public String initWLyyDoctorTable2WLyyUserTable() {

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

@ -2056,13 +2056,14 @@ public class DoctorController extends BaseController {
    @ResponseBody
    @RequestMapping(value = "/getDoctorManagerRole", method = RequestMethod.GET)
    public String getDoctorManagerRole(
            @ApiParam(required = false, name = "code", value = "医生code") @RequestParam(value = "code", required = false) String code
            @ApiParam(required = false, name = "code", value = "医生code") @RequestParam(value = "code", required = false) String code,
            @ApiParam(required = false, name = "authenCode", value = "权限code,如:Manage_Article_Authentication") @RequestParam(value = "authenCode", required = false) String authenCode
    ) {
        try {
            if (org.springframework.util.StringUtils.isEmpty(code)) {
                code = super.getUID();
            }
            List<Map<String, Object>> returnData = doctorInfoService.getDoctorManagerRole(code);
            List<Map<String, Object>> returnData = doctorInfoService.getDoctorManagerRole(code,authenCode);
            return write(200, "获取成功", "data", returnData);
        } catch (Exception e) {
            error(e);

+ 100 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -6,8 +6,11 @@ import com.yihu.wlyy.wechat.util.WeiXinMessageReplyUtils;
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
@ -21,6 +24,8 @@ import java.util.*;
@Component
public class WeiXinEventProcess {
    private static Logger logger = LoggerFactory.getLogger(WeiXinEventProcess.class);
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Value("${wechat.appId}")
@ -29,6 +34,9 @@ public class WeiXinEventProcess {
    private String serverUrl;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 微信推送事件处理
@ -313,7 +321,38 @@ public class WeiXinEventProcess {
            json.put("type", 20);
            //模板消息json串
            result = json.toString();
        } else {
        }else if (StringUtils.isNotEmpty(eventKey) && (("wechat_hslq").equals(eventKey)) ||
                eventKey.startsWith("qrscene_wechat_hslq")) {
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            Map<String, String> article = new HashMap<>();
            // 图文URL
            String url = systemConf.getProperty("doctor_subscribe_url");
            // 图文消息图片URL
            String picUrl = systemConf.getProperty("doctor_qrcode_pic_url");
            // URL设置服务器URL、AppId
            url = url.replace("{server}", wechat_base_url)
                    .replace("{appId}", appId);
            //图片地址
            picUrl = picUrl.replace("{server}", serverUrl);
            article.put("Url", url);
            article.put("Title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
            article.put("Description", "请点击查看家庭签约");
            article.put("PicUrl", picUrl);
            articles.add(article);
            //设置共有的图文消息
            setUrlItems(articles, systemConf);
            setWifi(message.get("FromUserName"),articles,systemConf);
            // 构建回复消息XML
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }else {
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
@ -346,6 +385,35 @@ public class WeiXinEventProcess {
        return result;
    }
    public void setWifi(String openid,List<Map<String, String>> articles, Properties systemConf){
        try{
            String sql = "SELECT t.id FROM wlyy_patient t WHERE t.openid = '"+openid+"'";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            logger.info("setWifi_openid:"+openid+" openid_listSize:"+list.size());
            if(list!=null&&list.size()>0) {
                Map<String, String> articleConsult = new HashMap<>();
                // 图文URL
                String urlConsult = systemConf.getProperty("patient_wifi_url");
                // 图文消息图片URL
                String picUrlConsult = systemConf.getProperty("patient_wifi_pic_url");
                // URL设置服务器URL、AppId
                urlConsult = urlConsult.replace("{server}", wechat_base_url)
                        .replace("{appId}", appId);
                //图片地址
                picUrlConsult = picUrlConsult.replace("{server}", serverUrl);
                articleConsult.put("Url", urlConsult);
                articleConsult.put("Title", "一键上网(莲前卫生服务中心家庭医生为您服务)");
                articleConsult.put("Description", "一键上网(莲前卫生服务中心家庭医生为您服务)");
                articleConsult.put("PicUrl", picUrlConsult);
                articles.add(articleConsult);
            }
        }catch (Exception e){
            logger.info(e.getMessage());
        }
    }
    /**
     * 设置微信公共的图文消息
     *
@ -555,6 +623,37 @@ public class WeiXinEventProcess {
            json.put("type", 20);
            //模板消息json串
            result = json.toString();
        }else if (StringUtils.isNotEmpty(eventKey) && (("wechat_hslq").equals(eventKey)) ||
                eventKey.startsWith("qrscene_wechat_hslq")) {
            // 配置信息
            Properties systemConf = SystemConf.getInstance().getSystemProperties();
            // 图文信息
            List<Map<String, String>> articles = new ArrayList<>();
            Map<String, String> article = new HashMap<>();
            // 图文URL
            String url = systemConf.getProperty("doctor_subscribe_url");
            // 图文消息图片URL
            String picUrl = systemConf.getProperty("doctor_qrcode_pic_url");
            // URL设置服务器URL、AppId
            url = url.replace("{server}", wechat_base_url)
                    .replace("{appId}", appId);
            //图片地址
            picUrl = picUrl.replace("{server}", serverUrl);
            article.put("Url", url);
            article.put("Title", "欢迎关注厦门i健康,快来签约家庭医生吧~");
            article.put("Description", "请点击查看家庭签约");
            article.put("PicUrl", picUrl);
            articles.add(article);
            //设置共有的图文消息
            setUrlItems(articles, systemConf);
            setWifi(message.get("FromUserName"),articles,systemConf);
            // 构建回复消息XML
            result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        }
        return result;

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

@ -28,8 +28,10 @@ patient_examination_url=https://open.weixin.qq.com/connect/oauth2/authorize?appi
patient_prescription_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fprescription%2fhtml%2fprescription_records.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect
#居民取药码
patient_QRCode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fprescription%2fhtml%2fmy-medicine-code.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect
#居民wifi图片地址
patient_wifi_pic_url = {server}/images/wifi.png
#居民wifi链接
patient_wifi_url = https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fintroduction%2fhtml%2fyygh.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
#就诊记录
patient_visit_pic ={server}/images/visit.png
#检查检验

BIN
patient-co/patient-co-wlyy/src/main/webapp/images/wifi.png