Commit f3695c8d authored by tianbo's avatar tianbo

添加根据es索引别名保存气瓶信息test方法

parent 96695f2c
...@@ -12,7 +12,6 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -12,7 +12,6 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
...@@ -33,4 +32,11 @@ public class CylinderStatisticsController { ...@@ -33,4 +32,11 @@ public class CylinderStatisticsController {
public ResponseModel<Page<Map<String, Object>>> getEarlyWarning(@RequestParam(value = "regionCode", required = false) String regionCode, @RequestParam(value = "appId", required = false) String appId){ public ResponseModel<Page<Map<String, Object>>> getEarlyWarning(@RequestParam(value = "regionCode", required = false) String regionCode, @RequestParam(value = "appId", required = false) String appId){
return ResponseHelper.buildResponse(service.getEarlyWarningStatistics(regionCode, appId)); return ResponseHelper.buildResponse(service.getEarlyWarningStatistics(regionCode, appId));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/test/saveCylinderFillingRecord2ES", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "testSaveCylinderFillingRecord2ES")
public ResponseModel testSaveCylinderFillingRecord2ES(){
return ResponseHelper.buildResponse(service.testSaveCylinderFillingRecord2ES());
}
} }
...@@ -4,20 +4,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -4,20 +4,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto; import com.yeejoin.amos.boot.module.cylinder.api.dto.KeyValueDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESCylinderFillingRecordRepository;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto; import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderAreaDataDto; import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderAreaDataDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData; import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderAreaData;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper; import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderAreaDataMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService; import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderAreaDataService;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.core.CountRequest; import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.CountResponse; import org.elasticsearch.client.core.CountResponse;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.ScriptQueryBuilder;
import org.elasticsearch.script.ScriptType;
import org.elasticsearch.script.Script;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -28,7 +28,6 @@ import java.io.IOException; ...@@ -28,7 +28,6 @@ import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -49,6 +48,9 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -49,6 +48,9 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
@Autowired @Autowired
RestHighLevelClient restHighLevelClient; RestHighLevelClient restHighLevelClient;
@Autowired
ESCylinderFillingRecordRepository esCylinderFillingRecordRepository;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -119,7 +121,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -119,7 +121,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
long totalResult = searchEsCount(false, true, regionCode, appId); long totalResult = searchEsCount(false, true, regionCode, appId);
result5.put("name", "充装检查率(%)"); result5.put("name", "充装检查率(%)");
if (totalAll != 0) { if (totalAll != 0) {
result5.put("value", new DecimalFormat("#.00").format (((double) totalCheck / totalAll) * 100)); result5.put("value", new DecimalFormat("#.00").format(((double) totalCheck / totalAll) * 100));
} else { } else {
result5.put("value", 0); result5.put("value", 0);
} }
...@@ -127,7 +129,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -127,7 +129,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
Map<String, Object> result6 = Maps.newHashMap(); Map<String, Object> result6 = Maps.newHashMap();
result6.put("name", "充装检查合格率(%)"); result6.put("name", "充装检查合格率(%)");
if (totalAll != 0) { if (totalAll != 0) {
result6.put("value", new DecimalFormat("#.00").format (((double) totalResult / totalAll) * 100)); result6.put("value", new DecimalFormat("#.00").format(((double) totalResult / totalAll) * 100));
} else { } else {
result6.put("value", 0); result6.put("value", 0);
} }
...@@ -184,7 +186,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -184,7 +186,7 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
} }
private long searchEsCount(Boolean checkOk, Boolean resultOk, String regionCode, String appId) { private long searchEsCount(Boolean checkOk, Boolean resultOk, String regionCode, String appId) {
CountRequest countRequest = new CountRequest("cylinder_filling_tb3"); CountRequest countRequest = new CountRequest("cylinder_filling");
// countRequest.indices("cylinder_filling"); // countRequest.indices("cylinder_filling");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
if (checkOk) { if (checkOk) {
...@@ -223,4 +225,26 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto ...@@ -223,4 +225,26 @@ public class CylinderAreaDataServiceImpl extends BaseService<CylinderAreaDataDto
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
public String testSaveCylinderFillingRecord2ES() {
SearchRequest searchRequest = new SearchRequest();
searchRequest.indices("cylinder_filling");
List<ESCylinderFillingRecordDto> dtoList = Lists.newArrayList();
ESCylinderFillingRecordDto esCylinderFillingRecordDto = new ESCylinderFillingRecordDto();
esCylinderFillingRecordDto.setAppId("1");
esCylinderFillingRecordDto.setCreditCode("1");
esCylinderFillingRecordDto.setCheckResult("合格");
esCylinderFillingRecordDto.setFillingResult("合格");
esCylinderFillingRecordDto.setUnitName("1test1");
dtoList.add(esCylinderFillingRecordDto);
ESCylinderFillingRecordDto esCylinderFillingRecordDto1 = new ESCylinderFillingRecordDto();
esCylinderFillingRecordDto1.setAppId("1");
esCylinderFillingRecordDto1.setCreditCode("1");
esCylinderFillingRecordDto1.setCheckResult("合格");
esCylinderFillingRecordDto1.setFillingResult("合格");
esCylinderFillingRecordDto1.setUnitName("1test1");
dtoList.add(esCylinderFillingRecordDto1);
esCylinderFillingRecordRepository.saveAll(dtoList);
return "success";
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment