linwe
2024-07-29 aeb7d068be92312dcdcea75e1240bcf2a78dd0fe
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());
      }
   }
}