forked from gzzfw/backEnd/gz-dyh

zhouxiantao
2024-09-08 d8a4d842d57c183322324f324396c33df7265479
综合查询
3 files added
8 files modified
393 ■■■■■ changed files
dyh-service/dyh-base/pom.xml 12 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/controller/web/CaseInfoWebController.java 82 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/controller/wechat/CaseInfoWechatController.java 5 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/CaseInfoMapper.java 17 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml 76 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CaseInfoWeChatDTO.java 2 ●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CaseInfoWeExcelDTO.java 30 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CasePageDTO.java 86 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CasePersonWeDTO.java 29 ●●●●● patch | view | raw | blame | history
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/service/CaseInfoService.java 54 ●●●● patch | view | raw | blame | history
dyh-service/dyh-sys/src/main/resources/config/application-dev.yml patch | view | raw | blame | history
dyh-service/dyh-base/pom.xml
@@ -28,7 +28,8 @@
        <druid.version>1.1.10</druid.version>
        <json-lib.version>2.4</json-lib.version>
        <qrcode.version>1.1</qrcode.version>
        <poi.version>3.9</poi.version>
<!--        <poi.version>3.9</poi.version>-->
        <poi.version>4.1.2</poi.version>
        <fastjson.version>1.2.83</fastjson.version>
        <baidu-sdk.version>4.2.0</baidu-sdk.version>
    </properties>
@@ -299,6 +300,15 @@
            <scope>test</scope>
        </dependency>
        <!-- easyexcel begin-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>3.1.1</version>
        </dependency>
        <!-- easyexcel end-->
    </dependencies>
</project>
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/controller/web/CaseInfoWebController.java
@@ -5,22 +5,33 @@
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.base.config.CurrentUser;
import cn.huge.module.cases.domain.dto.CaseInfoWeExcelDTO;
import cn.huge.module.cases.domain.dto.CasePageDTO;
import cn.huge.module.cases.domain.dto.CasePersonWeDTO;
import cn.huge.module.cases.domain.dto.RegisterSaveDTO;
import cn.huge.module.cases.domain.po.CaseInfo;
import cn.huge.module.cases.service.CaseInfoService;
import cn.huge.module.client.api.impl.CustClientImpl;
import cn.huge.module.cust.dto.CtUserDTO;
import com.alibaba.excel.EasyExcel;
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.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -520,4 +531,75 @@
    }
    /**
     * 综合查询
     * @url {ctx}/api/web/caseInfo/pageQueryAll
     * @param page 页码
     * @param size 每页数量
     * @return Object
     */
    @GetMapping("/pageQueryAll")
    public Object pageQueryAll(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
        try {
            Map<String, Object> terms = getParameter();
            Sort sort = Sort.by(Sort.Direction.DESC, "a.create_time");
            PageRequest pageRequest = PageRequest.of(page-1, size, sort);
            Page<CasePageDTO> caseInfoPage = service.pageQueryAll(pageRequest, terms);
            return ReturnSucUtils.getRepInfo( "处理成功", caseInfoPage);
        } catch (Exception e) {
            log.error("Controller接口[CaseInfoWebController.pageQueryAll]请求异常:"+e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
    /**
     * 综合查询-导出
     *
     * @return Object
     * @url {ctx}/api/web/caseInfo/exportQueryAll
     */
    @RequestMapping("/exportQueryAll")
    public void exportQueryAll(HttpServletResponse response) {
        try {
            Map<String, Object> terms = getParameter();
            Sort sort = Sort.by(Sort.Direction.DESC, "a.create_time");
            PageRequest pageRequest = PageRequest.of(0, 1000000, sort);
            Page<CasePageDTO> caseInfoPage = service.pageQueryAll(pageRequest, terms);
            List<CaseInfoWeExcelDTO> excelList = new ArrayList<>();
            if(ObjectUtils.isNotEmpty(caseInfoPage.getContent())){
                for (CasePageDTO casePageDTO : caseInfoPage.getContent()) {
                    CaseInfoWeExcelDTO caseInfoWeExcelDTO = new CaseInfoWeExcelDTO();
                    BeanUtils.copyProperties(casePageDTO,caseInfoWeExcelDTO);
                    if(ObjectUtils.isNotEmpty(casePageDTO.getPlaintiffList())){
                        StringBuffer sb = new StringBuffer();
                        for (CasePersonWeDTO casePersonWeDTO : casePageDTO.getPlaintiffList()) {
                            sb.append(casePersonWeDTO.getTrueName()).append(",");
                        }
                        if(ObjectUtils.isNotEmpty(sb)){
                            caseInfoWeExcelDTO.setPlaintiffStr(sb.substring(0,sb.length()-1));
                        }
                    }
                    if(ObjectUtils.isNotEmpty(casePageDTO.getDefendantList())){
                        StringBuffer sb = new StringBuffer();
                        for (CasePersonWeDTO casePersonWeDTO : casePageDTO.getDefendantList()) {
                            sb.append(casePersonWeDTO.getTrueName()).append(",");
                        }
                        if(ObjectUtils.isNotEmpty(sb)){
                            caseInfoWeExcelDTO.setDefendantStr(sb.substring(0,sb.length()-1));
                        }
                    }
                    excelList.add(caseInfoWeExcelDTO);
                }
            }
            String fileName = "综合查询.xlsx";
            response.setCharacterEncoding("UTF-8");
            response.setHeader("content-Type", "application/vnd.ms-excel;charset=UTF-8");
            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
            ServletOutputStream outputStream = response.getOutputStream();
            EasyExcel.write(outputStream, CaseInfoWeExcelDTO.class).sheet("综合查询").doWrite(excelList);
        } catch (Exception e) {
            log.error("Controller接口[CaseInfoWebController.exportQueryAll]请求异常:"+e, e);
        }
    }
}
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/controller/wechat/CaseInfoWechatController.java
@@ -5,9 +5,8 @@
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.base.config.CurrentUser;
import cn.huge.module.cases.domain.dto.CaseInfoWeChatDTO;
import cn.huge.module.cases.domain.dto.CaseInfoWechatDTO;
import cn.huge.module.cases.domain.dto.RegisterSaveDTO;
import cn.huge.module.cases.domain.po.CaseInfo;
import cn.huge.module.cases.service.CaseInfoService;
import cn.huge.module.client.api.impl.UtilsClientImpl;
import com.google.common.collect.Maps;
@@ -98,7 +97,7 @@
            Map<String, Object> terms = getParameter();
            Sort sort = Sort.by(Sort.Direction.DESC, "create_time");
            PageRequest pageRequest = PageRequest.of(page-1, size, sort);
            Page<CaseInfoWeChatDTO> caseInfoPage = service.pageQueryWechat(userId,pageRequest, terms);
            Page<CaseInfoWechatDTO> caseInfoPage = service.pageQueryWechat(userId,pageRequest, terms);
            return ReturnSucUtils.getRepInfo( "处理成功", caseInfoPage);
        } catch (Exception e) {
            log.error("Controller接口[CaseInfoWechatController.pageCard]请求异常:"+e, e);
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/CaseInfoMapper.java
@@ -1,6 +1,6 @@
package cn.huge.module.cases.dao.mapper;
import cn.huge.module.cases.domain.dto.CaseInfoWeChatDTO;
import cn.huge.module.cases.domain.dto.CasePageDTO;
import cn.huge.module.cases.domain.po.CaseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@@ -62,4 +62,19 @@
    */
    List<CaseInfo> pageTerms(@Param("page") PageRequest page, @Param("terms") Map<String, Object> terms);
    /**
     * 按条件查询实体总数
     * @param terms 查询条件集合
     * @return long
     */
    long countTermsAll(@Param("terms") Map<String, Object> terms);
    /**
     * 按条件查询实体分页结果集
     * @param page 分页对象
     * @param terms 查询条件集合
     * @return List<CaseInfo>
     */
    List<CasePageDTO> pageTermsAll(@Param("page") PageRequest page, @Param("terms") Map<String, Object> terms);
}
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/dao/mapper/xml/CaseInfoMapper.xml
@@ -79,8 +79,26 @@
            <result property="createTime" column="create_time"/>
            <result property="updateTime" column="update_time"/>
    </resultMap>
    <resultMap id="dataResult-all" type="cn.huge.module.cases.domain.dto.CasePageDTO">
    </resultMap>
    <!-- 表 -->
    <sql id='table-name'>dyh_case_info</sql>
    <sql id="column-part-all">
        a.id,
        a.status,
        a.status_name,
        a.canal,
        a.canal_name,
        a.case_level,
        a.case_type,
        a.case_type_name,
        a.input_unit_id,
        a.input_unit_name,
        b.medi_result_name,
        b.mediate_dept_id,
        b.mediate_dept_name
    </sql>
    <!-- 字段 -->
    <sql id="column-part">
        id,
@@ -219,6 +237,38 @@
            <if test="entity.custId != null">cust_id = #{entity.custId},</if>
            <if test="entity.createTime != null">create_time = #{entity.createTime},</if>
            <if test="entity.updateTime != null">update_time = #{entity.updateTime}</if>
    </sql>
    <!-- 条件 -->
    <sql id="where-part-all">
        <if test="terms != null">
            <if test="terms.status != null and terms.status !=''">
                and a.status = #{terms.status}
            </if>
            <if test="terms.statusName != null and terms.statusName !=''">
                and a.status_name = #{terms.statusName}
            </if>
            <if test="terms.canal != null and terms.canal !=''">
                and a.canal = #{terms.canal}
            </if>
            <if test="terms.canalName != null and terms.canalName !=''">
                and a.canal_name = #{terms.canalName}
            </if>
            <if test="terms.caseLevel != null and terms.caseLevel !=''">
                and a.case_level = #{terms.caseLevel}
            </if>
            <if test="terms.caseType != null and terms.caseType !=''">
                and a.case_type = #{terms.caseType}
            </if>
            <if test="terms.caseTypeName != null and terms.caseTypeName !=''">
                and a.case_type_name = #{terms.caseTypeName}
            </if>
            <if test="terms.inputUnitId != null and terms.inputUnitId !=''">
                and a.input_unit_id = #{terms.inputUnitId}
            </if>
            <if test="terms.inputUnitName != null and terms.inputUnitName !=''">
                and a.input_unit_name = #{terms.inputUnitName}
            </if>
        </if>
    </sql>
    <!-- 条件 -->
    <sql id="where-part">
@@ -512,4 +562,30 @@
    </select>
    <!--  根据条件统计  -->
    <select id="countTermsAll" resultType="java.lang.Long">
        select
        COUNT(1)
        from
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.case_id
        <include refid="where-part-all"/>
    </select>
    <!--  根据条件分页查询  -->
    <select id="pageTermsAll" resultMap="dataResult-all">
        SELECT
        <include refid="column-part-all"/>
        FROM
        dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.case_id
        <include refid="where-part-all"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(a.create_time), a.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
</mapper> 
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CaseInfoWeChatDTO.java
@@ -10,7 +10,7 @@
 * @create 2024-09-05 10:17
 */
@Data
public class CaseInfoWeChatDTO {
public class CaseInfoWechatDTO {
    /**
     * 主键编号
     */
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CaseInfoWeExcelDTO.java
New file
@@ -0,0 +1,30 @@
package cn.huge.module.cases.domain.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
 * @author zhouxiantao
 * @create 2024-09-07 15:15
 */
@Data
public class CaseInfoWeExcelDTO {
    @ExcelProperty(value="事项状态")
    private String statusName;
    @ExcelProperty(value="事项来源")
    private String canalName;
    @ExcelProperty(value="事项等级")
    private Integer caseLevel;
    @ExcelProperty(value="纠纷类型")
    private String caseTypeName;
    @ExcelProperty(value="调解结果")
    private String mediResultName;
    @ExcelProperty(value="实际调解部门")
    private String mediateDeptName;
    @ExcelProperty(value="登记组织")
    private String inputUnitName;
    @ExcelProperty(value="申请人")
    private String plaintiffStr;
    @ExcelProperty(value="被申请人")
    private String defendantStr;
}
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CasePageDTO.java
New file
@@ -0,0 +1,86 @@
package cn.huge.module.cases.domain.dto;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.List;
/**
 * @author zhouxiantao
 * @create 2024-09-06 14:35
 */
@Data
public class CasePageDTO {
    /**
     * 主键编号
     */
    private String id;
    /**
     * 事项状态,1:待签收,2:待受理,3:办理中,4:结案审核,5:待评价,6:已归档
     */
    private Integer status;
    /**
     * 事项状态名称
     */
    private String statusName;
    /**
     * 事项来源
     */
    private String canal;
    /**
     * 事项来源名称
     */
    private String canalName;
    /**
     * 事项等级
     */
    private Integer caseLevel;
    /**
     * 纠纷类型
     */
    private String caseType;
    /**
     * 纠纷类型名称
     */
    private String caseTypeName;
    /**
     * 调解结果
     */
    private String mediResult;
    /**
     * 调解结果名称
     */
    private String mediResultName;
    /**
     * 实际调解部门编号
     */
    private String mediateDeptId;
    /**
     * 实际调解部门名称
     */
    private String mediateDeptName;
    /**
     * 登记组织编号
     */
    private String inputUnitId;
    /**
     * 登记组织名称
     */
    private String inputUnitName;
    /**
     * 申请人集合
     * */
    private List<CasePersonWeDTO> plaintiffList;
    /**
     * 被申请人集合
     * */
    private List<CasePersonWeDTO> defendantList;
}
dyh-service/dyh-mediate/src/main/java/cn/huge/module/cases/domain/dto/CasePersonWeDTO.java
New file
@@ -0,0 +1,29 @@
package cn.huge.module.cases.domain.dto;
import lombok.Data;
/**
 * @author zhouxiantao
 * @create 2024-09-05 11:36
 */
@Data
public class CasePersonWeDTO {
    /**
     * 姓名/企业/机构名称
     */
    private String trueName;
    /**
     * 联系方式
     */
    private String mobile;
    /**
     * 当事人地位
     */
    private String perType;
    /**
     * 当事人地位名称
     */
    private String perTypeName;
}
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;
@@ -703,13 +697,13 @@
    }
    /**
     * 按条件分页查询
     * 按条件分页查询-小程序查询
     * @param page 分页对象
     * @param terms 条件
     * @return Page
     */
    public Page<CaseInfoWeChatDTO> pageQueryWechat(String userId,PageRequest page, Map<String, Object> terms){
        List<CaseInfoWeChatDTO> list = new ArrayList<>();
    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)){
            throw new RuntimeException("请选择人员类型");
@@ -724,7 +718,7 @@
        }
        List<CasePerson> casePersonList = personService.list(personWrapper);
        if(ObjectUtils.isEmpty(casePersonList)){
            return new PageImpl<CaseInfoWeChatDTO>(list, page, 0);
            return new PageImpl<CaseInfoWechatDTO>(list, page, 0);
        }
        List<String> ids = casePersonList.stream().map(CasePerson::getCaseId).collect(Collectors.toList());
        terms.put("idList",ids);
@@ -732,7 +726,7 @@
        List<CaseInfo> content = mapper.pageTerms(page, terms);
        if(ObjectUtils.isNotEmpty(content)){
            for(CaseInfo caseInfo: content){
                CaseInfoWeChatDTO caseInfoWeChatDTO = new CaseInfoWeChatDTO();
                CaseInfoWechatDTO caseInfoWeChatDTO = new CaseInfoWechatDTO();
                BeanUtils.copyProperties(caseInfo, caseInfoWeChatDTO);
                if(ObjectUtils.isNotEmpty(caseInfo.getProcess()) && caseInfo.getProcess().equals(1) || caseInfo.getProcess().equals(2)){
                    caseInfoWeChatDTO.setProcessStatus(1);
@@ -768,6 +762,40 @@
                list.add(caseInfoWeChatDTO);
            }
        }
        return new PageImpl<CaseInfoWeChatDTO>(list, page, total);
        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);
    }
}
dyh-service/dyh-sys/src/main/resources/config/application-dev.yml