Quellcode durchsuchen

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

humingfen vor 7 Jahren
Ursprung
Commit
2ecb8227ef
21 geänderte Dateien mit 648 neuen und 70 gelöschten Zeilen
  1. 146 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/imm/ChildImmuneVaccin.java
  2. 5 5
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/MysqlToEsQuotaJob.java
  3. 133 5
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  4. 16 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java
  5. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/PatientInfoService.java
  6. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceLogService.java
  7. 3 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java
  8. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/CreditLogService.java
  9. 29 16
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/TaskService.java
  10. 31 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  11. 54 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  12. 31 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java
  13. 7 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/WeiXinCoreService.java
  14. 6 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java
  15. 77 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java
  16. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  17. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java
  18. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  19. 82 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/bank/CreditsLogController.java
  20. 2 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/bank/TaskController.java
  21. 2 1
      patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

+ 146 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/imm/ChildImmuneVaccin.java

@ -0,0 +1,146 @@
package com.yihu.wlyy.entity.imm;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 儿童可预约疫苗
 * @author huangwenjie
 * @date 2018/6/21 08:24
 */
@Entity
@Table(name = "wlyy_child_immune_vaccin")
public class ChildImmuneVaccin extends IdEntity {
	private String code;
	private String name;                    //儿童姓名
	private String idcard;                  //儿童身份证号
	private String ssc;                     //儿童社保卡号
	private String barcode;                 //儿童免疫条码
	private String ymkc;                    //true:可约,false:不可约
	private String ymmc;                    //疫苗名称
	private String ymkcsm;                  //疫苗库存说明(库存充足,可以预约/库存不足,不能预约)
	private String ymbm;                    //疫苗编码
	private String jzzc;                    //接种针次
	private Integer alert_tag;              //0待提醒,1已提醒
	private Date alert_time;                //提醒时间
	private Date create_time;               //创建时间
	private Date update_time;               //创建时间
	
	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getIdcard() {
		return idcard;
	}
	
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	
	public String getSsc() {
		return ssc;
	}
	
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	
	public String getBarcode() {
		return barcode;
	}
	
	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}
	
	public String getYmkc() {
		return ymkc;
	}
	
	public void setYmkc(String ymkc) {
		this.ymkc = ymkc;
	}
	
	public String getYmmc() {
		return ymmc;
	}
	
	public void setYmmc(String ymmc) {
		this.ymmc = ymmc;
	}
	
	public String getYmkcsm() {
		return ymkcsm;
	}
	
	public void setYmkcsm(String ymkcsm) {
		this.ymkcsm = ymkcsm;
	}
	
	public String getYmbm() {
		return ymbm;
	}
	
	public void setYmbm(String ymbm) {
		this.ymbm = ymbm;
	}
	
	public String getJzzc() {
		return jzzc;
	}
	
	public void setJzzc(String jzzc) {
		this.jzzc = jzzc;
	}
	
	public Integer getAlert_tag() {
		return alert_tag;
	}
	
	public void setAlert_tag(Integer alert_tag) {
		this.alert_tag = alert_tag;
	}
	
	public Date getCreate_time() {
		return create_time;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public void setCreate_time(Date create_time) {
		this.create_time = create_time;
	}
	
	public Date getUpdate_time() {
		return update_time;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public void setUpdate_time(Date update_time) {
		this.update_time = update_time;
	}
	
	public Date getAlert_time() {
		return alert_time;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public void setAlert_time(Date alert_time) {
		this.alert_time = alert_time;
	}
}

+ 5 - 5
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/job/business/MysqlToEsQuotaJob.java

@ -63,7 +63,7 @@ public class MysqlToEsQuotaJob implements Job {
    private String year;//要统计的年份
    private Date quotaDate;//统计的时间
    private String timeLevel;//1 日 2年
    private Integer incrementInterval;//增量的时间间隔(天)
    private String incrementInterval;//增量的时间间隔(天)
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
@ -108,7 +108,7 @@ public class MysqlToEsQuotaJob implements Job {
        this.timeLevel = map.getString("timeLevel");
        this.endTime = map.getString("endTime");
        this.startTime = map.getString("startTime");
        this.incrementInterval = (Integer) map.get("incrementInterval");
        this.incrementInterval = map.get("incrementInterval")!=null?String.valueOf(map.get("incrementInterval")):"1";
        //为空默认是统计昨天的数据  统计昨天的数据是从 前天的下午17:00:00 到昨天的下午17:00:00
        //初始化结束时间
        if (StringUtils.isEmpty(endTime)) {
@ -332,12 +332,12 @@ public class MysqlToEsQuotaJob implements Job {
    public void getStartTime() throws Exception{
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        if(this.incrementInterval==1){//日
        if("1".equals(this.incrementInterval)){//日
            startTime = new LocalDate(new DateTime().minusDays(2)).toString("yyyy-MM-dd") + " 17:00:00";
        }else if(this.incrementInterval==2){//周
        }else if("2".equals(this.incrementInterval)){//周
            Date monday = DateUtil.getMondayOfThisDayToDate(sf.parse(endTime));
            startTime =sf.format(monday)+ " 17:00:00";
        }else if(this.incrementInterval==3){//月
        }else if("3".equals(this.incrementInterval)){//月
            Date fristDay = DateUtil.getFristDayOfMonthToDate(sf.parse(endTime));
            startTime = sf.format(fristDay)+ " 17:00:00";
        }

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

@ -110,6 +110,7 @@ public class JobService {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("jobConfig", wlyyJobConfigVO.getId());
        params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
        if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
            for (int j = 1; j <= 2; j++) {
                if (breakPoint(wlyyJobConfigVO, j)) continue;
@ -129,6 +130,7 @@ public class JobService {
        Map<String, String> params = new HashMap<String, String>();
        params.put("jobConfig", wlyyJobConfigVO.getId());
        params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
        for (int i = 1; i <= 2; i++) {
            if (breakPoint(wlyyJobConfigVO, i)) continue;
            params.put("timeLevel", i + "");
@ -141,6 +143,10 @@ public class JobService {
    }
    private boolean breakPoint(WlyyJobConfigVO wlyyJobConfigVO, int i) {
        //该方法使用于每日统计
        if(wlyyJobConfigVO.getIncrementInterval()!=1){
            return true;
        }
        //如果为空或者等3说明纪要生成到达量也要生成增量
        if (StringUtils.isEmpty(wlyyJobConfigVO.getTimeLevel()) || Integer.valueOf(wlyyJobConfigVO.getTimeLevel()) == 3) {
            return false;
@ -149,13 +155,14 @@ public class JobService {
        if (!(StringUtils.isEmpty(wlyyJobConfigVO.getTimeLevel())) && Integer.valueOf(wlyyJobConfigVO.getTimeLevel()) == i) {
            return false;
        }
        if(wlyyJobConfigVO.getIncrementInterval()!=1){
            return true;
        }
        return true;
    }
    private boolean breakPoint(QuartzJobConfig wlyyJobConfigVO, int i) {
        //该方法使用于每日统计
        if(wlyyJobConfigVO.getIncrementInterval()!=1){
            return true;
        }
        //如果为空或者等3说明纪要生成到达量也要生成增量
        if (StringUtils.isEmpty(wlyyJobConfigVO.getTimeLevel()) || Integer.valueOf(wlyyJobConfigVO.getTimeLevel()) == 3) {
            return false;
@ -176,6 +183,7 @@ public class JobService {
            Map<String, String> params = new HashMap<String, String>();
            params.put("jobConfig", wlyyJobConfigVO.getId());
            params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
            for (int i = 1; i <= day; i++) {
                for (int j = 1; j <= 2; j++) {
                    if (breakPoint(wlyyJobConfigVO, j)) continue;
@ -220,6 +228,7 @@ public class JobService {
            Map<String, String> params = new HashMap<String, String>();
            params.put("jobConfig", wlyyJobConfigVO.getId());
            params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
            //往quartz框架添加任务
            params.put("startTime", daybefore);
            params.put("endTime", yesterday);
@ -266,7 +275,7 @@ public class JobService {
        Map<String, String> params = new HashMap<String, String>();
        params.put("jobConfig", wlyyJobConfigVO.getId());
        params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
        //往quartz框架添加任务
        params.put("startTime", daybefore);
        params.put("endTime", yesterday);
@ -292,6 +301,7 @@ public class JobService {
        Map<String, String> params = new HashMap<String, String>();
        params.put("jobConfig", wlyyJobConfigVO.getId());
        params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
        for (int i = 1; i <= day; i++) {
            //往quartz框架添加任务
            params.put("startTime", getYesterday(0 - i - 1));
@ -400,7 +410,7 @@ public class JobService {
        Map<String, String> params = new HashMap<String, String>();
        params.put("jobConfig", wlyyJobConfigVO.getId());
        params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
        //往quartz框架添加任务
        params.put("startTime", daybefore);
        params.put("endTime", yesterday);
@ -436,6 +446,7 @@ public class JobService {
            Map<String, String> params = new HashMap<String, String>();
            params.put("jobConfig", wlyyJobConfigVO.getId());
            params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
            //往quartz框架添加任务
            params.put("startTime", daybefore);
            params.put("endTime", yesterday);
@ -467,4 +478,121 @@ public class JobService {
            throw new Exception("已经停止");
        }
    }
    /**************************************按周或按月****************************************/
    public void productWeekByDayToDay(String start, String end,String id) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startDate = sdf.parse(start);
        Date endDate = sdf.parse(end);
        if (startDate.after(endDate)) {
            throw new Exception("日期参数错误");
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startDate);
        int a = calendar.get(Calendar.YEAR);
        calendar.clear();
        calendar.setTime(endDate);
        int b = calendar.get(Calendar.YEAR);
        int startWeek = DateUtil.week(startDate);
        if(a!=b){
            Date lastDate = DateUtil.getYearLast(a);
            int lastWeek = DateUtil.week(lastDate);
            for(int i=startWeek;i<=lastWeek;i++){
                start = getDate(startDate ,i,2);
                end = getDate(startDate ,i+1,1);
                productDataByOneDay2(start,end,2,id);
            }
            startDate =lastDate;
        }
        startWeek = DateUtil.week(startDate);
        int endWeek = DateUtil.week(endDate);
        for(int i=startWeek;i<=endWeek;i++){
            start = getDate(startDate ,i,2);
            end = getDate(startDate ,i+1,1);
            productDataByOneDay2(start,end,2,id);
        }
    }
    public void productMonthByDayToDay(String start, String end,String id) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startDate = sdf.parse(start);
        Date endDate = sdf.parse(end);
        if (startDate.after(endDate)) {
            throw new Exception("日期参数错误");
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startDate);
        int a = calendar.get(Calendar.YEAR);
        int a1 = calendar.get(Calendar.MONTH);
        calendar.clear();
        calendar.setTime(endDate);
        int b = calendar.get(Calendar.YEAR);
        int b1 = calendar.get(Calendar.MONTH);
        if(a!=b){
            for(int i=a1;i<=12;i++){
//            start = getDate(startDate ,i,1)+" 00:00:00";
//            end = getDate(startDate ,i,7)+" 59:59:59";
                start = DateUtil.getFristDayOfMonth(startDate);
                end = DateUtil.getLastDayOfMonth(startDate);
                productDataByOneDay2(start,end,3,id);
            }
            a1=1;
            calendar.clear();
            calendar.set(Calendar.YEAR, b);
            startDate = calendar.getTime();
        }
        for(int i=a1;i<=b1;i++){
            start = DateUtil.getFristDayOfMonth(startDate);
            end = DateUtil.getLastDayOfMonth(startDate);
            productDataByOneDay2(start,end,3,id);
        }
    }
    public void productDataByOneDay2(String start, String end,Integer incrementInterval,String id) throws Exception {
        String condition = "";
        if(!StringUtils.isEmpty(id)){
            condition+=" and a.id in ("+id+") ";
        }
        if(incrementInterval!=null){
            condition +=" and a.increment_interval ="+incrementInterval.intValue();
        }
        String sql = "select * from wlyy_job_config_new a where  a.del='1' and a.id !=11 "+condition+" order by a.id asc";
        List<QuartzJobConfig> quartzJobConfigs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(QuartzJobConfig.class));
        for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
            WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
            BeanUtils.copyProperties(quartzJobConfig, wlyyJobConfigVO);
            Map<String, String> params = new HashMap<String, String>();
            params.put("jobConfig", wlyyJobConfigVO.getId());
            params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
            //往quartz框架添加任务
            params.put("startTime", start);
            params.put("endTime", end);
            for (int j = 1; j <= 2; j++) {
//                if (Integer.valueOf(wlyyJobConfigVO.getId()) > 86 && j == 2) continue;
                params.put("timeLevel", j + "");
                if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                    quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                    Thread.sleep(sleepTime);
                }
            }
        }
    }
    public String getDate(Date date ,int weekNum,int day){
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.WEEK_OF_YEAR, weekNum); // 设置为2016年的第10周
        cal.set(Calendar.DAY_OF_WEEK, day); // 1表示周日,2表示周一,7表示周六
        return sf.format(cal.getTime());
    }
}

+ 16 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/imm/ChildImmuneVaccinDao.java

@ -0,0 +1,16 @@
package com.yihu.wlyy.repository.imm;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author huangwenjie
 * @date 2018/6/21 09:38
 */
public interface ChildImmuneVaccinDao extends PagingAndSortingRepository<ChildImmuneVaccin, Long>,
		JpaSpecificationExecutor<ChildImmuneVaccin> {
	@Query("select p from ChildImmuneVaccin p where p.barcode=?1")
	ChildImmuneVaccin getChildImmuneVaccinByBarcode(String barcode);
}

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

@ -1751,7 +1751,11 @@ public class PatientInfoService extends BaseService {
       /* String sql = "SELECT p.code,p.name,CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' END sex,p.idcard,f.doctor_name" +
                " FROM wlyy_patient p  LEFT JOIN wlyy_sign_family f ON p.code = f.patient" +
                " WHERE f.status = 1 AND p.name LIKE '%"+keyWord+"%' OR p.idcard LIKE '%"+keyWord+"%' and f.hospital = '"+hospital+"'"+" limit ?,?";*/
        String sql ="SELECT f.patient as code,f.name,f.idcard,f.doctor_name FROM wlyy_sign_family f where f.status > 0 AND f.hospital = '"+hospital+"' AND f.name LIKE '%"+keyWord+"%' OR f.idcard LIKE '%"+keyWord+"%' limit ?,?";
        String sql ="SELECT f.patient as code,f.name,f.idcard,f.doctor_name FROM wlyy_sign_family f where f.status > 0 AND f.hospital = '"+hospital+"' " ;
        if (StringUtils.isNotEmpty(keyWord)){
            sql +=  "AND f.name LIKE '%"+keyWord+"%' OR f.idcard LIKE '%"+keyWord+"%'";
        }
        sql += " limit ?,?";
        patientList = jdbcTemplate.queryForList(sql ,new Object[]{start,pageSize});
        String patientDeviceSql = "SELECT user as patientCode FROM wlyy_patient_device WHERE device_sn='"+deviceSn+"'";

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/device/PatientDeviceLogService.java

@ -74,7 +74,7 @@ public class PatientDeviceLogService extends BaseService {
                "  SELECT sf.name, pd.* FROM wlyy_patient_device_log pd" +
                "  LEFT JOIN wlyy_sign_family sf ON pd.patient = sf.patient" +
                "  WHERE" +
                "   pd.is_del = 1 and sf.doctor= '" +doctor+"'"+
                "   pd.is_del = 1 and (sf.doctor= '" +doctor+"' or sf.doctor_health = '"+doctor+"')"+
                "  ORDER BY" +
                "  create_time DESC) a" +
                " GROUP BY a.device_sn) b" +

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java

@ -180,6 +180,7 @@ public class PatientHealthGuidanceService extends BaseService {
			Date currentTime = new Date();
			long h24 = 60*60*24;
			for(Map<String, Object> one :list){
				if((Integer)one.get("manage_result")==1||(Integer)one.get("manage_result")==2)continue;
				String tempSql="";
				Date temp =(Date)one.get("czrq");
				if(currentTime.getTime()-temp.getTime()>h24){//有效干预
@ -189,6 +190,8 @@ public class PatientHealthGuidanceService extends BaseService {
				}
				jdbcTemplate.execute(tempSql);
			}
			String tempSql="update wlyy.wlyy_message a set a.has_read = 0,a.over='0' where a.tz_code in ("+tzCode+") and a.type=2 ";
			jdbcTemplate.execute(tempSql);
		}
		return guidance;

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/CreditLogService.java

@ -311,7 +311,7 @@ public class CreditLogService {
            response = httpClientUtil.httpPost(url,params);
            object1 = JSONObject.parseObject(response);
            JSONArray array = object1.getJSONArray("detailModelList");
            for (int i = 0;i<array.size();i++){
            for (int i = 0;array != null && i<array.size();i++){
                JSONObject object2 = array.getJSONObject(i);
                String patientId = object2.getString("patientId");
                Patient patient = patientDao.findByCode(patientId);

+ 29 - 16
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/bank/TaskService.java

@ -5,8 +5,10 @@ package com.yihu.wlyy.service.app.health.bank;/**
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -17,6 +19,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -44,6 +47,8 @@ public class TaskService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private PatientFamilyMemberDao patientFamilyMemberDao;
    /**
@ -117,10 +122,14 @@ public class TaskService {
     * @param object 参加任务JSON
     * @return
     */
    public JSONObject attendTask(JSONObject object){
    public JSONObject attendTask(JSONObject object) throws Exception {
        String response = null;
        Patient patient = patientDao.findByCode(object.getString("patientId"));
        String unionId = "1";
        Patient patient1 = patientDao.findByUnionid(unionId);
        if (patient1 != null){
            throw new Exception("该居民已报过名!");
        }
        patient.setUnionid(unionId);
        patientDao.save(patient);
        object.put("unionId",unionId);
@ -142,26 +151,30 @@ public class TaskService {
     *
     * @param openId 微信id
     *
     * @param page 页码
     *
     * @param size 分页大小
     *
     * @return
     */
    public JSONObject selectByOpenId(String openId, Integer page,Integer size){
        String sql = "select * from wlyy_patient where openid = '"+ openId +"' LIMIT "+(page-1)*size+","+size;
        List<Patient> patientList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(Patient.class));
        String sqlcount = "select * from wlyy_patient where openid = '"+ openId +"'";
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlcount);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
            count = (Long) rstotal.get(0).get("total");
    public JSONObject selectByOpenId(String openId,String code){
        String sql = "select * from wlyy_patient where code = '"+code+"' and openid = '"+openId+"'";
        List<Patient> patients = jdbcTemplate.query(sql,new BeanPropertyRowMapper(Patient.class));
        Patient patient = new Patient();
        if (patients != null && patients.size()!=0){
            patient = patients.get(0);
        }
        List<Patient> patientList = new ArrayList<>();
        JSONObject object = new JSONObject();
        object.put("patientList",patientList);
        object.put("total",count);
        object.put("page",page);
        object.put("size",size);
        if (patient != null){
            patientList.add(patient);
            List<PatientFamilyMember> patientFamilyMemberList = patientFamilyMemberDao.findByPatient(patient.getCode());
            for (PatientFamilyMember patientFamilyMember:patientFamilyMemberList){
                Patient patient1 = patientDao.findByCode(patientFamilyMember.getFamilyMember());
                patientList.add(patient1);
            }
            object.put("patientList",patientList);
            object.put("total",patientFamilyMemberList.size());
            object.put("page",1);
            object.put("size",100);
        }
        return object;
    }
}

+ 31 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -983,16 +983,38 @@ public class PatientPrescriptionPayService extends BaseService {
                        Date dt = com.yihu.wlyy.util.DateUtil.stringToDate(deliveryTime, "yyyy-MM-dd");
                        expressage.setDeliveryTime(dt);
                    }
                    //根据居民code查询团队长及所在团队待处理订单数量
                    String sql = "SELECT a.id teamCode,a.leader_code leaderCode,d.`name` leaderName " +
                            " FROM wlyy_sign_family t,wlyy_admin_team a,wlyy_doctor d " +
                            " WHERE t.`status`=1 AND t.admin_team_code=a.id AND d.code=a.leader_code " +
                            " AND t.patient=? ";
                    Map<String, Object> team = jdbcTemplate.queryForMap(sql, people);
                    //1.4.8 加入签约过期逻辑处理,确保签约过期以后支付可以成功
                    String teamCode;
                    String leaderCode;
                    String leaderName;
                    try{
                        //根据居民code查询团队长及所在团队待处理订单数量
                        String sql = "SELECT a.id teamCode,a.leader_code leaderCode,d.`name` leaderName " +
                                " FROM wlyy_sign_family t,wlyy_admin_team a,wlyy_doctor d " +
                                " WHERE t.`status`=1 AND t.admin_team_code=a.id AND d.code=a.leader_code " +
                                " AND t.patient=? ";
                        Map<String, Object> team = jdbcTemplate.queryForMap(sql, people);
                        if(team!=null){
                            teamCode = team.get("teamCode").toString();
                            leaderCode = team.get("leaderCode").toString();
                            leaderName = team.get("leaderName").toString();
                        }else {
                            //取历史处方的信息
                            teamCode = prescription.getAdminTeamId()+"";
                            leaderCode = prescription.getDoctor();
                            leaderName = prescription.getDoctorName();
                        }
                    }catch (Exception e){
                        //因签约过期引起的异常处理
                        //取历史处方的信息
                        teamCode = prescription.getAdminTeamId()+"";
                        leaderCode = prescription.getDoctor();
                        leaderName = prescription.getDoctorName();
                    }
                    logger.debug("================> get order amount!");
                    String teamCode = team.get("teamCode").toString();
                    String leaderCode = team.get("leaderCode").toString();
                    String leaderName = team.get("leaderName").toString();
                    String count = infoService.getCountExpressage(teamCode).toString();
                    JSONObject jsonObject = new JSONObject();
                    jsonObject = JSON.parseObject(count);

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

@ -940,6 +940,18 @@ public class StatisticsESService {
            saveModels = elasticsearchUtil.findLineChartDateQuotaLevel0(startDate, endDate, area, level, index, timelevel, SaveModel.interval_day);
        }
        List<JSONObject> result = new ArrayList<>();
//        if (saveModels != null && saveModels.size() >0) {
            List<Map<String, Object>> resultList = DateUtil.findDates(dateFormat.parse(startDate), dateFormat.parse(DateUtil.getNextDay(endDate, 1)));
//            result.clear();
            for (Map<String, Object> one : resultList) {
                JSONObject json = new JSONObject();
                json.put("range", one.get("date"));
                json.put("amount", 0);
                result.add(json);
            }
//        }
        if (saveModels != null) {
            // 计算结果
            for (SaveModel saveModel : saveModels) {
@ -949,20 +961,40 @@ public class StatisticsESService {
                    range = df.format(saveModel.getQuotaDate());
                }
                long amount = saveModel.getResult2().longValue();
                json.put("range", range);
                json.put("amount", amount);
                result.add(json);
            }
            if (saveModels != null && saveModels.size() == 1 && saveModels.get(0).getHospital() == null) {
                List<Map<String, Object>> resultList = DateUtil.findDates(dateFormat.parse(startDate), dateFormat.parse(DateUtil.getNextDay(endDate, 1)));
                result.clear();
                for (Map<String, Object> map : resultList) {
                    JSONObject json = new JSONObject();
                    json.put("range", map.get("date"));
                    json.put("amount", 0);
                    result.add(json);
                for(JSONObject obj : result){
                    if((obj.get("range")+"").equals(range)){
                        obj.put("amount", amount);
                    }
                }
//                json.put("range", range);
//                json.put("amount", amount);
//                result.add(json);
            }
//            if (saveModels != null && saveModels.size() == 1 && saveModels.get(0).getHospital() == null) {
//                List<Map<String, Object>> resultList = DateUtil.findDates(dateFormat.parse(startDate), dateFormat.parse(DateUtil.getNextDay(endDate, 1)));
//                result.clear();
//                for (Map<String, Object> map : resultList) {
//                    JSONObject json = new JSONObject();
//                    json.put("range", map.get("date"));
//                    json.put("amount", 0);
//                    result.add(json);
//                }
//            }
//            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
//            Date startDate1 = sf.parse(startDate);
//            Date endDate1 = sf.parse(endDate);
//            long days = DateUtil.getDays(startDate1,endDate1);
//            Calendar calendar = Calendar.getInstance();
//            calendar.setTime(startDate1);
//            List<JSONObject> resultTemp = new ArrayList<>();
//            for(int i=1;i<=days;i++){
//                calendar.add(calendar.DATE,i);//把日期往后增加一天.整数往后推,负数往前移动
//                String dateString = sf.format(calendar.getTime());
//                Map<String, Object> map = new HashMap<>();
//                map.put("range",sf.format(calendar.getTime()));
//                map.put()
//            }
            // 排序
            result.sort(new Comparator<JSONObject>() {
@ -5435,9 +5467,16 @@ public class StatisticsESService {
        //居民活跃统计
//        resultMap.put("activityPatientRange",df.format(participantCount > 0.0 ? ((participantCount) / (allCount * 1.0000) * 100) : 0.0) + "%");//已报名
        resultMap.put("participantRange",df.format(participantCount > 0.0 ? ((participantCount) / (applyCount * 1.0000) * 100) : 0.0) + "%");//已参与
        resultMap.put("creditsRange",df.format(creditsCount > 0.0 ? ((creditsCount) / (applyCount * 1.0000) * 100) : 0.0) + "%");//已获取积分
        resultMap.put("expiryRange","0%");//已兑奖
        if(applyCount>0){
            resultMap.put("participantRange",df.format(participantCount > 0.0 ? ((participantCount) / (applyCount * 1.0000) * 100) : 0.0) + "%");//已参与
            resultMap.put("creditsRange",df.format(creditsCount > 0.0 ? ((creditsCount) / (applyCount * 1.0000) * 100) : 0.0) + "%");//已获取积分
            resultMap.put("expiryRange","0%");//已兑奖
        }else{
            resultMap.put("participantRange","0%");//已参与
            resultMap.put("creditsRange","0%");//已获取积分
            resultMap.put("expiryRange","0%");//已兑奖
        }
        return resultMap;
    }

+ 31 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java

@ -1,8 +1,10 @@
package com.yihu.wlyy.service.imm;
import com.yihu.wlyy.entity.imm.ChildFamilyImmune;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import com.yihu.wlyy.entity.imm.ChildInfo;
import com.yihu.wlyy.repository.imm.ChildFamilyImmuneDao;
import com.yihu.wlyy.repository.imm.ChildImmuneVaccinDao;
import com.yihu.wlyy.repository.imm.ChildInfoDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang.StringUtils;
@ -32,6 +34,8 @@ public class ChildFamilyImmuneService extends BaseService {
	private ChildInfoDao childInfoDao;
	@Autowired
	JdbcTemplate jdbcTemplate;
	@Autowired
	private ChildImmuneVaccinDao childImmuneVaccinDao;
	
	/**
	 * 绑定家庭成员免疫关系
@ -89,4 +93,31 @@ public class ChildFamilyImmuneService extends BaseService {
		List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
		return rs;
	}
	
	/**
	 * 获取签约居民待接种疫苗列表
	 * @param doctorcode
	 * @return
	 */
	public List<Map<String,Object>> getImmVaccinList(String doctorcode) {
		String sql = "select t.*,m.family_name,m.child_name,m.birthday from wlyy_child_immune_vaccin t " +
				" inner join ( " +
				" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday from  wlyy_child_family_immune a " +
				" inner join (select patient,name from wlyy_sign_family where type in (1,2) and `status` = 1 and expenses_status = 1 and doctor = '"+doctorcode+"') b " +
				" on a.family_code = b.patient " +
				" left join wlyy_child_info c on c.`code` = a.child_code " +
				") m on m.barcode = t.barcode ";
		
		List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
		return rs;
	}
	
	/**
	 * 根据免疫条码获取待接种免疫记录
	 * @param barcode
	 * @return
	 */
	public ChildImmuneVaccin getChildImmuneVaccinByBarcode(String barcode){
		return childImmuneVaccinDao.getChildImmuneVaccinByBarcode(barcode);
	}
}

+ 7 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/WeiXinCoreService.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.service.weixin;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.process.WeiXinEventProcess;
import com.yihu.wlyy.wechat.util.WeiXinMessageUtils;
import org.dom4j.Document;
@ -12,6 +13,8 @@ import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -28,6 +31,7 @@ import java.util.Map;
 */
@Service
public class WeiXinCoreService extends BaseService {
    private Logger logger= LoggerFactory.getLogger(WeiXinCoreService.class);
    @Autowired
    private WeiXinEventProcess weiXinEventProcess;
@ -58,7 +62,7 @@ public class WeiXinCoreService extends BaseService {
                Element ele = (Element) e;
                message.put(ele.getName(), ele.getText());
            }
            System.out.println("weixin  event:" + message.toString());
            logger.info("weixin  event:" + message.toString());
            // 释放资源
            inputStream.close();
            // 添加access_token参数
@ -91,9 +95,9 @@ public class WeiXinCoreService extends BaseService {
                String content = message.get("Content");
                if ("续签".equals(content)){
//                      发送续签和签约图文消息
                    System.out.print("content======? "+content);
                    logger.info("content======? "+content);
                    result = weiXinEventProcess.replyKeyword(message);
                    System.out.print("图文结束======? ");
                    logger.info("图文结束======? ");
                }
                break;
            default:

+ 6 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -8,9 +8,11 @@ import com.yihu.wlyy.entity.device.vo.DeviceWxMessageDTO;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDeviceDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.device.DeviceDetailService;
import com.yihu.wlyy.service.app.device.DeviceWxMessageService;
@ -87,6 +89,8 @@ public class DoctorDeviceController extends BaseController {
	private DeviceWxMessageService deviceWxMessageService;
	@Autowired
	private PatientDeviceDao patientDeviceDao;
	@Autowired
	private SignFamilyDao signFamilyDao;
	@Autowired
	private JmsTemplate jmsTemplate;
@ -144,8 +148,9 @@ public class DoctorDeviceController extends BaseController {
			//修改设备表中{"1":"0", "2":"0"}绑定次数 和其他绑定信息,
			deviceDetailService.updateAfterBinding(device,new Date(),flag);
			Patient patient = patientDao.findByCode(device.getUser());
			SignFamily signFamily = signFamilyDao.findSignByPatient(patient.getCode(),2);
			//调用增加积分接口  海沧区的居民才能添加积分
			if (flag && "350205".equals(patient.getTown())){
			if (flag && "350205".equals(signFamily.getHospital().substring(0,6))){
				String flagStr ="";
				if ("1".equals(device.getCategoryCode())){
					flagStr="GLU_BIND";

+ 77 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.doctor.imm;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import com.yihu.wlyy.entity.imm.ChildInfoVO;
import com.yihu.wlyy.service.imm.ChildFamilyImmuneService;
import com.yihu.wlyy.service.imm.ChildInfoService;
@ -7,6 +8,7 @@ import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -77,4 +79,79 @@ public class DoctorImmController extends BaseController {
			return error(-1, e.getMessage());
		}
	}
	
	@RequestMapping(value = "/getImmVaccinList", method = RequestMethod.GET)
	@ApiOperation(value = "获取签约居民待接种疫苗列表")
	public String getImmVaccinList(@ApiParam(name = "doctorcode", value = "医生CODE", defaultValue = "")
	                               @RequestParam(value = "doctorcode", required = false) String doctorcode){
		
		try {
			
			if(StringUtils.isBlank(doctorcode)){
				doctorcode = getUID();
			}
			
			List<Map<String, Object>> immrs = childFamilyImmuneService.getImmVaccinList(doctorcode);
			JSONArray jsonArray = new JSONArray();
			if (immrs != null) {
				for (Map<String, Object> map : immrs) {
					JSONObject json = new JSONObject();
					json.put("child_code", map.get("child_code"));//儿童编码
					json.put("name", map.get("name"));//儿童姓名
					json.put("photo", map.get("photo"));//头像
					json.put("idcard", map.get("idcard"));//新生儿身份证号
					json.put("barcode", map.get("barcode"));//新生儿条码
					json.put("family_code", map.get("family_code"));//家人CODE
					json.put("relation", map.get("relation"));//---1父亲 2母亲 3老公 4老婆 5儿子 6女儿 7其他
					json.put("del", map.get("del"));//0为有效,1为删除状态
					jsonArray.put(json);
				}
			}
			return write(200, "查询成功", "data", jsonArray);
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	@RequestMapping(value = "/alertImmVacclinByDoctor", method = RequestMethod.POST)
	@ApiOperation(value = "医生批量提醒待接种疫苗接种")
	public String alertImmVacclinByDoctor(@ApiParam(name = "doctorcode", value = "医生CODE", defaultValue = "")
	                                      @RequestParam(value = "doctorcode", required = true) String doctorcode){
		try {
			// TODO: 2018/6/21
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	
	@RequestMapping(value = "/alertImmVacclinByPatient", method = RequestMethod.POST)
	@ApiOperation(value = "医生提醒单个居民疫苗接种")
	public String alertImmVacclinByPatient(@ApiParam(name = "code", value = "待接种记录CODE", defaultValue = "")
	                                      @RequestParam(value = "待接种记录CODE", required = true) String code){
		try {
			// TODO: 2018/6/21
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	
	@RequestMapping(value = "/getPatientImmVacclin", method = RequestMethod.GET)
	@ApiOperation(value = "根据儿童免疫条码获取待接种疫苗")
	public String getPatientImmVacclin(@ApiParam(name = "barcode", value = "儿童免疫编码", defaultValue = "")
	                                       @RequestParam(value = "儿童免疫编码", required = true) String barcode){
		try {
			ChildImmuneVaccin childImmuneVaccin = childFamilyImmuneService.getChildImmuneVaccinByBarcode(barcode);
			return write(200, "请求成功","data",childImmuneVaccin);
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	
	
}

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

@ -528,7 +528,7 @@ public class PatientInfoController extends BaseController {
    @RequestMapping(value = "/getPatientSignByNameOrIdCard",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("在绑定设备的时候查找患者(带签约信息)")
    public String getPatientSignByNameOrIdCard(@ApiParam(value = "关键搜索词", name = "keyWord") @RequestParam(value = "keyWord",required = true)String keyWord,
    public String getPatientSignByNameOrIdCard(@ApiParam(value = "关键搜索词", name = "keyWord") @RequestParam(value = "keyWord",required = false)String keyWord,
                                               @ApiParam(value = "设备sn码", name = "deviceSn") @RequestParam(value = "deviceSn",required = true)String deviceSn,
                                               @ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page,
                                               @ApiParam(name="pageSize",value="",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize){

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/device/PatientDeviceController.java

@ -236,7 +236,8 @@ public class PatientDeviceController extends BaseController {
            }
            //修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息
            deviceDetailService.updateAfterBinding(device,new Date(),flag);
            if (flag && "350205".equals(patient.getTown())){
            SignFamily signFamily = signFamilyDao.findSignByPatient(patient.getCode());
            if (flag && "350205".equals(signFamily.getHospital().substring(0,6))){
                String flagStr ="";
                if ("1".equals(device.getCategoryCode())){
                    flagStr="GLU_BIND";

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.patient.family;
import com.yihu.wlyy.entity.imm.ChildImmuneVaccin;
import com.yihu.wlyy.entity.imm.ChildInfo;
import com.yihu.wlyy.entity.imm.ChildInfoVO;
import com.yihu.wlyy.entity.patient.Patient;
@ -543,4 +544,17 @@ public class FamilyMemberController extends WeixinBaseController {
            return error(-1, e.getMessage());
        }
    }
    
    @RequestMapping(value = "/getPatientImmVacclin", method = RequestMethod.GET)
    @ApiOperation(value = "根据儿童免疫条码获取待接种疫苗")
    public String getPatientImmVacclin(@ApiParam(name = "barcode", value = "儿童免疫编码", defaultValue = "")
                                       @RequestParam(value = "儿童免疫编码", required = true) String barcode){
        try {
            ChildImmuneVaccin childImmuneVaccin = childFamilyImmuneService.getChildImmuneVaccinByBarcode(barcode);
            return write(200, "请求成功","data",childImmuneVaccin);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 82 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/bank/CreditsLogController.java

@ -4,8 +4,15 @@
package com.yihu.wlyy.web.patient.health.bank;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.app.health.bank.CreditLogService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -18,6 +25,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-05-07 8:50
@ -31,6 +41,14 @@ public class CreditsLogController extends BaseController {
    @Autowired
    private CreditLogService service;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    /**
@ -66,11 +84,73 @@ public class CreditsLogController extends BaseController {
     */
    @RequestMapping(value = "/insertCredits",method = RequestMethod.POST)
    @ApiOperation("添加积分")
    public String insert(@ApiParam(name = "creditsDetail",value = "居民对象JSON")
                          @RequestParam(name = "creditsDetail") String creditsDetail){
    public String insert(@ApiParam(name = "creditsDetail",value = "居民id集合")
                         @RequestParam(name = "creditsDetail") String creditsDetail){
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            JSONObject result = service.insert(object);
            String status = result.getString("status");
            logger.info("健康银行居民新增积分:"+result.toString());
            if ("200".equals(status)){
                List<Map<String,Object>> list = (List<Map<String,Object>>)result.get("detailModelList");
                if (list!=null && list.size()>0){
                    //积分
                    String integrate = String.valueOf(list.get(0).get("integrate"));
                    String patientid = String.valueOf(list.get(0).get("patientId"));
                    String total = String.valueOf(list.get(0).get("total"));
                    try {
                        //@TODO 获取积分调用发送微信模板接口
                        Patient people = patientDao.findByCode(patientid);
                        String openId = people.getOpenid();
                        String name = people.getName();
                        org.json.JSONObject sendJson = new org.json.JSONObject();
                        String first = "";
                        String remark = "";
                        String url = "";
                        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                        first = templateConfig.getFirst();
                        remark = templateConfig.getRemark();
//                    String keyword1 = templateConfig.getKeyword1();
                        sendJson.put("keyword1", integrate);
                        sendJson.put("keyword2", DateUtil.getStringDate());
                        sendJson.put("keyword3", total);
                        sendJson.put("first", first);
                        sendJson.put("remark", remark);
                        url = templateConfig.getUrl();
                        url = url.replace("key1",(integrate==null?"":integrate));
                        sendJson.put("url", url);//带参数的模板跳转链接
                        System.out.println(sendJson.toString());
                        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 23, openId, name, sendJson);
//	                    //发送代理人
//	                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
//	                    if (jsonArray != null && jsonArray.length() > 0) {
//		                    for (int i = 0; i < jsonArray.length(); i++) {
//			                    org.json.JSONObject j = jsonArray.getJSONObject(i);
//			                    Patient member = (Patient) j.get("member");
//			                    int start = url.indexOf("&toUser=");
//			                    int end = url.indexOf("&", start + 1);
//			                    String touser = url.substring(start, end);
//			                    url = url.replace(touser, "&toUser=" + member.getCode());
//			                    //name患者姓名
//			                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
//			                    sendJson.put("url", url);
//			                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
//		                    }
//	                    }
                    }catch (Exception e){
                        logger.info("健康银行居民新增积分,微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
                    }
                }
            }
            return write(200,"添加成功","data",result);
        }catch (Exception e){
            error(e);

+ 2 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/health/bank/TaskController.java

@ -107,20 +107,14 @@ public class TaskController extends BaseController{
    /**
     * 获取用户信息
     *
     * @param page 页码
     *
     * @param size  分页大小
     *
     * @return
     */
    @RequestMapping(value = "/selectByOpenId",method = RequestMethod.POST)
    @ApiOperation("获取用户信息")
    public String selectByOpenId( @ApiParam(name = "page", value = "第几页,从1开始")
                                      @RequestParam(value = "page", defaultValue = "1",required = false)Integer page,
                                  @ApiParam(name = "size",defaultValue = "10",value = ",每页分页大小")
                                      @RequestParam(value = "size", required = false)Integer size){
    public String selectByOpenId(){
        try {
            return write(200,"添加成功","data",service.selectByOpenId(getOpenid(),page,size));
            return write(200,"查询成功","data",service.selectByOpenId(getOpenid(),getUID()));
        }catch (Exception e){
            error(e);
            return error(-1,e.getMessage());

+ 2 - 1
patient-co/patient-co-wlyy/src/main/resources/application-devtest.yml

@ -99,7 +99,8 @@ wechat:
yihu:
  yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
  #yihu_OpenPlatform_url: http://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/
  yihu_OpenPlatform_url: http://58.22.123.195:1480/OpenPlatform/cgiBin/1.0/
  yihu_OpenPlatform_appId: 9000276
  yihu_OpenPlatform_secret: OKC8BS1KGXTDE9GPP1EO4VYLUXF8DJ7QUP72H613ZXA