新增测试接口

This commit is contained in:
liyongxiang 2025-03-14 14:15:00 +08:00
parent 498802bf47
commit 60c33535e8
3 changed files with 33 additions and 0 deletions

View File

@ -45,6 +45,14 @@ public class BasicController {
log.info("获取电费相关信息响应:{}", JSON.toJSONString(response)); log.info("获取电费相关信息响应:{}", JSON.toJSONString(response));
return response; return response;
} }
@PostMapping("/getElectricityInfo1")
@ResponseBody
public Object getElectricityInfo1(@RequestBody Map<String,Object> param) {
log.info("获取电费相1关信息入参{}", JSON.toJSONString(param));
Object response = basicService.getElectricityInfo1(param);
log.info("获取电费相1关信息响应{}", JSON.toJSONString(response));
return response;
}
// http://127.0.0.1:8080/user // http://127.0.0.1:8080/user
@RequestMapping("/user") @RequestMapping("/user")

View File

@ -10,4 +10,6 @@ import java.util.Map;
public interface BasicService { public interface BasicService {
Response getElectricityInfo(Map<String,Object> param); Response getElectricityInfo(Map<String,Object> param);
Object getElectricityInfo1(Map<String,Object> param);
} }

View File

@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -64,6 +65,28 @@ public class BasicServiceImpl implements BasicService {
return response; return response;
} }
@Override
public Object getElectricityInfo1(Map<String, Object> param) {
String keyWord = (String) param.get("kw");
DataAndView dataAndView =new DataAndView();
List<ElectricityBill> bills = new ArrayList<>();
TypeAndQuery typeAndQuery = new TypeAndQuery();
analysisKeyWord(keyWord,typeAndQuery);
dataAndView.setType(typeAndQuery.getType());
log.info("数据库查询电费!");
bills = electricityBillMapper.queryElectricityByDate();
StringBuilder electricityBill =new StringBuilder();
StringBuilder statementDate =new StringBuilder();
bills.stream().forEach(bill ->{
electricityBill.append(bill.getElectricityBill()).append(";");
statementDate.append(bill.getStatementDate()).append(";");
});
Map<String,String> result = new HashMap<>();
result.put("electricityBill",electricityBill.deleteCharAt(electricityBill.length()-1).toString());
result.put("statementDate",statementDate.deleteCharAt(electricityBill.length()-1).toString());
dataAndView.setData(result);
return dataAndView;
}
private void analysisKeyWord(String keyWord,TypeAndQuery typeAndQuery){ private void analysisKeyWord(String keyWord,TypeAndQuery typeAndQuery){
int querySymbol = 0; int querySymbol = 0;