优化代码逻辑

This commit is contained in:
liyongxiang 2025-03-05 18:18:12 +08:00
parent 107f28a7a6
commit 498802bf47
1 changed files with 5 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package com.example.demo.service.impl; package com.example.demo.service.impl;
import com.alibaba.fastjson.JSON;
import com.example.demo.constant.EleConstant; import com.example.demo.constant.EleConstant;
import com.example.demo.constant.StaConstant; import com.example.demo.constant.StaConstant;
import com.example.demo.mapper.ElectricityBillMapper; import com.example.demo.mapper.ElectricityBillMapper;
@ -30,12 +31,11 @@ public class BasicServiceImpl implements BasicService {
Response response = new Response(); Response response = new Response();
List<ElectricityBill> bills = new ArrayList<>(); List<ElectricityBill> bills = new ArrayList<>();
TypeAndQuery typeAndQuery = new TypeAndQuery(); TypeAndQuery typeAndQuery = new TypeAndQuery();
String type =new String();
Integer querySymbol = new Integer(0);
analysisKeyWord(keyWord,typeAndQuery); analysisKeyWord(keyWord,typeAndQuery);
if (0 == typeAndQuery.getQuerySymbol()){ if (0 == typeAndQuery.getQuerySymbol()){
log.info("不支持的查询类型"); log.info("不支持的查询类型");
response.setSta(StaConstant.UNSUPPORTED_QUERY_TYPE); response.setSta(StaConstant.UNSUPPORTED_QUERY_TYPE);
response.setMessage("failed");
response.setData("暂时还不支持查询此类问题,您可以说查询电费或查询电量"); response.setData("暂时还不支持查询此类问题,您可以说查询电费或查询电量");
return response; return response;
} }
@ -44,6 +44,7 @@ public class BasicServiceImpl implements BasicService {
if (1 == typeAndQuery.getQuerySymbol()){ if (1 == typeAndQuery.getQuerySymbol()){
log.info("数据库查询电量!"); log.info("数据库查询电量!");
response.setSta(StaConstant.UNSUPPORTED_QUERY_TYPE); response.setSta(StaConstant.UNSUPPORTED_QUERY_TYPE);
response.setMessage("failed");
response.setData("电量查询暂未开放!"); response.setData("电量查询暂未开放!");
return response; return response;
}else if (2 == typeAndQuery.getQuerySymbol()){ }else if (2 == typeAndQuery.getQuerySymbol()){
@ -51,10 +52,12 @@ public class BasicServiceImpl implements BasicService {
bills = electricityBillMapper.queryElectricityByDate(); bills = electricityBillMapper.queryElectricityByDate();
dataAndView.setData(bills); dataAndView.setData(bills);
response.setSta(StaConstant.SUCCESS); response.setSta(StaConstant.SUCCESS);
response.setMessage("success");
response.setData(dataAndView); response.setData(dataAndView);
}else { }else {
log.info("暂时还没有此类查询!"); log.info("暂时还没有此类查询!");
response.setSta(StaConstant.UNSUPPORTED_QUERY_TYPE); response.setSta(StaConstant.UNSUPPORTED_QUERY_TYPE);
response.setMessage("failed");
response.setData("暂时还不支持查询此类问题,您可以说查询电费或查询电量"); response.setData("暂时还不支持查询此类问题,您可以说查询电费或查询电量");
return response; return response;
} }