Commit 90ca2549 authored by suhuiguang's avatar suhuiguang

1.集群es redis 适配

parent 51c5b9e7
package com.yeejoin.amos.boot.module.elevator.biz.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
......@@ -16,6 +13,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
@Configuration
public class ElasticSearchClientConfig {
......@@ -35,27 +34,19 @@ public class ElasticSearchClientConfig {
new UsernamePasswordCredentials(username, password));
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost);
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒)
return requestConfigBuilder.setConnectTimeout(5000 * 1000)
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
.setSocketTimeout(6000 * 1000);
});
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000 * 1000) // 连接超时(默认为1秒)
.setSocketTimeout(6000 * 1000);// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
}
});// 调整最大重试超时时间(默认为30秒).setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(builder);
} catch (Exception e) {
......
......@@ -148,17 +148,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
private static String USE_CODE = "use_code";
......@@ -1200,11 +1192,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询
// //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
}
ResponseModel<Page<Map<String, Object>>> model = new ResponseModel<>();
JSONObject object = getCompanyType().get(0);
String level = object.getString("level");
String code = object.getString("orgCode");
......@@ -1219,19 +1210,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size"));
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress, esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
......@@ -1329,7 +1307,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<JSONObject> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
......@@ -1348,7 +1326,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
throw new RuntimeException(e);
} finally {
try {
esClient.close();
restHighLevelClient.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -10,25 +10,15 @@ import com.yeejoin.amos.boot.module.elevator.flc.api.dto.CylinderFillingRecordDt
import com.yeejoin.amos.boot.module.elevator.flc.api.entity.CylinderFillingRecord;
import com.yeejoin.amos.boot.module.elevator.flc.api.mapper.CylinderFillingRecordMapper;
import com.yeejoin.amos.boot.module.elevator.flc.api.service.ICylinderFillingRecordService;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -55,17 +45,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Autowired
CylinderFillingRecordMapper cylinderFillingRecordMapper;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
/**
* 分页查询
......@@ -127,7 +108,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
//@Scheduled(cron = "${tzs.cylinder.fill.cron}")
public void setTimeSaveCylinderInfoToES(){
public void setTimeSaveCylinderInfoToES() {
Page<ESCylinderFillingRecordDto> cylinderFillingRecordPage = new Page<>();
Page<ESCylinderFillingRecordDto> cyinderInfoList = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
Long count = cyinderInfoList.getCurrent();
......@@ -143,10 +124,10 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
cylinderFillingRecordPage.setCurrent(i);
cylinderFillingRecordPage.setSize(1000);
cylinderFillingRecordPage = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
cylinderFillingRecordPage.getRecords().stream().map(item->{
if(!ObjectUtils.isEmpty(item.getSequenceCode())){
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(),item.getSequenceCode());
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
cylinderFillingRecordPage.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
item.setUnitName(cyinderFillingRecordInfo.getUnitName());
item.setFactoryNum(cyinderFillingRecordInfo.getFactoryNum());
item.setCylinderVariety(cyinderFillingRecordInfo.getCylinderVariety());
......@@ -164,7 +145,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
// for (ESCylinderFillingRecordDto ci : cylinderFillingRecordPage.getRecords()) {
// saveCylinderFillingRecordToES(ci);
// }
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
saveCylinderFillingRecord2ES(cylinderFillingRecordPage.getRecords());
}
}
......@@ -174,7 +155,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Override
public Page<ESCylinderFillingRecordDto> getCyinderFillingRecord(Page<ESCylinderFillingRecordDto> cylinderFillingRecordDto) {
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordDto);
if(!ObjectUtils.isEmpty(cyinderFillingRecord)){
if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cyinderFillingRecord.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
......@@ -202,26 +183,6 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
public Page<ESCylinderFillingRecordDto> queryByKeys(ESCylinderFillingRecordDto esCylinderFillingRecordDto, int pageNum, int pageSize) {
Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_filling");
......@@ -328,7 +289,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
boolMust.must(query);
}
if(flag) { // 搜索全部
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
......@@ -340,9 +301,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<ESCylinderFillingRecordDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderFillingRecordDto esCylinderFillingRecordDto1 = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderFillingRecordDto.class);
list.add(esCylinderFillingRecordDto1);
......@@ -352,6 +312,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
......@@ -362,7 +328,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<CylinderFillingRecord> cylinderFillingRecordList = new ArrayList<>();
for (ESCylinderFillingRecordDto record : records) {
CylinderFillingRecord cylinderFillingRecord = new CylinderFillingRecord();
BeanUtils.copyProperties(record,cylinderFillingRecord);
BeanUtils.copyProperties(record, cylinderFillingRecord);
cylinderFillingRecord.setIsNotEs("1");
cylinderFillingRecord.setSequenceNbr(record.getSequenceNbr());
cylinderFillingRecordList.add(cylinderFillingRecord);
......
......@@ -25,17 +25,9 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -43,7 +35,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
......@@ -68,1040 +59,1011 @@ import java.util.function.IntConsumer;
@Service
@Slf4j
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper>
implements ICylinderInfoService {
implements ICylinderInfoService {
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
private ScheduleMapper scheduleMapper;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
ESCylinderInfoRepository esCylinderInfoRepository;
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal-monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0 ;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year+"-"+monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder /(double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
private ScheduleMapper scheduleMapper;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
ESCylinderInfoRepository esCylinderInfoRepository;
@Autowired
RestHighLevelClient restHighLevelClient;
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal - monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year + "-" + monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder / (double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
// cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
//@Scheduled(cron = "${tzs.cylinder.info.cron}")
public void setTimeSaveCylinderInfoToES(){
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if(!ObjectUtils.isEmpty(cylinderInfoPage)){
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
//@Scheduled(cron = "${tzs.cylinder.info.cron}")
public void setTimeSaveCylinderInfoToES() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
// for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) {
// saveCylinderInfoToES(ci);
// }
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record,esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record,cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci,esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if(!ObjectUtils.isEmpty(saveResult)){
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if(flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record, esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record, cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci, esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if (!ObjectUtils.isEmpty(saveResult)) {
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
// r.setEarlyWarningLevelName(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getName());
// r.setInspectionStatusDesc(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getStatus());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
// warningMsgDto.setUserType(cylinderInfoDto.getCustomType());
// warningMsgDto.setUserPeople(cylinderInfoDto.getCustomName());
// warningMsgDto.setUserPeoplePhone(cylinderInfoDto.getContactPhone());
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
// cylinderInfo.setNextInspectionDate(c.getNextInspectionDate());
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderInfoList(page,cylinderInfoDto,sort,appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderOutInfoList(page,cylinderInfoDto,sort,appids);
}
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderInfoList(page, cylinderInfoDto, sort, appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderOutInfoList(page, cylinderInfoDto, sort, appids);
}
}
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:23306/tzs_amos_tzs_biz_init?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://192.168.249.180:54321/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
#eureka properties:
eureka.instance.hostname= eureka
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.ip-address = 172.16.3.133
spring.datasource.password=Yeejoin@2023
eureka.client.service-url.defaultZone=http://192.168.249.13:10001/eureka/,http://192.168.249.139:10001/eureka/
eureka.instance.prefer-ip-address=true
eureka.instance.ip-address=192.168.249.13
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username=elastic
elasticsearch.password=123456
elasticsearch.password=Yeejoin@2023
spring.elasticsearch.rest.uris=http://192.168.249.218:9200,http://192.168.249.114:9200,http://192.168.249.155:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
#集群环境
spring.redis.cluster.nodes=192.168.249.218:6377,192.168.249.114:6377,192.168.249.155:6377
spring.redis.password=Yeejoin@2023
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.broker=tcp://192.168.249.180:2883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
##wechatToken
tzs.cti.url=http://36.41.172.83:8000
##wechatTokenls
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -61,41 +50,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## \u9884\u8B66\u901A\u77E5\u6A21\u677Fid
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##\u7763\u67E5\u6574\u6539\u901A\u77E5
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \u516C\u4F17\u53F7\u6D4B\u8BD5\u7528\u6237id\uFF08\u5E73\u53F0userId\uFF09
## ???????id???userId?
tzs.wechat.test.userId=3413513
fileserver.domain=https://rpm.yeeamos.com:8888/
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://192.168.249.180:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=192.168.249.13
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://192.168.249.180:19000/
## 生成监管码前缀域名
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.90:53306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.99:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=172.16.10.90
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= Yeejoin@2020
## unit(h)
alertcall.es.synchrony.time=48
fileserver.domain=https://rpm.yeeamos.com:8888/
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.90
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.90:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://172.16.10.90:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.elevator.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
org.filter.group.seq=1564150103147573249
duty.seats.role.ids=1585956200472674305,1585956257590706177
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://36.46.137.116:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
#spring.datasource.url=jdbc:vastbase://36.46.151.113:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz
spring.datasource.username=admin
spring.datasource.password=Yeejoin@2023
#DB properties:
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://172.16.10.230:53306/${TZS_BIZ_DATABASE}?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
#spring.datasource.username=${MYSQL_ROOT_USER}
#spring.datasource.password=${MYSQL_ROOT_PASSWORD}
#eureka prioperties:
#eureka.client.serviceUrl.defaultZone=http://172.16.10.230:10001/eureka/
#eureka.client.register-with-eureka=true
#eureka.client.fetch-registry=true
#eureka.client.healthcheck.enabled=true
#ribbon.eureka.enabled=true
#eureka.instance.hostname=${spring.cloud.client.ip-address}
#eureka.instance.prefer-ip-address=true
#eureka.instance.instance-id=${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
#eureka.instance.lease-expiration-duration-in-seconds=10
#eureka.instance.lease-renewal-interval-in-seconds=5
#management.endpoint.health.show-details=always
#management.endpoints.web.exposure.include=*
#
#eureka.instance.prefer-ip-address = true
#eureka.instance.ip-address = 172.16.10.230
eureka.client.service-url.defaultZone =http://172.16.10.230:10001/eureka/
eureka.client.service-url.defaultZone=http://172.16.10.230:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
......@@ -36,25 +11,13 @@ eureka.instance.health-check-url=http://172.16.3.34:${server.port}${server.servl
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.34:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.34:${server.port}${server.servlet.context-path}/doc.html
eureka.instance.ip-address = 172.16.3.34
eureka.instance.ip-address=172.16.3.34
## ES properties:
biz.elasticsearch.port=9200
biz.elasticsearch.address=172.16.10.230
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= a123456
elasticsearch.username=elastic
elasticsearch.password=a123456
spring.elasticsearch.rest.uris=http:/172.16.10.230:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.230
......@@ -65,7 +28,6 @@ spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
......@@ -73,20 +35,13 @@ emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.41.172.83:8000
##wechatToken
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -96,67 +51,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## ???????id???userId?
tzs.wechat.test.userId=3413513
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://172.16.10.230:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=172.16.10.230
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://172.16.10.230:9000/
## ɼǰ׺
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://113.134.211.174:3306/xiy_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.28:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://192.168.1.10:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.3.28
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.3.28:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.elevator.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:13306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
......@@ -37,20 +37,20 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.apache.ibatis" level="debug"/>
<logger name="org.mybatis" level="debug" />
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="org.springframework" level="debug"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
<logger name="org.apache.activemq" level="debug"/>
<logger name="org.typroject" level="debug"/>
<logger name="com.yeejoin" level="debug"/>
<!-- 日志输出级别 -->
<root level="ERROR">
<root level="error">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/96333.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- ELK管理 -->
<appender name="ELK" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>172.16.10.230:4560</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/96333.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/96333.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
package com.yeejoin.amos.boot.module.cylinder.biz.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
......@@ -16,6 +13,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
@Configuration
public class ElasticSearchClientConfig {
......@@ -35,27 +34,19 @@ public class ElasticSearchClientConfig {
new UsernamePasswordCredentials(username, password));
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost);
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒)
return requestConfigBuilder.setConnectTimeout(5000 * 1000)
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
.setSocketTimeout(6000 * 1000);
});
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000 * 1000) // 连接超时(默认为1秒)
.setSocketTimeout(6000 * 1000);// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
}
});// 调整最大重试超时时间(默认为30秒).setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(builder);
} catch (Exception e) {
......
......@@ -148,17 +148,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
private static String USE_CODE = "use_code";
......@@ -1200,11 +1191,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询
// //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
}
ResponseModel<Page<Map<String, Object>>> model = new ResponseModel<>();
JSONObject object = getCompanyType().get(0);
String level = object.getString("level");
String code = object.getString("orgCode");
......@@ -1219,19 +1209,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size"));
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress, esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
......@@ -1329,7 +1306,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<JSONObject> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
......@@ -1348,7 +1325,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
throw new RuntimeException(e);
} finally {
try {
esClient.close();
restHighLevelClient.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -4,31 +4,22 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESCylinderFillingRecordRepository;
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.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderFillingRecord;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderFillingRecordMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.service.ICylinderFillingRecordService;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -56,17 +47,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Autowired
CylinderFillingRecordMapper cylinderFillingRecordMapper;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
/**
* 分页查询
......@@ -128,8 +110,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Scheduled(cron = "${tzs.cylinder.fill.cron}")
@SchedulerLock(name="cylinderFillingRecord2ESTask",lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES(){
@SchedulerLock(name = "cylinderFillingRecord2ESTask", lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES() {
Page<ESCylinderFillingRecordDto> cylinderFillingRecordPage = new Page<>();
Page<ESCylinderFillingRecordDto> cyinderInfoList = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
Long count = cyinderInfoList.getCurrent();
......@@ -145,10 +127,10 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
cylinderFillingRecordPage.setCurrent(i);
cylinderFillingRecordPage.setSize(1000);
cylinderFillingRecordPage = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
cylinderFillingRecordPage.getRecords().stream().map(item->{
if(!ObjectUtils.isEmpty(item.getSequenceCode())){
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(),item.getSequenceCode());
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
cylinderFillingRecordPage.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
item.setUnitName(cyinderFillingRecordInfo.getUnitName());
item.setFactoryNum(cyinderFillingRecordInfo.getFactoryNum());
item.setCylinderVariety(cyinderFillingRecordInfo.getCylinderVariety());
......@@ -166,7 +148,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
// for (ESCylinderFillingRecordDto ci : cylinderFillingRecordPage.getRecords()) {
// saveCylinderFillingRecordToES(ci);
// }
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
saveCylinderFillingRecord2ES(cylinderFillingRecordPage.getRecords());
}
}
......@@ -176,7 +158,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Override
public Page<ESCylinderFillingRecordDto> getCyinderFillingRecord(Page<ESCylinderFillingRecordDto> cylinderFillingRecordDto) {
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordDto);
if(!ObjectUtils.isEmpty(cyinderFillingRecord)){
if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cyinderFillingRecord.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
......@@ -204,26 +186,6 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
public Page<ESCylinderFillingRecordDto> queryByKeys(ESCylinderFillingRecordDto esCylinderFillingRecordDto, int pageNum, int pageSize) {
Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_filling");
......@@ -330,7 +292,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
boolMust.must(query);
}
if(flag) { // 搜索全部
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
......@@ -342,9 +304,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<ESCylinderFillingRecordDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderFillingRecordDto esCylinderFillingRecordDto1 = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderFillingRecordDto.class);
list.add(esCylinderFillingRecordDto1);
......@@ -354,6 +315,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
......@@ -364,7 +331,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<CylinderFillingRecord> cylinderFillingRecordList = new ArrayList<>();
for (ESCylinderFillingRecordDto record : records) {
CylinderFillingRecord cylinderFillingRecord = new CylinderFillingRecord();
BeanUtils.copyProperties(record,cylinderFillingRecord);
BeanUtils.copyProperties(record, cylinderFillingRecord);
cylinderFillingRecord.setIsNotEs("1");
cylinderFillingRecord.setSequenceNbr(record.getSequenceNbr());
cylinderFillingRecordList.add(cylinderFillingRecord);
......
......@@ -7,12 +7,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESCylinderInfoRepository;
import com.yeejoin.amos.boot.module.cylinder.api.dto.WarningMsgDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.api.entity.MsgLog;
import com.yeejoin.amos.boot.module.cylinder.api.enums.EarlyWarningLevelEnum;
import com.yeejoin.amos.boot.module.cylinder.api.mapper.ScheduleMapper;
import com.yeejoin.amos.boot.module.cylinder.biz.dao.ESCylinderInfoRepository;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.MsgLogServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.StartPlatformTokenService;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.TzsAuthServiceImpl;
......@@ -26,17 +26,9 @@ import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -69,1062 +61,1031 @@ import java.util.function.IntConsumer;
@Service
@Slf4j
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper>
implements ICylinderInfoService {
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
implements ICylinderInfoService {
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Autowired
MsgLogServiceImpl msgLogService;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Autowired
private RuleTrigger ruleTrigger;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Autowired
private ScheduleMapper scheduleMapper;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${elasticsearch.password}")
private String esPwd;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
@Autowired
ESCylinderInfoRepository esCylinderInfoRepository;
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synFillingUnloadDataTask",lockAtMostFor = "PT6H")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synAreaDataTask",lockAtMostFor = "PT60M")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "* * 2 * * ?")
@SchedulerLock(name="addIntegrityDataTask",lockAtMostFor = "PT60M")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="cylinderUnitInfoTask",lockAtMostFor = "PT60M")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal-monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0 ;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="cylinderInfoTask",lockAtMostFor = "PT6H")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitCylinderInfoDataTask",lockAtMostFor = "PT6H")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitCylinderFillingDataTask",lockAtMostFor = "PT6H")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year+"-"+monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitCylinderTagsDataTask",lockAtMostFor = "PT6H")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder /(double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitIntegrityDataTask",lockAtMostFor = "PT6H")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synUnitFillingCheckDataTask",lockAtMostFor = "PT6H")
public void synUnitFillingCheckData() {
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synFillingUnloadDataTask", lockAtMostFor = "PT6H")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synAreaDataTask", lockAtMostFor = "PT60M")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "* * 2 * * ?")
@SchedulerLock(name = "addIntegrityDataTask", lockAtMostFor = "PT60M")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "cylinderUnitInfoTask", lockAtMostFor = "PT60M")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal - monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "cylinderInfoTask", lockAtMostFor = "PT6H")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synUnitCylinderInfoDataTask", lockAtMostFor = "PT6H")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synUnitCylinderFillingDataTask", lockAtMostFor = "PT6H")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year + "-" + monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synUnitCylinderTagsDataTask", lockAtMostFor = "PT6H")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder / (double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synUnitIntegrityDataTask", lockAtMostFor = "PT6H")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synUnitFillingCheckDataTask", lockAtMostFor = "PT6H")
public void synUnitFillingCheckData() {
// cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name="synFillingUnloadUnitDataTask",lockAtMostFor = "PT6H")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
@Scheduled(cron = "${tzs.cylinder.info.cron}")
@SchedulerLock(name="cylinderInfoToESTask",lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES(){
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if(!ObjectUtils.isEmpty(cylinderInfoPage)){
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
@SchedulerLock(name = "synFillingUnloadUnitDataTask", lockAtMostFor = "PT6H")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
@Scheduled(cron = "${tzs.cylinder.info.cron}")
@SchedulerLock(name = "cylinderInfoToESTask", lockAtMostFor = "PT6H")
public void setTimeSaveCylinderInfoToES() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
// for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) {
// saveCylinderInfoToES(ci);
// }
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record,esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record,cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci,esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if(!ObjectUtils.isEmpty(saveResult)){
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if(flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record, esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record, cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci, esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if (!ObjectUtils.isEmpty(saveResult)) {
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
// r.setEarlyWarningLevelName(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getName());
// r.setInspectionStatusDesc(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getStatus());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
// warningMsgDto.setUserType(cylinderInfoDto.getCustomType());
// warningMsgDto.setUserPeople(cylinderInfoDto.getCustomName());
// warningMsgDto.setUserPeoplePhone(cylinderInfoDto.getContactPhone());
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
// cylinderInfo.setNextInspectionDate(c.getNextInspectionDate());
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderInfoList(page,cylinderInfoDto,sort,appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderOutInfoList(page,cylinderInfoDto,sort,appids);
}
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderInfoList(page, cylinderInfoDto, sort, appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderOutInfoList(page, cylinderInfoDto, sort, appids);
}
}
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:23306/tzs_amos_tzs_biz_init?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://192.168.249.180:54321/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
#eureka properties:
eureka.instance.hostname= eureka
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.ip-address = 172.16.3.133
spring.datasource.password=Yeejoin@2023
eureka.client.service-url.defaultZone=http://192.168.249.13:10001/eureka/,http://192.168.249.139:10001/eureka/
eureka.instance.prefer-ip-address=true
eureka.instance.ip-address=192.168.249.13
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username=elastic
elasticsearch.password=123456
elasticsearch.password=Yeejoin@2023
spring.elasticsearch.rest.uris=http://192.168.249.218:9200,http://192.168.249.114:9200,http://192.168.249.155:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
#集群环境
spring.redis.cluster.nodes=192.168.249.218:6377,192.168.249.114:6377,192.168.249.155:6377
spring.redis.password=Yeejoin@2023
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.broker=tcp://192.168.249.180:2883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
##wechatToken
tzs.cti.url=http://36.41.172.83:8000
##wechatTokenls
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -61,41 +50,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## \u9884\u8B66\u901A\u77E5\u6A21\u677Fid
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##\u7763\u67E5\u6574\u6539\u901A\u77E5
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \u516C\u4F17\u53F7\u6D4B\u8BD5\u7528\u6237id\uFF08\u5E73\u53F0userId\uFF09
## ???????id???userId?
tzs.wechat.test.userId=3413513
fileserver.domain=https://rpm.yeeamos.com:8888/
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://192.168.249.180:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=192.168.249.13
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://192.168.249.180:19000/
## 生成监管码前缀域名
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.90:53306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.99:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=172.16.10.90
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= Yeejoin@2020
## unit(h)
alertcall.es.synchrony.time=48
fileserver.domain=https://rpm.yeeamos.com:8888/
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.90
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.90:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://172.16.10.90:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.cylinder.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
org.filter.group.seq=1564150103147573249
duty.seats.role.ids=1585956200472674305,1585956257590706177
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://36.46.137.116:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
#spring.datasource.url=jdbc:vastbase://36.46.151.113:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz
spring.datasource.username=admin
spring.datasource.password=Yeejoin@2023
#DB properties:
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://172.16.10.230:53306/${TZS_BIZ_DATABASE}?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
#spring.datasource.username=${MYSQL_ROOT_USER}
#spring.datasource.password=${MYSQL_ROOT_PASSWORD}
#eureka prioperties:
#eureka.client.serviceUrl.defaultZone=http://172.16.10.230:10001/eureka/
#eureka.client.register-with-eureka=true
#eureka.client.fetch-registry=true
#eureka.client.healthcheck.enabled=true
#ribbon.eureka.enabled=true
#eureka.instance.hostname=${spring.cloud.client.ip-address}
#eureka.instance.prefer-ip-address=true
#eureka.instance.instance-id=${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
#eureka.instance.lease-expiration-duration-in-seconds=10
#eureka.instance.lease-renewal-interval-in-seconds=5
#management.endpoint.health.show-details=always
#management.endpoints.web.exposure.include=*
#
#eureka.instance.prefer-ip-address = true
#eureka.instance.ip-address = 172.16.10.230
eureka.client.service-url.defaultZone =http://172.16.10.230:10001/eureka/
eureka.client.service-url.defaultZone=http://172.16.10.230:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
......@@ -36,25 +11,13 @@ eureka.instance.health-check-url=http://172.16.3.34:${server.port}${server.servl
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.34:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.34:${server.port}${server.servlet.context-path}/doc.html
eureka.instance.ip-address = 172.16.3.34
eureka.instance.ip-address=172.16.3.34
## ES properties:
biz.elasticsearch.port=9200
biz.elasticsearch.address=172.16.10.230
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= a123456
elasticsearch.username=elastic
elasticsearch.password=a123456
spring.elasticsearch.rest.uris=http:/172.16.10.230:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.230
......@@ -65,7 +28,6 @@ spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
......@@ -73,20 +35,13 @@ emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.41.172.83:8000
##wechatToken
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -96,67 +51,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## ???????id???userId?
tzs.wechat.test.userId=3413513
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://172.16.10.230:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=172.16.10.230
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://172.16.10.230:9000/
## ɼǰ׺
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://113.134.211.174:3306/xiy_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.28:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://192.168.1.10:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.3.28
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.3.28:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.cylinder.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:13306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
......@@ -8,7 +8,7 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/96333.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/Tcm.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
......@@ -37,20 +37,20 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.apache.ibatis" level="debug"/>
<logger name="org.mybatis" level="debug" />
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="org.springframework" level="debug"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
<logger name="org.apache.activemq" level="debug"/>
<logger name="org.typroject" level="debug"/>
<logger name="com.yeejoin" level="debug"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<root level="error">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/cylinder.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- ELK管理 -->
<appender name="ELK" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>172.16.10.230:4560</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/cylinder.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/cylinder.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
package com.yeejoin.amos.boot.module.jczs.biz.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
......@@ -16,6 +13,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
@Configuration
public class ElasticSearchClientConfig {
......@@ -28,34 +27,25 @@ public class ElasticSearchClientConfig {
private String password;
@Bean
@Qualifier("highLevelClient")
public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost);
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒)
return requestConfigBuilder.setConnectTimeout(5000 * 1000)
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
.setSocketTimeout(6000 * 1000);
});
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000 * 1000) // 连接超时(默认为1秒)
.setSocketTimeout(6000 * 1000);// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
}
});// 调整最大重试超时时间(默认为30秒).setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(builder);
} catch (Exception e) {
......
......@@ -89,6 +89,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
@Autowired
EquipmentCategoryMapper equipmentCategoryMapper;
@Autowired
RestHighLevelClient restHighLevelClient;
@Value("classpath:/json/equipCategory.json")
private Resource equipCategory;
......@@ -148,18 +151,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
private static String USE_CODE = "use_code";
private static String ORG_BRANCH_CODE = "supervise_org_code";
......@@ -1200,11 +1191,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询
// //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
}
ResponseModel<Page<Map<String, Object>>> model = new ResponseModel<>();
JSONObject object = getCompanyType().get(0);
String level = object.getString("level");
String code = object.getString("orgCode");
......@@ -1219,19 +1209,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size"));
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress, esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
......@@ -1329,7 +1306,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<JSONObject> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
......@@ -1348,7 +1325,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
throw new RuntimeException(e);
} finally {
try {
esClient.close();
restHighLevelClient.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -10,24 +10,15 @@ import com.yeejoin.amos.boot.module.jczs.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.jczs.flc.api.entity.CylinderFillingRecord;
import com.yeejoin.amos.boot.module.jczs.flc.api.mapper.CylinderFillingRecordMapper;
import com.yeejoin.amos.boot.module.jczs.flc.api.service.ICylinderFillingRecordService;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -55,17 +46,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Autowired
CylinderFillingRecordMapper cylinderFillingRecordMapper;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
/**
* 分页查询
......@@ -127,7 +109,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Scheduled(cron = "${tzs.cylinder.fill.cron}")
public void setTimeSaveCylinderInfoToES(){
public void setTimeSaveCylinderInfoToES() {
Page<ESCylinderFillingRecordDto> cylinderFillingRecordPage = new Page<>();
Page<ESCylinderFillingRecordDto> cyinderInfoList = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
Long count = cyinderInfoList.getCurrent();
......@@ -143,10 +125,10 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
cylinderFillingRecordPage.setCurrent(i);
cylinderFillingRecordPage.setSize(1000);
cylinderFillingRecordPage = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
cylinderFillingRecordPage.getRecords().stream().map(item->{
if(!ObjectUtils.isEmpty(item.getSequenceCode())){
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(),item.getSequenceCode());
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
cylinderFillingRecordPage.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
item.setUnitName(cyinderFillingRecordInfo.getUnitName());
item.setFactoryNum(cyinderFillingRecordInfo.getFactoryNum());
item.setCylinderVariety(cyinderFillingRecordInfo.getCylinderVariety());
......@@ -164,7 +146,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
// for (ESCylinderFillingRecordDto ci : cylinderFillingRecordPage.getRecords()) {
// saveCylinderFillingRecordToES(ci);
// }
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
saveCylinderFillingRecord2ES(cylinderFillingRecordPage.getRecords());
}
}
......@@ -174,7 +156,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Override
public Page<ESCylinderFillingRecordDto> getCyinderFillingRecord(Page<ESCylinderFillingRecordDto> cylinderFillingRecordDto) {
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordDto);
if(!ObjectUtils.isEmpty(cyinderFillingRecord)){
if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cyinderFillingRecord.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
......@@ -202,26 +184,6 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
public Page<ESCylinderFillingRecordDto> queryByKeys(ESCylinderFillingRecordDto esCylinderFillingRecordDto, int pageNum, int pageSize) {
Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_filling");
......@@ -328,7 +290,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
boolMust.must(query);
}
if(flag) { // 搜索全部
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
......@@ -340,9 +302,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<ESCylinderFillingRecordDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderFillingRecordDto esCylinderFillingRecordDto1 = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderFillingRecordDto.class);
list.add(esCylinderFillingRecordDto1);
......@@ -352,6 +313,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
......@@ -362,7 +329,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<CylinderFillingRecord> cylinderFillingRecordList = new ArrayList<>();
for (ESCylinderFillingRecordDto record : records) {
CylinderFillingRecord cylinderFillingRecord = new CylinderFillingRecord();
BeanUtils.copyProperties(record,cylinderFillingRecord);
BeanUtils.copyProperties(record, cylinderFillingRecord);
cylinderFillingRecord.setIsNotEs("1");
cylinderFillingRecord.setSequenceNbr(record.getSequenceNbr());
cylinderFillingRecordList.add(cylinderFillingRecord);
......
......@@ -25,17 +25,9 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -136,18 +128,8 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
StartPlatformTokenService startPlatformTokenService;
......@@ -760,27 +742,6 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
......@@ -906,9 +867,8 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
......@@ -918,6 +878,12 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
......
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:23306/tzs_amos_tzs_biz_init?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://192.168.249.180:54321/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
#eureka properties:
eureka.instance.hostname= eureka
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.ip-address = 172.16.3.133
spring.datasource.password=Yeejoin@2023
eureka.client.service-url.defaultZone=http://192.168.249.13:10001/eureka/,http://192.168.249.139:10001/eureka/
eureka.instance.prefer-ip-address=true
eureka.instance.ip-address=192.168.249.13
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username=elastic
elasticsearch.password=123456
elasticsearch.password=Yeejoin@2023
spring.elasticsearch.rest.uris=http://192.168.249.218:9200,http://192.168.249.114:9200,http://192.168.249.155:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
#集群环境
spring.redis.cluster.nodes=192.168.249.218:6377,192.168.249.114:6377,192.168.249.155:6377
spring.redis.password=Yeejoin@2023
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.broker=tcp://192.168.249.180:2883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
##wechatToken
tzs.cti.url=http://36.41.172.83:8000
##wechatTokenls
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -61,41 +50,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## \u9884\u8B66\u901A\u77E5\u6A21\u677Fid
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##\u7763\u67E5\u6574\u6539\u901A\u77E5
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \u516C\u4F17\u53F7\u6D4B\u8BD5\u7528\u6237id\uFF08\u5E73\u53F0userId\uFF09
## ???????id???userId?
tzs.wechat.test.userId=3413513
fileserver.domain=https://rpm.yeeamos.com:8888/
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://192.168.249.180:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=192.168.249.13
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://192.168.249.180:19000/
## 生成监管码前缀域名
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.90:53306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.99:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=172.16.10.90
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= Yeejoin@2020
## unit(h)
alertcall.es.synchrony.time=48
fileserver.domain=https://rpm.yeeamos.com:8888/
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.90
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.90:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://172.16.10.90:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.jczs.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
org.filter.group.seq=1564150103147573249
duty.seats.role.ids=1585956200472674305,1585956257590706177
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://36.46.137.116:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
#spring.datasource.url=jdbc:vastbase://36.46.151.113:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz
spring.datasource.username=admin
spring.datasource.password=Yeejoin@2023
#DB properties:
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://172.16.10.230:53306/${TZS_BIZ_DATABASE}?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
#spring.datasource.username=${MYSQL_ROOT_USER}
#spring.datasource.password=${MYSQL_ROOT_PASSWORD}
#eureka prioperties:
#eureka.client.serviceUrl.defaultZone=http://172.16.10.230:10001/eureka/
#eureka.client.register-with-eureka=true
#eureka.client.fetch-registry=true
#eureka.client.healthcheck.enabled=true
#ribbon.eureka.enabled=true
#eureka.instance.hostname=${spring.cloud.client.ip-address}
#eureka.instance.prefer-ip-address=true
#eureka.instance.instance-id=${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
#eureka.instance.lease-expiration-duration-in-seconds=10
#eureka.instance.lease-renewal-interval-in-seconds=5
#management.endpoint.health.show-details=always
#management.endpoints.web.exposure.include=*
#
#eureka.instance.prefer-ip-address = true
#eureka.instance.ip-address = 172.16.10.230
eureka.client.service-url.defaultZone =http://172.16.10.230:10001/eureka/
eureka.client.service-url.defaultZone=http://172.16.10.230:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
......@@ -36,25 +11,13 @@ eureka.instance.health-check-url=http://172.16.3.34:${server.port}${server.servl
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.34:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.34:${server.port}${server.servlet.context-path}/doc.html
eureka.instance.ip-address = 172.16.3.34
eureka.instance.ip-address=172.16.3.34
## ES properties:
biz.elasticsearch.port=9200
biz.elasticsearch.address=172.16.10.230
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= a123456
elasticsearch.username=elastic
elasticsearch.password=a123456
spring.elasticsearch.rest.uris=http:/172.16.10.230:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.230
......@@ -65,7 +28,6 @@ spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
......@@ -73,20 +35,13 @@ emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.41.172.83:8000
##wechatToken
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -96,67 +51,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## ???????id???userId?
tzs.wechat.test.userId=3413513
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://172.16.10.230:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=172.16.10.230
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://172.16.10.230:9000/
## ɼǰ׺
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://113.134.211.174:3306/xiy_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.28:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://192.168.1.10:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.3.28
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.3.28:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.jczs.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:13306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
......@@ -8,7 +8,7 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/cylinder.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/Tcm.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
......@@ -37,20 +37,20 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.apache.ibatis" level="debug"/>
<logger name="org.mybatis" level="debug" />
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="org.springframework" level="debug"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
<logger name="org.apache.activemq" level="debug"/>
<logger name="org.typroject" level="debug"/>
<logger name="com.yeejoin" level="debug"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<root level="error">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/jczs.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- ELK管理 -->
<appender name="ELK" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>172.16.10.230:4560</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/jczs.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/jczs.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
package com.yeejoin.amos.boot.module.tcm.biz.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
......@@ -15,6 +12,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
@Configuration
public class ElasticSearchClientConfig {
......@@ -28,34 +26,25 @@ public class ElasticSearchClientConfig {
private String password;
@Bean
@Qualifier("highLevelClient")
public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost);
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒)
return requestConfigBuilder.setConnectTimeout(5000 * 1000)
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
.setSocketTimeout(6000 * 1000);
});
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000 * 1000) // 连接超时(默认为1秒)
.setSocketTimeout(6000 * 1000);// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
}
});// 调整最大重试超时时间(默认为30秒).setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(builder);
} catch (Exception e) {
......
......@@ -122,6 +122,9 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
private String code;
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
private RedisUtils redisUtils;
//管辖机构redis缓存key
private static final String REGULATOR_UNIT_TREE = "REGULATOR_UNIT_TREE";
......@@ -148,17 +151,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
private static String USE_CODE = "use_code";
......@@ -1200,11 +1192,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return save;
}
public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询
// //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
}
ResponseModel<Page<Map<String, Object>>> model = new ResponseModel<>();
JSONObject object = getCompanyType().get(0);
String level = object.getString("level");
String code = object.getString("orgCode");
......@@ -1219,19 +1210,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size"));
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress, esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
......@@ -1329,7 +1307,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<JSONObject> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
......@@ -1348,7 +1326,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
throw new RuntimeException(e);
} finally {
try {
esClient.close();
restHighLevelClient.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -10,25 +10,15 @@ import com.yeejoin.amos.boot.module.tcm.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.CylinderFillingRecord;
import com.yeejoin.amos.boot.module.tcm.flc.api.mapper.CylinderFillingRecordMapper;
import com.yeejoin.amos.boot.module.tcm.flc.api.service.ICylinderFillingRecordService;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -55,17 +45,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Autowired
CylinderFillingRecordMapper cylinderFillingRecordMapper;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
/**
* 分页查询
......@@ -127,7 +108,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
//@Scheduled(cron = "${tzs.cylinder.fill.cron}")
public void setTimeSaveCylinderInfoToES(){
public void setTimeSaveCylinderInfoToES() {
Page<ESCylinderFillingRecordDto> cylinderFillingRecordPage = new Page<>();
Page<ESCylinderFillingRecordDto> cyinderInfoList = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
Long count = cyinderInfoList.getCurrent();
......@@ -143,10 +124,10 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
cylinderFillingRecordPage.setCurrent(i);
cylinderFillingRecordPage.setSize(1000);
cylinderFillingRecordPage = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
cylinderFillingRecordPage.getRecords().stream().map(item->{
if(!ObjectUtils.isEmpty(item.getSequenceCode())){
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(),item.getSequenceCode());
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
cylinderFillingRecordPage.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
item.setUnitName(cyinderFillingRecordInfo.getUnitName());
item.setFactoryNum(cyinderFillingRecordInfo.getFactoryNum());
item.setCylinderVariety(cyinderFillingRecordInfo.getCylinderVariety());
......@@ -164,7 +145,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
// for (ESCylinderFillingRecordDto ci : cylinderFillingRecordPage.getRecords()) {
// saveCylinderFillingRecordToES(ci);
// }
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
saveCylinderFillingRecord2ES(cylinderFillingRecordPage.getRecords());
}
}
......@@ -174,7 +155,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Override
public Page<ESCylinderFillingRecordDto> getCyinderFillingRecord(Page<ESCylinderFillingRecordDto> cylinderFillingRecordDto) {
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordDto);
if(!ObjectUtils.isEmpty(cyinderFillingRecord)){
if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cyinderFillingRecord.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
......@@ -203,25 +184,6 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_filling");
......@@ -328,7 +290,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
boolMust.must(query);
}
if(flag) { // 搜索全部
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
......@@ -340,7 +302,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<ESCylinderFillingRecordDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
......@@ -352,6 +314,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
......@@ -362,7 +330,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<CylinderFillingRecord> cylinderFillingRecordList = new ArrayList<>();
for (ESCylinderFillingRecordDto record : records) {
CylinderFillingRecord cylinderFillingRecord = new CylinderFillingRecord();
BeanUtils.copyProperties(record,cylinderFillingRecord);
BeanUtils.copyProperties(record, cylinderFillingRecord);
cylinderFillingRecord.setIsNotEs("1");
cylinderFillingRecord.setSequenceNbr(record.getSequenceNbr());
cylinderFillingRecordList.add(cylinderFillingRecord);
......
......@@ -25,17 +25,9 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -43,7 +35,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
......@@ -68,1040 +59,1010 @@ import java.util.function.IntConsumer;
@Service
@Slf4j
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper>
implements ICylinderInfoService {
implements ICylinderInfoService {
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
private ScheduleMapper scheduleMapper;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Autowired
RestHighLevelClient restHighLevelClient;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
@Autowired
ESCylinderInfoRepository esCylinderInfoRepository;
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal-monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0 ;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year+"-"+monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder /(double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal - monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year + "-" + monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder / (double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
// cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
// @Scheduled(cron = "${tzs.cylinder.info.cron}")
public void setTimeSaveCylinderInfoToES(){
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if(!ObjectUtils.isEmpty(cylinderInfoPage)){
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
//@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
// @Scheduled(cron = "${tzs.cylinder.info.cron}")
public void setTimeSaveCylinderInfoToES() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
// for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) {
// saveCylinderInfoToES(ci);
// }
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record,esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record,cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci,esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if(!ObjectUtils.isEmpty(saveResult)){
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if(flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record, esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record, cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci, esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if (!ObjectUtils.isEmpty(saveResult)) {
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
// r.setEarlyWarningLevelName(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getName());
// r.setInspectionStatusDesc(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getStatus());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
// warningMsgDto.setUserType(cylinderInfoDto.getCustomType());
// warningMsgDto.setUserPeople(cylinderInfoDto.getCustomName());
// warningMsgDto.setUserPeoplePhone(cylinderInfoDto.getContactPhone());
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
// cylinderInfo.setNextInspectionDate(c.getNextInspectionDate());
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderInfoList(page,cylinderInfoDto,sort,appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderOutInfoList(page,cylinderInfoDto,sort,appids);
}
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderInfoList(page, cylinderInfoDto, sort, appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderOutInfoList(page, cylinderInfoDto, sort, appids);
}
}
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:23306/tzs_amos_tzs_biz_init?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://192.168.249.180:54321/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
#eureka properties:
eureka.instance.hostname= eureka
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.ip-address = 172.16.3.133
spring.datasource.password=Yeejoin@2023
eureka.client.service-url.defaultZone=http://192.168.249.13:10001/eureka/,http://192.168.249.139:10001/eureka/
eureka.instance.prefer-ip-address=true
eureka.instance.ip-address=192.168.249.13
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username=elastic
elasticsearch.password=123456
elasticsearch.password=Yeejoin@2023
spring.elasticsearch.rest.uris=http://192.168.249.218:9200,http://192.168.249.114:9200,http://192.168.249.155:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
#集群环境
spring.redis.cluster.nodes=192.168.249.218:6377,192.168.249.114:6377,192.168.249.155:6377
spring.redis.password=Yeejoin@2023
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.broker=tcp://192.168.249.180:2883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
##wechatToken
tzs.cti.url=http://36.41.172.83:8000
##wechatTokenls
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -61,41 +50,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## \u9884\u8B66\u901A\u77E5\u6A21\u677Fid
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##\u7763\u67E5\u6574\u6539\u901A\u77E5
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \u516C\u4F17\u53F7\u6D4B\u8BD5\u7528\u6237id\uFF08\u5E73\u53F0userId\uFF09
## ???????id???userId?
tzs.wechat.test.userId=3413513
fileserver.domain=https://rpm.yeeamos.com:8888/
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://192.168.249.180:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=192.168.249.13
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://192.168.249.180:19000/
## 生成监管码前缀域名
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.90:53306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.99:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=172.16.10.90
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= Yeejoin@2020
## unit(h)
alertcall.es.synchrony.time=48
fileserver.domain=https://rpm.yeeamos.com:8888/
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.90
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.90:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://172.16.10.90:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.tzs.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
org.filter.group.seq=1564150103147573249
duty.seats.role.ids=1585956200472674305,1585956257590706177
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://36.46.137.116:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
#spring.datasource.url=jdbc:vastbase://36.46.151.113:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz
spring.datasource.username=admin
spring.datasource.password=Yeejoin@2023
#DB properties:
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://172.16.10.230:53306/${TZS_BIZ_DATABASE}?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
#spring.datasource.username=${MYSQL_ROOT_USER}
#spring.datasource.password=${MYSQL_ROOT_PASSWORD}
#eureka prioperties:
#eureka.client.serviceUrl.defaultZone=http://172.16.10.230:10001/eureka/
#eureka.client.register-with-eureka=true
#eureka.client.fetch-registry=true
#eureka.client.healthcheck.enabled=true
#ribbon.eureka.enabled=true
#eureka.instance.hostname=${spring.cloud.client.ip-address}
#eureka.instance.prefer-ip-address=true
#eureka.instance.instance-id=${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
#eureka.instance.lease-expiration-duration-in-seconds=10
#eureka.instance.lease-renewal-interval-in-seconds=5
#management.endpoint.health.show-details=always
#management.endpoints.web.exposure.include=*
#
#eureka.instance.prefer-ip-address = true
#eureka.instance.ip-address = 172.16.10.230
eureka.client.service-url.defaultZone =http://172.16.10.230:10001/eureka/
eureka.client.service-url.defaultZone=http://172.16.10.230:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
......@@ -36,25 +12,13 @@ eureka.instance.health-check-url=http://172.16.3.34:${server.port}${server.servl
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.34:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.34:${server.port}${server.servlet.context-path}/doc.html
eureka.instance.ip-address = 172.16.3.34
eureka.instance.ip-address=172.16.3.34
## ES properties:
biz.elasticsearch.port=9200
biz.elasticsearch.address=172.16.10.230
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= a123456
elasticsearch.username=elastic
elasticsearch.password=a123456
spring.elasticsearch.rest.uris=http:/172.16.10.230:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.230
......@@ -65,7 +29,6 @@ spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
......@@ -73,20 +36,13 @@ emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.41.172.83:8000
##wechatToken
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -96,67 +52,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## ???????id???userId?
tzs.wechat.test.userId=3413513
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://172.16.10.230:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=172.16.10.230
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://172.16.10.230:9000/
## ɼǰ׺
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://113.134.211.174:3306/xiy_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.28:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://192.168.1.10:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.3.28
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.3.28:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.tzs.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:13306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
spring.application.name=TZS-COMMON
spring.application.name=TZS-COMMON-SHG
server.servlet.context-path=/tcm
server.port=11001
server.port=11002
spring.profiles.active=dev3
#最大等待队列长度,默认100
server.tomcat.accept-count=1000
......@@ -11,7 +11,7 @@ server.tomcat.threads.max=800
#最小线程数,默认10
server.tomcat.threads.min-spare=100
logging.level.net.javacrumbs.shedlock=DEBUG
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
......
......@@ -8,7 +8,7 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/jczs.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/Tcm.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
......@@ -37,20 +37,20 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.apache.ibatis" level="debug"/>
<logger name="org.mybatis" level="debug" />
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="org.springframework" level="debug"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
<logger name="org.apache.activemq" level="debug"/>
<logger name="org.typroject" level="debug"/>
<logger name="com.yeejoin" level="debug"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<root level="error">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/Tcm.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- ELK管理 -->
<appender name="ELK" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>172.16.10.230:4560</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
</root>
</configuration>
\ No newline at end of file
......@@ -37,20 +37,20 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.apache.ibatis" level="debug"/>
<logger name="org.mybatis" level="debug" />
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="org.springframework" level="debug"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
<logger name="org.apache.activemq" level="debug"/>
<logger name="org.typroject" level="debug"/>
<logger name="com.yeejoin" level="debug"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<root level="debug">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/Tcm.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/Tcm.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
package com.yeejoin.amos.boot.module.ymt.biz.config;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
......@@ -16,6 +13,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
@Configuration
public class ElasticSearchClientConfig {
......@@ -35,27 +34,19 @@ public class ElasticSearchClientConfig {
new UsernamePasswordCredentials(username, password));
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost);
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒)
return requestConfigBuilder.setConnectTimeout(5000 * 1000)
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
.setSocketTimeout(6000 * 1000);
});
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
public RequestConfig.Builder customizeRequestConfig(
RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000 * 1000) // 连接超时(默认为1秒)
.setSocketTimeout(6000 * 1000);// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
}
});// 调整最大重试超时时间(默认为30秒).setMaxRetryTimeoutMillis(60000);
return new RestHighLevelClient(builder);
} catch (Exception e) {
......
......@@ -158,17 +158,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
private static String USE_CODE = "use_code";
......@@ -1185,11 +1176,10 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
public Page<JSONObject> queryByKeys(JSONObject map) {
//根据当前登录人查询
// //根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
}
ResponseModel<Page<Map<String, Object>>> model = new ResponseModel<>();
JSONObject object = getCompanyType().get(0);
String level = object.getString("level");
String code = object.getString("orgCode");
......@@ -1204,19 +1194,6 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
}
Page<JSONObject> result = new Page<>(map.getInteger("number"), map.getInteger("size"));
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress, esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
......@@ -1226,12 +1203,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//SEQUENCE_NBR
if (!ObjectUtils.isEmpty(map.getString("SEQUENCE_NBR"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("SEQUENCE_NBR", "*" + map.getString("SEQUENCE_NBR") + "*"));
meBuilder.must(QueryBuilders.matchPhraseQuery("SEQUENCE_NBR", "*"+map.getString("SEQUENCE_NBR")+"*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_NAME", "*" + map.getString("ORG_BRANCH_NAME") + "*"));
query.must(QueryBuilders.matchPhraseQuery("ORG_BRANCH_NAME", "*"+map.getString("ORG_BRANCH_NAME")+"*" ));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
......@@ -1241,12 +1218,12 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_NAME"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchPhraseQuery("USE_UNIT_NAME", "*" + map.getString("USE_UNIT_NAME") + "*"));
query.must(QueryBuilders.matchPhraseQuery("USE_UNIT_NAME", "*"+map.getString("USE_UNIT_NAME")+"*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("USE_UNIT_CREDIT_CODE", "*" + map.getString("USE_UNIT_CREDIT_CODE") + "*"));
meBuilder.must(QueryBuilders.matchPhraseQuery("USE_UNIT_CREDIT_CODE", "*"+map.getString("USE_UNIT_CREDIT_CODE")+"*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
......@@ -1256,23 +1233,23 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
}
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_LIST", "*" + map.getString("EQU_LIST") + "*"));
meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_LIST", "*"+map.getString("EQU_LIST")+"*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_CATEGORY"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_CATEGORY", "*" + map.getString("EQU_CATEGORY") + "*"));
meBuilder.must(QueryBuilders.matchPhraseQuery("EQU_CATEGORY", "*"+map.getString("EQU_CATEGORY")+"*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("USE_ORG_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.wildcardQuery("USE_ORG_CODE", "*" + map.getString("USE_ORG_CODE").toLowerCase() + "*"));
meBuilder.must(QueryBuilders.wildcardQuery("USE_ORG_CODE", "*"+map.getString("USE_ORG_CODE").toLowerCase()+"*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("CODE96333"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.wildcardQuery("CODE96333", "*" + map.getString("CODE96333").toLowerCase() + "*"));
meBuilder.must(QueryBuilders.wildcardQuery("CODE96333", "*"+map.getString("CODE96333").toLowerCase()+"*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_CODE"))) {
......@@ -1283,7 +1260,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.wildcardQuery("SUPERVISORY_CODE", "*" + map.getString("SUPERVISORY_CODE").toLowerCase() + "*"));
meBuilder.must(QueryBuilders.wildcardQuery("SUPERVISORY_CODE", "*"+map.getString("SUPERVISORY_CODE").toLowerCase()+"*"));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("USE_PLACE"))) {
......@@ -1296,14 +1273,14 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
query.must(QueryBuilders.matchPhraseQuery("ADDRESS", "*" + map.getString("ADDRESS") + "*"));
boolMust.must(query);
}
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE"))) {
if (!ObjectUtils.isEmpty(map.getString("EQU_STATE")) ) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("EQU_STATE", map.getLong("EQU_STATE")));
boolMust.must(meBuilder);
}
if (!ObjectUtils.isEmpty(map.getString("STATUS"))) {
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*" + map.getString("STATUS") + "*"));
meBuilder.must(QueryBuilders.matchPhraseQuery("STATUS", "*"+map.getString("STATUS")+"*"));
boolMust.must(meBuilder);
}
builder.query(boolMust);
......@@ -1314,7 +1291,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
List<JSONObject> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits().getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
......@@ -1333,7 +1310,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
throw new RuntimeException(e);
} finally {
try {
esClient.close();
restHighLevelClient.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
......
......@@ -10,24 +10,15 @@ import com.yeejoin.amos.boot.module.ymt.flc.api.dto.CylinderFillingRecordDto;
import com.yeejoin.amos.boot.module.ymt.flc.api.entity.CylinderFillingRecord;
import com.yeejoin.amos.boot.module.ymt.flc.api.mapper.CylinderFillingRecordMapper;
import com.yeejoin.amos.boot.module.ymt.flc.api.service.ICylinderFillingRecordService;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -55,17 +46,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Autowired
CylinderFillingRecordMapper cylinderFillingRecordMapper;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
RestHighLevelClient restHighLevelClient;
/**
* 分页查询
......@@ -127,7 +109,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Scheduled(cron = "${tzs.cylinder.fill.cron}")
public void setTimeSaveCylinderInfoToES(){
public void setTimeSaveCylinderInfoToES() {
Page<ESCylinderFillingRecordDto> cylinderFillingRecordPage = new Page<>();
Page<ESCylinderFillingRecordDto> cyinderInfoList = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
Long count = cyinderInfoList.getCurrent();
......@@ -143,10 +125,10 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
cylinderFillingRecordPage.setCurrent(i);
cylinderFillingRecordPage.setSize(1000);
cylinderFillingRecordPage = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordPage);
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
cylinderFillingRecordPage.getRecords().stream().map(item->{
if(!ObjectUtils.isEmpty(item.getSequenceCode())){
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(),item.getSequenceCode());
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
cylinderFillingRecordPage.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
item.setUnitName(cyinderFillingRecordInfo.getUnitName());
item.setFactoryNum(cyinderFillingRecordInfo.getFactoryNum());
item.setCylinderVariety(cyinderFillingRecordInfo.getCylinderVariety());
......@@ -164,7 +146,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
// for (ESCylinderFillingRecordDto ci : cylinderFillingRecordPage.getRecords()) {
// saveCylinderFillingRecordToES(ci);
// }
if(!ObjectUtils.isEmpty(cylinderFillingRecordPage)){
if (!ObjectUtils.isEmpty(cylinderFillingRecordPage)) {
saveCylinderFillingRecord2ES(cylinderFillingRecordPage.getRecords());
}
}
......@@ -174,7 +156,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Override
public Page<ESCylinderFillingRecordDto> getCyinderFillingRecord(Page<ESCylinderFillingRecordDto> cylinderFillingRecordDto) {
Page<ESCylinderFillingRecordDto> cyinderFillingRecord = cylinderFillingRecordMapper.getCyinderFillingRecord(cylinderFillingRecordDto);
if(!ObjectUtils.isEmpty(cyinderFillingRecord)){
if (!ObjectUtils.isEmpty(cyinderFillingRecord)) {
cyinderFillingRecord.getRecords().stream().map(item -> {
if (!ObjectUtils.isEmpty(item.getSequenceCode())) {
ESCylinderFillingRecordDto cyinderFillingRecordInfo = cylinderFillingRecordMapper.getCyinderFillingRecordInfo(item.getAppId(), item.getSequenceCode());
......@@ -202,26 +184,6 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
public Page<ESCylinderFillingRecordDto> queryByKeys(ESCylinderFillingRecordDto esCylinderFillingRecordDto, int pageNum, int pageSize) {
Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_filling");
......@@ -328,7 +290,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
boolMust.must(query);
}
if(flag) { // 搜索全部
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
......@@ -340,9 +302,8 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<ESCylinderFillingRecordDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderFillingRecordDto esCylinderFillingRecordDto1 = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderFillingRecordDto.class);
list.add(esCylinderFillingRecordDto1);
......@@ -352,6 +313,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
......@@ -362,7 +329,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
List<CylinderFillingRecord> cylinderFillingRecordList = new ArrayList<>();
for (ESCylinderFillingRecordDto record : records) {
CylinderFillingRecord cylinderFillingRecord = new CylinderFillingRecord();
BeanUtils.copyProperties(record,cylinderFillingRecord);
BeanUtils.copyProperties(record, cylinderFillingRecord);
cylinderFillingRecord.setIsNotEs("1");
cylinderFillingRecord.setSequenceNbr(record.getSequenceNbr());
cylinderFillingRecordList.add(cylinderFillingRecord);
......
......@@ -25,17 +25,9 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
......@@ -68,1040 +60,1010 @@ import java.util.function.IntConsumer;
@Service
@Slf4j
public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, CylinderInfo, CylinderInfoMapper>
implements ICylinderInfoService {
implements ICylinderInfoService {
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitServiceImpl cylinderUnitServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderUnitDataServiceImpl cylinderUnitDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderInfoDataServiceImpl cylinderInfoDataServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderTagsServiceImpl cylinderTagsServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderFillingServiceImpl cylinderFillingServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderIntegrityDataServiceImpl cylinderIntegrityDataServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingRecordServiceImpl cylinderFillingRecordServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderFillingCheckServiceImpl cylinderFillingCheckServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderAreaDataServiceImpl cylinderAreaDataServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderFillingUnloadDataServiceImpl cylinderFillingUnloadDataServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderInfoDataUnitServiceImpl cylinderInfoDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderFillingDataUnitServiceImpl cylinderFillingDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderTagsDataUnitServiceImpl cylinderTagsDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderIntegrityDataUnitServiceImpl cylinderIntegrityDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingCheckDataUnitServiceImpl cylinderFillingCheckDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
CylinderFillingUnloadDataUnitServiceImpl cylinderFillingUnloadDataUnitServiceImpl;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
MsgLogServiceImpl msgLogService;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
private RuleTrigger ruleTrigger;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
TzsAuthServiceImpl tzsAuthService;
@Autowired
private ScheduleMapper scheduleMapper;
@Autowired
private ScheduleMapper scheduleMapper;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶监管/cylwarningmsg}")
private String packageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Autowired
RestHighLevelClient restHighLevelClient;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Value("${elasticsearch.username}")
private String esUserName;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Value("${elasticsearch.password}")
private String esPwd;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
StartPlatformTokenService startPlatformTokenService;
@Autowired
CylinderInfoMapper cylinderInfoMapper;
@Autowired
@Autowired
ESCylinderInfoRepository esCylinderInfoRepository;
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal-monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0 ;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}else
{
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year+"-"+monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder /(double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
/**
* 分页查询
*/
public Page<CylinderInfoDto> queryForCylinderInfoPage(Page<CylinderInfoDto> page) {
return queryForPage(page, null, false);
}
/**
* 列表查询 示例
*/
public List<CylinderInfoDto> queryForCylinderInfoList() {
return queryForList("", false);
}
@Override
public Map<String, String> queryNumAndOutOfDateNum(Long unitId) {
return baseMapper.queryNumAndOutOfDateNum(unitId);
}
/**
* 获取上个月气瓶总量
*/
public Integer getMonthInfoTotal(String regionCode) {
return baseMapper.getMonthInfoTotal(regionCode);
}
/**
* 获取上个月气瓶总量
*/
public Integer getLastMonthInfoTotal(String regionCode) {
return baseMapper.getLastMonthInfoTotal(regionCode);
}
/**
* 获取上上个月气瓶总量
*/
public Integer getMonthBeforeLastInfoTotal(String regionCode) {
return baseMapper.getMonthBeforeLastInfoTotal(regionCode);
}
public Integer getInfoTotalByRegionCode(String regionCode) {
return baseMapper.getInfoTotalByRegionCode(regionCode);
}
public Double queryIntegirtyByAppId(String appId) {
return this.baseMapper.queryIntegirtyByAppId(appId);
}
public Integer getWarnNum(String code) {
return baseMapper.getWarnNum(code);
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadData() {
cylinderFillingUnloadDataServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadData>());
countByRegion(regionModel -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataDto temp = new CylinderFillingUnloadDataDto();
Double fillingSum = cylinderFillingRecordServiceImpl
.getFillingSum(String.valueOf(regionModel.getRegionCode()), now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataServiceImpl.createWithModel(temp);
}
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synAreaData() {
cylinderAreaDataServiceImpl.remove(new LambdaQueryWrapper<CylinderAreaData>());
countByRegion(regionModel -> {
CylinderAreaDataDto temp = new CylinderAreaDataDto();
temp.setAreaName(regionModel.getRegionName());
String code = regionModel.getRegionCode() + "";
Integer cylinderTotal = this.getInfoTotalByRegionCode(code);
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(code);
Integer cylinderUnitWarn = cylinderUnitServiceImpl.getWarnNum(code);
Integer cylinderInfoWarn = this.getWarnNum(code);
int warmTotal = cylinderUnitWarn + cylinderInfoWarn;
String parentCode = "";
if ("610000".equals(code)) {
parentCode = "-1";
} else if (!"00".equals(code.substring(4, 6))) {
parentCode = code.substring(0, 4) + "00";
} else {
parentCode = "610000";
}
temp.setCylinderNum(Long.valueOf(cylinderTotal));
temp.setParentRegionCode(parentCode);
temp.setRegionCode(regionModel.getRegionCode() + "");
temp.setUnitNum(Long.valueOf(cylinderUnitTotal));
temp.setWarnNum((long) warmTotal);
cylinderAreaDataServiceImpl.createWithModel(temp);
});
}
/**
* 按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "* * 2 * * ?")
public void addIntegrityData() {
System.out.println("====================数据完整性开始============================");
cylinderIntegrityDataServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityData>());
countByRegion(regionModel -> {
List<CylinderUnit> unitlist = cylinderUnitServiceImpl.list(new LambdaQueryWrapper<CylinderUnit>()
.like(CylinderUnit::getRegionCode, regionModel.getRegionCode()));
List<CylinderIntegrityDataDto> tempList = new LinkedList<>();
System.out.println(
"====================regioncode: " + regionModel.getRegionCode() + "============================");
unitlist.forEach(t -> {
System.out.println("====================appId: " + t.getAppId() + "============================");
CylinderIntegrityDataDto temp = new CylinderIntegrityDataDto();
String appId = t.getAppId();
Double totalIntegirty = 0d;
// tz_cylinder_info
Double unitIntegirty = t.getIntegrity();
unitIntegirty = unitIntegirty == null ? 0d : unitIntegirty;
// tz_cylinder_tags
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(appId);
tagIntegirty = tagIntegirty == null ? 0d : tagIntegirty;
// tz_cylinder_info
Double infoIntegirty = this.queryIntegirtyByAppId(appId);
infoIntegirty = infoIntegirty == null ? 0d : infoIntegirty;
// tz_cylinder_filling_record 30天内
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(appId);
recordIntegirty = recordIntegirty == null ? 0d : recordIntegirty;
// tz_cylinder_filling 30天内ji
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(appId);
fillingIntegirty = fillingIntegirty == null ? 0d : fillingIntegirty;
// tz_cylinder_filling_check 30天内
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(appId);
checkIntegirty = checkIntegirty == null ? 0d : checkIntegirty;
totalIntegirty = (unitIntegirty + tagIntegirty + infoIntegirty + recordIntegirty + fillingIntegirty
+ checkIntegirty) / 6;
BigDecimal bg = new BigDecimal(totalIntegirty);
totalIntegirty = bg.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue() * 100;
temp.setAppId(appId);
temp.setRegionCode(String.valueOf(regionModel.getRegionCode()));
temp.setIntegrity(totalIntegirty);
temp.setUnitName(t.getUnitName());
// 判断list 是否达到5个,如果达到则对比最后一个进行替换
if (tempList.size() == 5) {
if (tempList.get(0).getIntegrity() < totalIntegirty) {
tempList.set(0, temp);
}
} else {
tempList.add(temp);
}
tempList.sort(Comparator.comparing(CylinderIntegrityDataDto::getIntegrity));
});
tempList.forEach(t -> {
System.out.println("====================unitName: " + t.getUnitName() + "============================");
t.setUpdateTime(new Date());
cylinderIntegrityDataServiceImpl.createWithModel(t);
});
});
System.out.println("====================数据完整性结束============================");
}
/**
* 企业总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderUnitInfo() {
cylinderUnitDataServiceImpl.remove(new LambdaQueryWrapper<CylinderUnitData>());
countByRegion(regionModel -> {
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderUnitTotal = cylinderUnitServiceImpl.getUnitTotalByRegionCode(regionCode);
Integer thisMonthUnitTotal = cylinderUnitServiceImpl.getThisMonthUnitTotalByRegionCode(regionCode);
Double lastUnitTotal = Double.valueOf(cylinderUnitServiceImpl.getLastMonthUnitTotal(regionCode));
Double monthUnitLastInfo = Double.valueOf(cylinderUnitServiceImpl.getMonthBeforeLastUnitTotal(regionCode));
double changeNum = thisMonthUnitTotal - lastUnitTotal;
double percent = 0d;
if (monthUnitLastInfo != 0) {
percent = (lastUnitTotal - monthUnitLastInfo) / monthUnitLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
CylinderUnitDataDto temp = new CylinderUnitDataDto();
temp.setChangeSum((long) changeNum);
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderUnitTotal);
temp.setUpdateTime(new Date());
cylinderUnitDataServiceImpl.createWithModel(temp);
});
}
/**
* 气瓶总量按区域统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void getCylinderInfo() {
cylinderInfoDataServiceImpl.remove(new LambdaQueryWrapper<>());
countByRegion(regionModel -> {
CylinderInfoDataDto temp = new CylinderInfoDataDto();
String regionCode = String.valueOf(regionModel.getRegionCode());
Integer cylinderTotal = this.getInfoTotalByRegionCode(regionCode);// 当前总数
Double InfoTotal = Double.valueOf(this.getMonthInfoTotal(regionCode));
Double lastInfoTotal = Double.valueOf(this.getLastMonthInfoTotal(regionCode));// 上月总数
Double monthBeforeLastInfo = Double.valueOf(this.getMonthBeforeLastInfoTotal(regionCode));// 上上月总数
double percent = 0d;
if (monthBeforeLastInfo != 0) {
percent = (lastInfoTotal - monthBeforeLastInfo) / monthBeforeLastInfo;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (InfoTotal - lastInfoTotal));
temp.setChangePercent((int) (percent * 100) + "");
temp.setRegionCode(regionCode);
temp.setTotalSum((long) cylinderTotal);
cylinderInfoDataServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderInfoData() {
cylinderInfoDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderInfoDataUnit>());
countByUnit(cylinderUnit -> {
CylinderInfoDataUnitDto temp = new CylinderInfoDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int count = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));// 当前总数
temp.setTotalSum((long) count);
Double month = Double.valueOf(baseMapper.getMonthInfoTotalUnit(cylinderUnit.getAppId()));
Double thismonth = Double.valueOf(baseMapper.getLastMonthInfoTotalUnit(cylinderUnit.getAppId()));// 上月总数
Double lastmonth = Double.valueOf(baseMapper.getMonthBeforeLastInfoTotalUnit(cylinderUnit.getAppId()));// 上上月总数
double percent = 0d;
if (lastmonth != 0) {
percent = (thismonth - lastmonth) / lastmonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
} else {
percent = 0;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangeSum((long) (month - thismonth));
temp.setChangePercent((int) (percent * 100) + "");
cylinderInfoDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 充装量按单位和月统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderFillingData() {
cylinderFillingDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingDataUnit>());
countByUnit(cylinderUnit -> {
// 按照月份 获取数据 取一年数据
Calendar calendar = Calendar.getInstance();
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingDataUnitDto temp = new CylinderFillingDataUnitDto();
String year = calendar.get(Calendar.YEAR) + "";
int month = calendar.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
temp.setFillingYear(year);
temp.setFillingMonth(monthStr);
temp.setFillingDate(year + "-" + monthStr);
// 本月
Double thisMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
temp.setTotalSum(thisMonth);
calendar.add(Calendar.MONTH, -1);
// 上月
Double lastMonth = cylinderFillingRecordServiceImpl.getFillingSumByMonth(cylinderUnit.getAppId(),
calendar.getTime());
double percent = 0d;
if (lastMonth != 0) {
percent = (thisMonth - lastMonth) / lastMonth;
BigDecimal bg = new BigDecimal(percent);
percent = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
temp.setChangePercent((int) (percent * 100) + "");
temp.setAppId(cylinderUnit.getAppId());
temp.setChangeSum(thisMonth - lastMonth);
cylinderFillingDataUnitServiceImpl.createWithModel(temp);
}
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitCylinderTagsData() {
cylinderTagsDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderTagsDataUnit>());
countByUnit(cylinderUnit -> {
CylinderTagsDataUnitDto temp = new CylinderTagsDataUnitDto();
temp.setAppId(cylinderUnit.getAppId());
int cylinder = this
.count(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getAppId, cylinderUnit.getAppId()));
int tags = cylinderTagsServiceImpl
.count(new LambdaQueryWrapper<CylinderTags>().eq(CylinderTags::getAppId, cylinderUnit.getAppId()));
String percent = "";
if (tags != 0) {
double zz = (double) cylinder / (double) tags;
DecimalFormat df = new DecimalFormat("##.00%");
if (Math.abs(zz) < 0.0000000000001) {
percent = "0.00%";
} else {
percent = df.format(zz);
}
}
temp.setCylinderSum((long) cylinder);
temp.setTagsSum((long) tags);
temp.setTagPercent(percent);
cylinderTagsDataUnitServiceImpl.createWithModel(temp);
});
}
/**
* 按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitIntegrityData() {
cylinderIntegrityDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderIntegrityDataUnit>());
countByUnit(cylinderUnit -> {
// 企业信息
CylinderIntegrityDataUnitDto uninInfo = new CylinderIntegrityDataUnitDto();
uninInfo.setAppId(cylinderUnit.getAppId());
uninInfo.setDataType("企业信息");
Double unitIntegirty = cylinderUnit.getIntegrity();
uninInfo.setIntegrity(unitIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(uninInfo);
// 气瓶基本信息
CylinderIntegrityDataUnitDto cylinderInfo = new CylinderIntegrityDataUnitDto();
cylinderInfo.setAppId(cylinderUnit.getAppId());
cylinderInfo.setDataType("气瓶基本信息");
Double cylinderIntegirty = this.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderInfo.setIntegrity(cylinderIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInfo);
// 气瓶标签信息
CylinderIntegrityDataUnitDto cylinderTag = new CylinderIntegrityDataUnitDto();
cylinderTag.setAppId(cylinderUnit.getAppId());
cylinderTag.setDataType("气瓶标签信息");
Double tagIntegirty = cylinderTagsServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderTag.setIntegrity(tagIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderTag);
// 气瓶检验信息
CylinderIntegrityDataUnitDto cylinderInspection = new CylinderIntegrityDataUnitDto();
cylinderInspection.setAppId(cylinderUnit.getAppId());
cylinderInspection.setDataType("气瓶检验信息");
cylinderInspection.setIntegrity(0d);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderInspection);
// 充装前检查
CylinderIntegrityDataUnitDto cylinderFilling = new CylinderIntegrityDataUnitDto();
cylinderFilling.setAppId(cylinderUnit.getAppId());
cylinderFilling.setDataType("充装前检查");
Double fillingIntegirty = cylinderFillingServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderFilling.setIntegrity(fillingIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderFilling);
// 充装信息
CylinderIntegrityDataUnitDto cylinderRecord = new CylinderIntegrityDataUnitDto();
cylinderRecord.setAppId(cylinderUnit.getAppId());
cylinderRecord.setDataType("充装信息");
Double recordIntegirty = cylinderFillingRecordServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderRecord.setIntegrity(recordIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderRecord);
// 充装后复查
CylinderIntegrityDataUnitDto cylinderCheck = new CylinderIntegrityDataUnitDto();
cylinderCheck.setAppId(cylinderUnit.getAppId());
cylinderCheck.setDataType("充装后复查");
Double checkIntegirty = cylinderFillingCheckServiceImpl.queryIntegirtyByAppId(cylinderUnit.getAppId());
cylinderCheck.setIntegrity(checkIntegirty);
cylinderIntegrityDataUnitServiceImpl.createWithModel(cylinderCheck);
});
}
/**
* 充装详情按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synUnitFillingCheckData() {
// cylinderFillingCheckDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingCheckDataUnit>());
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
@Scheduled(cron = "${tzs.cylinder.info.cron}")
public void setTimeSaveCylinderInfoToES(){
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if(!ObjectUtils.isEmpty(cylinderInfoPage)){
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
countByUnit(cylinderUnit -> {
List<CylinderFillingCheckDataUnitDto> allCylinderFillingCheckDataList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), null);
// 按照月份 获取数据 取一年数据
Calendar c = Calendar.getInstance();
// 第一次查询到该appId对应的统计数据为空,则计算过去一年12个月的数据统计
if (ValidationUtil.isEmpty(allCylinderFillingCheckDataList)) {
// 按月份获取充装量
// 当月与上月 对比获取数据
for (int i = 0; i < 12; i++) {
// 获取当月数据
CylinderFillingCheckDataUnitDto temp = new CylinderFillingCheckDataUnitDto();
calcCylinderFillingCheckDataUnitData(cylinderUnit, c, temp);
c.add(Calendar.MONTH, -1);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(temp);
}
} else {
// 如果已经有该appId对应数据,则直接更新当前月的数据即可
Calendar current = Calendar.getInstance();
String year = current.get(Calendar.YEAR) + "";
int month = current.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
List<CylinderFillingCheckDataUnitDto> existDataDtoList =
cylinderFillingCheckDataUnitServiceImpl.queryCylinderFillingCheckListByParam(cylinderUnit.getAppId(), year + "-" + monthStr);
CylinderFillingCheckDataUnitDto tempDto = new CylinderFillingCheckDataUnitDto();
if (!ValidationUtil.isEmpty(existDataDtoList) && !ValidationUtil.isEmpty(existDataDtoList.get(0))) {
tempDto = existDataDtoList.get(0);
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.updateWithModel(tempDto);
} else if (ValidationUtil.isEmpty(existDataDtoList)) {
// 处理当前月第一天还没数据情况
calcCylinderFillingCheckDataUnitData(cylinderUnit, current, tempDto);
cylinderFillingCheckDataUnitServiceImpl.createWithModel(tempDto);
}
}
});
}
/**
* 计算当前单位的充装检查数据统计
*
* @param cylinderUnit
* @param calender
* @param cylinderFillingCheckDataUnitDto
*/
public void calcCylinderFillingCheckDataUnitData(CylinderUnit cylinderUnit, Calendar calender, CylinderFillingCheckDataUnitDto cylinderFillingCheckDataUnitDto) {
String year = calender.get(Calendar.YEAR) + "";
int month = calender.get(Calendar.MONTH) + 1;
String monthStr = month < 10 ? "0" + month : month + "";
cylinderFillingCheckDataUnitDto.setFillingMonth(monthStr);
cylinderFillingCheckDataUnitDto.setFillingYear(year);
cylinderFillingCheckDataUnitDto.setFillingDate(year + "-" + monthStr);
Integer countThisMonth = cylinderFillingRecordServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
cylinderFillingCheckDataUnitDto.setTotalSum((long) countThisMonth);
// 获取本月数据
Integer fillingCount = cylinderFillingServiceImpl.getFillingCountByMonth(cylinderUnit.getAppId(),
calender.getTime());
Integer fillingCheckCount = cylinderFillingCheckServiceImpl
.getFillingCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装前检查率:充装前检查次数/充装次数
double before = 0d;
if (countThisMonth != 0) {
before = (double) (fillingCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCount((long) fillingCount);
cylinderFillingCheckDataUnitDto.setFillingPercent(before * 100);
// 充装后检查率:充装后检查次数/充装次数
double after = 0d;
if (countThisMonth != 0) {
after = (double) (fillingCheckCount) / (double) countThisMonth;
}
cylinderFillingCheckDataUnitDto.setFillingCheckCount((long) fillingCheckCount);
cylinderFillingCheckDataUnitDto.setFillingCheckPercent(after * 100);
// 充装合格率:充装前检查合格次数+充装后检查合格次数/2*充装次数
double passed = 0d;
// 充装前检查合格次数
Integer fillingPassedCount = cylinderFillingServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
// 充装后检查合格次数
Integer fillingCheckPassedCount = cylinderFillingCheckServiceImpl
.getFillingPassedCountByMonth(cylinderUnit.getAppId(), calender.getTime());
if (countThisMonth != 0) {
passed = ((double) (fillingPassedCount) + (double) fillingCheckPassedCount)
/ (double) (2 * countThisMonth);
}
cylinderFillingCheckDataUnitDto.setFillingPassedCount((long) (fillingPassedCount + fillingCheckPassedCount));
cylinderFillingCheckDataUnitDto.setTotalSumDouble((long) 2 * countThisMonth);
cylinderFillingCheckDataUnitDto.setFillingPassedPercent(passed * 100);
cylinderFillingCheckDataUnitDto.setAppId(cylinderUnit.getAppId());
}
/**
* 充装量、卸液量按单位统计
*/
@Transactional(rollbackFor = Exception.class)
@Scheduled(cron = "0 0 2 * * ?")
public void synFillingUnloadUnitData() {
cylinderFillingUnloadDataUnitServiceImpl.remove(new LambdaQueryWrapper<CylinderFillingUnloadDataUnit>());
countByUnit(cylinderUnit -> {
Calendar now = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < 30; i++) {
now.add(Calendar.DATE, -1);
CylinderFillingUnloadDataUnitDto temp = new CylinderFillingUnloadDataUnitDto();
Double fillingSum = cylinderFillingRecordServiceImpl.getFillingSumByDate(cylinderUnit.getAppId(),
now.getTime());
Double unloadSum = 0d;
temp.setFillingSum(fillingSum);
temp.setAppId(cylinderUnit.getAppId());
temp.setStatisDate(now.getTime());
temp.setStatisDateStr(sdf.format(now.getTime()));
temp.setUnloadSum(unloadSum);
cylinderFillingUnloadDataUnitServiceImpl.createWithModel(temp);
}
});
}
@Scheduled(cron = "${tzs.cylinder.info.cron}")
public void setTimeSaveCylinderInfoToES() {
Page<CylinderInfoDto> cylinderInfoPage = new Page<>();
Page<CylinderInfoDto> cyinderInfoList = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
Long count = cyinderInfoList.getCurrent();
Long times = 0L;
if (count != 0) {
times = count / 1000;
Long last = count % 1000;
if (last > 0) {
times++;
}
}
for (int i = 0; i <= times; i++) {
cylinderInfoPage.setCurrent(1);
cylinderInfoPage.setSize(1000);
cylinderInfoPage = cylinderInfoMapper.getCyinderInfoList(cylinderInfoPage);
if (!ObjectUtils.isEmpty(cylinderInfoPage)) {
saveCylinderInfo2ES(cylinderInfoPage.getRecords());
}
// for (CylinderInfoDto ci : cylinderInfoPage.getRecords()) {
// saveCylinderInfoToES(ci);
// }
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record,esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record,cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci,esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if(!ObjectUtils.isEmpty(saveResult)){
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(esUserName, esPwd)); //es账号密码
RestHighLevelClient esClient =new RestHighLevelClient(
RestClient.builder(
new HttpHost(esAddress,esPort)
).setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
})
);
// RestHighLevelClient esClient = new RestHighLevelClient(
// RestClient.builder(new HttpHost(esAddress, esPort, "http"))
// );
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if(flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = esClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
System.out.println(hit);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
}
}
@Override
public void saveCylinderInfo2ES(List<CylinderInfoDto> records) {
List<ESCylinderInfoDto> esCylinderInfoDto = new ArrayList<>();
List<CylinderInfo> CylinderInfoList = new ArrayList<>();
for (CylinderInfoDto record : records) {
ESCylinderInfoDto esCylinderInfo = new ESCylinderInfoDto();
BeanUtils.copyProperties(record, esCylinderInfo);
esCylinderInfoDto.add(esCylinderInfo);
CylinderInfo cylinderInfo = new CylinderInfo();
BeanUtils.copyProperties(record, cylinderInfo);
cylinderInfo.setSequenceNbr(record.getSequenceNbr());
cylinderInfo.setIsNotEs("1");
CylinderInfoList.add(cylinderInfo);
}
esCylinderInfoRepository.saveAll(esCylinderInfoDto);
this.updateBatchById(CylinderInfoList);
}
@Override
public Integer getInfoTotal() {
return cylinderInfoMapper.getInfoTotal();
}
@Override
public ESCylinderInfoDto saveCylinderInfoToES(CylinderInfoDto ci) {
ESCylinderInfoDto esCylinderInfoDto = new ESCylinderInfoDto();
BeanUtils.copyProperties(ci, esCylinderInfoDto);
ESCylinderInfoDto saveResult = esCylinderInfoRepository.save(esCylinderInfoDto);
if (!ObjectUtils.isEmpty(saveResult)) {
//同步到es后修改
CylinderInfo cylinderInfo = new CylinderInfo();
cylinderInfo.setIsNotEs("1");
cylinderInfoMapper.update(cylinderInfo, new QueryWrapper<CylinderInfo>().eq("sequence_nbr", ci.getSequenceNbr()));
}
return saveResult;
}
@Override
public Page<ESCylinderInfoDto> queryByKeys(CylinderInfoDto cylinderInfoDto, int pageNum, int pageSize) {
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
SearchRequest request = new SearchRequest();
request.indices("cylinder_info");
//通用匹配规则,条件构建
boolean flag = true;
SearchSourceBuilder builder = new SearchSourceBuilder();
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//匹配统一信用代码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCreditCode())) {
flag = false;
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery();
meBuilder.must(QueryBuilders.matchQuery("creditCode", cylinderInfoDto.getCreditCode()));
boolMust.must(meBuilder);
}
//匹配RegionCode
if (!ObjectUtils.isEmpty(cylinderInfoDto.getRegionCode())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("regionCode", "*" + cylinderInfoDto.getRegionCode() + "*"));
boolMust.should(appIdBuilder);
}
//匹配appid
if (!ObjectUtils.isEmpty(cylinderInfoDto.getAppId())) {
flag = false;
BoolQueryBuilder appIdBuilder = QueryBuilders.boolQuery();
appIdBuilder.must(QueryBuilders.matchQuery("appId", "*" + cylinderInfoDto.getAppId() + "*"));
boolMust.should(appIdBuilder);
}
//匹配产权单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitName())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitName", "*" + cylinderInfoDto.getUnitName() + "*"));
boolMust.must(query);
}
//匹配出厂编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getFactoryNum())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("factoryNum", "*" + cylinderInfoDto.getFactoryNum() + "*"));
boolMust.must(query);
}
//匹配气瓶品种
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderVariety())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderVariety", cylinderInfoDto.getCylinderVariety()));
boolMust.must(query);
}
//匹配二维码编码
if (!ObjectUtils.isEmpty(cylinderInfoDto.getQrCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("qrCode", "*" + cylinderInfoDto.getQrCode() + "*"));
boolMust.must(query);
}
//匹配电子标签
if (!ObjectUtils.isEmpty(cylinderInfoDto.getElectronicLabelCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("electronicLabelCode", "*" + cylinderInfoDto.getElectronicLabelCode() + "*"));
boolMust.must(query);
}
//匹配气瓶唯一标识
if (!ObjectUtils.isEmpty(cylinderInfoDto.getSequenceCode())) {
flag = false;
BoolQueryBuilder sequenceCodeBuilder = QueryBuilders.boolQuery();
sequenceCodeBuilder.must(QueryBuilders.matchQuery("sequenceCode", cylinderInfoDto.getSequenceCode()));
boolMust.must(sequenceCodeBuilder);
}
//匹配单位内部编号
if (!ObjectUtils.isEmpty(cylinderInfoDto.getUnitInnerCode())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("unitInnerCode", "*" + cylinderInfoDto.getUnitInnerCode() + "*"));
boolMust.must(query);
}
//气瓶状态
if (!ObjectUtils.isEmpty(cylinderInfoDto.getCylinderStatus())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("cylinderStatus", cylinderInfoDto.getCylinderStatus()));
boolMust.must(query);
}
//制造单位
if (!ObjectUtils.isEmpty(cylinderInfoDto.getManufacturingUnit())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.matchQuery("manufacturingUnit", "*" + cylinderInfoDto.getManufacturingUnit() + "*"));
boolMust.must(query);
}
//检验日期
if (!ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateStart()) && !ObjectUtils.isEmpty(cylinderInfoDto.getInspectionDateEnd())) {
flag = false;
BoolQueryBuilder query = QueryBuilders.boolQuery();
query.must(QueryBuilders.rangeQuery("inspectionDate").from(cylinderInfoDto.getInspectionDateStart()).to(cylinderInfoDto.getInspectionDateEnd()));
boolMust.must(query);
}
if (flag) { // 搜索全部
boolMust.must(QueryBuilders.matchAllQuery());
}
builder.query(boolMust);
builder.from((pageNum - 1) * pageSize);
builder.size(pageSize);
builder.trackTotalHits(true);
request.source(builder);
List<ESCylinderInfoDto> list = new LinkedList<>();
long totle = 0;
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (org.elasticsearch.search.SearchHit hit : response.getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
ESCylinderInfoDto esCylinderInfoDto = JSONObject.toJavaObject(jsonObject.getJSONObject("sourceAsMap"), ESCylinderInfoDto.class);
list.add(esCylinderInfoDto);
}
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
restHighLevelClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return result;
}
/**
* 根据月份统计
*/
private void countByMonth(IntConsumer consumer) {
for (int i = 0; i < 12; i++) {
consumer.accept(i);
}
}
/**
* 根据单位统计
*/
private void countByUnit(Consumer<CylinderUnit> consumer) {
List<CylinderUnit> units = cylinderUnitServiceImpl.list();
units.forEach(consumer);
}
/**
* 根据区域统计
*/
private void countByRegion(Consumer<RegionModel> consumer) {
List<RegionModel> regionList = new ArrayList<>();
startPlatformTokenService.getToken();
Collection<RegionModel> regions = Systemctl.regionClient.queryForTree(null).getResult();
regions.forEach(regionModel -> convertTreeToList(regionList, regionModel));
regionList.forEach(consumer);
}
/**
* 将区域树转为区域List列表
*/
private void convertTreeToList(List<RegionModel> regionList, RegionModel region) {
regionList.add(region);
if (region.getChildren() != null) {
region.getChildren().forEach(c -> {
convertTreeToList(regionList, c);
});
}
}
public Integer getOverDateStatisticsNumber(String earlyWarningLevel) {
return this.baseMapper.countOverDateNumber(earlyWarningLevel);
}
public Page<CylinderInfoDto> earlyWarningLevelPageList(Page<CylinderInfoDto> page, String earlyWarningLevel) {
Page<CylinderInfoDto> result = this.baseMapper.queryPageListByEarlyWarningLevel(page, earlyWarningLevel);
result.getRecords().forEach(r -> {
// r.setEarlyWarningLevelName(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getName());
// r.setInspectionStatusDesc(EarlyWarningLevelEnum.getEumByLevel(earlyWarningLevel).getStatus());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
});
return result;
}
public void calEarlyWarningLevel() {
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则开始");
}
// 1.批量分组大小
int size = 500;
int total = this.count();
int groupNumber = total / size + 1;
// 2.批量小分组处理数据,调用规则
for (int i = 0; i < groupNumber; i++) {
Page<CylinderInfo> page = new Page<>();
page.setCurrent(i);
page.setSize(size);
LambdaQueryWrapper<CylinderInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.select(CylinderInfo::getSequenceCode, CylinderInfo::getSequenceNbr)
.orderByDesc(CylinderInfo::getSequenceNbr);
IPage<CylinderInfo> result = this.page(page, wrapper);
for (CylinderInfo r : result.getRecords()) {
// 设置token
tzsAuthService.setRequestContext();
// 调用规则
this.touchRuleToCalLevel(r);
}
}
if (log.isDebugEnabled()) {
log.debug("气瓶超期预警时间调用规则完成");
}
}
private void touchRuleToCalLevel(CylinderInfo r) {
Date now = new Date();
String dateStr;
try {
dateStr = DateUtils.dateFormat(now, DateUtils.DATE_TIME_PATTERN);
} catch (ParseException e) {
throw new RuntimeException("日期个时候失败");
}
// 1.气瓶详情
CylinderInfoDto cylinderInfoDto = this.getDetail(r.getSequenceCode());
try {
WarningMsgDto warningMsgDto = new WarningMsgDto();
int interval = DateUtils.dateBetweenIncludeToday(now, cylinderInfoDto.getNextInspectionDate()) - 1;
warningMsgDto.setNum(String.valueOf(interval));
warningMsgDto.setFactoryNum(cylinderInfoDto.getFactoryNum());
// warningMsgDto.setUserType(cylinderInfoDto.getCustomType());
// warningMsgDto.setUserPeople(cylinderInfoDto.getCustomName());
// warningMsgDto.setUserPeoplePhone(cylinderInfoDto.getContactPhone());
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
warningMsgDto.setCode(cylinderInfoDto.getSequenceCode());
warningMsgDto.setCompanyName(cylinderInfoDto.getUnitName());
warningMsgDto.setPhone(cylinderInfoDto.getPersonMobilePhone());
warningMsgDto.setPeople(cylinderInfoDto.getUnitPerson());
warningMsgDto.setCurrentTime(dateStr);
// 2.循环调用规则 触发计算等级及发送消息
if (log.isInfoEnabled()) {
log.info("调用规则对象!+:{}", JSON.toJSONString(warningMsgDto));
}
ruleTrigger.publish(warningMsgDto, packageId, null);
} catch (Exception e) {
log.error("调用规则失败!:{},{}", JSON.toJSONString(cylinderInfoDto), e);
}
}
public CylinderInfoDto getDetail(String sequenceCode) {
CylinderInfoDto dto = scheduleMapper.getCylDetail(sequenceCode);
dto.setInspectionStatusDesc(StringUtils.isNotEmpty(dto.getEarlyWarningLevel())
? EarlyWarningLevelEnum.getEumByLevel(dto.getEarlyWarningLevel()).getStatus()
: "");
return dto;
}
public List<MsgLog> getMsgList(String sequenceCode, String terminalType) {
LambdaQueryWrapper<MsgLog> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(MsgLog::getRelationCode, sequenceCode);
wrapper.eq(StringUtils.isNotEmpty(terminalType), MsgLog::getTerminalType, terminalType);
wrapper.orderByDesc(MsgLog::getSendTime);
return msgLogService.list(wrapper);
}
/**
* 更新气瓶等级
*
* @param sequenceCode 唯一表设
* @param level 等级
* @return CylinderInfo
*/
public CylinderInfo updateEarlyWarningLevel(String sequenceCode, String level) {
CylinderInfo cylinderInfo = this
.getOne(new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, sequenceCode));
cylinderInfo.setEarlyWarningLevel(level);
cylinderInfo.setEarlyWarningLevelCalDate(new Date());
this.updateById(cylinderInfo);
return cylinderInfo;
}
public Boolean nextInspectionDateUpdate(List<CylinderInfoDto> cylinderInfoDtos) {
// 1.更新下次检验日期
List<CylinderInfo> cylinderInfos = new ArrayList<>();
cylinderInfoDtos.forEach(c -> {
CylinderInfo cylinderInfo = this.getOne(
new LambdaQueryWrapper<CylinderInfo>().eq(CylinderInfo::getSequenceCode, c.getSequenceCode()));
// cylinderInfo.setNextInspectionDate(c.getNextInspectionDate());
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderInfoList(page,cylinderInfoDto,sort,appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort,List<String> appids){
return cylinderInfoMapper.cyinderOutInfoList(page,cylinderInfoDto,sort,appids);
}
cylinderInfos.add(cylinderInfo);
});
if (!cylinderInfos.isEmpty()) {
this.updateBatchById(cylinderInfos);
}
// 2.循环调用规则 触发计算等级及发送消息
cylinderInfos.forEach(this::touchRuleToCalLevel);
return Boolean.TRUE;
}
public Page<CylinderInfoDto> cyinderInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderInfoList(page, cylinderInfoDto, sort, appids);
}
public Page<CylinderInfoDto> getCyinderInfoList(Page<CylinderInfoDto> page) {
return cylinderInfoMapper.getCyinderInfoList(page);
}
public Page<CylinderInfoDto> cyinderOutInfoList(Page<CylinderInfoDto> page, CylinderInfoDto cylinderInfoDto, String sort, List<String> appids) {
return cylinderInfoMapper.cyinderOutInfoList(page, cylinderInfoDto, sort, appids);
}
}
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:23306/tzs_amos_tzs_biz_init?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.datasource.driver-class-name=cn.com.vastbase.Driver
spring.datasource.url=jdbc:vastbase://192.168.249.180:54321/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
#eureka properties:
eureka.instance.hostname= eureka
eureka.instance.prefer-ip-address = true
eureka.client.serviceUrl.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.ip-address = 172.16.3.133
spring.datasource.password=Yeejoin@2023
eureka.client.service-url.defaultZone=http://192.168.249.13:10001/eureka/,http://192.168.249.139:10001/eureka/
eureka.instance.prefer-ip-address=true
eureka.instance.ip-address=192.168.249.13
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://${eureka.instance.ip-address}:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username=elastic
elasticsearch.password=123456
elasticsearch.password=Yeejoin@2023
spring.elasticsearch.rest.uris=http://192.168.249.218:9200,http://192.168.249.114:9200,http://192.168.249.155:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
#集群环境
spring.redis.cluster.nodes=192.168.249.218:6377,192.168.249.114:6377,192.168.249.155:6377
spring.redis.password=Yeejoin@2023
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.broker=tcp://192.168.249.180:2883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.46.151.113:8000
##wechatToken
tzs.cti.url=http://36.41.172.83:8000
##wechatTokenls
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -61,41 +50,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## \u9884\u8B66\u901A\u77E5\u6A21\u677Fid
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##\u7763\u67E5\u6574\u6539\u901A\u77E5
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## \u516C\u4F17\u53F7\u6D4B\u8BD5\u7528\u6237id\uFF08\u5E73\u53F0userId\uFF09
## ???????id???userId?
tzs.wechat.test.userId=3413513
fileserver.domain=https://rpm.yeeamos.com:8888/
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://192.168.249.180:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=192.168.249.13
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://192.168.249.180:19000/
## 生成监管码前缀域名
regulatory_code_prefix=https://nav.sspai.top/tzs?code=
outSystem.user.password=a1234560
amos.system.user.app-key=AMOS_STUDIO
amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.10.90:53306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.99:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.99:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.99:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=172.16.10.90
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= Yeejoin@2020
## unit(h)
alertcall.es.synchrony.time=48
fileserver.domain=https://rpm.yeeamos.com:8888/
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.90
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.90:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://172.16.10.90:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.tzs.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
org.filter.group.seq=1564150103147573249
duty.seats.role.ids=1585956200472674305,1585956257590706177
\ No newline at end of file
......@@ -4,31 +4,7 @@ spring.datasource.url=jdbc:vastbase://36.46.137.116:5432/tzs_amos_tzs_biz_init?c
#spring.datasource.url=jdbc:vastbase://36.46.151.113:5432/tzs_amos_tzs_biz_init?currentSchema=amos_tzs_biz
spring.datasource.username=admin
spring.datasource.password=Yeejoin@2023
#DB properties:
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://172.16.10.230:53306/${TZS_BIZ_DATABASE}?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
#spring.datasource.username=${MYSQL_ROOT_USER}
#spring.datasource.password=${MYSQL_ROOT_PASSWORD}
#eureka prioperties:
#eureka.client.serviceUrl.defaultZone=http://172.16.10.230:10001/eureka/
#eureka.client.register-with-eureka=true
#eureka.client.fetch-registry=true
#eureka.client.healthcheck.enabled=true
#ribbon.eureka.enabled=true
#eureka.instance.hostname=${spring.cloud.client.ip-address}
#eureka.instance.prefer-ip-address=true
#eureka.instance.instance-id=${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
#eureka.instance.lease-expiration-duration-in-seconds=10
#eureka.instance.lease-renewal-interval-in-seconds=5
#management.endpoint.health.show-details=always
#management.endpoints.web.exposure.include=*
#
#eureka.instance.prefer-ip-address = true
#eureka.instance.ip-address = 172.16.10.230
eureka.client.service-url.defaultZone =http://172.16.10.230:10001/eureka/
eureka.client.service-url.defaultZone=http://172.16.10.230:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
......@@ -36,25 +12,13 @@ eureka.instance.health-check-url=http://172.16.3.34:${server.port}${server.servl
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.34:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://172.16.3.34:${server.port}${server.servlet.context-path}/doc.html
eureka.instance.ip-address = 172.16.3.34
eureka.instance.ip-address=172.16.3.34
## ES properties:
biz.elasticsearch.port=9200
biz.elasticsearch.address=172.16.10.230
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
elasticsearch.username= elastic
elasticsearch.password= a123456
elasticsearch.username=elastic
elasticsearch.password=a123456
spring.elasticsearch.rest.uris=http:/172.16.10.230:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.10.230
......@@ -65,7 +29,6 @@ spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=false
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
......@@ -73,20 +36,13 @@ emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=super
emqx.password=123456
emqx.keepAliveInterval=1000
tzs.cti.appkey=4e805006-3fef-ae43-3915-a153731007c4
tzs.cti.secretkey=7bd29115-99ee-4f7d-1fb1-7c4719d5f43a
tzs.cti.url=http://36.41.172.83:8000
##wechatToken
tzs.wechat.token=yeejoin_2021
##wechatTicketUrl
tzs.wechat.ticketurl=https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=
#tzs.wechat.tempId.kr=rjW8x9rRitIpa21Jekyx2nzBzpJy7tycssCXSN4YhWw
tzs.wechat.tempId.kr=bxchKYhYW7aHbGKM2pVyR_yY2-bG4sRMNU3ZRQbMKYM
tzs.wechat.url.kr=tzs.yeeamos.com/persondetail.html
......@@ -96,67 +52,41 @@ tzs.wechat.url.wx=tzs.yeeamos.com/repairPersondetail.html
#tzs.wechat.tempId.ts=Kr7lcV8g4g_lgyW_RpwnNgw_HDxxRuVx759EoFWrIfU
tzs.wechat.tempId.ts=VWqgY-lXFt4dg2EL4pLjfDCBAU49Z0mRxVaQhAMMW8Q
tzs.wechat.url.ts=tzs.yeeamos.com/taskComplaintDetail.html
mqtt.topic.task.newtask=tzs-task-newtask
mqtt.topic.task.personinfo=tzs-task-personinfo
mqtt.topic.elevator.push=/tzs/tcb_elevator
mqtt.topic.alertInfo.push=/tzs/tcb_alertInfo
mqtt.topic.alertReport.push=/tzs/tcb_alertReport
mqtt.topic.alertHeart.push=/tzs/tcb_alertHeart
mqtt.topic.alertMatrix.push=/tzs/tcb_alertMatrix
mqtt.topic.cti.push=/cti/record
cti.user.name=tzs_cti
cti.user.pwd=a1234567
flc.sms.tempCode=SMS_TZS_0001
## ??????id
tzs.wechat.tempId.warning=-pHsHLIjW8j-_AemoZycf6Dmu6iYc-YWWaJ0cAPGeUY
##??????
tzs.wechat.tempId.supervise=P5XGbszS2Pc6kynvGjzPpZ--ikAwDZo6O7WdJ2EUxtE
## ???????id???userId?
tzs.wechat.test.userId=3413513
##new properties
org.filter.group.seq=1564150103147573249
fileserver.domain=http://172.16.10.230:19000/
log.level=INFO
duty.seats.role.ids=1585956200472674305,1585956257590706177
## ???? properties:
rule.definition.load=false
##rule.definition.model-package=com.yeejoin.amos.boot.module.jcs.api.dto
rule.definition.default-agency=tzs
rule.definition.local-ip=172.16.10.230
#\u6C14\u74F6\u5145\u88C5\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.fill.cron=0 0 12 * * ?
#\u6C14\u74F6\u57FA\u672C\u4FE1\u606F\u5B9A\u65F6\u540C\u6B65\u81F3es
tzs.cylinder.info.cron=0 0 1 * * ?
# ??????????
minio.url.path=http://172.16.10.230:9000/
## ɼǰ׺
regulatory_code_prefix=https://sxtzsb.sxsei.com:9435/tzs?code=
#outSystem.user.password=a1234560
#amos.system.user.app-key=AMOS_STUDIO
#amos.system.user.product=STUDIO_APP_WEB
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://113.134.211.174:3306/xiy_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://172.16.3.28:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://172.16.3.28:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://192.168.1.10:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=172.16.3.28
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.3.28:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
rule.definition.load=false
rule.definition.model-package=com.yeejoin.amos.boot.module.tzs.api.dto
rule.definition.default-agency=tzs
rule.definition.localIp=172.16.3.39
\ No newline at end of file
#DB properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://36.46.151.113:13306/tzs_amos_tzs_biz?allowMultiQueries=true&serverTimezone=GMT%2B8\
&characterEncoding=utf8
spring.datasource.username=root
spring.datasource.password=Yeejoin@2020
##eureka properties:
eureka.client.service-url.defaultZone =http://36.46.151.113:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url=http://localhost:${server.port}${server.servlet.context-path}/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/doc.html
## ES properties:
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=elasticsearch
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
spring.elasticsearch.rest.uris=http://${biz.elasticsearch.address}:9200
## unit(h)
alertcall.es.synchrony.time=48
#redis properties:
spring.redis.database=1
spring.redis.host=36.46.151.113
spring.redis.port=16379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
spring.redis.lettuce.pool.max-wait=-1
spring.redis.lettuce.pool.max-idle=10
spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
## emqx properties:
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://36.46.151.113:1883
emqx.user-name=admin
emqx.password=public
tzs.cti.url=http://113.134.211.174:8000
......@@ -8,7 +8,7 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ymt.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/Tcm.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
......@@ -37,20 +37,20 @@
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.apache.ibatis" level="debug"/>
<logger name="org.mybatis" level="debug" />
<logger name="java.sql.Connection" level="debug"/>
<logger name="java.sql.Statement" level="debug"/>
<logger name="java.sql.PreparedStatement" level="debug"/>
<logger name="org.springframework" level="debug"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="debug"/>
<logger name="org.apache.activemq" level="debug"/>
<logger name="org.typroject" level="debug"/>
<logger name="com.yeejoin" level="debug"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<root level="error">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ymt.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- ELK管理 -->
<appender name="ELK" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>172.16.10.230:4560</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO" />
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin" level="INFO"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<!-- <appender-ref ref="FILE" /> -->
<appender-ref ref="STDOUT" />
<!-- <appender-ref ref="ELK" />-->
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ymt.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %-50.50logger{50} - %msg [%file:%line] %n" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ymt.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<logger name="com.baomidou.mybatisplus" level="DEBUG"/>
<logger name="org.apache.activemq" level="INFO"/>
<logger name="org.typroject" level="DEBUG"/>
<logger name="com.yeejoin" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ 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