From 60d52f83688b0eb5b2c8bff6752a0370111a275d Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Fri, 14 Jun 2024 19:43:40 +0800
Subject: [PATCH] 同步数据,并且设置好网格及警格

---
 src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcOrderServiceImpl.java        |   39 ++++++++++++
 src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.java            |   12 +++-
 src/main/java/org/springblade/modules/eCallEventTwo/entity/ECallEventTwoEntity.java             |   13 ++++
 src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.xml             |   91 ++++++++++++++++++++++++++---
 src/main/java/org/springblade/modules/eCallEventTwo/vo/ECallEventTwoVO.java                     |   10 +++
 src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcCallEventTwoServiceImpl.java |   13 ++++
 6 files changed, 162 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/springblade/modules/eCallEventTwo/entity/ECallEventTwoEntity.java b/src/main/java/org/springblade/modules/eCallEventTwo/entity/ECallEventTwoEntity.java
index 8f8f69b..c3d5276 100644
--- a/src/main/java/org/springblade/modules/eCallEventTwo/entity/ECallEventTwoEntity.java
+++ b/src/main/java/org/springblade/modules/eCallEventTwo/entity/ECallEventTwoEntity.java
@@ -284,4 +284,17 @@
 	@TableField(value = "update_time",fill = FieldFill.UPDATE)
 	private Date updateTime;
 
+	/**
+	 * 网格编号
+	 */
+	@ApiModelProperty(value = "网格编号")
+	@TableField("grid_code")
+	private String gridCode;
+	/**
+	 * 警务网格编号
+	 */
+	@ApiModelProperty(value = "警务网格编号")
+	@TableField("jw_grid_code")
+	private String jwGridCode;
+
 }
diff --git a/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.java b/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.java
index ca0f81c..f22211b 100644
--- a/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.java
+++ b/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.java
@@ -16,11 +16,13 @@
  */
 package org.springblade.modules.eCallEventTwo.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
 import org.springblade.modules.eCallEventTwo.dto.ECallEventTwoDTO;
 import org.springblade.modules.eCallEventTwo.entity.ECallEventTwoEntity;
 import org.springblade.modules.eCallEventTwo.vo.ECallEventTwoVO;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
+
 import java.util.List;
 
 /**
@@ -38,7 +40,11 @@
 	 * @param eCallEventTwo
 	 * @return
 	 */
-	List<ECallEventTwoVO> selectECallEventTwoPage(IPage page, ECallEventTwoVO eCallEventTwo);
+	List<ECallEventTwoVO> selectECallEventTwoPage(IPage page,
+												  @Param("eCallEventTwo") ECallEventTwoVO eCallEventTwo,
+												  @Param("gridCodeList") List<String> gridCodeList,
+												  @Param("regionChildCodesList") List<String> regionChildCodesList,
+												  @Param("isAdministrator") Integer isAdministrator);
 
 
 
diff --git a/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.xml b/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.xml
index 1236bf0..e62b436 100644
--- a/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.xml
+++ b/src/main/java/org/springblade/modules/eCallEventTwo/mapper/EcCallEventTwoMapper.xml
@@ -8,7 +8,7 @@
 
 
     <select id="selectECallEventTwoPage" resultMap="eCallEventTwoResultMap">
-        select * from jczz_e_call_event_two
+        select jecet.* from jczz_e_call_event_two jecet
         <where>
             <if test="eCallEventTwo.orderId != null "> and order_id = #{eCallEventTwo.orderId}</if>
             <if test="eCallEventTwo.orderCode != null  and eCallEventTwo.orderCode != ''"> and order_code like concat('%',#{eCallEventTwo.orderCode},'%') </if>
@@ -44,16 +44,85 @@
             <if test="eCallEventTwo.directFeed != null  and eCallEventTwo.directFeed != ''"> and direct_feed = #{eCallEventTwo.directFeed}</if>
             <if test="eCallEventTwo.directFeedHandler != null  and eCallEventTwo.directFeedHandler != ''"> and direct_feed_handler = #{eCallEventTwo.directFeedHandler}</if>
             <if test="eCallEventTwo.directFeedTime != null "> and direct_feed_time = #{eCallEventTwo.directFeedTime}</if>
-            <if test="eCallEventTwo.images != null  and eCallEventTwo.images != ''"> and images = #{eCallEventTwo.images}</if>
-            <if test="eCallEventTwo.status != null  and eCallEventTwo.status != ''"> and status = #{eCallEventTwo.status}</if>
-            <if test="eCallEventTwo.tagApply != null  and eCallEventTwo.tagApply != ''"> and tag_apply = #{eCallEventTwo.tagApply}</if>
-            <if test="eCallEventTwo.tagDelay != null  and eCallEventTwo.tagDelay != ''"> and tag_delay = #{eCallEventTwo.tagDelay}</if>
-            <if test="eCallEventTwo.tagDoing != null  and eCallEventTwo.tagDoing != ''"> and tag_doing = #{eCallEventTwo.tagDoing}</if>
-            <if test="eCallEventTwo.tagResp != null  and eCallEventTwo.tagResp != ''"> and tag_resp = #{eCallEventTwo.tagResp}</if>
-            <if test="eCallEventTwo.tagDone != null  and eCallEventTwo.tagDone != ''"> and tag_done = #{eCallEventTwo.tagDone}</if>
-            <if test="eCallEventTwo.tagCheck != null  and eCallEventTwo.tagCheck != ''"> and tag_check = #{eCallEventTwo.tagCheck}</if>
-            <if test="eCallEventTwo.tagChkTel != null  and eCallEventTwo.tagChkTel != ''"> and tag_chk_tel = #{eCallEventTwo.tagChkTel}</if>
-            <if test="eCallEventTwo.tagRedo != null  and eCallEventTwo.tagRedo != ''"> and tag_redo = #{eCallEventTwo.tagRedo}</if>
+            <if test="eCallEventTwo.images != null  and eCallEventTwo.images != ''">and images =
+                #{eCallEventTwo.images}
+            </if>
+            <if test="eCallEventTwo.status != null  and eCallEventTwo.status != ''">and status =
+                #{eCallEventTwo.status}
+            </if>
+            <if test="eCallEventTwo.tagApply != null  and eCallEventTwo.tagApply != ''">and tag_apply =
+                #{eCallEventTwo.tagApply}
+            </if>
+            <if test="eCallEventTwo.tagDelay != null  and eCallEventTwo.tagDelay != ''">and tag_delay =
+                #{eCallEventTwo.tagDelay}
+            </if>
+            <if test="eCallEventTwo.tagDoing != null  and eCallEventTwo.tagDoing != ''">and tag_doing =
+                #{eCallEventTwo.tagDoing}
+            </if>
+            <if test="eCallEventTwo.tagResp != null  and eCallEventTwo.tagResp != ''">and tag_resp =
+                #{eCallEventTwo.tagResp}
+            </if>
+            <if test="eCallEventTwo.tagDone != null  and eCallEventTwo.tagDone != ''">and tag_done =
+                #{eCallEventTwo.tagDone}
+            </if>
+            <if test="eCallEventTwo.tagCheck != null  and eCallEventTwo.tagCheck != ''">and tag_check =
+                #{eCallEventTwo.tagCheck}
+            </if>
+            <if test="eCallEventTwo.tagChkTel != null  and eCallEventTwo.tagChkTel != ''">and tag_chk_tel =
+                #{eCallEventTwo.tagChkTel}
+            </if>
+            <if test="eCallEventTwo.tagRedo != null  and eCallEventTwo.tagRedo != ''">and tag_redo =
+                #{eCallEventTwo.tagRedo}
+            </if>
+            <if test="isAdministrator==2">
+                <choose>
+                    <when test="eCallEventTwo.roleName != null and eCallEventTwo.roleName != ''">
+                        <if test="eCallEventTwo.roleName=='wgy'">
+                            <choose>
+                                <when test="gridCodeList !=null and gridCodeList.size()>0">
+                                    and jecet.grid_code in
+                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
+                                        #{code}
+                                    </foreach>
+                                </when>
+                                <otherwise>
+                                    and jecet.grid_code in ('')
+                                </otherwise>
+                            </choose>
+                        </if>
+                        <if test="eCallEventTwo.roleName=='mj'">
+                            <choose>
+                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                                    and jecet.jw_grid_code in
+                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
+                                             separator=",">
+                                        #{code}
+                                    </foreach>
+                                </when>
+                                <otherwise>
+                                    and jecet.jw_grid_code in ('')
+                                </otherwise>
+                            </choose>
+                        </if>
+                    </when>
+                    <otherwise>
+                        <choose>
+                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                                and
+                                (
+                                jecet.grid_code in
+                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                                    #{code}
+                                </foreach>
+                                )
+                            </when>
+                            <otherwise>
+                                and  ( jecet.grid_code in ('')  )
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
+            </if>
         </where>
         order by order_id desc
     </select>
diff --git a/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcCallEventTwoServiceImpl.java b/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcCallEventTwoServiceImpl.java
index 8b10703..5b60460 100644
--- a/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcCallEventTwoServiceImpl.java
+++ b/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcCallEventTwoServiceImpl.java
@@ -19,6 +19,7 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.common.param.CommonParamSet;
 import org.springblade.common.param.GridSet;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.modules.eCallEventTwo.dto.ECallEventTwoDTO;
@@ -49,7 +50,17 @@
 
 	@Override
 	public IPage<ECallEventTwoVO> selectECallEventTwoPage(IPage<ECallEventTwoVO> page, ECallEventTwoVO eCallEventTwo) {
-		List<ECallEventTwoVO> eCallEventTwoVOS = baseMapper.selectECallEventTwoPage(page, eCallEventTwo);
+
+		// 公共参数设置
+		CommonParamSet commonParamSet = new CommonParamSet().invoke(ECallEventTwoVO.class, eCallEventTwo);
+
+
+		// 返回
+		List<ECallEventTwoVO> eCallEventTwoVOS = baseMapper.selectECallEventTwoPage(page,
+			eCallEventTwo,
+			commonParamSet.getGridCodeList(),
+			commonParamSet.getRegionChildCodesList(),
+			commonParamSet.getIsAdministrator());
 		return page.setRecords(eCallEventTwoVOS);
 	}
 
diff --git a/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcOrderServiceImpl.java b/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcOrderServiceImpl.java
index 3157730..7639b48 100644
--- a/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcOrderServiceImpl.java
+++ b/src/main/java/org/springblade/modules/eCallEventTwo/service/impl/EcOrderServiceImpl.java
@@ -8,6 +8,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springblade.common.utils.SpringUtils;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.modules.eCallEventTwo.dto.*;
 import org.springblade.modules.eCallEventTwo.entity.ECallEventTwoEntity;
@@ -15,6 +16,10 @@
 import org.springblade.modules.eCallEventTwo.mapper.EcOrderMapper;
 import org.springblade.modules.eCallEventTwo.service.EcOrderService;
 import org.springblade.modules.eCallEventTwo.service.IECallEventTwoService;
+import org.springblade.modules.grid.entity.GridEntity;
+import org.springblade.modules.grid.service.IGridService;
+import org.springblade.modules.police.entity.PoliceAffairsGridEntity;
+import org.springblade.modules.police.service.IPoliceAffairsGridService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -121,13 +126,45 @@
 			IPage<EcOrder> resultPage = baseMapper.selectPage(page, objectQueryWrapper);
 			List<EcOrder> records = resultPage.getRecords();
 			List<ECallEventTwoEntity> recordEntityList = BeanUtil.copy(records, ECallEventTwoEntity.class);
-			boolean b = ecOrderService.saveOrUpdateBatch(recordEntityList);
+			recordEntityList.forEach(ecOrderEntity -> {
+				// 点落面 设置警格网格信息
+				setGridInfo(ecOrderEntity);
+			});
+			boolean b = ecOrderService.saveBatch(recordEntityList);
 			System.out.println("更新第" + pageNum + "页" + b);
 		}
 	}
 
 	/**
+	 * 设置警格网格信息
+	 *
+	 * @param ecOrderEntity
+	 */
+	public void setGridInfo(ECallEventTwoEntity ecOrderEntity) {
+		if (ecOrderEntity.getSceneGeoLng() == null || ecOrderEntity.getSceneGeoLat() == null) {
+			return;
+		}
+		// 根据位置设置网格,警格编号
+		IGridService gridService = SpringUtils.getBean(IGridService.class);
+		IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class);
+		String point = "'POINT(" + ecOrderEntity.getSceneGeoLng().toString() + " " + ecOrderEntity.getSceneGeoLat().toString() + ")'";
+		// 点坐标解析网格
+		List<GridEntity> gridEntityList = gridService.spatialAnalysis(point);
+		if (gridEntityList.size() > 0) {
+			GridEntity gridEntity = gridEntityList.get(0);
+			ecOrderEntity.setGridCode(gridEntity.getGridCode());
+		}
+		// 点坐标解析警格
+		List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point);
+		if (policeAffairsGridEntityList.size() > 0) {
+			PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0);
+			ecOrderEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode());
+		}
+	}
+
+	/**
 	 * 获取单位考核指标
+	 *
 	 * @return
 	 */
 	@Override
diff --git a/src/main/java/org/springblade/modules/eCallEventTwo/vo/ECallEventTwoVO.java b/src/main/java/org/springblade/modules/eCallEventTwo/vo/ECallEventTwoVO.java
index 55fce70..f6763d8 100644
--- a/src/main/java/org/springblade/modules/eCallEventTwo/vo/ECallEventTwoVO.java
+++ b/src/main/java/org/springblade/modules/eCallEventTwo/vo/ECallEventTwoVO.java
@@ -16,6 +16,7 @@
  */
 package org.springblade.modules.eCallEventTwo.vo;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.springblade.modules.eCallEventTwo.entity.ECallEventTwoEntity;
 import org.springblade.core.tool.node.INode;
 import lombok.Data;
@@ -32,8 +33,17 @@
 public class ECallEventTwoVO extends ECallEventTwoEntity {
 	private static final long serialVersionUID = 1L;
 
+	@ApiModelProperty(value = "经度")
 	private String lng;
+	@ApiModelProperty(value = "纬度")
 	private String lat;
+	@ApiModelProperty(value = "警务网格编号")
 	private String jwGridCode;
 
+	@ApiModelProperty(value = "社区编号")
+	private String communityCode;
+
+	@ApiModelProperty(value = "角色名称")
+	private String roleName;
+
 }

--
Gitblit v1.9.3