bobol
9 months ago
6 changed files with 130 additions and 1 deletions
@ -0,0 +1,34 @@ |
|||
package com.lzbi.external.controller; |
|||
|
|||
import com.lzbi.common.core.domain.AjaxResult; |
|||
import com.lzbi.external.service.ParamsService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
@RequestMapping("/external/params") |
|||
@RestController |
|||
public class ParamsController { |
|||
|
|||
@Autowired |
|||
private ParamsService paramsService; |
|||
|
|||
/** |
|||
* 获取供热面积 |
|||
* @return |
|||
*/ |
|||
@GetMapping("/heat-supply-area/singleAsset") |
|||
public AjaxResult getHeatSupplyArea(@RequestParam(value = "assetCode") String assetCode) { |
|||
return AjaxResult.success(paramsService.getHeatSupplyArea(assetCode)); |
|||
} |
|||
|
|||
/** |
|||
* 获取供气面积 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/heat-supply-area/multipleAsset") |
|||
public AjaxResult getGasSupplyArea(@RequestBody List<String> assetCodeList) { |
|||
return AjaxResult.success(paramsService.getGasSupplyArea(assetCodeList)); |
|||
} |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.lzbi.external.service; |
|||
|
|||
import com.lzbi.common.constant.ParamsModelCodeConstants; |
|||
import com.lzbi.draft.domain.DcBusiParamDraftDay; |
|||
import com.lzbi.draft.mapper.DcBusiParamDraftDayMapper; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class ParamsService { |
|||
|
|||
@Resource |
|||
private DcBusiParamDraftDayMapper dcBusiParamDraftDayMapper; |
|||
|
|||
public Double getHeatSupplyArea(String assetCode) { |
|||
DcBusiParamDraftDay dcBusiParamDraftDay = dcBusiParamDraftDayMapper.selectLastDataByAssetCodeAndParamsModelCode(assetCode, ParamsModelCodeConstants.供暖面积); |
|||
return dcBusiParamDraftDay.getValLast(); |
|||
} |
|||
|
|||
public Map<String, Double> getGasSupplyArea(List<String> assetCodeList) { |
|||
if (CollectionUtils.isEmpty(assetCodeList)) { |
|||
throw new RuntimeException("资产编码列表不能为空"); |
|||
} |
|||
List<DcBusiParamDraftDay> list = dcBusiParamDraftDayMapper.selectLastDataByAssetCodeListAndParamsModelCode(assetCodeList, ParamsModelCodeConstants.供暖面积); |
|||
if (CollectionUtils.isEmpty(list)) { |
|||
throw new RuntimeException("暂无数据"); |
|||
} |
|||
Map<String, Double> map = list.stream().collect(Collectors.toMap(DcBusiParamDraftDay::getAssetCode, DcBusiParamDraftDay::getValLast)); |
|||
return map; |
|||
} |
|||
} |
Loading…
Reference in new issue