forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-08 a85508278ebdd73b32a92446ff741609ddb7d047
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java
@@ -4,15 +4,11 @@
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;
@@ -26,10 +22,8 @@
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;
@@ -386,9 +380,68 @@
            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());
@@ -644,12 +697,12 @@
    }
    /**
     * 按条件分页查询
     * 按条件分页查询-小程序查询
     * @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)){
@@ -711,4 +764,38 @@
        }
        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);
    }
}