yang_shj
8 months ago
6 changed files with 121 additions and 0 deletions
@ -0,0 +1,26 @@
|
||||
package com.hnac.hzims.operational.fill.feign; |
||||
|
||||
import com.hnac.hzims.operational.OperationalConstants; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@FeignClient( |
||||
value = OperationalConstants.APP_NAME, |
||||
fallback = IGenerateClientFallback.class |
||||
) |
||||
public interface IGenerateClient { |
||||
|
||||
String API_PREFIX = "/feign/generate/"; |
||||
|
||||
String STATION_GENERATE_BY_TIME = API_PREFIX + "/stationGenerateByTime"; |
||||
|
||||
|
||||
@GetMapping(STATION_GENERATE_BY_TIME) |
||||
Double stationGenerateByTime(@RequestParam("stationId") String stationId, |
||||
@RequestParam("startTime") String startTime, |
||||
@RequestParam("endTime") String endTime); |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.hnac.hzims.operational.fill.feign; |
||||
|
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* @author hx |
||||
*/ |
||||
@Component |
||||
public class IGenerateClientFallback implements IGenerateClient { |
||||
|
||||
@Override |
||||
public Double stationGenerateByTime(String stationId, String startTime, String endTime) { |
||||
return 0.0; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.hnac.hzims.operational.fill.feign; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.hnac.hzims.operational.fill.entity.GenerateEntity; |
||||
import com.hnac.hzims.operational.fill.service.GenerateService; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springblade.core.tool.utils.CollectionUtil; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* @author ysj |
||||
*/ |
||||
@RestController |
||||
@Slf4j |
||||
@AllArgsConstructor |
||||
public class GenerateClient implements IGenerateClient { |
||||
|
||||
private final GenerateService generateService; |
||||
|
||||
@Override |
||||
@GetMapping(STATION_GENERATE_BY_TIME) |
||||
public Double stationGenerateByTime(String stationId, String startTime, String endTime) { |
||||
List<GenerateEntity> generates = generateService.list(Wrappers.<GenerateEntity>lambdaQuery() |
||||
.eq(GenerateEntity::getStationCode,stationId) |
||||
.ge(GenerateEntity::getFillDate,startTime) |
||||
.le(GenerateEntity::getGenerate,endTime) |
||||
); |
||||
if(CollectionUtil.isEmpty(generates)){ |
||||
return 0.0; |
||||
} |
||||
return generates.stream().mapToDouble(GenerateEntity::getGenerate).sum(); |
||||
} |
||||
} |
Loading…
Reference in new issue