Selaa lähdekoodia

Merge branch 'dev' of liuwenbin/patient-co-management into dev

chenweida 7 vuotta sitten
vanhempi
commit
a542a7e028

+ 15 - 7
common/common-entity/src/main/java/com/yihu/wlyy/entity/job/QuartzJobConfig.java

@ -27,8 +27,8 @@ public class QuartzJobConfig implements java.io.Serializable {
	private String sqlYear;
	private String cacheKey;//缓存的key
	private String extractType;// 1或者为空:数据库 2ES
	private String timeLevel;//1增量 2到达量 3生成到达量也生成增量
	private Integer incrementInterval; //增量的时间间隔(1天,2周,3月)
    private String timeLevel;//1增量 2到达量 3生成到达量也生成增量
	private String startTime;
@ -201,12 +201,20 @@ public class QuartzJobConfig implements java.io.Serializable {
		this.endTime = endTime;
	}
	@Column(name = "time_level", length = 1)
	public String getTimeLevel() {
		return timeLevel;
	@Column(name = "increment_interval", length = 2)
	public Integer getIncrementInterval() {
		return incrementInterval;
	}
	public void setTimeLevel(String timeLevel) {
		this.timeLevel = timeLevel;
	public void setIncrementInterval(Integer incrementInterval) {
		this.incrementInterval = incrementInterval;
	}
    @Column(name = "time_level", length = 1)
    public String getTimeLevel() {
        return timeLevel;
    }
    public void setTimeLevel(String timeLevel) {
        this.timeLevel = timeLevel;
    }
}

+ 31 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/JobController.java

@ -317,4 +317,35 @@ public class JobController extends BaseController {
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /************************************************************************************/
    /**
     * 生成过去某一天到某一天的全部的数据
     *
     * @param start
     * @param end
     * @return
     */
    @ApiOperation(value = "生成过去某一天到某一天的全部的数据(包含头尾)按周或月统计")
    @RequestMapping(value = "productDataByDayToDay2", method = RequestMethod.GET)
    public String productDataByDayToDay2( @ApiParam(name = "start", value = "yyyy-MM-dd", required = true)@RequestParam(value = "start", required = true)String start,
                                         @ApiParam(name = "end", value = "yyyy-MM-dd", required = true)@RequestParam(value = "end", required = true)String end,
                                          @ApiParam(name = "incrementInterval", value = "2周,3月", required = true)@RequestParam(value = "incrementInterval", required = true)Integer incrementInterval,
                                          @ApiParam(name = "id", value = "指标id,逗号分隔(为空表示全部)", required = false)@RequestParam(value = "id", required = false)String id) {
        try {
            if(incrementInterval==2){
                jobService.productWeekByDayToDay(start,end,id);
            }else if(incrementInterval==3){
                jobService.productMonthByDayToDay(start,end,id);
            }else{
                return success("启动失败!");
            }
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
}

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

@ -6,6 +6,7 @@ import com.yihu.wlyy.statistics.dao.QuartzJobConfigDao;
import com.yihu.wlyy.statistics.dao.SignFamilyDao;
import com.yihu.wlyy.statistics.etl.cache.Cache;
import com.yihu.wlyy.statistics.job.business.CacheCleanJob;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.QuartzHelper;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import org.springframework.beans.BeanUtils;
@ -148,6 +149,9 @@ public class JobService {
        if (!(StringUtils.isEmpty(wlyyJobConfigVO.getTimeLevel())) && Integer.valueOf(wlyyJobConfigVO.getTimeLevel()) == i) {
            return false;
        }
        if(wlyyJobConfigVO.getIncrementInterval()!=1){
            return true;
        }
        return true;
    }

+ 99 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/DateUtil.java

@ -179,7 +179,7 @@ public class DateUtil {
	 * 将短时间格式时间转换为字符串 yyyy-MM-dd
	 *
	 * @param dateDate
	 * @param k
	 * @param
	 * @return
	 */
	public static String dateToStr(Date dateDate, String format) {
@ -717,4 +717,102 @@ public class DateUtil {
		Calendar cal = Calendar.getInstance();
		return cal.get(Calendar.YEAR);
	}
	/**
	 * 获取周一
	 * @return
	 */
	public static String getMondayOfThisDate(Date date) {
		SimpleDateFormat df2 = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
		return df2.format(getMondayOfThisDayToDate(date));
	}
	/**
	 * 获取周一
	 * @return
	 */
	public static Date getMondayOfThisDayToDate(Date date) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
		if (day_of_week == 0)
			day_of_week = 7;
		c.add(Calendar.DATE, -day_of_week + 1);
		return c.getTime();
	}
    /**
     * 得到本周周日
     *
     * @return yyyy-MM-dd
     */
    public static String getSundayOfThisDate(Date date) {
        SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int day_of_week = c.get(Calendar.DAY_OF_WEEK) - 1;
        if (day_of_week == 0)
            day_of_week = 7;
        c.add(Calendar.DATE, -day_of_week + 7);
        return df2.format(c.getTime());
    }
	/**
	 * 获取当月第一天
	 * @return
	 */
	public static String getFristDayOfMonth(Date date) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		return format.format(getFristDayOfMonthToDate(date));
	}
	public static Date getFristDayOfMonthToDate(Date date) {
		// 获取前月的第一天
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.MONTH, 0);
		c.set(Calendar.DAY_OF_MONTH,1);//设置为1号,当前日期既为本月第一天
		return c.getTime();
	}
	/**
	 * 获取当月的最后一天
	 * @param date
	 * @return
	 */
	public static String getLastDayOfMonth(Date date) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		return format.format(getLastDayOfMonthToDate(date));
	}
	public static Date getLastDayOfMonthToDate(Date date){
		Calendar ca = Calendar.getInstance();
		ca.setTime(date);
		ca.set(Calendar.DAY_OF_MONTH, ca.getActualMaximum(Calendar.DAY_OF_MONTH));
		return ca.getTime();
	}
	//获取输入时间是当前年度的第几周
	public static Integer week(Date date){
		Calendar calendar = Calendar.getInstance();
		calendar.setFirstDayOfWeek(Calendar.MONDAY);
		calendar.setTime(date);
		return calendar.get(Calendar.WEEK_OF_YEAR);
	}
	//获取输入时间是当前年度的第几周
	public static Integer month(Date date){
		Calendar calendar = Calendar.getInstance();
		calendar.setFirstDayOfWeek(Calendar.MONDAY);
		calendar.setTime(date);
		return calendar.get(Calendar.MONTH);
	}
	/**
	 * 获取某年最后一天日期
	 * @param year 年份
	 * @return Date
	 */
	public static Date getYearLast(int year){
		Calendar calendar = Calendar.getInstance();
		calendar.clear();
		calendar.set(Calendar.YEAR, year);
		calendar.roll(Calendar.DAY_OF_YEAR, -1);
		Date currYearLast = calendar.getTime();
		return currYearLast;
	}
}

+ 9 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/vo/WlyyJobConfigVO.java

@ -22,9 +22,9 @@ public class WlyyJobConfigVO implements  Serializable {
    private String sqlDay;//按日统计
    private String sqlYear;//按年统计
    private String cacheKey;//缓存的key
    private Integer incrementInterval;//增量的时间间隔(1天,2周,3月)
    private String timeLevel;//1增量 2到达量 3生成到达量也生成增量
    public WlyyJobConfigVO() {
    }
@ -156,6 +156,14 @@ public class WlyyJobConfigVO implements  Serializable {
        this.cacheKey = cacheKey;
    }
    public Integer getIncrementInterval() {
        return incrementInterval;
    }
    public void setIncrementInterval(Integer incrementInterval) {
        this.incrementInterval = incrementInterval;
    }
    public String getTimeLevel() {
        return timeLevel;
    }

+ 16 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -2345,6 +2345,7 @@ public class EsStatisticsController extends BaseController {
        //                                   @RequestParam(required = true) String index,
                                           @ApiParam(name = "level", value = "地区级别,1 团队,2 机构,3 区,4 市") @RequestParam(required = true) int level,
                                           @ApiParam(name = "activityCode", value = "活动的id") @RequestParam(required = false) String activityCode,
//                                           @ApiParam(name = "index", value = "报名量91,活跃量(95天,90周,94月)") @RequestParam(required = true) String index,
                                           @RequestParam(required = false) String year) {
        try {
            level = elasticsearchUtil.changeLevel(level);
@ -2352,10 +2353,12 @@ public class EsStatisticsController extends BaseController {
//            JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, "90", lowCode, year,SaveModel.timeLevel_ZL);
//            result.put("index_89", json);
            String index = "";
            if(StringUtils.isNotEmpty(activityCode)){
                index="91,90";
            }else{
            if(interval==1){
                index="91,95";
            }else if(interval==2){
                index="91,90";
            }else if(interval==2){
                index="91,94";
            }
            if (index != null) {
                if (org.springframework.util.StringUtils.isEmpty(year)) {
@ -2363,9 +2366,17 @@ public class EsStatisticsController extends BaseController {
                    year =  Constant.getNowYearByDate(endDate);
                }
                String[] indexes = index.split(",");
                for (String idx : indexes) {
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, activityCode, year,SaveModel.timeLevel_DDL);
                    result.put("index_"+idx, json);
                    if("91".equals(idx)){
                        JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, activityCode, year,SaveModel.timeLevel_DDL);
                        result.put("index_"+idx, json);
                    }else{
                        JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, activityCode, year,SaveModel.timeLevel_ZL);
                        result.put("index_90", json);
                    }
                }
            }
            return write(200, "查询成功!", "data", result);