From f7bf2df07c6588a950a596377c3f7122cf879efc Mon Sep 17 00:00:00 2001 From: huxin02 Date: Fri, 14 Mar 2025 18:06:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A7=E6=B3=95=E5=A4=84=E7=BD=9A=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E3=80=81=E6=B6=88=E6=81=AF=E6=8E=A5=E5=8F=A3=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LawEnfPenaltyStatRepository.java | 57 ++++++++++++++++ .../repository/MaterialsRepository.java | 13 ++++ .../repository/MessageReceiverRepository.java | 66 +++++++++++++++++++ .../repository/MessageRepository.java | 32 +++++++++ 4 files changed, 168 insertions(+) create mode 100644 server/src/main/java/com/aisino/iles/lawenforcement/repository/LawEnfPenaltyStatRepository.java create mode 100644 server/src/main/java/com/aisino/iles/lawenforcement/repository/MaterialsRepository.java create mode 100644 server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageReceiverRepository.java create mode 100644 server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageRepository.java diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/LawEnfPenaltyStatRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/LawEnfPenaltyStatRepository.java new file mode 100644 index 0000000..43b54d1 --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/LawEnfPenaltyStatRepository.java @@ -0,0 +1,57 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.core.repository.BaseRepo; +import com.aisino.iles.lawenforcement.model.LawEnfPenaltyStat; +import com.aisino.iles.lawenforcement.model.dto.LawEnfPenaltyStatDto; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +/** + * 执法处罚统计仓库接口 + */ +@Repository +public interface LawEnfPenaltyStatRepository extends BaseRepo { + + /** + * 执法处罚统计市级 + * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 执法信息列表 + */ + // @Query(name = "getLawEnfPenaltyStat", nativeQuery = true) +// @Query(value = " WITH d AS (SELECT * FROM zf_agency t where agency_level in(2,3)) "+ +// " SELECT d.agency_code agencyCode,d.agency_name agencyName,d.agency_level agencyLevel, ifnull(q.xccs, 0) xccs,ifnull(q.fxwt,0) fxwts,ifnull(q.jjwt,0) jjwts,ifnull(q.las,0) las,ifnull(q.cfs,0) cfs " + +// " from d left join (select xccs.agencyCode agencyCode, xccs.xccs ,fxwt.fxwt,jjwt.jjwt, las.las,cfs.cfs " + +// " from ( select dw.agency_code agencyCode ,count(xc.online_patrol_id) xccs from zf_online_patrol_info xc" + +// " left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime group by dw.agency_code ) xccs left join " + +// " ( select dw.agency_code agencyCode ,count(xc.online_patrol_id) fxwt from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime and xc.approval_status='0' group by dw.agency_code ) fxwt on xccs.agencyCode = fxwt.agencyCode left join " + +// " ( select dw.agency_code agencyCode ,count(xc.online_patrol_id) jjwt from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime and xc.approval_status <> '0' group by dw.agency_code ) jjwt on fxwt.agencyCode = jjwt.agencyCode left join " + +// " ( select dw.agency_code agencyCode ,count(la.case_id) las from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id " + +// " left join zf_enforcement_info zf on xc.enforcement_id = zf.enforcement_id left join zf_case_info la on zf.enforcement_id= la.enforcement_id where la.filling_date>= :startTime and la.filling_date<=:endTime group by dw.agency_code ) las on xccs.agencyCode=las.agencyCode left join " + +// " ( select dw.agency_code agencyCode ,count(la.case_id) cfs from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id " + +// " left join zf_enforcement_info zf on xc.enforcement_id = zf.enforcement_id left join zf_case_info la on zf.enforcement_id= la.enforcement_id where la.filling_date>= :startTime and la.filling_date<=:endTime and zf.current_node_Code in('reviewing_done','brainstorm','closed','done') group by dw.agency_code ) cfs on cfs.agencyCode=las.agencyCode " + +// " ) q on d.agency_code = q. agencyCode " , nativeQuery = true) + @Query(name = "getOnlinePatrolStat") + List> getLawEnfPenaltyStat(LocalDateTime startTime, LocalDateTime endTime); + +// @Query(value = " WITH d AS (SELECT * FROM zf_agency t "+ +// " SELECT d.agency_code agencyCode,d.agency_name agencyName,d.agency_level agencyLevel, ifnull(q.xccs, 0) xccs,ifnull(q.fxwt,0) fxwts,ifnull(q.jjwt,0) jjwts,ifnull(q.las,0) las,ifnull(q.cfs,0) cfs " + +// " from d left join (select xccs.agencyCode agencyCode, xccs.xccs ,fxwt.fxwt,jjwt.jjwt ,las.las,cfs.cfs " + +// " from ( select dw.agency_code agencyCode ,count(xc.online_patrol_id) xccs from zf_online_patrol_info xc" + +// " left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime and dw.agency_id=:agencyCode group by dw.agency_code ) xccs left join " + +// " ( select dw.agency_code agencyCode ,count(xc.online_patrol_id) fxwt from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime and xc.approval_status='0' and dw.agency_id=:agencyCode group by dw.agency_code ) fxwt on xccs.agencyCode = fxwt.agencyCode left join " + +// " ( select dw.agency_code agencyCode ,count(xc.online_patrol_id) jjwt from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime and xc.approval_status <> '0' and dw.agency_id=:agencyCode group by dw.agency_code ) jjwt on fxwt.agencyCode = jjwt.agencyCode left join " + +// " ( select dw.agency_code agencyCode ,count(la.case_id) las from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id " + +// " left join zf_enforcement_info zf on xc.enforcement_id = zf.enforcement_id left join zf_case_info la on zf.enforcement_id= la.enforcement_id where la.filling_date>= :startTime and la.filling_date<=:endTime and dw.agency_id=:agencyCode group by dw.agency_code ) las on xccs.agencyCode=las.agencyCode left join " + +// " ( select dw.agency_code agencyCode ,count(la.case_id) las from zf_online_patrol_info xc left join zf_agency dw on xc.agency_id = dw.agency_id " + +// " left join zf_enforcement_info zf on xc.enforcement_id = zf.enforcement_id left join zf_case_info la on zf.enforcement_id= la.enforcement_id where la.filling_date>= :startTime and la.filling_date<=:endTime and dw.agency_id=:agencyCode and zf.current_node_Code in('reviewing_done','brainstorm','closed','done') group by dw.agency_code ) cfs on cfs.agencyCode=las.agencyCode " + +// " ) q on d.agency_code = q. agencyCode " , nativeQuery = true) + @Query(name = "getOnlinePatrolStatByDistrict") + List> getLawEnfPenaltyStatByDistrict( String agencyCode, LocalDateTime startTime, LocalDateTime endTime); + +} diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/MaterialsRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/MaterialsRepository.java new file mode 100644 index 0000000..df9f93a --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/MaterialsRepository.java @@ -0,0 +1,13 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.core.repository.BaseRepo; +import com.aisino.iles.lawenforcement.model.Materials; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface MaterialsRepository extends BaseRepo { + List findByLinkId(String linkId); + +} diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageReceiverRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageReceiverRepository.java new file mode 100644 index 0000000..be03758 --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageReceiverRepository.java @@ -0,0 +1,66 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.lawenforcement.model.Message.MessageStatus; +import com.aisino.iles.lawenforcement.model.MessageReceiver; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +/** + * 消息接收者仓库接口 + */ +@Repository +public interface MessageReceiverRepository extends JpaRepository { + + /** + * 根据接收者ID和消息ID查找消息接收记录 + * + * @param receiverId 接收者ID + * @param messageId 消息ID + * @return 消息接收记录(可选) + */ + Optional findByReceiverIdAndMessageId(String receiverId, String messageId); + + /** + * 根据接收者ID查找所有消息接收记录,并按创建时间降序排序 + * + * @param receiverId 接收者ID + * @param statuses 消息状态列表(可选) + * @param pageable 分页参数 + * @return 消息接收记录分页结果 + */ + @Query("SELECT mr FROM MessageReceiver mr JOIN FETCH mr.message m WHERE mr.receiverId = :receiverId AND (mr.status IS NULL OR mr.status IN :statuses) ORDER BY m.createTime DESC") + Page findByReceiverIdAndStatusIn(@Param("receiverId") String receiverId, @Param("statuses") Collection statuses, Pageable pageable); + + /** + * 根据接收者ID和消息ID列表查找所有消息接收记录 + * + * @param receiverId 接收者ID + * @param messageIds 消息ID列表 + * @return 消息接收记录列表 + */ + List findByReceiverIdAndMessageIdIn(String receiverId, List messageIds); + + /** + * 统计接收者的未读消息数量 + * + * @param receiverId 接收者ID + * @return 未读消息数量 + */ + long countByReceiverIdAndStatus(String receiverId, MessageStatus status); + + /** + * 根据消息ID查找所有接收者记录 + * + * @param messageId 消息ID + * @return 消息接收记录列表 + */ + List findByMessageId(String messageId); +} diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageRepository.java new file mode 100644 index 0000000..c0c64e1 --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/MessageRepository.java @@ -0,0 +1,32 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.lawenforcement.model.Message; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +/** + * 消息仓库接口 + */ +@Repository +public interface MessageRepository extends JpaRepository { + + /** + * 根据业务键查找消息 + * + * @param businessKey 业务键 + * @return 消息对象(可选) + */ + Optional findByBusinessKey(String businessKey); + + /** + * 检查指定业务键的消息是否存在 + * + * @param businessKey 业务键 + * @return 是否存在 + */ + boolean existsByBusinessKey(String businessKey); +}