package cn.huge.module.casebook.controller.web;
|
|
import cn.huge.base.common.utils.ReturnFailUtils;
|
import cn.huge.base.common.utils.ReturnSucUtils;
|
import cn.huge.base.config.CurrentUser;
|
import cn.huge.module.casebook.domain.dto.CaseBookPageDTO;
|
import cn.huge.module.casebook.domain.po.CasebookInfo;
|
import cn.huge.module.casebook.service.CasebookInfoService;
|
import cn.huge.module.client.api.impl.CustClientImpl;
|
import cn.huge.module.cust.dto.CtUserDTO;
|
import cn.huge.module.mediate.constant.CaseBaseConsts;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.google.common.collect.Maps;
|
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
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.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
import java.util.stream.Stream;
|
|
/**
|
* @title: dyh_casebook_info接口api-web端
|
* @description: dyh_casebook_info接口api-web端
|
* @company: hugeinfo
|
* @author: liyj
|
* @time: 2024-10-26 12:31:22
|
* @version: 1.0.0
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/web/caseBook")
|
public class CaseBookWebController {
|
|
@Autowired(required = false)
|
private HttpServletRequest request;
|
|
@Autowired
|
private CasebookInfoService casebookInfoService;
|
@Autowired
|
private CustClientImpl custClient;
|
|
/**
|
* 案件导入-导入草稿
|
* @url {ctx}/api/web/caseBook/pageImportDraft
|
* @param page 页码
|
* @param size 每页数量
|
* @param sortType 排序方式(1:正序;2:倒序)
|
* @return Object
|
*/
|
@GetMapping("/pageImportDraft")
|
public Object pageImportDraft(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size
|
, @RequestParam(value = "sortType") int sortType, @CurrentUser String userId) {
|
try {
|
// 查询条件
|
Map<String, Object> terms = Maps.newHashMap();
|
// 导入时间区间
|
String importStart = request.getParameter("importStart");
|
String importEnd = request.getParameter("importEnd");
|
if(StringUtils.isNotBlank(importStart) && StringUtils.isNotBlank(importEnd)) {
|
terms.put("importStart", importStart);
|
terms.put("importEnd", importEnd);
|
}
|
// 纠纷发生时间区间
|
String occurStart = request.getParameter("occurStart");
|
String occurEnd = request.getParameter("occurEnd");
|
if(StringUtils.isNotBlank(occurStart) && StringUtils.isNotBlank(occurEnd)) {
|
terms.put("occurStart", occurStart);
|
terms.put("occurEnd", occurEnd);
|
}
|
// 申请方
|
String plaintiffs = request.getParameter("plaintiffs");
|
if (StringUtils.isNotBlank(plaintiffs)){
|
terms.put("plaintiffs", plaintiffs);
|
}
|
// 被申请方
|
String defendants = request.getParameter("defendants");
|
if (StringUtils.isNotBlank(defendants)){
|
terms.put("defendants", defendants);
|
}
|
// 调解员
|
String mediator = request.getParameter("mediator");
|
if (StringUtils.isNotBlank(mediator)){
|
terms.put("mediator", mediator);
|
}
|
// 化解结果
|
String mediResult = request.getParameter("mediResult");
|
if (StringUtils.isNotBlank(mediResult)){
|
terms.put("mediResult", mediResult);
|
}
|
// 纠纷类型
|
String caseType = request.getParameter("caseType");
|
if (StringUtils.isNotBlank(caseType)){
|
terms.put("caseType", caseType);
|
}
|
// 协助调解员
|
String assistMediator = request.getParameter("assistMediator");
|
if (StringUtils.isNotBlank(assistMediator)){
|
terms.put("assistMediator", assistMediator);
|
}
|
CtUserDTO loginUser = custClient.clientGetUserAll(userId);
|
terms.put("inputUnitId", loginUser.getUnitId());
|
// 排序
|
Sort sort = null;
|
if(sortType == 1) {
|
sort = Sort.by(Sort.Direction.DESC, "t1.create_time");
|
}
|
if (sortType == 1){
|
sort = Sort.by(Sort.Direction.ASC, "t1.create_time");
|
}
|
PageRequest pageRequest = PageRequest.of(page-1, size, sort);
|
Page<CaseBookPageDTO> caseBookPageDTOPage = casebookInfoService.pageImportDraft(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo(caseBookPageDTOPage);
|
} catch (Exception e) {
|
log.error("[CaseBookWebController.pageImportDraft]请求失败,异常信息:"+e, e);
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 案件导入-导入成功
|
* @url {ctx}/api/web/caseBook/pageImportSuc
|
* @param page 页码
|
* @param size 每页数量
|
* @param sortType 排序方式(1:正序;2:倒序)
|
* @return Object
|
*/
|
@GetMapping("/pageImportSuc")
|
public Object pageImportSuc(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size
|
, @RequestParam(value = "sortType") int sortType, @CurrentUser String userId) {
|
try {
|
// 查询条件
|
Map<String, Object> terms = Maps.newHashMap();
|
// 转入时间区间
|
String importStart = request.getParameter("importStart");
|
String importEnd = request.getParameter("importEnd");
|
if(StringUtils.isNotBlank(importStart) && StringUtils.isNotBlank(importEnd)) {
|
terms.put("importStart", importStart);
|
terms.put("importEnd", importEnd);
|
}
|
// 纠纷发生时间区间
|
String occurStart = request.getParameter("occurStart");
|
String occurEnd = request.getParameter("occurEnd");
|
if(StringUtils.isNotBlank(occurStart) && StringUtils.isNotBlank(occurEnd)) {
|
terms.put("occurStart", occurStart);
|
terms.put("occurEnd", occurEnd);
|
}
|
// 申请方
|
String plaintiffs = request.getParameter("plaintiffs");
|
if (StringUtils.isNotBlank(plaintiffs)){
|
terms.put("plaintiffs", plaintiffs);
|
}
|
// 被申请方
|
String defendants = request.getParameter("defendants");
|
if (StringUtils.isNotBlank(defendants)){
|
terms.put("defendants", defendants);
|
}
|
// 调解员
|
String mediator = request.getParameter("mediator");
|
if (StringUtils.isNotBlank(mediator)){
|
terms.put("mediator", mediator);
|
}
|
// 化解结果
|
String mediResult = request.getParameter("mediResult");
|
if (StringUtils.isNotBlank(mediResult)){
|
terms.put("mediResult", mediResult);
|
}
|
// 纠纷类型
|
String caseType = request.getParameter("caseType");
|
if (StringUtils.isNotBlank(caseType)){
|
terms.put("caseType", caseType);
|
}
|
// 协助调解员
|
String assistMediator = request.getParameter("assistMediator");
|
if (StringUtils.isNotBlank(assistMediator)){
|
terms.put("assistMediator", assistMediator);
|
}
|
CtUserDTO loginUser = custClient.clientGetUserAll(userId);
|
terms.put("inputUnitId", loginUser.getUnitId());
|
// 排序
|
Sort sort = null;
|
if(sortType == 1) {
|
sort = Sort.by(Sort.Direction.DESC, "t1.create_time");
|
}
|
if (sortType == 1){
|
sort = Sort.by(Sort.Direction.ASC, "t1.create_time");
|
}
|
PageRequest pageRequest = PageRequest.of(page-1, size, sort);
|
Page<CaseBookPageDTO> caseBookPageDTOPage = casebookInfoService.pageImportSuc(pageRequest, terms);
|
return ReturnSucUtils.getRepInfo(caseBookPageDTOPage);
|
} catch (Exception e) {
|
log.error("[CaseBookWebController.pageImportSuc]请求失败,异常信息:"+e, e);
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 案件导入-导入操作
|
* @url {ctx}/api/web/caseBook/inputCaseByExcel
|
* @return Object
|
*/
|
@GetMapping("/inputCaseByExcel")
|
public Object inputCaseByExcel(@RequestParam(value = "fileId") String fileId, @CurrentUser String userId) {
|
try {
|
return casebookInfoService.inputCaseByExcel(fileId, userId, request);
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 案件导入-删除草稿
|
* @url {ctx}/api/web/caseBook/deleteDraft
|
* @return Object
|
*/
|
@PostMapping("/deleteDraft")
|
public Object deleteDraft(@RequestBody List<String> idList, @CurrentUser String userId) {
|
try {
|
casebookInfoService.deleteDraft(idList);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 案件导入-草稿转入正式案件
|
* @url {ctx}/api/web/caseBook/importToCase
|
* @return Object
|
*/
|
@PostMapping("/importToCase")
|
public Object importToCase(@RequestBody List<String> idList, @CurrentUser String userId) {
|
try {
|
casebookInfoService.importToCase(idList, userId);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
/**
|
* 案件导入-全部草稿转入正式案件
|
* @url {ctx}/api/web/caseBook/importToCaseAll
|
* @return Object
|
*/
|
@GetMapping("/importToCaseAll")
|
public Object importToCaseAll(@CurrentUser String userId) {
|
try {
|
// 查询条件
|
Map<String, Object> terms = Maps.newHashMap();
|
// 导入时间区间
|
String importStart = request.getParameter("importStart");
|
String importEnd = request.getParameter("importEnd");
|
if(StringUtils.isNotBlank(importStart) && StringUtils.isNotBlank(importEnd)) {
|
terms.put("importStart", importStart);
|
terms.put("importEnd", importEnd);
|
}
|
// 纠纷发生时间区间
|
String occurStart = request.getParameter("occurStart");
|
String occurEnd = request.getParameter("occurEnd");
|
if(StringUtils.isNotBlank(occurStart) && StringUtils.isNotBlank(occurEnd)) {
|
terms.put("occurStart", occurStart);
|
terms.put("occurEnd", occurEnd);
|
}
|
// 申请方
|
String plaintiffs = request.getParameter("plaintiffs");
|
if (StringUtils.isNotBlank(plaintiffs)){
|
terms.put("plaintiffs", plaintiffs);
|
}
|
// 被申请方
|
String defendants = request.getParameter("defendants");
|
if (StringUtils.isNotBlank(defendants)){
|
terms.put("defendants", defendants);
|
}
|
// 调解员
|
String mediator = request.getParameter("mediator");
|
if (StringUtils.isNotBlank(mediator)){
|
terms.put("mediator", mediator);
|
}
|
// 化解结果
|
String mediResult = request.getParameter("mediResult");
|
if (StringUtils.isNotBlank(mediResult)){
|
terms.put("mediResult", mediResult);
|
}
|
// 纠纷类型
|
String caseType = request.getParameter("caseType");
|
if (StringUtils.isNotBlank(caseType)){
|
terms.put("caseType", caseType);
|
}
|
// 协助调解员
|
String assistMediator = request.getParameter("assistMediator");
|
if (StringUtils.isNotBlank(assistMediator)){
|
terms.put("assistMediator", assistMediator);
|
}
|
CtUserDTO loginUser = custClient.clientGetUserAll(userId);
|
terms.put("inputUnitId", loginUser.getUnitId());
|
// 查询
|
casebookInfoService.importToCaseAll(terms, userId);
|
return ReturnSucUtils.getRepInfo();
|
} catch (Exception e) {
|
log.error("[CaseBookWebController.importToCaseAll]请求失败,异常信息:"+e, e);
|
return ReturnFailUtils.getRepInfo();
|
}
|
}
|
|
}
|