Browse Source

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

zd_123 7 years ago
parent
commit
9cef9fb6cc
15 changed files with 1686 additions and 31 deletions
  1. 13 10
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRemindRecordsEntity.java
  2. 54 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientTeamRemindRecord.java
  3. 25 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/Application.java
  4. 7 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  5. 21 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientRemindRecordsDao.java
  6. 17 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientTeamRemindRecordDao.java
  7. 3 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  8. 480 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/physicalExamination/PhysicalExaminationRemindService.java
  9. 14 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java
  10. 748 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  11. 139 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  12. 6 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  13. 84 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PyhsicExamRemindController.java
  14. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  15. 75 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

+ 13 - 10
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRemindRecordsEntity.java

@ -2,9 +2,12 @@ package com.yihu.wlyy.entity.patient;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.*;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
/**
 * 居民提醒记录表
@ -14,13 +17,13 @@ import java.sql.Timestamp;
 */
@Entity
@Table(name = "wlyy_people_remind_records")
public class PatientRemindRecordsEntity extends IdEntity implements Serializable {
public class PatientRemindRecords extends IdEntity implements Serializable {
	private String code;
	private Integer type;           //1老年人体检提醒,2免疫计划提醒
	private String patientCode;     //居民CODE
	private String relationCode;    //关联的业务逻辑CODE
	private Timestamp remindTime;   //提醒时间
	private Timestamp createTime;   //创建时间
	private Date remindTime;   //提醒时间
	private Date createTime;   //创建时间
	
	private static final long serialVersionUID = 8358924836164389434L;
	
@ -43,7 +46,7 @@ public class PatientRemindRecordsEntity extends IdEntity implements Serializable
	public void setType(Integer type) {
		this.type = type;
	}
	
	@Basic
	@Column(name = "patient_code")
	public String getPatientCode() {
@ -66,21 +69,21 @@ public class PatientRemindRecordsEntity extends IdEntity implements Serializable
	
	@Basic
	@Column(name = "remind_time")
	public Timestamp getRemindTime() {
	public Date getRemindTime() {
		return remindTime;
	}
	
	public void setRemindTime(Timestamp remindTime) {
	public void setRemindTime(Date remindTime) {
		this.remindTime = remindTime;
	}
	
	@Basic
	@Column(name = "create_time")
	public Timestamp getCreateTime() {
	public Date getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(Timestamp createTime) {
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

+ 54 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientTeamRemindRecord.java

@ -0,0 +1,54 @@
package com.yihu.wlyy.entity.patient;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * 居民团队批量提醒记录表
 * Created by yeshijie on 2017/10/19.
 */
@Entity
@Table(name = "wlyy_patient_team_remind_record")
public class PatientTeamRemindRecord extends IdEntity implements Serializable  {
   private Long adminTeamCode;//'行政团队code',
   private Integer type;//类型1老年人体检提醒,2儿童免疫接种提醒
   private Integer status;//状态0未发送 1已发送
   private Date createTime;
    public Long getAdminTeamCode() {
        return adminTeamCode;
    }
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 25 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/Application.java

@ -2,7 +2,10 @@ package com.yihu.wlyy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.boot.context.web.ErrorPageFilter;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
/**
@ -15,4 +18,26 @@ public class Application {
    public static void main(String[] args) {
        ctx = SpringApplication.run(Application.class, args);
    }
    /**
     * start 解决如下问题
     * Cannot forward to error page for
     * request [/strategy/list/] as the response has already been committed. As a
     * result, the response may have the wrong status code. If your application is
     * running on WebSphere Application Server you may be able to resolve this
     * problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
     */
    @Bean
    public ErrorPageFilter errorPageFilter() {
        return new ErrorPageFilter();
    }
    @Bean
    public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(filter);
        filterRegistrationBean.setEnabled(false);
        return filterRegistrationBean;
    }
    //end
}

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

@ -14,6 +14,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import com.yihu.wlyy.entity.patient.Patient;
import java.util.Date;
import java.util.List;
public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
@ -67,4 +68,10 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    @Query(value=" select p.* from wlyy_patient p LEFT JOIN wlyy_sign_family s on s.patient = p.code WHERE s.status > 0  and p.disease >0 and p.status>0 and s.admin_team_code = ?1 and (s.doctor = ?2 or s.doctor_health =?2)",nativeQuery = true)
    List<Patient> findAllSignPatientTeamcode(String teamcode, String  doctorcode);
    @Query(value="SELECT DISTINCT t.*FROM wlyy_sign_family t1,wlyy_patient t WHERE t.`code`=t1.patient AND t1.STATUS>0 AND " +
            " t1.admin_team_code= ?1 AND(YEAR(curdate())-IF(length(t.idcard)=18,substring(t.idcard,7,4),IF(length(t.idcard)=15,concat('19',substring(t.idcard,7,2)),NULL)))>65 " +
            " AND t1.idcard NOT IN(SELECT DISTINCT s.idcard FROM wlyy_sign_family s,wlyy_old_people_physical_examination o WHERE s.admin_team_code=?1 AND s.`status`>0 AND s.idcard=o.id_card " +
            " AND o.medical_time>?2 )ORDER BY t1.openid DESC,CONVERT(t1.NAME USING gbk)",nativeQuery = true)
    List<Patient> findExaminationRemind(long teamcode, Date medicalTime);
}

+ 21 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientRemindRecordsDao.java

@ -0,0 +1,21 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientRemindRecords;
import com.yihu.wlyy.entity.patient.PatientReservation;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2017/10/19.
 */
public interface PatientRemindRecordsDao extends PagingAndSortingRepository<PatientRemindRecords, Long>, JpaSpecificationExecutor<PatientRemindRecords> {
    //查找7天内的提醒记录
    @Query("select a from PatientRemindRecords a where a.patientCode = ?1 and a.type=?2 and TIMESTAMPDIFF(DAY, NOW(), a.remindTime) >-7 ")
    List<PatientRemindRecords> findByPatientAndType(String patientCode, Integer type);
}

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientTeamRemindRecordDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientTeamRemindRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2017/10/19.
 */
public interface PatientTeamRemindRecordDao extends PagingAndSortingRepository<PatientTeamRemindRecord, Long>, JpaSpecificationExecutor<PatientTeamRemindRecord> {
    @Query("select a from PatientTeamRemindRecord a where a.adminTeamCode = ?1 and a.type=?2 and a.status=0 ")
    List<PatientTeamRemindRecord> findByAdminTeamCodeAndType(Long adminTeamCode, Integer type);
}

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

@ -7,16 +7,14 @@ import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabel;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientDisease;
import com.yihu.wlyy.entity.patient.PatientRemindRecords;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelInfoDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDiseaseDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.repository.patient.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.util.DateUtil;
@ -3913,6 +3911,7 @@ public class SignPatientLabelInfoService extends BaseService {
        }
    }
    /**
     * 获取医生所有团队的所有居民
     *
@ -4058,7 +4057,6 @@ public class SignPatientLabelInfoService extends BaseService {
     *
     * @param doctor
     * @param filter
     * @param diseaseCondition
     * @return
     * @throws Exception
     */

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

@ -0,0 +1,480 @@
package com.yihu.wlyy.service.app.physicalExamination;
import com.google.common.collect.Lists;
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.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientRemindRecordsDao;
import com.yihu.wlyy.repository.patient.PatientTeamRemindRecordDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
 * Created by Reece on 2017/10/19/019.
 * <p>
 * 65岁以上居民体检提醒(微信模板+短信通知)
 */
@Service
public class PhysicalExaminationRemindService extends BaseService {
    private Logger logger = LoggerFactory.getLogger(PhysicalExaminationRemindService.class);
    @Autowired
    private SMSService smsService;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
    private WeiXinOpenIdUtils openIdUtils;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientRemindRecordsDao patientRemindRecordsDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private DoctorDao doctorDao;
    @Autowired
    private PatientTeamRemindRecordDao patientTeamRemindRecordDao;
    /**
     * 单个提醒居民按钮
     * @param patient
     * @param doctor
     */
    public Integer singleRemindPhyExam(String patient,String doctor){
        List<PatientRemindRecords> records = patientRemindRecordsDao.findByPatientAndType(patient,1);
        if(records!=null&&records.size()>0){
            return -1;
        }
        Doctor d = doctorDao.findByCode(doctor);
        try{
            sendSingleNotice(patient,d.getName());
        }catch (Exception e){
            e.printStackTrace();
            logger.error("体检提醒失败"+e.getMessage());
        }
        return 0;
    }
    /**
     * 单个提醒居民按钮
     * @param teamCode
     * @param doctor
     */
    public Integer remindPhyExams(Long teamCode,String doctor){
        List<PatientTeamRemindRecord> records = patientTeamRemindRecordDao.findByAdminTeamCodeAndType(teamCode,1);
        if(records!=null&&records.size()>0){
            return -1;
        }
        PatientTeamRemindRecord record = new PatientTeamRemindRecord();
        record.setType(1);
        record.setCreateTime(new Date());
        record.setStatus(0);
        record.setAdminTeamCode(teamCode);
        patientTeamRemindRecordDao.save(record);
        Doctor d = doctorDao.findByCode(doctor);
        try{
            sendBatchNotice(teamCode,d.getName(),record.getId());
        }catch (Exception e){
            e.printStackTrace();
            logger.error("批量体检提醒失败"+e.getMessage());
        }
        return 0;
    }
    /**
     * 健康体检 是否显示批量提醒按钮
     * @param teamCode
     * @return
     */
    public Integer isShowRemindBtns(long teamCode){
        Integer re = 0;
        List<Map<String, Object>> signList = new ArrayList<>();
        String sql = "";
        Object[] args = null;
        sql = "SELECT " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " WHERE " +
                "     t1.status > 0 " +
                "    AND t1.admin_team_code = ? " +
                "    AND (YEAR(curdate()) -IF(length(idcard) = 18,substring(idcard, 7, 4),IF(length(idcard) = 15,concat('19', substring(idcard, 7, 2)),NULL)))>65 " +
                "    AND t1.idcard not in " +
                "       (SELECT DISTINCT s.idcard " +
                "           from wlyy_sign_family s," +
                "                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) ";
        args = new Object[]{teamCode,teamCode,DateUtil.getLastYear()};
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                String patient = sign.get("patient") == null ? "" : sign.get("patient").toString();
                if (StringUtils.isEmpty(patient)) {
                    continue;
                }
                List<PatientRemindRecords> records = patientRemindRecordsDao.findByPatientAndType(patient,1);
                if(records==null||records.size()==0){
                    re = 1;
                    break;
                }
            }
        }else{
            re = 1;
        }
        return re;
    }
    /**
     * 获取65岁以上老年人1年内无体检记录列表
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     * @throws Exception
     */
    public JSONArray getOldPatientByTeamCode(long teamCode, int page, int pagesize) throws Exception {
        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;
        //标签类别为空的时候
        sql = "SELECT " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " WHERE " +
                "     t1.status > 0 " +
                "    AND t1.admin_team_code = ? " +
                "    AND (YEAR(curdate()) -IF(length(idcard) = 18,substring(idcard, 7, 4),IF(length(idcard) = 15,concat('19', substring(idcard, 7, 2)),NULL)))>65 " +
                "    AND t1.idcard not in " +
                "       (SELECT DISTINCT s.idcard " +
                "           from wlyy_sign_family s," +
                "                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) ";
        args = new Object[]{teamCode,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) {
                    continue;
                }
                JSONObject json = new JSONObject();
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        boolean epTime = false;
                        try {
                            epTime = redisTemplate.opsForSet().isMember("expenses:remind:set", p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!epTime) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", 1);
                        }
                    }
                } else {
                    // 缴费情况
                    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血糖仪+血压仪
                String deviceType = "";
                if(!patientDeviceTypeMap.isEmpty() && patientDeviceTypeMap.keySet().contains(p.getCode())){
                    deviceType = (String) patientDeviceTypeMap.get(p.getCode());
                }
                json.put("deviceType",deviceType);
                boolean epTime = false;
                try {
                    epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (!epTime) {
                    json.put("wechatFocusRemind", 0);
                } else {
                    json.put("wechatFocusRemind", 1);
                }
                // 7天提醒标志
                List<PatientRemindRecords> records = patientRemindRecordsDao.findByPatientAndType(p.getCode(),1);
                if(records!=null&&records.size()>0){
                    json.put("physicalExamRemind", 1);//7天内已提醒
                }else {
                    json.put("physicalExamRemind", 0);
                }
                result.put(p.getCode(), json);
            }
        }
        if (result.size() > 0) {
            List<JSONObject> list = Lists.newArrayList(result.values());
            Collections.sort(list, new Comparator<JSONObject>() {
                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    //微信綁定情況
                    String openid1 = o1.has("openid") ? o1.getString("openid") : "";
                    String openid2 = o2.has("openid") ? o2.getString("openid") : "";
                    int re = openid1.compareTo(openid2);
                    if (re > 0) {
                        return -1;
                    } else if (re < 0) {
                        return 1;
                    } else {
                        return 0;
                    }
                }
            });
            return new JSONArray(list);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 发送单条提醒
     *
     * @param userCode 居民code
     * @param doctName 医生姓名
     */
    public void sendSingleNotice(String userCode, String doctName) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        String accessToken = accessTokenUtils.getAccessToken();
        Patient patient = patientDao.findByCode(userCode);
        String mobile = patient.getMobile();
        Boolean flag = true;
        // 推送消息给微信端
        JSONObject json = new org.json.JSONObject();
        json.put("first", "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~");
        json.put("keyword1", "健康体检");
        json.put("keyword2", format.format(new Date()));
        json.put("url", "");
        json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~");
        if (StringUtils.isNotBlank(patient.getOpenid())) {
            pushMsgTask.putWxMsg(accessToken, 11, patient.getOpenid(), patient.getName(), json);
            flag = false;
        }
        //发送代理人
        JSONArray jsonArray = openIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid());
        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");
                json.remove("toUser");
                json.put("toUser", member.getCode());
                json.remove("first");
                try {
                    json.put("first", openIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isNotBlank(member.getOpenid())) {
                    pushMsgTask.putWxMsg(accessToken, 11, member.getOpenid(), patient.getName(), json);
                    flag = false;
                }
            }
        }
//        微信发送失败发送短信
        if (flag&&StringUtils.isNotEmpty(mobile)){
            smsService.sendMsg(mobile,"您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~");
        }
        //保存发送提醒
        PatientRemindRecords patientRemindRecord = new PatientRemindRecords();
        patientRemindRecord.setCode(getCode());
        patientRemindRecord.setCreateTime(new Date());
        patientRemindRecord.setPatientCode(userCode);
        patientRemindRecord.setRemindTime(new Date());
        patientRemindRecord.setType(1);
        patientRemindRecordsDao.save(patientRemindRecord);
    }
    /**
     * 发送批量提醒
     *
     * @param teamId 团队ID
     * @param doctName 医生姓名
     * @return
     */
    @Async
    public void sendBatchNotice(long teamId, String doctName,Long remindId) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
        String accessToken = accessTokenUtils.getAccessToken();
        // 推送消息给微信端
        JSONObject json = new org.json.JSONObject();
        json.put("first", "您的家庭医生" + doctName + "提醒,您可以到签约社区进行免费的健康体检啦~");
        json.put("keyword1", "健康体检");
        json.put("keyword2", format.format(new Date()));
        json.put("url", "");
        json.put("remark", "为了您和您的家庭医生了解您近期的健康状况,请及时到您签约的社区体检哟~");
        String sql = "SELECT DISTINCT " +
                " t1.* " +
                " FROM" +
                " wlyy_sign_family t1 " +
                " WHERE " +
                " t1. STATUS > 0 " +
                " AND t1.admin_team_code = 485 " +
                " AND ( " +
                " YEAR (curdate()) - " +
                " IF ( " +
                " length(idcard) = 18, " +
                " substring(idcard, 7, 4), " +
                " IF ( " +
                " length(idcard) = 15, " +
                " concat('19', substring(idcard, 7, 2)), " +
                " NULL " +
                " ) " +
                " ) " +
                " ) > 65 " +
                " AND t1.idcard NOT IN ( " +
                " SELECT DISTINCT " +
                " s.idcard " +
                " FROM " +
                " wlyy_sign_family s, " +
                " wlyy_old_people_physical_examination o " +
                " WHERE " +
                " s.admin_team_code =485 " +
                " AND s.`status` > 0 " +
                " AND s.idcard = o.id_card " +
                " AND o.medical_time >'2016-10-19 15:12:11' " +
                " )" +
                " ORDER BY " +
                " t1.openid DESC, " +
                " CONVERT (t1. NAME USING gbk)";
        List<Patient>patients = patientDao.findExaminationRemind(485,new Date());
        Patient patient = patientDao.findByCode("");
        if (StringUtils.isNotBlank(patient.getOpenid())) {
            pushMsgTask.putWxMsg(accessToken, 11, patient.getOpenid(), patient.getName(), json);
        }
        //发送代理人
        JSONArray jsonArray = openIdUtils.getAgentOpenId(patient.getCode(), patient.getOpenid());
        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");
                json.remove("toUser");
                json.put("toUser", member.getCode());
                json.remove("first");
                try {
                    json.put("first", openIdUtils.getTitleMes(patient, j.isNull("relation") ? 1 : j.getInt("relation"), patient.getName()));
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (StringUtils.isNotBlank(member.getOpenid())) {
                    pushMsgTask.putWxMsg(accessToken, 11, member.getOpenid(), patient.getName(), json);
                }
            }
        }
        //更新提醒状态
        PatientTeamRemindRecord record = patientTeamRemindRecordDao.findOne(remindId);
        record.setStatus(1);
        patientTeamRemindRecordDao.save(record);
    }
}

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

@ -2711,6 +2711,20 @@ public class StatisticsAllService extends BaseService {
        return rs;
    }
    public List<Map<String, Object>> translateTeamLeaderName2(List<Map<String, Object>> rs) {
        Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
        if (rs != null && rs.size() > 0) {
            for (Map<String, Object> r : rs) {
                Integer id = (Integer) r.get("code");
                String name = getTeamLeaderNameByTeamCode(leaders, id);
                if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
                    r.put("name", name);
                }
            }
        }
        return rs;
    }
    public JSONArray translateTeamLeaderName(JSONArray rs) {
        Map<Integer, Map<String, Object>> leaders = getAllTeamLeaders();
        if (rs != null) {
@ -3051,7 +3065,6 @@ public class StatisticsAllService extends BaseService {
    /**
     * 根据父级的quato_code,查找二级数据列表
     * @param date
     * @param level
     * @param index
     * @param area
     * @param lowCode

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

@ -5002,9 +5002,9 @@ public class StatisticsService extends BaseService {
            stateSql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
        //机构
        }else if("2".equals(level)){
            totalSql += " p.hospital = '"+area+"' ";
            processingSql += " p.hospital = '"+area+"' ";
            stateSql += " p.hospital = '"+area+"' ";
            totalSql += " AND p.hospital = '"+area+"' ";
            processingSql += " AND p.hospital = '"+area+"' ";
            stateSql += " AND p.hospital = '"+area+"' ";
        }
        Map<String,Object> rs = new HashedMap();
@ -5062,7 +5062,8 @@ public class StatisticsService extends BaseService {
     * @return
     */
    public List<Map<String,Object>> getPrescriptionTotalHistogram(String level,String area,String disease,String type){
        List<Map<String,Object>> rs = new ArrayList<>();
        List<Map<String,Object>> rs =new ArrayList<>();
        Calendar dd = Calendar.getInstance();//定义日期实例
        Date endDate = new Date();
@ -5093,7 +5094,7 @@ public class StatisticsService extends BaseService {
            sql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
            //机构
        }else if("2".equals(level)){
            sql += " p.hospital = '"+area+"' ";
            sql += " AND p.hospital = '"+area+"' ";
        }
        //类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
        if("1".equals(type)){
@ -5114,15 +5115,15 @@ public class StatisticsService extends BaseService {
        sql += " AND p.create_time >='"+DateUtil.dateToStr(dd.getTime(),"YYYY-MM-dd HH:mm:ss")+"' AND p.create_time <='"+ DateUtil.dateToStr(new Date(),"YYYY-MM-dd HH:mm:ss")+"'  GROUP BY LEFT(p.create_time,7) ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Iterator iterator = list.iterator();
        for(Map<String,Object> m:rs){
            Iterator iterator = list.iterator();
            while (iterator.hasNext()){
                Map<String,Object> ml = ( Map<String,Object>)iterator.next();
                String monthKey = (String)m.get("month");
                String monthKeyDb = (String)ml.get("month");
                if(monthKey.equals(monthKeyDb)){
                    m.put("count",ml.get("count"));
                    iterator.remove();
                }
            }
        }
@ -5274,6 +5275,9 @@ public class StatisticsService extends BaseService {
            }
        }
        rs = jdbcTemplate.queryForList(sql);
        if("1".equals(level)){
            statisticsAllService.translateTeamLeaderName2(rs);
        }
        return rs;
    }
@ -5304,6 +5308,26 @@ public class StatisticsService extends BaseService {
    }
    public String setDiseaseTypeSql2(String disease,String type,String sql){
        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 ";
        }
        //类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
        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;
        }
        sql +=" AND p.`status` >="+PrescriptionLog.PrescriptionLogStatus.pay_success.getValue();
        return sql;
    }
    public Map<String,Object> getPrescriptionCost(String level,String area,String disease){
        Map<String,Object> rs = new HashedMap();
@ -5359,5 +5383,722 @@ public class StatisticsService extends BaseService {
        }
        return rs;
    }
    /**
     * 获取中部费用平均值
     * @param level
     * @param area
     * @param disease
     * @param startDate
     * @param endDate
     * @param type 1.按日,2.按周,3.按月
     */
    public List<Map<String,Object>> getPrescriptionCostAvgLine(String level,String area,String disease,String startDate,String endDate,String type){
        startDate += " 00:00:00";
        endDate += " 23:59:59";
        if("1".equals(type)){
            //按日
            List<Map<String,Object>> rs = DateUtil.findDates(DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
            String sql = "SELECT " +
                    " avg(t.total_amount) avg, " +
                    " LEFT(t.create_time,10) date " +
                    " FROM " +
                    " wlyy_prescription_pay t ";
            sql = setLevelAndDisSql(sql,disease,level,area);
            sql +=  " AND t.trade_status = 1 " +
                    " AND t.create_time >='"+startDate+"' " +
                    " AND t.create_time <='"+endDate+"' " +
                    " GROUP BY LEFT(t.create_time,10)";
            return getDatesRs(sql,rs);
        }else if("2".equals(type)){
            //按周
            List<Map<String,Object>> rs = DateUtil.findDateASWeeks(DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
            String sql ="SELECT " +
                    " avg(t.total_amount) avg, " +
                    " LEFT(date_sub(t.create_time,INTERVAL WEEKDAY(t.create_time) +0 DAY),10) date " +
                    " FROM " +
                    " wlyy_prescription_pay t ";
            sql = setLevelAndDisSql(sql,disease,level,area);
            sql +=  " AND t.trade_status = 1 " +
                    " AND t.create_time >='"+startDate+"' " +
                    " AND t.create_time <='"+endDate+"' " +
                    " GROUP BY DATE_FORMAT(t.create_time, '%v %x')";
            return getDatesRs(sql,rs);
        }else if("3".equals(type)){
            //按月
            List<Map<String,Object>> rs = DateUtil.findDateASMonth(DateUtil.stringToDate(startDate,"yyyy-MM-dd HH:mm:ss"),DateUtil.stringToDate(endDate,"yyyy-MM-dd HH:mm:ss"));
            String sql = "SELECT " +
                    " avg(t.total_amount) avg, " +
                    " LEFT(t.create_time,7) date " +
                    " FROM " +
                    " wlyy_prescription_pay t ";
            sql = setLevelAndDisSql(sql,disease,level,area);
            sql +=  " AND t.trade_status = 1 " +
                    " AND t.create_time >='"+startDate+"' " +
                    " AND t.create_time <='"+endDate+"' " +
                    " GROUP BY LEFT(t.create_time,7)";
            return getDatesRs(sql,rs);
        }
        return null;
    }
    public String setLevelAndDisSql(String sql,String disease,String level,String area){
        if(StringUtils.isNotBlank(disease)){
            sql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = t.prescription_code ";
        }
        if("4".equals(level)){
            sql +=" WHERE 1=1  ";
        }else if("3".equals(level)){
            sql +=" JOIN wlyy_prescription p ON t.prescription_code = p.code WHERE LEFT(p.hospital,6) ='"+area+"' ";
        }else if("2".equals(level)){
            sql +=" JOIN wlyy_prescription p ON t.prescription_code = p.code WHERE p.hospital ='"+area+"' ";
        }
        if(StringUtils.isNotBlank(disease)){
            sql += " AND  d.health_problem ='"+disease+"'";
        }
        return sql;
    }
    public String setLevelAndDisSql2(String sql,String disease,String level,String area){
        if(StringUtils.isNotBlank(disease)){
            sql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = t.prescription_code ";
        }
        if("4".equals(level)){
            sql +=" WHERE 1=1  ";
        }else if("3".equals(level)){
            sql +=" WHERE LEFT(p.hospital,6) ='"+area+"' ";
        }else if("2".equals(level)){
            sql +=" WHERE p.hospital ='"+area+"' ";
        }
        if(StringUtils.isNotBlank(disease)){
            sql += " AND  d.health_problem ='"+disease+"'";
        }
        return sql;
    }
    public List<Map<String,Object>> getDatesRs(String sql,List<Map<String,Object>> rs){
        List<Map<String,Object>> dayList = jdbcTemplate.queryForList(sql);
        for(Map<String,Object> map :rs){
            String dateKey = (String)map.get("date");
            Iterator iterator = dayList.iterator();
            while (iterator.hasNext()){
                Map<String,Object> day = (Map<String,Object>)iterator.next();
                String dateKeyDb =(String)day.get("date");
                if(dateKey.equals(dateKeyDb)){
                    BigDecimal a =  (BigDecimal)day.get("avg");
                    map.put("avg",a.divide((new BigDecimal(100))).setScale(2,BigDecimal.ROUND_HALF_UP));
                }
            }
        }
        return rs;
    }
    /**
     * 获取下部部费用平均值或总数
     * @param level
     * @param lowlevel
     * @param area
     * @param disease
     * @param type 1.总量,2.平均值
     * @return
     */
    public List<Map<String,Object>> getPrescriptionCostLowLevel(String level,String lowlevel,String area,String disease,String type){
        //市级
        if("4".equals(level)){
            //区级
            if("3".equals(lowlevel)){
                if("1".equals(type)){
                    //总量
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " FROM dm_town tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
                            " LEFT (p.hospital, 6) code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code ";
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY LEFT (p.hospital, 6) " +
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " tw.city = '350200' " +
                            " ORDER BY sum DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    return rs;
                }else{
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " FROM dm_town tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
                            " LEFT (p.hospital, 6) code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code ";
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY LEFT (p.hospital, 6) " +
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " tw.city = '350200' " +
                            " ORDER BY avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    return rs;
                }
            //机构
            }else if("2".equals(lowlevel)){
                if("1".equals(type)){
                    //总量
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
                            " p.hospital code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code ";
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY p.hospital " +
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " tw.city = '350200' " +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY sum DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    return rs;
                }else{
                    String sql = " SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
                            " p.hospital code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code ";
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY p.hospital " +
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " tw.city = '350200' " +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    return rs;
                }
            //团队
            }else if("1".equals(lowlevel)){
                if("1".equals(type)){
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
                            " p.admin_team_id code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code " ;
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " ORDER BY sum DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
                }else{
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
                            " p.admin_team_id code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code " ;
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " GROUP BY p.hospital " +
                            " ) c ON c.code = tw.id  " +
                            " ORDER BY avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
                }
            }
        //区级
        }else if("3".equals(level)){
            //机构
            if("2".equals(lowlevel)){
                if("1".equals(type)){
                    //总量
                    String sql = "SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
                            " p.hospital code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code ";
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " AND LEFT(p.hospital,6)='"+area+"' " +
                            " GROUP BY p.hospital " +
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " ADN tw.city = '350200' " +
                            " AND tw.town = '"+ area+"'" +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY sum DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    return rs;
                }else{
                    String sql = " SELECT  " +
                            " tw.`code`, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " FROM dm_hospital tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
                            " p.hospital code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code ";
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " AND LEFT(p.hospital,6)='"+area+"' " +
                            " GROUP BY p.hospital " +
                            " ) c ON c.code = tw.code  " +
                            " WHERE " +
                            " tw.city = '350200' " +
                            " AND tw.town = '"+ area+"'" +
                            " AND LENGTH(tw.code)=10 " +
                            " ORDER BY avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    return rs;
                }
            //团队
            }else if("1".equals(lowlevel)){
                if("1".equals(type)){
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
                            " p.admin_team_id code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code " ;
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " AND LEFT(p.hospital,6) ='"+area+"' " +
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  LEFT(tw.org_code,6) ='"+area+"' " +
                            " ORDER BY sum DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
                }else{
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
                            " p.admin_team_id code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code " ;
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " AND LEFT(p.hospital,6) ='"+area+"' " +
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  LEFT(tw.org_code,6) ='"+area+"' " +
                            " ORDER BY avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
                }
            }
        //机构
        }else if("2".equals(level)){
            //团队
            if("1".equals(lowlevel)){
                if("1".equals(type)){
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(c.sum/100,0) sum " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " sum(t.total_amount) sum, " +
                            " p.admin_team_id code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code " ;
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " AND p.hospital,6 ='"+area+"' " +
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  tw.org_code ='"+area+"' " +
                            " ORDER BY sum DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
                }else{
                    String sql = "SELECT  " +
                            " tw.`id` code, " +
                            " tw.`name`, " +
                            " ifnull(FORMAT(c.avg/100,2),0) avg " +
                            " FROM wlyy_admin_team tw LEFT JOIN ( " +
                            " SELECT " +
                            " avg(t.total_amount) avg, " +
                            " p.admin_team_id code " +
                            " FROM " +
                            " wlyy_prescription_pay t JOIN wlyy_prescription p ON p.code = t.prescription_code " ;
                    sql = setDisSql(sql,disease);
                    sql +=  " AND t.trade_status = 1 " +
                            " AND p.hospital ='"+area+"' " +
                            " GROUP BY p.admin_team_id " +
                            " ) c ON c.code = tw.id  " +
                            " WHERE  tw.org_code ='"+area+"' " +
                            " ORDER BY avg DESC ";
                    List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
                    statisticsAllService.translateTeamLeaderName2(rs);
                    return rs;
                }
            }
        }
        return null;
    }
    public String setDisSql(String sql,String disease){
        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 ";
        }
        return sql;
    }
    public List<Map<String,Object>> getPrescriptionDispatchingTotal(String level,String area,String disease){
        String sql = "SELECT " +
                " COUNT(1) total" +
                " FROM " +
                " wlyy_prescription p " ;
        sql = setLevelAndDisSql2(sql,disease, level, area);
        sql += " AND p.`status` > 50 " +
                " AND p.dispensary_type = ? ";
        List<Map<String,Object>> rs = new ArrayList();
        //自取数目
        List<Map<String,Object>> seltList = jdbcTemplate.queryForList(sql,new Object[]{1});
        if(seltList!=null&&seltList.size()>0){
            Map<String,Object> map = new HashedMap();
            map.put("seltTotal",seltList.get(0).get("total"));
            rs.add(map);
        }else{
            Map<String,Object> map = new HashedMap();
            map.put("seltTotal",0);
            rs.add(map);
        }
        //快递配送
        List<Map<String,Object>> deliveryList = jdbcTemplate.queryForList(sql,new Object[]{2});
        if(deliveryList!=null&&deliveryList.size()>0){
            Map<String,Object> map = new HashedMap();
            map.put("deliveryTotal",deliveryList.get(0).get("total"));
            rs.add(map);
        }else{
            Map<String,Object> map = new HashedMap();
            map.put("deliveryTotal",0);
            rs.add(map);
        }
        //健管师配送
        List<Map<String,Object>> healthDoctorList = jdbcTemplate.queryForList(sql,new Object[]{2});
        if(healthDoctorList!=null&&healthDoctorList.size()>0){
            Map<String,Object> map = new HashedMap();
            map.put("doctorTotal",healthDoctorList.get(0).get("total"));
            rs.add(map);
        }else{
            Map<String,Object> map = new HashedMap();
            map.put("doctorTotal",0);
            rs.add(map);
        }
        return rs;
    }
    /**
     *
     * @param level
     * @param area
     * @param disease
     * @param type 1.自取,2.快递配送,3.健管师配送
     * @return
     */
    public List<Map<String,Object>> getPrescriptionDispatchingHistogram(String level,String area,String disease,String type){
        List<Map<String,Object>> rs =new ArrayList<>();
        Calendar dd = Calendar.getInstance();//定义日期实例
        Date endDate = new Date();
        dd.setTime(endDate);
        for(int i=1;i<7;i++){
            Map<String,Object> mc = new HashedMap();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            String date = sdf.format(dd.getTime());
            mc.put("month",date);
            mc.put("count",0);
            dd.add(Calendar.MONTH,-1);
            rs.add(mc);
        }
        String sql = "SELECT count(1) AS count,LEFT(p.create_time,7) AS month " +
                " 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("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+"' ";
        }
        //类型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;
        }
        sql += " AND p.`status` >="+PrescriptionLog.PrescriptionLogStatus.pay_success.getValue()+" AND p.create_time >='"+DateUtil.dateToStr(dd.getTime(),"YYYY-MM-dd HH:mm:ss")+"' AND p.create_time <='"+ DateUtil.dateToStr(new Date(),"YYYY-MM-dd HH:mm:ss")+"'  GROUP BY LEFT(p.create_time,7) ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for(Map<String,Object> m:rs){
            Iterator iterator = list.iterator();
            while (iterator.hasNext()){
                Map<String,Object> ml = ( Map<String,Object>)iterator.next();
                String monthKey = (String)m.get("month");
                String monthKeyDb = (String)ml.get("month");
                if(monthKey.equals(monthKeyDb)){
                    m.put("count",ml.get("count"));
                }
            }
        }
        return rs;
    }
    /**
     *
     * @param level
     * @param lowlevel
     * @param area
     * @param disease
     * @param type 1.自取,2.快递配送,3.健管师配送
     * @return
     */
    public List<Map<String,Object>> getPrescriptionDispatchingLowLevel(String level,String lowlevel,String area,String disease,String type){
        List<Map<String,Object>> rs ;
        String sql =null;
        //市级维度
        if("4".equals(level)){
            //默认查找市级维度
            if("3".equals(lowlevel)){
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " dm_town t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        " count(1) count, " +
                        " LEFT (p.hospital, 6) code " +
                        " FROM " +
                        " wlyy_prescription p ";
                sql = setDiseaseTypeSql2(disease,type,sql);
                sql +=  " GROUP BY " +
                        "  LEFT (p.hospital, 6) " +
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " ORDER BY num DESC";
            }else if("2".equals(lowlevel)){
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        " count(1) count, " +
                        " p.hospital code " +
                        " FROM " +
                        " wlyy_prescription p ";
                sql = setDiseaseTypeSql2(disease,type,sql);
                sql += " GROUP BY " +
                        "  p.hospital " +
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " ORDER BY num DESC";
            }else if("1".equals(lowlevel)){
                sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        "  count(1) count, " +
                        "  p.admin_team_id code " +
                        "  FROM " +
                        "  wlyy_prescription p " ;
                sql = setDiseaseTypeSql2(disease,type,sql);
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " ORDER BY num DESC ";
            }
            //区级维度
        }else if("3".equals(level)){
            if("2".equals(lowlevel)){
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        " count(1) count, " +
                        " p.hospital code " +
                        " FROM " +
                        " wlyy_prescription p ";
                sql = setDiseaseTypeSql2(disease,type,sql);
                sql += " GROUP BY " +
                        "  p.hospital " +
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " AND t.town ='"+area+"'" +
                        " ORDER BY num DESC";
            }else if("1".equals(lowlevel)){
                sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        "  count(1) count, " +
                        "  p.admin_team_id code " +
                        "  FROM " +
                        "  wlyy_prescription p " ;
                sql = setDiseaseTypeSql2(disease,type,sql);
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE LEFT(t.org_code,6) ='"+area+"' " +
                        " ORDER BY num DESC ";
            }
            //机构级维度
        }else if("2".equals(level)){
            if("1".equals(lowlevel)){
                sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        "  count(1) count, " +
                        "  p.admin_team_id code " +
                        "  FROM " +
                        "  wlyy_prescription p " ;
                sql = setDiseaseTypeSql2(disease,type,sql);
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE t.org_code ='"+area+"'" +
                        " ORDER BY num DESC ";
            }
        }
        rs = jdbcTemplate.queryForList(sql);
        if("1".equals(level)){
            statisticsAllService.translateTeamLeaderName2(rs);
        }
        return rs;
    }
}

+ 139 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.util;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import java.sql.Time;
@ -884,9 +885,146 @@ public class DateUtil {
		return  cal.getTime();
	}
	public static List<Map<String,Object>> findDates(Date dBegin, Date dEnd) {
		List<Map<String,Object>> lDate = new ArrayList();
		Map<String,Object> st = new HashedMap();
		st.put("date",DateUtil.dateToStr(dBegin,"yyyy-MM-dd"));
		st.put("avg",0);
		lDate.add(st);
		Calendar calBegin = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calBegin.setTime(dBegin);
		Calendar calEnd = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calEnd.setTime(dEnd);
		// 测试此日期是否在指定日期之后
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			Map<String,Object> stt = new HashedMap();
			stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM-dd"));
			stt.put("avg",0);
			lDate.add(stt);
		}
		return lDate;
	}
	public static List<Map<String,Object>> findDateASWeeks(Date dBegin, Date dEnd) {
		List<Map<String,Object>> lDate = new ArrayList();
		Calendar calBegin = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calBegin.setTime(dBegin);
		if(checkDateMonday(calBegin)){
			Map<String,Object> st = new HashedMap();
			st.put("date",DateUtil.dateToStr(dBegin,"yyyy-MM-dd"));
			st.put("avg",0);
			lDate.add(st);
		}
		Calendar calEnd = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calEnd.setTime(dEnd);
		// 测试此日期是否在指定日期之后
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			if(checkDateMonday(calBegin)){
				Map<String,Object> stt = new HashedMap();
				stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM-dd"));
				stt.put("avg",0);
				lDate.add(stt);
			}
		}
		return lDate;
	}
	public static List<Map<String,Object>> findDateASMonth(Date dBegin, Date dEnd) {
		List<Map<String,Object>> lDate = new ArrayList();
		Calendar calBegin = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calBegin.setTime(dBegin);
		if(checkFristDayOfDateMonth(calBegin)){
			Map<String,Object> st = new HashedMap();
			st.put("date",DateUtil.dateToStr(dBegin,"yyyy-MM"));
			st.put("avg",0);
			lDate.add(st);
		}
		Calendar calEnd = Calendar.getInstance();
		// 使用给定的 Date 设置此 Calendar 的时间
		calEnd.setTime(dEnd);
		// 测试此日期是否在指定日期之后
		while (dEnd.after(calBegin.getTime())) {
			// 根据日历的规则,为给定的日历字段添加或减去指定的时间量
			calBegin.add(Calendar.DAY_OF_MONTH, 1);
			if(checkFristDayOfDateMonth(calBegin)){
				Map<String,Object> stt = new HashedMap();
				stt.put("date",DateUtil.dateToStr(calBegin.getTime(),"yyyy-MM"));
				stt.put("avg",0);
				lDate.add(stt);
			}
		}
		return lDate;
	}
	public static boolean checkDateMonday(Calendar cal){
		int week=cal.get(Calendar.DAY_OF_WEEK)-1;
		if(week ==1){
			return true;
		}else{
			return false;
		}
	}
	public static boolean checkFristDayOfDateMonth(Calendar cal){
		int today = cal.get(cal.DAY_OF_MONTH);
		if(today ==1){
			return true;
		}else{
			return false;
		}
	}
	public static List<Map<String,Object>> getLast6Month(){
		List<Map<String,Object>> rs = new ArrayList<>();
		Calendar dd = Calendar.getInstance();//定义日期实例
		Date endDate = new Date();
		dd.setTime(endDate);
		for(int i=1;i<7;i++){
			Map<String,Object> mc = new HashedMap();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
			String date = sdf.format(dd.getTime());
			mc.put("month",date);
			mc.put("count",0);
			dd.add(Calendar.MONTH,-1);
			rs.add(mc);
		}
		return rs;
	}
	/**
	 * 获取去年日期
	 * @return
     */
	public static String getLastYear(){
		Calendar cal = Calendar.getInstance();
		cal.add(Calendar.YEAR,-1);
		return dateToStrLong(cal.getTime());
	}
	/**
	 * 获取儿童的年龄
	 * @param birthday
	 * @param date
	 * @return
     */
	public static String getChildAge(Date date){

+ 6 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -285,8 +285,8 @@ public class ElasticsearchUtil {
            sql.append(" and ");
        }
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" imeLevel='" + timeLevel + "'  ");
        sql.append(" areaLevel='5'");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
@ -379,8 +379,8 @@ public class ElasticsearchUtil {
            sql.append(" and ");
        }
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" imeLevel='" + timeLevel + "'  ");
        sql.append(" areaLevel='5'");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }
@ -473,8 +473,8 @@ public class ElasticsearchUtil {
            sql.append(" and ");
        }
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" imeLevel='" + timeLevel + "'  ");
        sql.append(" areaLevel='5'");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + startDate + "'");
        }

+ 84 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PyhsicExamRemindController.java

@ -0,0 +1,84 @@
package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.service.app.physicalExamination.PhysicalExaminationRemindService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2017/10/20.
 */
@RestController
@RequestMapping(value = "/doctor/patient_label_info", method = {RequestMethod.GET, RequestMethod.POST})
@Api(description = "居民标签管理")
public class PyhsicExamRemindController extends BaseController{
    @Autowired
    private PhysicalExaminationRemindService physicalExaminationRemindService;
    @RequestMapping(value = "getOldPatientByTeamCode", method = RequestMethod.GET)
    @ApiOperation("一年内无体检记录的65岁及以上老年居民")
    public String getOldPatientByTeamCode(@ApiParam(name = "adminTeamCode", value = "行政团队编码", defaultValue = "644")
                                          @RequestParam(value = "adminTeamCode", required = true) Long adminTeamCode,
                                          @ApiParam(name = "page", value = "第几页", defaultValue = "0")
                                          @RequestParam(value = "page", required = false) Integer page,
                                          @ApiParam(name = "pagesize", value = "分页大小", defaultValue = "10")
                                          @RequestParam(value = "pagesize", required = false) Integer pagesize){
        try {
            page = page==null?0:page;
            pagesize = pagesize==null?10:pagesize;
            JSONArray list = physicalExaminationRemindService.getOldPatientByTeamCode(adminTeamCode,page,pagesize);
            return write(200, "查询成功", "data", list);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "isShowRemindBtns", method = RequestMethod.GET)
    @ApiOperation("是否显示批量提醒按钮")
    public String isShowRemindBtns(@ApiParam(name = "adminTeamCode", value = "行政团队编码", defaultValue = "644")
                                   @RequestParam(value = "adminTeamCode", required = true) Long adminTeamCode){
        try {
            Integer re = physicalExaminationRemindService.isShowRemindBtns(adminTeamCode);
            return write(200, "查询成功", "data", re);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "singleRemindPhyExam", method = RequestMethod.POST)
    @ApiOperation("单个提醒居民")
    public String singleRemindPhyExam(@ApiParam(name = "patient", value = "居民code", defaultValue = "644")
                                      @RequestParam(value = "patient", required = true) String patient){
        try {
            physicalExaminationRemindService.singleRemindPhyExam(patient,getUID());
            return success("提醒成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "remindPhyExams", method = RequestMethod.POST)
    @ApiOperation("批量提醒居民")
    public String remindPhyExams(@ApiParam(name = "adminTeamCode", value = "行政团队编码", defaultValue = "644")
                                 @RequestParam(value = "adminTeamCode", required = true) Long adminTeamCode){
        try {
            physicalExaminationRemindService.remindPhyExams(adminTeamCode,getUID());
            return success("提醒成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

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

@ -3,7 +3,6 @@ package com.yihu.wlyy.web.doctor.patient;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.app.scheme.DoctorSchemeService;
import com.yihu.wlyy.service.app.sign.FamilyContractService;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.web.BaseController;

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

@ -1726,6 +1726,81 @@ public class StatisticsController extends BaseController {
        }
    }
    @RequestMapping("/getPrescriptionCostAvgLine")
    @ResponseBody
    @ApiOperation("费用统计-中部折线图接口")
    public String getPrescriptionCostAvgLine(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                             @ApiParam(name="area", value="级别编码") @RequestParam(required = true)String area,
                                             @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease,
                                             @ApiParam(name="startDate", value="开始时间") @RequestParam(required = false)String startDate,
                                             @ApiParam(name="endDate", value="结束时间") @RequestParam(required = false)String endDate,
                                             @ApiParam(name="type", value="1.按日,2.按周,3.按月") @RequestParam(required = false)String type){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionCostAvgLine(level,area,disease,startDate,endDate,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionCostLowLevel")
    @ResponseBody
    @ApiOperation("费用统计-下部列表接口")
    public String getPrescriptionCostLowLevel(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                              @ApiParam(name="lowlevel", value="第二级别") @RequestParam(required = true)String lowlevel,
                                              @ApiParam(name="area", value="级别编码") @RequestParam(required = true)String area,
                                              @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease,
                                              @ApiParam(name="type", value="1.总量,2.平均值")@RequestParam(required =true)String type){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionCostLowLevel(level,lowlevel,area,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionDispatchingTotal")
    @ResponseBody
    @ApiOperation("配送统计-头部总数接口")
    public String getPrescriptionDispatchingTotal(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                                  @ApiParam(name="area", value="级别编码") @RequestParam(required = true)String area,
                                                  @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionDispatchingTotal(level,area,disease));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionDispatchingHistogram")
    @ResponseBody
    @ApiOperation("配送统计-中部条形图")
    public String getPrescriptionDispatchingHistogram(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                                      @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){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionDispatchingHistogram(level,area,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionDispatchingLowLevel")
    @ResponseBody
    @ApiOperation("配送统计-下部条形图")
    public String getPrescriptionDispatchingLowLevel(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                                     @ApiParam(name="lowlevel", value="第二级别") @RequestParam(required = true)String lowlevel,
                                                     @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){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionDispatchingLowLevel(level,lowlevel,area,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}