feat: 增加从账单获取电价接口
This commit is contained in:
parent
beba4dae71
commit
d2e5bfafea
|
@ -86,6 +86,16 @@ public class BasicController {
|
|||
return response;
|
||||
}
|
||||
|
||||
@PostMapping("/getElePriceFromBill")
|
||||
@ResponseBody
|
||||
public Object getElePriceFromBill(@RequestBody ElePriceInfoModel model) {
|
||||
Object response = new Object();
|
||||
log.info("获取电费电价信息入参:model:{}", JSON.toJSONString(model));
|
||||
response = basicService.getElePriceFromBill(model);
|
||||
log.info("获取电费电价返回:{}", JSON.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
// http://127.0.0.1:8080/user
|
||||
@RequestMapping("/user")
|
||||
@ResponseBody
|
||||
|
|
|
@ -15,4 +15,5 @@ public class ElePriceInfoModel {
|
|||
private String elecType;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private String elecNumber;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.example.demo.service;
|
|||
import com.example.demo.model.ElePriceInfoModel;
|
||||
import com.example.demo.model.ElecBindInfoModel;
|
||||
import com.example.demo.model.Response;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -18,4 +16,6 @@ public interface BasicService {
|
|||
Object getBindingInfo(ElecBindInfoModel model);
|
||||
|
||||
Object getElePriceInfo(ElePriceInfoModel model);
|
||||
|
||||
Object getElePriceFromBill(ElePriceInfoModel param);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.example.demo.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.example.demo.constant.EleConstant;
|
||||
import com.example.demo.constant.StaConstant;
|
||||
|
@ -16,6 +17,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
|
@ -128,6 +130,25 @@ public class BasicServiceImpl implements BasicService {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElePriceFromBill(ElePriceInfoModel param) {
|
||||
// 处理时间
|
||||
String startTime = param.getStartTime().replace("-","");
|
||||
String endTime = param.getEndTime().replace("-","");
|
||||
List<ElectricityBill> electricityBills = electricityBillMapper.selectList(
|
||||
new LambdaQueryWrapper<ElectricityBill>()
|
||||
.eq(ElectricityBill::getElectricityUserNumber, param.getElecNumber())
|
||||
.between(ElectricityBill::getStatementDate, startTime, endTime));
|
||||
List<Map<String, Object>> list = electricityBills.stream().map(e -> {
|
||||
Map<String, Object> priceMap = new HashMap<>();
|
||||
priceMap.put("price", e.getImplementElectricityPrices());
|
||||
String date = e.getStatementDate().replaceAll("(\\d{4})(\\d{2})", "$1-$2");
|
||||
priceMap.put("date", date);
|
||||
return priceMap;
|
||||
}).collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
private void analysisKeyWord(String keyWord,TypeAndQuery typeAndQuery){
|
||||
int querySymbol = 0;
|
||||
String type = EleConstant.LINE_TYPE_BG;
|
||||
|
|
Loading…
Reference in New Issue