From aeb7d068be92312dcdcea75e1240bcf2a78dd0fe Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 29 Jul 2024 16:49:58 +0800
Subject: [PATCH] 代码优化
---
src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java b/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java
index 597e1fb..5b39532 100644
--- a/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java
+++ b/src/main/java/org/springblade/modules/checkInRecords/service/impl/CheckInRecordsServiceImpl.java
@@ -19,12 +19,18 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.logging.log4j.util.Strings;
import org.springblade.common.cache.SysCache;
+import org.springblade.common.utils.SpringUtils;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.checkInRecords.dto.CheckInRecordsDTO;
import org.springblade.modules.checkInRecords.entity.CheckInRecordsEntity;
import org.springblade.modules.checkInRecords.vo.CheckInRecordsVO;
import org.springblade.modules.checkInRecords.mapper.CheckInRecordsMapper;
import org.springblade.modules.checkInRecords.service.ICheckInRecordsService;
+import org.springblade.modules.grid.entity.GridEntity;
+import org.springblade.modules.grid.entity.GridPatrolRecordEntity;
+import org.springblade.modules.grid.service.IGridService;
+import org.springblade.modules.police.entity.PoliceAffairsGridEntity;
+import org.springblade.modules.police.service.IPoliceAffairsGridService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -77,4 +83,34 @@
return this.baseMapper.selectCheckInRecordsList(checkInRecordsDTO);
}
+ @Override
+ public boolean saveCheckInRecords(CheckInRecordsEntity checkInRecords) {
+ checkInRecords.setCreateUserId(AuthUtil.getUserId());
+ setGridInfo(checkInRecords);
+ return save(checkInRecords);
+ }
+
+
+ /**
+ * 设置警格网格信息
+ * @param checkInRecords
+ */
+ public void setGridInfo(CheckInRecordsEntity checkInRecords) {
+ // 根据位置设置网格,警格编号
+ IGridService gridService = SpringUtils.getBean(IGridService.class);
+ IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class);
+ String point = "'POINT(" + checkInRecords.getLng() + " " + checkInRecords.getLat() + ")'";
+ //点坐标解析网格
+ List<GridEntity> gridEntityList = gridService.spatialAnalysis(point);
+ if (gridEntityList.size()>0){
+ GridEntity gridEntity = gridEntityList.get(0);
+ checkInRecords.setGridCode(gridEntity.getGridCode());
+ }
+ //点坐标解析警格
+ List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point);
+ if (policeAffairsGridEntityList.size()>0){
+ PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0);
+ checkInRecords.setJwGridCode(policeAffairsGridEntity.getJwGridCode());
+ }
+ }
}
--
Gitblit v1.9.3