| | |
| | | import cn.huge.base.common.utils.DateUtils; |
| | | import cn.huge.base.common.utils.IdUtils; |
| | | import cn.huge.base.common.utils.ObjectUtils; |
| | | import cn.huge.module.cases.domain.dto.CaseInfoDTO; |
| | | import cn.huge.module.cases.domain.dto.*; |
| | | |
| | | import cn.huge.module.cases.domain.dto.CaseInfoWeChatDTO; |
| | | import cn.huge.module.cases.domain.dto.CasePersonWechatDTO; |
| | | import cn.huge.module.cases.domain.dto.RegisterSaveDTO; |
| | | import cn.huge.module.cases.domain.po.CaseAgent; |
| | | import cn.huge.module.cases.domain.po.CaseInfoUnfold; |
| | | import cn.huge.module.cases.domain.po.CasePerson; |
| | | import cn.huge.module.client.api.SysClient; |
| | | import cn.huge.module.client.api.impl.CustClientImpl; |
| | | import cn.huge.module.client.api.impl.SysClientImpl; |
| | | import cn.huge.module.client.api.impl.UtilsClientImpl; |
| | |
| | | import cn.huge.module.draft.service.CasedraftInfoService; |
| | | import cn.huge.module.mediate.dto.WechatBindCaseDTO; |
| | | import cn.huge.module.sys.dto.FileIdTypeInfoBaseDTO; |
| | | import cn.huge.module.sys.dto.FileTypeInfoBaseDTO; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Maps; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | String ids = idList.stream().map(String::valueOf).collect(Collectors.joining("','")); |
| | | ids = "'"+ ids + "'"; |
| | | Map<String, Object> term = new HashMap<>(); |
| | | term.put("mainId", caseId); |
| | | term.put("ownerIds", ids); |
| | | //查询所有附件 |
| | | List<FileIdTypeInfoBaseDTO> fileInfoList = sysClient.listIdTypeInfoByOwnerIdList(term, caseId); |
| | | List<FileIdTypeInfoBaseDTO> fileInfoList = sysClient.listIdTypeInfoByOwnerIdList(term); |
| | | for(FileIdTypeInfoBaseDTO fileInfo: fileInfoList){ |
| | | if(caseId.equals(fileInfo.getOwnerId())){ |
| | | caseInfoDTO.setFileInfoList(fileInfo.getFileList()); |
| | | } |
| | | } |
| | | for(CasePerson casePerson: casePersonList){ |
| | | //把附件根据编号放入 |
| | | for(FileIdTypeInfoBaseDTO fileInfo: fileInfoList){ |
| | | if(casePerson.getId().equals(fileInfo.getOwnerId())){ |
| | | casePerson.setFileInfoList(fileInfo.getFileList()); |
| | | } |
| | | } |
| | | } |
| | | for(CaseAgent caseAgent: caseAgentList){ |
| | | for(FileIdTypeInfoBaseDTO fileInfo: fileInfoList){ |
| | | if(caseAgent.getId().equals(fileInfo.getOwnerId())){ |
| | | caseAgent.setFileInfoList(fileInfo.getFileList()); |
| | | } |
| | | } |
| | | } |
| | | caseInfoDTO.setPersonList(casePersonList); |
| | | caseInfoDTO.setAgentList(caseAgentList); |
| | | } |
| | | return caseInfoDTO; |
| | | } |
| | | |
| | | /** |
| | | * PC端-查询纠纷信息 |
| | | * @param caseId 纠纷编号 |
| | | * @return CaseInfo 纠纷信息 |
| | | */ |
| | | public CaseInfoDTO getCaseArchivesInfo(String caseId){ |
| | | CaseInfo caseInfo = mapper.selectById(caseId); |
| | | CaseInfoDTO caseInfoDTO = new CaseInfoDTO(); |
| | | if (ObjectUtils.isNotEmpty(caseInfo)) { |
| | | |
| | | BeanUtils.copyProperties(caseInfo, caseInfoDTO); |
| | | //查询所有当事人 |
| | | QueryWrapper<CasePerson> personQueryWrapper = new QueryWrapper<>(); |
| | | personQueryWrapper.eq("case_id", caseId); |
| | | List<CasePerson> casePersonList = personService.list(personQueryWrapper); |
| | | |
| | | //查询所有代理人 |
| | | QueryWrapper<CaseAgent> caseAgentQueryWrapper = new QueryWrapper<>(); |
| | | caseAgentQueryWrapper.eq("case_id", caseId); |
| | | List<CaseAgent> caseAgentList = agentService.list(caseAgentQueryWrapper); |
| | | List<String> idList = new ArrayList<>(); |
| | | |
| | | idList.add(caseId); |
| | | idList.addAll(casePersonList.stream().map(CasePerson::getId).collect(Collectors.toList())); |
| | | idList.addAll(caseAgentList.stream().map(CaseAgent::getId).collect(Collectors.toList())); |
| | | String ids = idList.stream().map(String::valueOf).collect(Collectors.joining("','")); |
| | | ids = "'"+ ids + "'"; |
| | | Map<String, Object> term = new HashMap<>(); |
| | | term.put("mainId", caseId); |
| | | term.put("ownerIds", ids); |
| | | //查询所有附件 |
| | | List<FileIdTypeInfoBaseDTO> fileInfoList = sysClient.listIdTypeInfoByOwnerIdList(term); |
| | | for(FileIdTypeInfoBaseDTO fileInfo: fileInfoList){ |
| | | if(caseId.equals(fileInfo.getOwnerId())){ |
| | | caseInfoDTO.setFileInfoList(fileInfo.getFileList()); |
| | |
| | | caseInfo.setInputWay(CaseBaseConsts.INPUT_WAY_1); |
| | | caseInfo.setCreateTime(nowDate); |
| | | caseInfo.setUpdateTime(nowDate); |
| | | caseInfo.setVisitTime(nowDate); |
| | | caseInfo.setDeleteStatus(BaseConsts.DELETE_STATUS_0); |
| | | caseInfo.setProcess(1); |
| | | caseInfo.setProcessName("来访登记"); |
| | | //todo case_ref生成、case_title生成 |
| | | |
| | | caseInfoUnfold.setId(utilsClient.getNewTimeId()); |
| | |
| | | private int saveCasePersonWechat(RegisterSaveDTO registerSaveDTO, StringBuffer plaintiffs, StringBuffer pagents, |
| | | StringBuffer defendants, StringBuffer dagents,PaUserDTO loginUser){ |
| | | int peopleNum = 0; |
| | | List<String> newPersonIdList = new ArrayList<>(); |
| | | List<String> newAgentIdList = new ArrayList<>(); |
| | | // 保存申请人 |
| | | List<CasePerson> personList = registerSaveDTO.getPersonList(); |
| | | if (CollectionUtils.isNotEmpty(personList)) { |
| | | for (CasePerson casePerson : personList) { |
| | | if(ObjectUtils.isEmpty(casePerson.getId())){ |
| | | casePerson.setId(utilsClient.getNewTimeCaseId()); |
| | | } |
| | | newPersonIdList.add(casePerson.getId()); |
| | | casePerson.setId(utilsClient.getNewTimeCaseId()); |
| | | casePerson.setCaseId(registerSaveDTO.getId()); |
| | | // casePerson.setPerType(CaseBaseConstsEnum.PERSON_TYPE_1.getIndex()); |
| | | // casePerson.setPerTypeName(CaseBaseConstsEnum.PERSON_TYPE_1.getDes()); |
| | | casePerson.setPartyUserId(loginUser.getId()); |
| | | casePerson.setCustId(registerSaveDTO.getCustId()); |
| | | casePerson.setCreateTime(registerSaveDTO.getUpdateTime()); |
| | | casePerson.setUpdateTime(registerSaveDTO.getUpdateTime()); |
| | | //todo 绑定当事人小程序 |
| | | |
| | | personService.saveOrUpdate(casePerson); |
| | | |
| | | //添加申请方和被申请方人名组合 |
| | |
| | | List<CaseAgent> agentList = registerSaveDTO.getAgentList(); |
| | | if (CollectionUtils.isNotEmpty(agentList)) { |
| | | for(CaseAgent caseAgent: agentList){ |
| | | newAgentIdList.add(caseAgent.getId()); |
| | | if(ObjectUtils.isEmpty(caseAgent.getId())){ |
| | | caseAgent.setId(utilsClient.getNewTimeCaseId()); |
| | | } |
| | | caseAgent.setId(utilsClient.getNewTimeCaseId()); |
| | | caseAgent.setPartyUserId(loginUser.getId()); |
| | | caseAgent.setCaseId(registerSaveDTO.getId()); |
| | | caseAgent.setAgentTypeName(CaseBaseConstsEnum.getDes(caseAgent.getAgentType())); |
| | | |
| | | caseAgent.setCustId(registerSaveDTO.getCustId()); |
| | | caseAgent.setCreateTime(registerSaveDTO.getUpdateTime()); |
| | | caseAgent.setUpdateTime(registerSaveDTO.getUpdateTime()); |
| | | |
| | | agentService.saveOrUpdate(caseAgent); |
| | | |
| | | if (StringUtils.isNotEmpty(pagents.toString())) { |
| | |
| | | } |
| | | //todo 绑定当事人小程序 |
| | | } |
| | | } |
| | | |
| | | // 删除冗余的申请人 |
| | | if (CollectionUtils.isNotEmpty(newPersonIdList)) { |
| | | List<String> oldPersonIdList = personService.listIdByCaseId(registerSaveDTO.getId()); |
| | | for (String oldPersonId : oldPersonIdList) { |
| | | if (!newPersonIdList.contains(oldPersonId)) { |
| | | personService.removeById(oldPersonId); |
| | | } |
| | | } |
| | | }else{ |
| | | QueryWrapper<CasePerson> casePersonQueryWrapper = new QueryWrapper<>(); |
| | | casePersonQueryWrapper.eq("case_id", registerSaveDTO.getId()); |
| | | personService.remove(casePersonQueryWrapper); |
| | | } |
| | | //删除冗余的代理人 |
| | | if(CollectionUtils.isNotEmpty(newAgentIdList)){ |
| | | List<String> oldAgentIdList = agentService.listIdByCaseId(registerSaveDTO.getId()); |
| | | for(String oldAgentId: oldAgentIdList){ |
| | | if(!newAgentIdList.contains(oldAgentId)){ |
| | | agentService.removeById(oldAgentId); |
| | | } |
| | | } |
| | | }else{ |
| | | QueryWrapper<CaseAgent> caseAgentQueryWrapper = new QueryWrapper<>(); |
| | | caseAgentQueryWrapper.eq("case_id", registerSaveDTO.getId()); |
| | | agentService.remove(caseAgentQueryWrapper); |
| | | } |
| | | |
| | | return peopleNum; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 按条件分页查询 |
| | | * 按条件分页查询-小程序查询 |
| | | * @param page 分页对象 |
| | | * @param terms 条件 |
| | | * @return Page |
| | | */ |
| | | public Page<CaseInfoWeChatDTO> pageQueryWechat(String userId,PageRequest page, Map<String, Object> terms){ |
| | | public Page<CaseInfoWeChatDTO> pageQueryWechat(String userId, PageRequest page, Map<String, Object> terms){ |
| | | List<CaseInfoWeChatDTO> list = new ArrayList<>(); |
| | | String personType = terms.get("personType")+""; |
| | | if(ObjectUtils.isEmpty(personType)){ |
| | |
| | | return new PageImpl<CaseInfoWeChatDTO>(list, page, 0); |
| | | } |
| | | List<String> ids = casePersonList.stream().map(CasePerson::getCaseId).collect(Collectors.toList()); |
| | | terms.put("idList",ids); |
| | | terms.put("ids",ids); |
| | | long total = mapper.countTerms(terms); |
| | | List<CaseInfo> content = mapper.pageTerms(page, terms); |
| | | if(ObjectUtils.isNotEmpty(content)){ |
| | | for(CaseInfo caseInfo: content){ |
| | | CaseInfoWeChatDTO caseInfoWeChatDTO = new CaseInfoWeChatDTO(); |
| | | BeanUtils.copyProperties(caseInfo, caseInfoWeChatDTO); |
| | | if(ObjectUtils.isNotEmpty(caseInfo.getProcess()) && caseInfo.getProcess().equals(1) || caseInfo.getProcess().equals(2)){ |
| | | caseInfoWeChatDTO.setProcessStatus(1); |
| | | caseInfoWeChatDTO.setProcessStatusName("待受理"); |
| | | }else if(ObjectUtils.isNotEmpty(caseInfo.getProcess()) && caseInfo.getProcess().equals(3) || caseInfo.getProcess().equals(4)){ |
| | | caseInfoWeChatDTO.setProcessStatus(2); |
| | | caseInfoWeChatDTO.setProcessStatusName("办理中"); |
| | | }else if(ObjectUtils.isNotEmpty(caseInfo.getProcess()) && caseInfo.getProcess().equals(5) || caseInfo.getProcess().equals(6)){ |
| | | caseInfoWeChatDTO.setProcessStatus(3); |
| | | caseInfoWeChatDTO.setProcessStatusName("已结案"); |
| | | }else{ |
| | | caseInfoWeChatDTO.setProcessStatus(4); |
| | | caseInfoWeChatDTO.setProcessStatusName("不予受理"); |
| | | } |
| | | caseInfoWeChatDTO.setProcessStatus(caseInfo.getInfoProcess()); |
| | | caseInfoWeChatDTO.setProcessStatusName(caseInfo.getInfoProcessName()); |
| | | QueryWrapper<CasePerson> personWrapper1 = new QueryWrapper<>(); |
| | | personWrapper1.eq("case_id", caseInfo.getId()); |
| | | List<CasePerson> casePersonList1 = personService.list(personWrapper1); |
| | |
| | | } |
| | | return new PageImpl<CaseInfoWeChatDTO>(list, page, total); |
| | | } |
| | | |
| | | /** |
| | | * 按条件分页查询-综合查询 |
| | | * @param page 分页对象 |
| | | * @param terms 条件 |
| | | * @return Page |
| | | */ |
| | | public Page<CasePageDTO> pageQueryAll(PageRequest page, Map<String, Object> terms){ |
| | | long total = mapper.countTermsAll(terms); |
| | | List<CasePageDTO> content = mapper.pageTermsAll(page, terms); |
| | | if(ObjectUtils.isNotEmpty(content)){ |
| | | for (CasePageDTO casePageDTO : content) { |
| | | QueryWrapper<CasePerson> personWrapper1 = new QueryWrapper<>(); |
| | | personWrapper1.eq("case_id", casePageDTO.getId()); |
| | | List<CasePerson> casePersonList1 = personService.list(personWrapper1); |
| | | //申请人集合 |
| | | List<CasePersonWeDTO> plaintiffList = new ArrayList<>(); |
| | | //被申请人集合 |
| | | List<CasePersonWeDTO> defendantList = new ArrayList<>(); |
| | | for (CasePerson casePerson : casePersonList1) { |
| | | CasePersonWeDTO casePersonWechatDTO = new CasePersonWeDTO(); |
| | | BeanUtils.copyProperties(casePerson, casePersonWechatDTO); |
| | | if(CaseBaseConstsEnum.PERSON_TYPE_1.getIndex().equals(casePerson.getPerType())){ |
| | | plaintiffList.add(casePersonWechatDTO); |
| | | }else if(CaseBaseConstsEnum.PERSON_TYPE_2.getIndex().equals(casePerson.getPerType())){ |
| | | defendantList.add(casePersonWechatDTO); |
| | | } |
| | | } |
| | | casePageDTO.setDefendantList(defendantList); |
| | | casePageDTO.setPlaintiffList(plaintiffList); |
| | | } |
| | | } |
| | | return new PageImpl<CasePageDTO>(content, page, total); |
| | | } |
| | | } |