From 71794ce4487fb1ef08d60585cb309b8b760037c3 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Mon, 19 Feb 2024 19:04:50 +0800
Subject: [PATCH] 二手交易查询修改

---
 src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.java            |    8 +
 src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java |   35 ++++++++
 src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.xml             |  103 ++++++++++++++++++++++++-
 src/main/java/org/springblade/modules/task/vo/TaskLabelReportingEventVO.java                    |   50 ++++++++++++
 4 files changed, 187 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.java b/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.java
index d8e97b2..c1f9379 100644
--- a/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.java
+++ b/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.java
@@ -16,7 +16,7 @@
  */
 package org.springblade.modules.task.mapper;
 
-import io.lettuce.core.dynamic.annotation.Param;
+import org.apache.ibatis.annotations.Param;
 import org.springblade.modules.task.dto.TaskLabelReportingEventDTO;
 import org.springblade.modules.task.entity.TaskLabelReportingEventEntity;
 import org.springblade.modules.task.vo.TaskLabelReportingEventVO;
@@ -39,7 +39,11 @@
 	 * @param taskLabelReportingEvent
 	 * @return
 	 */
-	List<TaskLabelReportingEventVO> selectTaskLabelReportingEventPage(IPage page,TaskLabelReportingEventVO taskLabelReportingEvent);
+	List<TaskLabelReportingEventVO> selectTaskLabelReportingEventPage(IPage page,
+																	  @Param("taskLabelReportingEvent") TaskLabelReportingEventVO taskLabelReportingEvent,
+																	  @Param("regionChildCodesList") List<String> regionChildCodesList,
+																	  @Param("isAdministrator") Integer isAdministrator,
+																	  @Param("gridCodeList") List<String> gridCodeList);
 
 
 
diff --git a/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.xml b/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.xml
index 1ae4a7d..d3ae7a4 100644
--- a/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.xml
+++ b/src/main/java/org/springblade/modules/task/mapper/TaskLabelReportingEventMapper.xml
@@ -36,14 +36,107 @@
         <result property="receiptUrls"    column="receipt_urls"    />
     </resultMap>
 
-
-    <select id="selectTaskLabelReportingEventPage" resultMap="taskLabelReportingEventResultMap">
-        select * from jczz_task_label_reporting_event where is_deleted = 0
+    <!--二手交易自定义分页查询-->
+    <select id="selectTaskLabelReportingEventPage" resultType="org.springblade.modules.task.vo.TaskLabelReportingEventVO">
+        select
+        jtlre.*,
+        jp.place_name,
+        jp.principal,
+        jp.principal_phone,
+        jp.nine_type ,
+        jp.front_type ,
+        jp.location,
+        br.town_name streetName,
+        br.village_name communityName
+        from
+        jczz_task_label_reporting_event jtlre
+        LEFT JOIN jczz_place jp ON jtlre.place_id=jp.id and jp.is_deleted = 0
+        LEFT JOIN jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0
+        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
+        LEFT JOIN blade_region br on br.code = jpag.community_code
+        where jtlre.is_deleted = 0
         <if test="taskLabelReportingEvent.userId != null and taskLabelReportingEvent.userId != ''">
-            AND user_id = #{taskLabelReportingEvent.userId}
+            AND jtlre.user_id = #{taskLabelReportingEvent.userId}
         </if>
         <if test="taskLabelReportingEvent.eventType != null and taskLabelReportingEvent.eventType != ''">
-            AND event_type = #{taskLabelReportingEvent.eventType}
+            AND jtlre.event_type = #{taskLabelReportingEvent.eventType}
+        </if>
+        <if test="taskLabelReportingEvent.transactionObject != null and taskLabelReportingEvent.transactionObject != ''">
+            AND jtlre.transaction_object like concat('%',#{taskLabelReportingEvent.transactionObject},'%')
+        </if>
+        <if test="taskLabelReportingEvent.transactionObjectTel != null and taskLabelReportingEvent.transactionObjectTel != ''">
+            AND jtlre.transaction_object_tel like concat('%',#{taskLabelReportingEvent.transactionObjectTel},'%')
+        </if>
+        <if test="taskLabelReportingEvent.idCard != null and taskLabelReportingEvent.idCard != ''">
+            AND jtlre.id_card like concat('%',#{taskLabelReportingEvent.idCard},'%')
+        </if>
+        <if test="taskLabelReportingEvent.frontType != null ">
+            AND jp.front_type = #{taskLabelReportingEvent.frontType}
+        </if>
+        <if test="taskLabelReportingEvent.placeName != null and taskLabelReportingEvent.placeName != ''">
+            AND jp.place_name like concat('%',#{taskLabelReportingEvent.placeName},'%')
+        </if>
+        <if test="taskLabelReportingEvent.principal != null and taskLabelReportingEvent.principal != ''">
+            AND jp.principal like concat('%',#{taskLabelReportingEvent.principal},'%')
+        </if>
+        <if test="taskLabelReportingEvent.principalPhone != null and taskLabelReportingEvent.principalPhone != ''">
+            AND jp.principal_phone like concat('%',#{taskLabelReportingEvent.principalPhone},'%')
+        </if>
+        <if test="taskLabelReportingEvent.roleName != null and taskLabelReportingEvent.roleName != ''">
+            <if test="taskLabelReportingEvent.roleName=='wgy'">
+                <if test="isAdministrator==2">
+                    <choose>
+                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                            and jp.grid_code in
+                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                                #{code}
+                            </foreach>
+                        </when>
+                        <otherwise>
+                            and jp.grid_code in ('')
+                        </otherwise>
+                    </choose>
+                </if>
+            </if>
+            <if test="taskLabelReportingEvent.roleName=='mj'">
+                <if test="isAdministrator==2">
+                    <choose>
+                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                            and jpag.community_code in
+                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                                #{code}
+                            </foreach>
+                        </when>
+                        <otherwise>
+                            and jpag.community_code in ('')
+                        </otherwise>
+                    </choose>
+                </if>
+            </if>
+        </if>
+        <if test="isAdministrator==2">
+            <choose>
+                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
+                    and
+                    (
+                    jg.grid_code in
+                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                        #{code}
+                    </foreach>
+                    or
+                    br.village_code in
+                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
+                        #{code}
+                    </foreach>
+                    )
+                </when>
+                <otherwise>
+                    and
+                    (
+                    jg.grid_code in ('') or br.village_code in ('')
+                    )
+                </otherwise>
+            </choose>
         </if>
     </select>
 
diff --git a/src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java b/src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java
index ed3b679..910f762 100644
--- a/src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java
+++ b/src/main/java/org/springblade/modules/task/service/impl/TaskLabelReportingEventServiceImpl.java
@@ -20,11 +20,18 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.util.Strings;
+import org.springblade.common.cache.SysCache;
 import org.springblade.common.constant.DictConstant;
+import org.springblade.common.utils.SpringUtils;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.modules.grid.service.IGridService;
 import org.springblade.modules.place.entity.PlaceEntity;
 import org.springblade.modules.place.service.IPlaceService;
+import org.springblade.modules.police.service.IPoliceAffairsGridService;
+import org.springblade.modules.system.service.IRegionService;
 import org.springblade.modules.task.dto.TaskLabelReportingEventDTO;
 import org.springblade.modules.task.entity.TaskLabelReportingEventEntity;
 import org.springblade.modules.task.mapper.TaskLabelReportingEventMapper;
@@ -36,6 +43,7 @@
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -57,7 +65,32 @@
 
 	@Override
 	public IPage<TaskLabelReportingEventVO> selectTaskLabelReportingEventPage(IPage<TaskLabelReportingEventVO> page, TaskLabelReportingEventVO taskLabelReportingEvent) {
-		return page.setRecords(baseMapper.selectTaskLabelReportingEventPage(page, taskLabelReportingEvent));
+		String roleName = SpringUtils.getRequestParam("roleName");
+		String communityCode = SpringUtils.getRequestParam("communityCode");
+		if (!Strings.isBlank(communityCode)) {
+			// 校验社区编号是否合规
+			if (null != SpringUtils.getBean(IRegionService.class).getById(communityCode)) {
+				taskLabelReportingEvent.setCommunityCode(communityCode);
+			}
+		}
+		List<String> regionChildCodesList = SysCache.getRegionChildCodesByDeptId(AuthUtil.getDeptId());
+		Integer isAdministrator = AuthUtil.isAdministrator() == true ? 1 : 2;
+		// 网格编号集合
+		List<String> gridCodeList = new ArrayList<>();
+		// 民警角色
+		if (!Strings.isBlank(roleName)) {
+			taskLabelReportingEvent.setRoleName(roleName);
+			if (roleName.equals("mj")) {
+				regionChildCodesList = SpringUtil.getBean(IPoliceAffairsGridService.class).getCommunityCodeListByUserId(AuthUtil.getUserId());
+			}
+			if (roleName.equals("wgy")) {
+				gridCodeList = SpringUtil.getBean(IGridService.class).getGridListByUserId(AuthUtil.getUserId());
+			}
+		}
+		if (AuthUtil.getUserAccount().equals("18879306957")) {
+			taskLabelReportingEvent.setCommunityCode("361102003027");
+		}
+		return page.setRecords(baseMapper.selectTaskLabelReportingEventPage(page, taskLabelReportingEvent,regionChildCodesList,isAdministrator,gridCodeList));
 	}
 
 	@Override
diff --git a/src/main/java/org/springblade/modules/task/vo/TaskLabelReportingEventVO.java b/src/main/java/org/springblade/modules/task/vo/TaskLabelReportingEventVO.java
index 1f7e020..031b765 100644
--- a/src/main/java/org/springblade/modules/task/vo/TaskLabelReportingEventVO.java
+++ b/src/main/java/org/springblade/modules/task/vo/TaskLabelReportingEventVO.java
@@ -32,10 +32,58 @@
 public class TaskLabelReportingEventVO extends TaskLabelReportingEventEntity {
 	private static final long serialVersionUID = 1L;
 
-
 	/**
 	 * 状态
 	 */
 	private Integer status;
+	private Integer nineType;
+
+	/**
+	 * 阵地类型
+	 */
+	private Integer frontType;
+
+	/**
+	 * 场所名称
+	 */
+	private String placeName;
+
+	/**
+	 * 场所负责人
+	 */
+	private String principal;
+
+	/**
+	 * 场所负责人电话
+	 */
+	private String principalPhone;
+
+	/**
+	 * 地址
+	 */
+	private String location;
+
+	/**+
+	 * 街道名称
+	 */
+	private String streetName;
+	/**+
+	 * 社区名称
+	 */
+	private String communityName;
+	/**+
+	 * 网格名称
+	 */
+	private String gridName;
+
+	/**
+	 * 角色别名
+	 */
+	private String roleName;
+
+	/**
+	 * 社区编号
+	 */
+	private String communityCode;
 
 }

--
Gitblit v1.9.3