package cn.huge.module.knowledge.controller.web; import cn.huge.base.common.utils.ReturnFailUtils; import cn.huge.base.common.utils.ReturnSucUtils; import cn.huge.module.knowledge.domain.dto.CategoryCountDTO; import cn.huge.module.knowledge.domain.dto.CpwsCaseinfoDTO; import cn.huge.module.knowledge.domain.dto.DictionaryDTO; import cn.huge.module.knowledge.domain.po.CpwsCaseInfo; import cn.huge.module.knowledge.service.CpwsCaseInfoService; import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; /** * @title: 裁判文书网案件信息表接口api-web端 * @description: 裁判文书网案件信息表接口api-web端 * @company: hugeinfo * @author: huangh * @time: 2024-12-10 17:13:00 * @version: 1.0.0 */ @Slf4j @RestController @RequestMapping("/api/web/cpwsCaseInfo") public class CpwsCaseInfoWebController { @Autowired(required = false) private HttpServletRequest request; @Autowired private CpwsCaseInfoService service; /** * 获取请求URL参数 * @return Map */ private Map getParameter(){ Map terms = Maps.newHashMap(); // 案件文本ID String cpwsCaseTextId = request.getParameter("cpwsCaseTextId"); if (StringUtils.isNotBlank(cpwsCaseTextId)){ terms.put("cpwsCaseTextId", cpwsCaseTextId); } // 原告 String plaintiff = request.getParameter("plaintiff"); if (StringUtils.isNotBlank(plaintiff)){ terms.put("plaintiff", plaintiff); } // 被告 String defendant = request.getParameter("defendant"); if (StringUtils.isNotBlank(defendant)){ terms.put("defendant", defendant); } // 案号 String caseNumber = request.getParameter("caseNumber"); if (StringUtils.isNotBlank(caseNumber)){ terms.put("caseNumber", caseNumber); } // 案件名称 String caseName = request.getParameter("caseName"); if (StringUtils.isNotBlank(caseName)){ terms.put("caseName", caseName); } // 法院 String court = request.getParameter("court"); if (StringUtils.isNotBlank(court)){ terms.put("court", court); } // 所属地区 String region = request.getParameter("region"); if (StringUtils.isNotBlank(region)){ terms.put("region", region); } // 案件类型 String caseType = request.getParameter("caseType"); if (StringUtils.isNotBlank(caseType)){ terms.put("caseType", caseType); } // 审理程序 String trialProcedure = request.getParameter("trialProcedure"); if (StringUtils.isNotBlank(trialProcedure)){ terms.put("trialProcedure", trialProcedure); } // 案由 String caseReason = request.getParameter("caseReason"); if (StringUtils.isNotBlank(caseReason)){ terms.put("caseReason", caseReason); } // 案由编号 String caseReasonId = request.getParameter("caseReasonId"); if (StringUtils.isNotBlank(caseReasonId)){ terms.put("caseReasonId", caseReasonId); } // 判决时间区间 String judgmentStart = request.getParameter("judgmentStart"); String judgmentEnd = request.getParameter("judgmentEnd"); if(StringUtils.isNotBlank(judgmentStart) && StringUtils.isNotBlank(judgmentEnd)) { terms.put("judgmentStart", judgmentStart); terms.put("judgmentEnd", judgmentEnd); } // 发布时间区间 String publicationStart = request.getParameter("publicationStart"); String publicationEnd = request.getParameter("publicationEnd"); if(StringUtils.isNotBlank(publicationStart) && StringUtils.isNotBlank(publicationEnd)) { terms.put("publicationStart", publicationStart); terms.put("publicationEnd", publicationEnd); } // 法院层级 String courtLevel = request.getParameter("courtLevel"); if (StringUtils.isNotBlank(courtLevel)){ terms.put("courtLevel", courtLevel); } // 法院名称 String courtName = request.getParameter("courtName"); if (StringUtils.isNotBlank(courtName)){ terms.put("courtName", courtName); } // 案由层级 String causeLevel = request.getParameter("causeLevel"); if (StringUtils.isNotBlank(causeLevel)){ terms.put("causeLevel", causeLevel); } // 案由名称 String causeName = request.getParameter("causeName"); if (StringUtils.isNotBlank(causeName)){ terms.put("causeName", causeName); } // 综治系统案由名称 String dyhCauseId = request.getParameter("dyhCauseId"); if (StringUtils.isNotBlank(dyhCauseId)){ terms.put("dyhCauseId", dyhCauseId); } // 区域查询-法院等级 String areaCourtLevel = request.getParameter("areaCourtLevel"); if (StringUtils.isNotBlank(areaCourtLevel)){ terms.put("areaCourtLevel", areaCourtLevel); } // 区域查询-法院等级 String areaCourtName = request.getParameter("areaCourtName"); if (StringUtils.isNotBlank(areaCourtName)){ terms.put("areaCourtName", areaCourtName); } // 关键词 String keyword = request.getParameter("keyword"); if (StringUtils.isNotBlank(keyword)){ terms.put("keyword", keyword); } return terms; } /** * 条件查询多个 * @url {ctx}/api/web/cpwsCaseInfo/listQuery * @return Object */ @GetMapping("/listQuery") public Object listQuery() { try { Map terms = getParameter(); return ReturnSucUtils.getRepInfo(service.listTerms(terms)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 统计判决案例和调解案例数量 * @url {ctx}/api/web/cpwsCaseInfo/typeCount * @return Object */ @GetMapping("/typeCount") public Object typeCount() { try { Map terms = getParameter(); return ReturnSucUtils.getRepInfo(service.typeCount(terms)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 各类别统计 * @url {ctx}/api/web/cpwsCaseInfo/categoryCount * @return Object */ @GetMapping("/categoryCount") public Object categoryCount() { try { Map terms = getParameter(); return ReturnSucUtils.getRepInfo(service.categoryCount(terms)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 年份统计 * @url {ctx}/api/web/cpwsCaseInfo/yearCount * @return Object */ @GetMapping("/yearCount") public Object yearCount() { try { Map terms = getParameter(); return ReturnSucUtils.getRepInfo(service.yearCount(terms)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 区域统计 * @url {ctx}/api/web/cpwsCaseInfo/areaCount * @return Object */ @GetMapping("/areaCount") public Object areaCount() { try { Map terms = getParameter(); return ReturnSucUtils.getRepInfo(service.areaCount(terms)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 区域统计-全数据树形结构 * @url {ctx}/api/web/cpwsCaseInfo/areaCountAll * @return Object */ @GetMapping("/areaCountAll") public Object areaCountAll() { try { Map terms = getParameter(); return ReturnSucUtils.getRepInfo(service.areaCountAll(terms)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 条件分页查询 * @url {ctx}/api/web/cpwsCaseInfo/pageQuery * @param page 页码 * @param size 每页数量 * @return Object */ @GetMapping("/pageQuery") public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) { try { Map terms = getParameter(); Sort sort = Sort.by(Sort.Direction.DESC, "c.create_time","c.cpws_case_info_id"); PageRequest pageRequest = PageRequest.of(page-1, size, sort); Page cpwsCaseInfoPage = service.pageQuery(pageRequest, terms); return ReturnSucUtils.getRepInfo( "处理成功", cpwsCaseInfoPage); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 根据编号查询单个 * @url {ctx}/api/web/cpwsCaseInfo/getById * @param id 主键编号 * @return Object */ @GetMapping("/getById") public Object getById(@RequestParam(value = "id") String id) { try { return ReturnSucUtils.getRepInfo(service.getById(id)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 根据主键单个 * @url {ctx}/api/web/cpwsCaseInfo/deleteById * @param id 主键编号 * @return Object */ @GetMapping("/deleteById") public Object deleteById(@RequestParam(value = "id") String id) { try { service.removeById(id); return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 新增或更新对象 * @url {ctx}/api/web/cpwsCaseInfo/saveCpwsCaseInfo * @param cpwsCaseInfo 实体对象 * @return Object */ @PostMapping("/saveCpwsCaseInfo") public Object saveCpwsCaseInfo(@RequestBody CpwsCaseInfo cpwsCaseInfo) { try { service.saveCpwsCaseInfo(cpwsCaseInfo); return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 根据ID查询案件标题 * @url {ctx}/api/web/cpwsCaseInfo/getCaseTitleById * @param id 案件ID * @return Object */ @GetMapping("/getCaseTitleById") public Object getCaseTitleById(@RequestParam(value = "id") String id) { try { return ReturnSucUtils.getRepInfo(service.getCaseTitleById(id)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } }