forked from luyan/epmet-cloud-lingshan
8 changed files with 232 additions and 0 deletions
@ -0,0 +1,35 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.extract.form.ExtractFormDTO; |
||||
|
import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractDailyService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/9/24 9:42 上午 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("screenextract") |
||||
|
public class ScreenExtractDailyController { |
||||
|
|
||||
|
@Autowired |
||||
|
private ScreenExtractDailyService screenExtractDailyService; |
||||
|
|
||||
|
/** |
||||
|
* @Description 抽取数据到大屏【天】 |
||||
|
* @param extractFormDTO |
||||
|
* @author zxc |
||||
|
* @date 2020/9/24 10:15 上午 |
||||
|
*/ |
||||
|
@PostMapping("extractdailyall") |
||||
|
public Result screenExtractDaily(@RequestBody ExtractFormDTO extractFormDTO){ |
||||
|
screenExtractDailyService.extractAll(extractFormDTO); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.epmet.service.evaluationindex.extract.toscreen; |
||||
|
|
||||
|
import com.epmet.dto.extract.form.ExtractFormDTO; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/9/24 9:57 上午 |
||||
|
*/ |
||||
|
public interface ScreenExtractDailyService { |
||||
|
|
||||
|
/** |
||||
|
* @Description 抽取数据到大屏【天】 |
||||
|
* @param extractFormDTO |
||||
|
* @author zxc |
||||
|
* @date 2020/9/24 10:15 上午 |
||||
|
*/ |
||||
|
void extractAll(ExtractFormDTO extractFormDTO); |
||||
|
|
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
package com.epmet.service.evaluationindex.extract.toscreen.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.constant.NumConstant; |
||||
|
import com.epmet.commons.tools.utils.DateUtils; |
||||
|
import com.epmet.dto.extract.form.ExtractFormDTO; |
||||
|
import com.epmet.service.evaluationindex.extract.toscreen.PartyBaseInfoService; |
||||
|
import com.epmet.service.evaluationindex.extract.toscreen.PioneerDataExtractService; |
||||
|
import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractDailyService; |
||||
|
import com.epmet.service.stats.DimCustomerService; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.util.CollectionUtils; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/9/24 9:57 上午 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class ScreenExtractDailyServiceImpl implements ScreenExtractDailyService { |
||||
|
|
||||
|
@Autowired |
||||
|
private DimCustomerService dimCustomerService; |
||||
|
@Autowired |
||||
|
private PartyBaseInfoService partyBaseInfoService; |
||||
|
@Autowired |
||||
|
private PioneerDataExtractService pioneerDataExtractService; |
||||
|
|
||||
|
/** |
||||
|
* @Description 抽取数据到大屏【天】 |
||||
|
* @param extractFormDTO |
||||
|
* @author zxc |
||||
|
* @date 2020/9/24 10:15 上午 |
||||
|
*/ |
||||
|
@Override |
||||
|
public void extractAll(ExtractFormDTO extractFormDTO) { |
||||
|
List<String> customerIds = new ArrayList<>(); |
||||
|
if (StringUtils.isNotBlank(extractFormDTO.getCustomerId())){ |
||||
|
customerIds.add(extractFormDTO.getCustomerId()); |
||||
|
}else { |
||||
|
int pageNo = NumConstant.ONE; |
||||
|
int pageSize = NumConstant.ONE_HUNDRED; |
||||
|
customerIds = dimCustomerService.selectCustomerIdPage(pageNo, pageSize); |
||||
|
} |
||||
|
if (!CollectionUtils.isEmpty(customerIds)){ |
||||
|
customerIds.forEach(customerId -> { |
||||
|
if (StringUtils.isNotBlank(extractFormDTO.getStartDate()) && StringUtils.isNotBlank(extractFormDTO.getEndDate())){ |
||||
|
List<String> daysBetween = DateUtils.getDaysBetween(extractFormDTO.getStartDate(), extractFormDTO.getEndDate()); |
||||
|
daysBetween.forEach(dateId -> { |
||||
|
extractDaily(customerId,dateId); |
||||
|
}); |
||||
|
}else if (StringUtils.isNotBlank(extractFormDTO.getDateId())){ |
||||
|
extractDaily(customerId,extractFormDTO.getDateId()); |
||||
|
}else { |
||||
|
String dateId = LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", ""); |
||||
|
extractDaily(customerId,dateId); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Description 按天计算 |
||||
|
* @param customerId |
||||
|
* @param dateId |
||||
|
* @author zxc |
||||
|
* @date 2020/9/24 10:16 上午 |
||||
|
*/ |
||||
|
public void extractDaily(String customerId,String dateId){ |
||||
|
partyBaseInfoService.statsPartyMemberBaseInfoToScreen(customerId,dateId); |
||||
|
pioneerDataExtractService.extractGridPioneerData(customerId,dateId); |
||||
|
pioneerDataExtractService.extractCommunityPioneerData(customerId,dateId); |
||||
|
pioneerDataExtractService.extractStreetPioneerData(customerId,dateId); |
||||
|
pioneerDataExtractService.extractDistrictPioneerData(customerId,dateId); |
||||
|
pioneerDataExtractService.extractCityPioneerData(customerId,dateId); |
||||
|
pioneerDataExtractService.extractProvincePioneerData(customerId,dateId); |
||||
|
} |
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/9/24 10:21 上午 |
||||
|
*/ |
||||
|
public interface ScreenExtractTaskService { |
||||
|
|
||||
|
Result screenExtractDaily(String params); |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSON; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.extract.form.ExtractFormDTO; |
||||
|
import com.epmet.feign.DataStatisticalOpenFeignClient; |
||||
|
import com.epmet.service.ScreenExtractTaskService; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/9/24 10:22 上午 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class ScreenExtractTaskServiceImpl implements ScreenExtractTaskService { |
||||
|
|
||||
|
@Autowired |
||||
|
private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public Result screenExtractDaily(String params) { |
||||
|
ExtractFormDTO extractFormDTO = new ExtractFormDTO(); |
||||
|
if (StringUtils.isNotBlank(params)) { |
||||
|
extractFormDTO = JSON.parseObject(params, ExtractFormDTO.class); |
||||
|
} |
||||
|
return dataStatisticalOpenFeignClient.extractDailyAll(extractFormDTO); |
||||
|
} |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.epmet.task; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.service.ScreenExtractTaskService; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/9/24 10:26 上午 |
||||
|
*/ |
||||
|
@Component("screenExtractDailyTask") |
||||
|
public class ScreenExtractDailyTask implements ITask{ |
||||
|
|
||||
|
@Autowired |
||||
|
private ScreenExtractTaskService screenExtractTaskService; |
||||
|
|
||||
|
private Logger logger = LoggerFactory.getLogger(getClass()); |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public void run(String params) { |
||||
|
logger.info("ScreenExtractDailyTask定时任务正在执行,参数为:{}", params); |
||||
|
Result result = screenExtractTaskService.screenExtractDaily(params); |
||||
|
if (result.success()){ |
||||
|
logger.info("ScreenExtractDailyTask定时任务执行成功"); |
||||
|
}else { |
||||
|
logger.error("ScreenExtractDailyTask定时任务执行失败:" + result.getMsg()); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue