diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/ExamineReportRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/ExamineReportRepository.java new file mode 100644 index 0000000..363be1e --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/ExamineReportRepository.java @@ -0,0 +1,9 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.core.repository.BaseRepo; +import com.aisino.iles.lawenforcement.model.ExamineReport; +import org.springframework.stereotype.Repository; + +@Repository +public interface ExamineReportRepository extends BaseRepo { +} diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/ExampleRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/ExampleRepository.java new file mode 100644 index 0000000..5381dae --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/ExampleRepository.java @@ -0,0 +1,9 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.core.repository.BaseRepo; +import com.aisino.iles.lawenforcement.model.Example; +import org.springframework.stereotype.Repository; + +@Repository +public interface ExampleRepository extends BaseRepo { +} \ No newline at end of file diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/HomePageRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/HomePageRepository.java new file mode 100644 index 0000000..56a079d --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/HomePageRepository.java @@ -0,0 +1,104 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.core.repository.BaseRepo; +import com.aisino.iles.lawenforcement.model.EnforcementInfo; +import com.aisino.iles.lawenforcement.model.dto.HomePageDto; +import com.aisino.iles.lawenforcement.model.dto.NodeCaseNumDto; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + +/** + * 大屏统计接口 + */ +@Repository +public interface HomePageRepository extends BaseRepo { + + @Query(value = "select count(0) from zf_enterprise qy join zf_agency a on qy.agency_id=a.agency_id where qy.del_flag = '0' and a.agency_code like :agencyCode ", nativeQuery = true) + Long getqys(String agencyCode); + + @Query(value = "select count(0) num from zf_enforce_check jc left join zf_enforcement_info zf on jc.enforcement_id=zf.enforcement_id where zf.current_node_code not in('plan_approval','plan_approval_failed','plan_approved')", nativeQuery = true) + Long getjcs(); + + @Query(value = "select count(0) num from zf_case_info where file_path is not null", nativeQuery = true) + Long getajs(); + + //查询待立案书 + @Query(value = "select count(0) num from zf_enforcement_info where current_node_code = 'inspect_summarize' and filling_flag = '1' ", nativeQuery = true) + Long getdla(); + + + @Query(value = "SELECT current_node_code as status, COUNT(*) AS stat_num FROM zf_enforcement_info GROUP BY current_node_code", nativeQuery = true) + List> countCurrentNodeCode(); + + + @Query(value = "select count(0) num from zf_enforcement_info f left join zf_agency a on f.agency_id=a.agency_id where a.agency_code = :agencyCode ", nativeQuery = true) + Long getZfxxsByDistrict(String agencyCode); + + @Query(value = "select count(0) from zf_enterprise qy join zf_agency a on qy.agency_id=a.agency_id where qy.is_remove = '0' and a.agency_code = :agencyCode ", nativeQuery = true) + Long getqysByDistrict(String agencyCode); + + @Query(value = "select count(0) num from zf_enforce_check jc left join zf_enforcement_info zf on jc.enforcement_id=zf.enforcement_id left join zf_agency a on zf.agency_id=a.agency_id where zf.current_node_code not in('plan_approval','plan_approval_failed','plan_approved') and a.agency_code = :agencyCode ", nativeQuery = true) + Long getjcsByDistrict(String agencyCode); + + @Query(value = "select count(0) num from zf_case_info c left join zf_enforcement_info f on c.enforcement_id=f.enforcement_id left join zf_agency a on f.agency_id=a.agency_id where c.file_path is not null and a.agency_code = :agencyCode ", nativeQuery = true) + Long getajsByDistrict(String agencyCode); + + @Query(value = "select count(0) from zf_zfclgl where sddm= :agencyCode ", nativeQuery = true) + Long getclsByDistrict(String agencyCode); + + @Query(value = "select count(0) from zf_zfclgl ", nativeQuery = true) + Long getcls(); + + //查询待立案书 + @Query(value = "select count(0) num from zf_enforcement_info f left join zf_agency a on f.agency_id=a.agency_id where f.current_node_code = 'inspect_summarize' and f.filling_flag = '1' and a.agency_code = :agencyCode ", nativeQuery = true) + Long getdlaByDistrict(String agencyCode); + + + @Query(value = "SELECT f.current_node_code as status, COUNT(f.enforcement_id) AS stat_num FROM zf_enforcement_info f left join zf_agency a on f.agency_id=a.agency_id where a.agency_code = :agencyCode GROUP BY f.current_node_code", nativeQuery = true) + List> countCurrentNodeCodeByDistrict(String agencyCode); + + @Query(value = "select count(0) num from zf_legal_document w left join zf_case_info c on w.case_id= c.case_id left join zf_enforcement_info f on c.enforcement_id=f.enforcement_id left join zf_agency a on f.agency_id=a.agency_id where w.status='done' and a.agency_code = :agencyCode ", nativeQuery = true) + Long getWssByDistrict(String agencyCode); + + @Query(value = "select count(0) num from zf_legal_document w where w.status='done' and w.document_date >= :startDate and w.document_date <= :endDate ", nativeQuery = true) + Long getDocumentNumForPlatform(LocalDateTime startDate, LocalDateTime endDate); + + @Query(value = "select count(0) num from zf_case_info where file_path is not null and file_path_time >= :startDate and file_path_time <= :endDate ", nativeQuery = true) + Long getDossiersNumForPlatform(LocalDateTime startDate, LocalDateTime endDate); + + + @Query(value = "SELECT count(0) num FROM zf_enforcement_info zf left join zf_case_info aj on zf.enforcement_id=aj.enforcement_id where zf.current_node_code in ('filed','investigating','investigation_done','analyze_judge','reviewing_failed','reviewing_done','brainstorm','closed','done') and aj.filling_date>=:startDate and aj.filling_date <= :endDate and zf.filling_flag = '1' ", nativeQuery = true) + Long getSlNum(LocalDateTime startDate, LocalDateTime endDate); + + @Query(value = "SELECT count(0) num FROM zf_enforcement_info zf left join zf_case_info aj on zf.enforcement_id=aj.enforcement_id where zf.current_node_code in ('investigating','investigation_done','analyze_judge','reviewing_failed','reviewing_done','brainstorm','closed','done') and aj.filling_date>=:startDate and aj.filling_date <= :endDate and zf.filling_flag = '1' ", nativeQuery = true) + Long getdcNum(LocalDateTime startDate, LocalDateTime endDate); + + @Query(value = "SELECT count(0) num FROM zf_enforcement_info zf left join zf_case_info aj on zf.enforcement_id=aj.enforcement_id where zf.current_node_code in ('reviewing_done','brainstorm','closed','done') and aj.filling_date>=:startDate and aj.filling_date <= :endDate and zf.filling_flag = '1' ", nativeQuery = true) + Long getjdNum(LocalDateTime startDate, LocalDateTime endDate); + + @Query(value = "SELECT count(0) num FROM zf_enforcement_info zf left join zf_case_info aj on zf.enforcement_id=aj.enforcement_id where zf.current_node_code in ('closed','done') and aj.filling_date>=:startDate and aj.filling_date <= :endDate and zf.filling_flag = '1' ", nativeQuery = true) + Long getzxNum(LocalDateTime startDate, LocalDateTime endDate); + + @Query("select new com.aisino.iles.lawenforcement.model.dto.NodeCaseNumDto(" + + /*立案*/ " cast(sum(case when a.currentNodeCode in ('filed', 'investigating', 'investigation_done', 'analyze_judge', 'inform', 'hearing', 'decided', 'execute', 'closed', 'done') then 1 else 0 end) as long)," + + /*完成调查取证*/ " cast(sum(case when a.currentNodeCode in ('investigation_done', 'analyze_judge', 'inform', 'hearing', 'decided', 'execute', 'closed', 'done') then 1 else 0 end) as long)," + + /*审理*/ " cast(sum(case when a.currentNodeCode in ('analyze_judge', 'inform', 'hearing', 'decided', 'execute', 'closed', 'done') then 1 else 0 end) as long)," + + /*告知*/ " cast(sum(case when a.currentNodeCode in ('inform', 'hearing', 'decided', 'execute', 'closed', 'done') then 1 else 0 end) as long)," + + /*陈述申辩或听证*/ " cast(sum(case when a.currentNodeCode in ('hearing', 'decided', 'execute', 'closed', 'done') then 1 else 0 end) as long)," + + /*执行*/ " cast(sum(case when a.currentNodeCode in ('decided', 'execute', 'closed', 'done') then 1 else 0 end) as long)," + + /*决定*/ " cast(sum(case when a.currentNodeCode in ('execute', 'closed', 'done') then 1 else 0 end) as long)," + + /*结案*/ " cast(sum(case when a.currentNodeCode in ('closed', 'done') then 1 else 0 end) as long)" + + " )" + + " from EnforcementInfo a join Case b on a.enforcementId = b.enforcementId" + + " where a.fillingFlag = '1'") + NodeCaseNumDto getNodeCaseNum(); + + @Query(value = "select count(0) from zf_case_info a left join zf_agency b on a.agency_id = b.agency_id where b.agency_code like :agencyCode ", nativeQuery = true) + Long getajsByAgencyCode(String agencyCode); + +} diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/InsEnterprseRepository.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/InsEnterprseRepository.java new file mode 100644 index 0000000..afb177a --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/InsEnterprseRepository.java @@ -0,0 +1,13 @@ +package com.aisino.iles.lawenforcement.repository; + +import com.aisino.iles.core.repository.BaseRepo; +import com.aisino.iles.lawenforcement.model.InsEnterprse; +import org.springframework.stereotype.Repository; + + +/** + * 在线巡查企业信息接口 + */ +@Repository +public interface InsEnterprseRepository extends BaseRepo { +} diff --git a/server/src/main/java/com/aisino/iles/lawenforcement/repository/impl/StatisticCustomRepositoryImpl.java b/server/src/main/java/com/aisino/iles/lawenforcement/repository/impl/StatisticCustomRepositoryImpl.java new file mode 100644 index 0000000..933422c --- /dev/null +++ b/server/src/main/java/com/aisino/iles/lawenforcement/repository/impl/StatisticCustomRepositoryImpl.java @@ -0,0 +1,1204 @@ +package com.aisino.iles.lawenforcement.repository.impl; + +import com.aisino.iles.common.util.StringUtils; +import com.aisino.iles.core.repository.PageCustomRepo; +import com.aisino.iles.lawenforcement.model.EnforcementInfoHistory; +import com.aisino.iles.lawenforcement.model.OnlinePatrol; +import jakarta.persistence.EntityManager; +import org.hibernate.query.Query; +import org.hibernate.transform.Transformers; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.jpa.repository.JpaContext; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Repository +public class StatisticCustomRepositoryImpl implements PageCustomRepo { + private final EntityManager entityManager; + + public StatisticCustomRepositoryImpl(JpaContext jpaContext) { + entityManager = jpaContext.getEntityManagerByManagedType(EnforcementInfoHistory.class); + } + + + public Page jcqyqkDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("startTime", startTime); + map.put("endTime", endTime); + sql.append("select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id"); + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id"); + sql.append(" where jc.check_date>= :startTime and jc.check_date<=:endTime"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" GROUP BY qy.enterprise_id union all"); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf left join zf_agency dw on zf.agency_id = dw.agency_id where zf.check_date>=:startTime and zf.check_date<= :endTime and zf.supplement_verify_result='1' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + + countSql.append(" select count(1) from ("); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id"); + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id"); + countSql.append(" where jc.check_date>= :startTime and jc.check_date<=:endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" GROUP BY qy.enterprise_id union all"); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf left join zf_agency dw on zf.agency_id = dw.agency_id where zf.supplement_verify_result='1' and zf.check_date>= :startTime and zf.check_date<= :endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" GROUP BY zf.unified_social_code) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + + + public Page jccsqkDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("startTime", startTime); + map.put("endTime", endTime); + countSql.append("select count(1) from ("); + countSql.append(" select qy.industry_type industryType, qy.unit_name unitName,qy.unified_social_code unifiedSocialCode,jc.check_date checkDate from"); + countSql.append(" zf_enforcement_info zf left join zf_enterprise qy on zf.enterprise_id = qy.enterprise_id"); + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id where jc.check_date>= :startTime and jc.check_date<=:endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" union all select zf.industry_type industryType, zf.unit_name unitName,zf.unified_social_code unifiedSocialCode,zf.check_date checkDate from zf_enforcement_info_history zf left join zf_agency dw on zf.agency_id = dw.agency_id where zf.supplement_verify_result='1' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" and zf.check_date>= :startTime and zf.check_date<=:endTime ) t "); + + sql.append("select qy.industry_type industryType, qy.unit_name unitName,qy.unified_social_code unifiedSocialCode,jc.check_date checkDate from"); + sql.append(" zf_enforcement_info zf left join zf_enterprise qy on zf.enterprise_id = qy.enterprise_id"); + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id where jc.check_date>=:startTime and jc.check_date<=:endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" union all select zf.industry_type industryType, zf.unit_name unitName,zf.unified_social_code unifiedSocialCode,zf.check_date checkDate from zf_enforcement_info_history zf left join zf_agency dw on zf.agency_id = dw.agency_id where zf.supplement_verify_result='1' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" and zf.check_date>= :startTime and zf.check_date<=:endTime"); + + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjccs").unwrap(Query.class); +// Query query = entityManager.createNativeQuery(sql.toString()) +// .unwrap(Query.class) +// .setResultTransformer(Transformers.aliasToBean(EnforcementInfoHistory.class)); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + + public List jcqkDetail(String gxdwbm, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("startTime", startTime); + map.put("endTime", endTime); + sql.append(" select jc.check_date checkDate, "); + + sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.zdyhs'), '') as integer), 0) zdyhs,"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.ybyhs'), '') as integer), 0) ybyhs,"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.zdyhs'), '') as integer), 0) +"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.ybyhs'), '') as integer), 0) yhzs,"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.xcclcss'), '') as integer), 0) xcclcss,"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.zlxqzgs'), '') as integer), 0) zlxqzgs,"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.zgfcyjs'), '') as integer), 0) zgfcyjs,"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.qtwss'), '') as integer), 0) qtwss,"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.xcclcss'), '') as integer), 0) +"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.zlxqzgs'), '') as integer), 0) +"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.zgfcyjs'), '') as integer), 0) +"); +sql.append("coalesce(cast(nullif(json_value(jc.supplement, '$.qtwss'), '') as integer), 0) wszs"); + + + + + sql.append(" from zf_enforcement_info zf "); + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + sql.append(" left join zf_enforce_check jc on zf.enforcement_id = jc.enforcement_id "); + sql.append(" where jc.check_date >= :startTime "); + sql.append(" and jc.check_date <= :endTime "); + sql.append(" and jc.supplement_verify_result = '1' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + + sql.append(" union all "); + sql.append(" select jc.check_date checkDate, "); + sql.append(" coalesce(jc.zdyhs, 0) zdyhs, "); + sql.append(" coalesce(jc.ybyhs,0 ) ybyhs, "); + sql.append(" coalesce(jc.zdyhs, 0) + COALESCE(jc.ybyhs, 0) yhzs, "); + sql.append(" coalesce(jc.xcclcss ,0) xcclcss, "); + sql.append(" coalesce(jc.zlxqzgs,0) zlxqzgs, "); + sql.append(" coalesce(jc.zgfcyjs,0) zgfcyjs, "); + sql.append(" coalesce(jc.qtwss,0) qtwss, "); + sql.append(" COALESCE(jc.xcclcss, 0) + COALESCE(jc.zlxqzgs, 0) + COALESCE(jc.zgfcyjs, 0) + COALESCE(jc.qtwss, 0) wszs "); + sql.append(" from zf_enforcement_info_history jc "); + sql.append(" left join zf_agency dw on jc.agency_id = dw.agency_id "); + sql.append(" where jc.check_date >= :startTime "); + sql.append(" and jc.check_date <= :endTime "); + sql.append(" and jc.supplement_verify_result = '1' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqk").unwrap(Query.class); + this.setParameters(query, map); + List tavernList = query.getResultList(); + return tavernList; + } + + + public Page zbbjgqyDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + + sql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress from zf_enterprise qy"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on qy.agency_id = dw.agency_id "); + } + sql.append(" where qy.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" GROUP BY qy.enterprise_id union all"); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where zf.supplement_verify_result='1' and zf.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + countSql.append("select count(1) from ( "); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress from zf_enterprise qy"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on qy.agency_id = dw.agency_id "); + } + countSql.append(" where qy.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" GROUP BY qy.enterprise_id union all"); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + countSql.append(" where zf.supplement_verify_result='1' and zf.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + + public Page jcqyqkByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + sql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress "); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + sql.append(" where jc.check_date>= :startTime and jc.check_date <= :endTime and qy.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" GROUP BY qy.enterprise_id union all "); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1 "); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where zf.check_date>= :startTime and zf.check_date <= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + countSql.append("select count(1) from ( "); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress "); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id "); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + countSql.append(" where jc.check_date>= :startTime and jc.check_date <= :endTime and qy.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code=:gxdwbm "); + } + countSql.append(" GROUP BY qy.enterprise_id union all "); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1 "); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf "); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + countSql.append(" where zf.check_date>= :startTime and zf.check_date <= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + + public Page jccsqkByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select qy.industry_type industryType, qy.unit_name unitName,qy.unified_social_code unifiedSocialCode,jc.check_date checkDate from"); + sql.append(" zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id"); + } + + sql.append(" where jc.check_date>= :startTime and jc.check_date <= :endTime and qy.industry_type = :industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" union all"); + sql.append(" select jc.industry_type industryType, jc.unit_name unitName,jc.unified_social_code unifiedSocialCode,jc.check_date checkDate from zf_enforcement_info_history jc"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on jc.agency_id = dw.agency_id "); + } + sql.append(" where jc.check_date>= :startTime and jc.check_date <= :endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm"); + } + sql.append(" and jc.supplement_verify_result = '1' and jc.industry_type = :industryType"); + + countSql.append("select count(1) from ("); + countSql.append(" select qy.industry_type industryType, qy.unit_name unitName,qy.unified_social_code unifiedSocialCode,jc.check_date checkDate from"); + countSql.append(" zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id"); + } + + countSql.append(" where jc.check_date>= :startTime and jc.check_date <= :endTime and qy.industry_type = :industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" union all"); + countSql.append(" select jc.industry_type industryType, jc.unit_name unitName,jc.unified_social_code unifiedSocialCode,jc.check_date checkDate from zf_enforcement_info_history jc"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on jc.agency_id = dw.agency_id "); + } + countSql.append(" where jc.check_date>= :startTime and jc.check_date <= :endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm"); + } + countSql.append(" and jc.supplement_verify_result = '1' and jc.industry_type = :industryType ) t"); + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjccs").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + public Page laqyqkByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + sql.append(" GROUP BY qy.enterprise_id union all"); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + sql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + countSql.append("select count(1) from ("); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + countSql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + + countSql.append(" GROUP BY qy.enterprise_id union all"); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + countSql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + public Page laqyslByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select la.filling_date fillingDate,la.case_name caseName,la.case_num caseNum,qy.industry_type industryType,qy.unit_name unitName,qy.unified_social_code unifiedSocialCode,qy.legal_representative legalRepresentative,qy.op_loc_address opLocAddress"); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id"); + sql.append(" left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on qy.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and la.supplement_verify_result='1' and qy.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" union all select la.filling_date fillingDate,la.case_name caseName,la.case_num caseNum,la.industry_type industryType,la.unit_name unitName,la.unified_social_code unifiedSocialCode,la.legal_representative legalRepresentative,la.op_loc_address opLocAddress"); + sql.append(" from zf_enforcement_info_history la"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on la.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and la.supplement_verify_result='1'"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" and la.industry_type=:industryType "); + + countSql.append("select count(1) from ("); + countSql.append(" select la.filling_date fillingDate,la.case_name caseName,la.case_num caseNum,qy.industry_type industryType,qy.unit_name unitName,qy.unified_social_code unifiedSocialCode,qy.legal_representative legalRepresentative,qy.op_loc_address opLocAddress"); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id"); + countSql.append(" left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on qy.agency_id = dw.agency_id "); + } + countSql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and la.supplement_verify_result='1' and qy.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" union all select la.filling_date fillingDate,la.case_name caseName,la.case_num caseNum,la.industry_type industryType,la.unit_name unitName,la.unified_social_code unifiedSocialCode,la.legal_representative legalRepresentative,la.op_loc_address opLocAddress"); + countSql.append(" from zf_enforcement_info_history la"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on la.agency_id = dw.agency_id "); + } + countSql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and la.supplement_verify_result='1'"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" and la.industry_type=:industryType ) t"); + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultlaqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + + public List laqkByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select la.filling_date fillingDate,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.wfxwsl') as integer) , 0) wfxwsl,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.sfyasf') as integer) , 0) sfyasf,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.fkze') as numeric(10,2)) , 0) fkze,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.cfqy') as numeric(10,2)) , 0) cfqy,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.cfgr') as numeric(10,2)) , 0) cfgr,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.sfyj') as integer) , 0) sfyj,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.sjrys') as integer) , 0) sjrys,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.sfyt') as integer) , 0) sfyt,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.yttbzzrs') as integer) , 0) yttbzzrs,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.sftb') as integer) , 0) sftb,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.tbrs') as integer) , 0) tbrs,"); + sql.append(" coalesce(cast(json_value(la.supplement, '$.sfzltczd') as integer) , 0) sfzltczd"); + sql.append(" from zf_enterprise qy"); + sql.append(" left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id"); + sql.append(" left join zf_case_info la on zf.enforcement_id = la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date >= :startTime"); + sql.append(" and la.filling_date <= :endTime"); + sql.append(" and la.supplement_verify_result = '1'"); + sql.append(" and qy.industry_type = :industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" union all"); + sql.append(" select la.filling_date fillingDate,"); + sql.append(" coalesce(la.wfxwsl, 0) wfxwsl,"); + sql.append(" coalesce(la.sfyasf, 0) sfyasf,"); + sql.append(" coalesce(la.fkze, 0) fkze,"); + sql.append(" coalesce(la.cfqy, 0) cfqy,"); + sql.append(" coalesce(la.cfgr, 0) cfgr,"); + sql.append(" coalesce(la.sfyj, 0) sfyj,"); + sql.append(" coalesce(la.sjrys, 0) sjrys,"); + sql.append(" coalesce(la.sfyt, 0) sfyt,"); + sql.append(" coalesce(la.yttbzzrs, 0) yttbzzrs,"); + sql.append(" coalesce(la.sftb, 0) sftb,"); + sql.append(" coalesce(la.tbrs, 0) tbrs,"); + sql.append(" coalesce(la.sfzltczd, 0) sfzltczd"); + sql.append(" from zf_enforcement_info_history la"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on la.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date >= :startTime"); + sql.append(" and la.filling_date <= :endTime"); + sql.append(" and la.supplement_verify_result = '1'"); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" and la.industry_type = :industryType"); + + Query query = entityManager.createNativeQuery(sql.toString(),"resultlaqk").unwrap(Query.class); + this.setParameters(query, map); + List tavernList = query.getResultList(); + return tavernList; + } + + public List jbbwsyhDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + sql.append(" select t1.check_date checkDate,t2.filling_date fillingDate, coalesce(t1.zdyhs,0) zdyhs, coalesce(t1.ybyhs,0) ybyhs,coalesce(t1.yhzs,0) yhzs,coalesce(t1.xcclcss,0) xcclcss,coalesce(t1.zlxqzgs,0) zlxqzgs,coalesce(t1.zgfcyjs,0) zgfcyjs,coalesce(t1.qtwss,0) qtwss,coalesce(t2.xzcfjdss,0) xzcfjdss, "); + sql.append(" coalesce(t1.xcclcss,0) + coalesce(t1.zlxqzgs,0) + coalesce(t1.zgfcyjs,0) + coalesce(t1.qtwss,0) + coalesce(t2.xzcfjdss,0) wszs "); + + sql.append(" from ( select qy.enterprise_id,jc.check_date, coalesce(cast(json_value(jc.supplement,'$.zdyhs') as integer ),0) zdyhs,coalesce(cast(json_value(jc.supplement,'$.ybyhs') as integer),0) ybyhs, coalesce(cast(json_value(jc.supplement,'$.zdyhs') as integer),0) + coalesce(cast(json_value(jc.supplement,'$.ybyhs') as integer),0) yhzs, "); + sql.append(" coalesce(cast(json_value(jc.supplement,'$.xcclcss') as integer),0) xcclcss,coalesce(cast(json_value(jc.supplement,'$.zlxqzgs') as integer),0) zlxqzgs,coalesce(cast(json_value(jc.supplement,'$.zgfcyjs') as integer),0) zgfcyjs,coalesce(cast(json_value(jc.supplement,'$.qtwss') as integer),0) qtwss "); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_enforce_check jc on zf.enforcement_id=jc.enforcement_id "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on qy.agency_id = dw.agency_id "); + } + sql.append(" where jc.check_date>= :startTime and jc.check_date <= :endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" and jc.supplement_verify_result='1' and qy.industry_type=:industryType ) t1 "); + sql.append(" left join ( select qy.enterprise_id,la.filling_date, coalesce(cast(json_value(la.supplement, '$.xzcfjdss') as integer),0) xzcfjdss from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id "); + sql.append(" left join zf_case_info la on zf.enforcement_id=la.enforcement_id "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on qy.agency_id = dw.agency_id "); + } + + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and la.supplement_verify_result='1' and qy.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" ) t2 on t1.enterprise_id = t2.enterprise_id "); + sql.append(" union all "); + sql.append(" select t1.check_date checkDate,t2.filling_date fillingDate, coalesce(t1.zdyhs,0) zdyhs, coalesce(t1.ybyhs,0) ybyhs,coalesce(t1.zdyhs,0) + coalesce(t1.ybyhs,0) yhzs,coalesce(t1.xcclcss,0) xcclcss,coalesce(t1.zlxqzgs,0) zlxqzgs,coalesce(t1.zgfcyjs,0) zgfcyjs,coalesce(t1.qtwss,0) qtwss,coalesce(t2.xzcfjdss,0) xzcfjdss, "); + sql.append(" coalesce(t1.xcclcss,0) + coalesce(t1.zlxqzgs,0) + coalesce(t1.zgfcyjs,0) + coalesce(t1.qtwss,0) + coalesce(t2.xzcfjdss,0) wszs from ( "); + sql.append(" select a.history_id,a.check_date, a.zdyhs,a.ybyhs, a.xcclcss,a.zlxqzgs,a.zgfcyjs,a.qtwss from zf_enforcement_info_history a "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on a.agency_id = dw.agency_id "); + } + sql.append(" where a.check_date>= :startTime and a.check_date <= :endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" and a.supplement_verify_result='1' and a.industry_type=:industryType ) t1 "); + sql.append(" left join (select b.history_id,b.filling_date, b.xzcfjdss from zf_enforcement_info_history b "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on b.agency_id = dw.agency_id "); + } + + sql.append(" where b.filling_date>= :startTime and b.filling_date <= :endTime and b.supplement_verify_result='1' and b.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" ) t2 on t1.history_id = t2.history_id "); + + Query query = entityManager.createNativeQuery(sql.toString(),"resultjbbwsyh").unwrap(Query.class); + this.setParameters(query, map); + List tavernList = query.getResultList(); + return tavernList; + } + + public List jbbwfxwfkDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + sql.append(" select la.filling_date fillingDate,coalesce(cast(json_value(la.supplement, '$.wfxwsl') as integer),0) wfxwsl,coalesce(cast(json_value(la.supplement, '$.fkze') as integer),0) fkze,coalesce(cast(json_value(la.supplement, '$.sfyj') as integer),0) sfyj from "); + sql.append(" zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on qy.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and la.supplement_verify_result='1' and qy.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code=:gxdwbm "); + } + sql.append(" union all "); + sql.append(" select la.filling_date fillingDate, la.wfxwsl wfxwsl,la.fkze fkze,la.sfyj from zf_enforcement_info_history la "); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on la.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and la.supplement_verify_result='1' and la.industry_type=:industryType "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append("and dw.agency_code=:gxdwbm "); + } + Query query = entityManager.createNativeQuery(sql.toString(),"resultlawfxwfk").unwrap(Query.class); + this.setParameters(query, map); + List tavernList = query.getResultList(); + return tavernList; + } + + public Page laytqyByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfyt') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + sql.append(" GROUP BY qy.enterprise_id union all"); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + sql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfyt=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + countSql.append("select count(1) from ("); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + countSql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfyt') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + + countSql.append(" GROUP BY qy.enterprise_id union all"); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + countSql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfyt=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + public Page lazkzzqyByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfzkzz') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + sql.append(" GROUP BY qy.enterprise_id union all"); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + sql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfzkzz=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + countSql.append("select count(1) from ("); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + countSql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfzkzz') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + + countSql.append(" GROUP BY qy.enterprise_id union all"); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + countSql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfzkzz=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + public Page latczdqyByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfzltczd') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + sql.append(" GROUP BY qy.enterprise_id union all"); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + sql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfzltczd=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + countSql.append("select count(1) from ("); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + countSql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfzltczd') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + + countSql.append(" GROUP BY qy.enterprise_id union all"); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + countSql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfzltczd=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + public Page lagbqyByindustryTypeDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, String industryType, LocalDate startTime, LocalDate endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + map.put("industryType", industryType); + map.put("startTime", startTime); + map.put("endTime", endTime); + + sql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + sql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + sql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfgb') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + sql.append(" GROUP BY qy.enterprise_id union all"); + sql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + sql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + sql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + sql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfgb=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + sql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val"); + + countSql.append("select count(1) from ("); + countSql.append(" select qy.enterprise_id enterpriseId,MIN(qy.unit_name) unitName,MIN(qy.unified_social_code) unifiedSocialCode,MIN(qy.industry_type) industryType,MIN(qy.legal_representative) legalRepresentative,MIN(qy.op_loc_address) opLocAddress"); + countSql.append(" from zf_enterprise qy left join zf_enforcement_info zf on qy.enterprise_id = zf.enterprise_id left join zf_case_info la on zf.enforcement_id=la.enforcement_id"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + countSql.append(" where la.filling_date>= :startTime and la.filling_date <= :endTime and qy.industry_type=:industryType and la.supplement_verify_result='1' and coalesce(cast(json_value(la.supplement, '$.sfgb') as integer),0)=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + + countSql.append(" GROUP BY qy.enterprise_id union all"); + countSql.append(" SELECT t1.history_id enterpriseId,t1.unit_name unitName, t1.unified_social_code unifiedSocialCode, t1.industry_type industryType,t1.legal_representative legalRepresentative,t1.op_loc_address opLocAddress FROM zf_enforcement_info_history t1"); + countSql.append(" JOIN ( SELECT zf.unified_social_code, MIN(zf.unit_name) AS min_val FROM zf_enforcement_info_history zf"); + if (StringUtils.isNotEmpty(gxdwbm)) { + countSql.append(" left join zf_agency dw on zf.agency_id = dw.agency_id "); + } + + countSql.append(" where zf.filling_date>=:startTime and zf.filling_date<= :endTime and zf.supplement_verify_result='1' and zf.industry_type=:industryType and zf.sfgb=1 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append(" GROUP BY zf.unified_social_code ) t2 ON t1.unified_social_code = t2.unified_social_code AND t1.unit_name = t2.min_val ) t"); + + + + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultjcqy").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "industryType"), count); + return rtnPage; + } + + public Page fxczfXCDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, LocalDateTime startTime, LocalDateTime endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + + map.put("startTime", startTime); + map.put("endTime", endTime); + + + sql.append(" select xc.create_time createTime,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + sql.append(" left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + + countSql.append("select count(1) from ( "); + countSql.append(" select xc.create_time createTime,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + countSql.append(" left join zf_agency dw on xc.agency_id = dw.agency_id where xc.create_time>= :startTime and xc.create_time<=:endTime "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append( " ) t"); + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultxcsDetail").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "createTime"), count); + return rtnPage; + } + public Page fxczffxwtDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, LocalDateTime startTime, LocalDateTime endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + + map.put("startTime", startTime); + map.put("endTime", endTime); + + + sql.append(" select xc.create_time createTime,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + sql.append(" 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' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + + countSql.append("select count(1) from ( "); + countSql.append(" select xc.create_time createTime,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + countSql.append(" 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' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append( " ) t"); + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultxcsDetail").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "createTime"), count); + return rtnPage; + } + public Page fxczfjjwtDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, LocalDateTime startTime, LocalDateTime endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + + map.put("startTime", startTime); + map.put("endTime", endTime); + + + sql.append(" select xc.create_time createTime,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + sql.append(" 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' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + + countSql.append("select count(1) from ( "); + countSql.append(" select xc.create_time createTime,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + countSql.append(" 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' "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + countSql.append( " ) t"); + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultxcsDetail").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "createTime"), count); + return rtnPage; + } + public Page fxczflasDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, LocalDateTime startTime, LocalDateTime endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + + map.put("startTime", startTime); + map.put("endTime", endTime); + + + sql.append(" select la.filling_date fillingDate,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + sql.append(" left join zf_agency dw on xc.agency_id = dw.agency_id "); + sql.append(" 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 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + countSql.append("select count(1) from ( "); + + countSql.append(" select la.filling_date fillingDate,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + countSql.append(" left join zf_agency dw on xc.agency_id = dw.agency_id "); + countSql.append(" 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 "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + + + countSql.append( " ) t"); + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultlasDetail").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "createTime"), count); + return rtnPage; + } + public Page fxczfcfsDetail(Integer page, Integer pagesize, String sort, String dir, + String gxdwbm, LocalDateTime startTime, LocalDateTime endTime) { + StringBuilder sql = new StringBuilder(), countSql = new StringBuilder(); + Map map = new HashMap<>(); + + map.put("startTime", startTime); + map.put("endTime", endTime); + + + sql.append(" select la.filling_date fillingDate,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + sql.append(" left join zf_agency dw on xc.agency_id = dw.agency_id "); + sql.append(" 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') "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + sql.append(" and dw.agency_code= :gxdwbm "); + } + + countSql.append("select count(1) from ( "); + + countSql.append(" select la.filling_date fillingDate,qy.unified_social_code unifiedSocialCode,qy.unit_name unitName from zf_online_patrol_info xc left join zf_enterprise qy on xc.enterprise_id=qy.enterprise_id "); + countSql.append(" left join zf_agency dw on xc.agency_id = dw.agency_id "); + countSql.append(" 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') "); + if (StringUtils.isNotEmpty(gxdwbm)) { + map.put("gxdwbm", gxdwbm); + countSql.append(" and dw.agency_code= :gxdwbm "); + } + + + countSql.append( " ) t"); + + Query countQuery = entityManager.createNativeQuery(countSql.toString()) + .unwrap(Query.class); + this.setParameters(countQuery, map); + Long count = Long.parseLong(String.valueOf(countQuery.uniqueResult())); + Query query = entityManager.createNativeQuery(sql.toString(),"resultlasDetail").unwrap(Query.class); + this.setParameters(query, map); + pageCondition(query, page, pagesize); + List tavernList = query.getResultList(); + pagesize = query.getMaxResults(); + Page rtnPage = new PageImpl(tavernList, commPageable(query.getFirstResult() / pagesize, pagesize, sort, dir, "createTime"), count); + return rtnPage; + } +} \ No newline at end of file