From d3c223eaa4df46d17c138ef8ed5eab8da9638416 Mon Sep 17 00:00:00 2001
From: lin <sbla5888@163.com>
Date: Wed, 10 Apr 2024 18:38:46 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/main/java/org/springblade/modules/task/service/impl/ECallEventServiceImpl.java | 30 ++++++++++
src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java | 42 +++++++------
src/main/java/org/springblade/modules/circle/entity/CircleEntity.java | 4
src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.java | 5 +
src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.xml | 8 ++
src/main/resources/application-prod.yml | 4
src/main/resources/application-test.yml | 2
src/main/java/org/springblade/es/controller/EsController.java | 41 +++++++------
src/main/java/org/springblade/modules/task/service/IECallEventService.java | 7 ++
src/main/java/org/springblade/modules/task/controller/ECallEventController.java | 10 +++
10 files changed, 111 insertions(+), 42 deletions(-)
diff --git a/src/main/java/org/springblade/es/controller/EsController.java b/src/main/java/org/springblade/es/controller/EsController.java
index cf08cc7..7aa4a08 100644
--- a/src/main/java/org/springblade/es/controller/EsController.java
+++ b/src/main/java/org/springblade/es/controller/EsController.java
@@ -5,7 +5,9 @@
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.core.tool.utils.Func;
import org.springblade.es.service.ElasticsearchDocumentService;
import org.springblade.es.vo.EsParam;
@@ -35,35 +37,37 @@
* 初始化
*/
@GetMapping("/init")
+ @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@ApiOperationSupport(order = 2)
public R init(EsParam esParam) {
return R.status(elasticsearchDocumentService.init(esParam));
}
- /**
- * 新增数据
- */
- @GetMapping("/add")
- @ApiOperationSupport(order = 3)
- public R add(EsParam esParam) {
- return R.status(elasticsearchDocumentService.add(esParam,null));
- }
-
- /**
- * 修改数据
- */
- @GetMapping("/update")
- @ApiOperationSupport(order = 4)
- public R update(EsParam esParam) {
- elasticsearchDocumentService.update(esParam,null,null);
- return R.status(true);
- }
+// /**
+// * 新增数据
+// */
+// @GetMapping("/add")
+// @ApiOperationSupport(order = 3)
+// public R add(EsParam esParam) {
+// return R.status(elasticsearchDocumentService.add(esParam,null));
+// }
+//
+// /**
+// * 修改数据
+// */
+// @GetMapping("/update")
+// @ApiOperationSupport(order = 4)
+// public R update(EsParam esParam) {
+// elasticsearchDocumentService.update(esParam,null,null);
+// return R.status(true);
+// }
/**
* 根据索引删除
*/
@PostMapping("/removeBatchByIndexNames")
@ApiOperationSupport(order = 5)
+ @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
public R removeBatchByIndexNames(@RequestParam String indexNames) {
return R.status(elasticsearchDocumentService.removeBatchByIndexNames(Func.toStrList(indexNames)));
}
@@ -72,6 +76,7 @@
* 根据条件删除
*/
@PostMapping("/removeByQuery")
+ @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
@ApiOperationSupport(order = 6)
public R removeByQuery(EsParam esParam) {
return R.status(elasticsearchDocumentService.removeByQuery(esParam));
diff --git a/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java b/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java
index 1906861..ebdf3a7 100644
--- a/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java
+++ b/src/main/java/org/springblade/es/service/ElasticsearchDocumentService.java
@@ -539,16 +539,19 @@
*/
public boolean removeBatchByIndexNames(List<String> indexNames) {
for (String indexName : indexNames) {
- DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName);
- try {
- // 执行删除索引操作
- AcknowledgedResponse deleteResponse = client.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
+ // 索引存在才删除
+ if (isIndexExists(indexName)) {
+ DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(indexName);
+ try {
+ // 执行删除索引操作
+ AcknowledgedResponse deleteResponse = client.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
- // 输出操作结果
- boolean acknowledged = deleteResponse.isAcknowledged();
- System.out.println("索引删除成功: " + acknowledged);
- } catch (IOException e) {
- e.printStackTrace();
+ // 输出操作结果
+ boolean acknowledged = deleteResponse.isAcknowledged();
+ System.out.println("索引删除成功: " + acknowledged);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
}
return true;
@@ -576,7 +579,8 @@
*/
@Async
public void update(EsParam esParam, T item,List<String> columnList) {
- if (elasticsearchSync) {
+ // 判断索引是否存在
+ if (elasticsearchSync && isIndexExists(esParam.getIndexName())) {
// 创建更新请求
UpdateByQueryRequest updateRequest = new UpdateByQueryRequest(esParam.getIndexName());
@@ -589,17 +593,17 @@
Map<String, Object> data = new HashMap<String, Object>();
data.put("tableName", esParam.getTableName());
- if (esParam.getTableName().equals("jczz_article")){
- setArticleMap((Article)item,data);
+ if (esParam.getTableName().equals("jczz_article")) {
+ setArticleMap((Article) item, data);
}
- if (esParam.getTableName().equals("jczz_place")){
- setPlaceMap((PlaceEntity) item,data);
+ if (esParam.getTableName().equals("jczz_place")) {
+ setPlaceMap((PlaceEntity) item, data);
}
- if (esParam.getTableName().equals("jczz_house")){
- setHouseMap((HouseEntity) item,data);
+ if (esParam.getTableName().equals("jczz_house")) {
+ setHouseMap((HouseEntity) item, data);
}
- if (esParam.getTableName().equals("jczz_household")){
- setHousehouldMap((HouseholdEntity) item,data);
+ if (esParam.getTableName().equals("jczz_household")) {
+ setHousehouldMap((HouseholdEntity) item, data);
}
Map<String, Object> param = new HashMap<String, Object>();
param.put("data", data);
@@ -675,7 +679,7 @@
* 删除数据--根据条件
*/
public boolean removeByQuery(EsParam esParam) {
- if (elasticsearchSync) {
+ if (elasticsearchSync && isIndexExists(esParam.getIndexName())) {
DeleteByQueryRequest deleteByQueryRequest = new DeleteByQueryRequest(esParam.getIndexName());
// 根据多个条件 生成 boolQueryBuilder
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
diff --git a/src/main/java/org/springblade/modules/circle/entity/CircleEntity.java b/src/main/java/org/springblade/modules/circle/entity/CircleEntity.java
index 24255a7..b6f4994 100644
--- a/src/main/java/org/springblade/modules/circle/entity/CircleEntity.java
+++ b/src/main/java/org/springblade/modules/circle/entity/CircleEntity.java
@@ -85,8 +85,8 @@
@TableField("event_id")
private Long eventId;
- /** 事件类型:1:报事报修 */
- @ApiModelProperty(value = "事件类型:1:报事报修", example = "")
+ /** 事件类型:1:报事报修 2:E呼即办*/
+ @ApiModelProperty(value = "事件类型:1:报事报修 2:E呼即办", example = "")
@TableField("even_type")
private Integer evenType;
diff --git a/src/main/java/org/springblade/modules/task/controller/ECallEventController.java b/src/main/java/org/springblade/modules/task/controller/ECallEventController.java
index 6379176..93dec03 100644
--- a/src/main/java/org/springblade/modules/task/controller/ECallEventController.java
+++ b/src/main/java/org/springblade/modules/task/controller/ECallEventController.java
@@ -127,5 +127,15 @@
return R.data(eCallEventService.dataHandle());
}
+ /**
+ * e呼即办数据批量分享到圈子
+ * @param type
+ * @return
+ */
+ @GetMapping("/batchShareCircle")
+ public R batchShareCircle(Integer type) {
+ return R.status(eCallEventService.batchShareCircle(type));
+ }
+
}
diff --git a/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.java b/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.java
index 94e2bc1..d46a350 100644
--- a/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.java
+++ b/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.java
@@ -46,4 +46,9 @@
@Param("isAdministrator") Integer isAdministrator);
+ /**
+ * 查询未分享到圈子的内容
+ * @return
+ */
+ List<ECallEventEntity> getNotShareCircleList();
}
diff --git a/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.xml b/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.xml
index 00783bf..fe20d64 100644
--- a/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.xml
+++ b/src/main/java/org/springblade/modules/task/mapper/EcCallEventMapper.xml
@@ -61,5 +61,13 @@
order by jece.create_time desc,jece.id desc
</select>
+ <!--查询未分享到圈子的内容-->
+ <select id="getNotShareCircleList" resultType="org.springblade.modules.task.entity.ECallEventEntity">
+ select
+ jece.*
+ from jczz_e_call_event jece
+ left join jczz_circle jc on jc.event_id = jece.id and jc.even_type = 2 and jc.deleted_falg =0
+ where jece.is_deleted = 0 and jc.id is null
+ </select>
</mapper>
diff --git a/src/main/java/org/springblade/modules/task/service/IECallEventService.java b/src/main/java/org/springblade/modules/task/service/IECallEventService.java
index e4d569f..cea3d1c 100644
--- a/src/main/java/org/springblade/modules/task/service/IECallEventService.java
+++ b/src/main/java/org/springblade/modules/task/service/IECallEventService.java
@@ -44,4 +44,11 @@
* e呼即办数据处理
*/
Object dataHandle();
+
+ /**
+ * e呼即办数据批量分享到圈子
+ * @param type
+ * @return
+ */
+ boolean batchShareCircle(Integer type);
}
diff --git a/src/main/java/org/springblade/modules/task/service/impl/ECallEventServiceImpl.java b/src/main/java/org/springblade/modules/task/service/impl/ECallEventServiceImpl.java
index 2db5463..f9b0423 100644
--- a/src/main/java/org/springblade/modules/task/service/impl/ECallEventServiceImpl.java
+++ b/src/main/java/org/springblade/modules/task/service/impl/ECallEventServiceImpl.java
@@ -20,7 +20,10 @@
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.cache.SysCache;
import org.springblade.common.param.CommonParamSet;
+import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.modules.circle.entity.CircleEntity;
+import org.springblade.modules.circle.service.ICircleService;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.task.entity.ECallEventEntity;
@@ -69,4 +72,31 @@
}
return null;
}
+
+ /**
+ * e呼即办数据批量分享到圈子
+ * @param type 0 :邻里 1协同
+ * @return
+ */
+ @Override
+ public boolean batchShareCircle(Integer type) {
+ boolean flag = true;
+ ICircleService circleService = SpringUtils.getBean(ICircleService.class);
+ // 查询未分享到圈子的内容
+ List<ECallEventEntity> list = baseMapper.getNotShareCircleList();
+ // 遍历插入到圈子表
+ for (ECallEventEntity callEventEntity : list) {
+ CircleEntity circleEntity = new CircleEntity();
+ circleEntity.setEventId(callEventEntity.getId());
+ circleEntity.setEvenType(2);
+ circleEntity.setCommunityCode(callEventEntity.getCommunityCode());
+ circleEntity.setCircleType(type);
+ circleEntity.setCircleText(callEventEntity.getRemark());
+ circleEntity.setHouseCode(callEventEntity.getAddressCode());
+ circleEntity.setCircleImages(callEventEntity.getImageUrls());
+ // 保存
+ circleService.saveCircle(circleEntity);
+ }
+ return flag;
+ }
}
diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml
index 4c8178d..468a79d 100644
--- a/src/main/resources/application-prod.yml
+++ b/src/main/resources/application-prod.yml
@@ -75,6 +75,6 @@
#es
elasticsearch:
enabled: false
- host: localhost
- sync: false
+ host: 127.0.0.1
+ sync: true
indexName: jczz
diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml
index 800e1e6..39a5c96 100644
--- a/src/main/resources/application-test.yml
+++ b/src/main/resources/application-test.yml
@@ -75,6 +75,6 @@
#es
elasticsearch:
enabled: false
- host: localhost
+ host: 127.0.0.1
sync: true
indexName: test
--
Gitblit v1.9.3