5 files added
5 files modified
| New file |
| | |
| | | package cn.huge.base.common.utils; |
| | | |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author zhouxiantao |
| | | * @date 2024/9/19 5:43 下午 |
| | | */ |
| | | public class BigDecimalUtil { |
| | | |
| | | //add,subtract,multiply,divide |
| | | |
| | | public static Double add(String first,String second){ |
| | | return toBigDecimal(first).add(toBigDecimal(second)).doubleValue(); |
| | | } |
| | | |
| | | public static Double add(Double first,Double second){ |
| | | return add(first.toString(),second.toString()); |
| | | } |
| | | |
| | | public static Double subtract(String first,String second){ |
| | | return toBigDecimal(first).subtract(toBigDecimal(second)).doubleValue(); |
| | | } |
| | | |
| | | public static Double subtract(Double first,Double second){ |
| | | return subtract(first.toString(),second.toString()); |
| | | } |
| | | |
| | | public static Double multiply(String first,String second){ |
| | | return toBigDecimal(first).multiply(toBigDecimal(second)).doubleValue(); |
| | | } |
| | | |
| | | public static Double multiply(Double first,Double second){ |
| | | return multiply(first.toString(),second.toString()); |
| | | } |
| | | |
| | | public static Double multiply(Integer first,Integer second){ |
| | | return multiply(first.toString(),second.toString()); |
| | | } |
| | | |
| | | /** |
| | | * @param first |
| | | * @param second |
| | | * @param scale 保留小数点位数 |
| | | * @param roundingMode 进位规则 |
| | | */ |
| | | public static Double divide(String first,String second, Integer scale, Integer roundingMode){ |
| | | if(null==second){ |
| | | return (double) 0; |
| | | } |
| | | if(0==Double.valueOf(second)){ |
| | | return (double) 0; |
| | | } |
| | | return toBigDecimal(first).divide(toBigDecimal(second), scale, roundingMode).doubleValue(); |
| | | } |
| | | |
| | | |
| | | public static String divideScale(String first, String second, Integer scale, Integer roundingMode){ |
| | | return toBigDecimal(first).divide(toBigDecimal(second), scale, roundingMode).toString(); |
| | | |
| | | } |
| | | |
| | | public static Double divideRoundHalf(Integer first, Integer second) { |
| | | if (null == second) { |
| | | return (double) 0; |
| | | } |
| | | if (0 == second.intValue()) { |
| | | return (double) 0; |
| | | } |
| | | return divide(first.toString(), second.toString(), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | |
| | | public static Double divide(Double first,Double second, Integer scale, Integer roundingMode){ |
| | | return divide(first.toString(),second.toString(), scale, roundingMode); |
| | | } |
| | | |
| | | public static Double divide(Integer first,Integer second, Integer scale, Integer roundingMode){ |
| | | if(null==second){ |
| | | return (double) 0; |
| | | } |
| | | if(0==second.intValue()){ |
| | | return (double) 0; |
| | | } |
| | | return divide(first.toString(),second.toString(), scale, roundingMode); |
| | | } |
| | | |
| | | public static BigDecimal toBigDecimal(String number){ |
| | | return new BigDecimal(number); |
| | | } |
| | | |
| | | public static BigDecimal toBigDecimal(Double number){ |
| | | return toBigDecimal(number.toString()); |
| | | } |
| | | |
| | | public static Double getPercent(Double number){ |
| | | return number * 100; |
| | | } |
| | | |
| | | /** |
| | | * @param first |
| | | * @param second |
| | | * @param scale 保留小数点位数 |
| | | * 进阶规则:四舍五入 |
| | | * 去掉小数点后面多余的0 |
| | | * */ |
| | | public static Double divideDelZero(Double first,Double second, Integer scale) { |
| | | if(ObjectUtils.isEmpty(second) || ObjectUtils.isEmpty(first)){ |
| | | return (double) 0; |
| | | } |
| | | if(second == 0 || first == 0){ |
| | | return (double) 0; |
| | | } |
| | | Double number = divide(first, second, scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | return noZeros.doubleValue(); |
| | | } |
| | | |
| | | /** |
| | | * @param first |
| | | * @param second |
| | | * @param scale 保留小数点位数 |
| | | * 进阶规则:四舍五入 |
| | | * 去掉小数点后面多余的0 |
| | | * */ |
| | | public static String divideToString(Double first,Double second, Integer scale) { |
| | | if(ObjectUtils.isEmpty(second) || ObjectUtils.isEmpty(first)){ |
| | | return "0"; |
| | | } |
| | | if(second == 0 || first == 0){ |
| | | return "0"; |
| | | } |
| | | Double number = divide(first, second, scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | return noZeros.toPlainString(); |
| | | } |
| | | |
| | | /** |
| | | * @param first |
| | | * @param second |
| | | * @param scale 保留小数点位数 |
| | | * 进阶规则:四舍五入 |
| | | * 去掉小数点后面多余的0 |
| | | * */ |
| | | public static String integerDivideDelZero(Integer first,Integer second, Integer scale) { |
| | | if(ObjectUtils.isEmpty(second) || ObjectUtils.isEmpty(first)){ |
| | | return "0"; |
| | | } |
| | | if(second == 0 || first == 0){ |
| | | return "0"; |
| | | } |
| | | Double number = divide(first, second, scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | return noZeros.toPlainString(); |
| | | } |
| | | |
| | | /** |
| | | * 字符串数字保留一位小数点,并且去掉小数点后面多余的0 |
| | | * 进阶规则:四舍五入 |
| | | * */ |
| | | public static String strDelZero(String number) { |
| | | BigDecimal numberD =new BigDecimal(number).setScale(1, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | String result = noZeros.toPlainString(); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * double保留对应的小数点,并且去掉小数点后面多余的0 |
| | | * 进阶规则:四舍五入 |
| | | * */ |
| | | public static Double doubleDelZero(Double number,Integer scale) { |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | return noZeros.doubleValue(); |
| | | } |
| | | |
| | | /** |
| | | * double保留对应的小数点,并且去掉小数点后面多余的0 |
| | | * 进阶规则:四舍五入 |
| | | * */ |
| | | public static String doubleToString(Double number,Integer scale) { |
| | | if(ObjectUtils.isEmpty(number)) { |
| | | return "0"; |
| | | } |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | String result = noZeros.toPlainString(); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * float保留对应的小数点,并且去掉小数点后面多余的0 |
| | | * 进阶规则:四舍五入 |
| | | * */ |
| | | public static String floatToString(Float number,Integer scale) { |
| | | if(ObjectUtils.isEmpty(number)) { |
| | | return "0"; |
| | | } |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | String result = noZeros.toPlainString(); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 百分比x100 保留对应的小数点,并且去掉小数点后面多余的0 |
| | | * 进阶规则:四舍五入 |
| | | * */ |
| | | public static String percentDelZero(Double number,Integer scale) { |
| | | BigDecimal numberD =new BigDecimal(number*100).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | String result = noZeros.toPlainString(); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 如果double为null返回0 |
| | | * */ |
| | | public static double stringToDouble(String number) { |
| | | if(ObjectUtils.isEmpty(number) || "null".equals(number)) { |
| | | return 0d; |
| | | } |
| | | return Double.valueOf(number); |
| | | } |
| | | |
| | | /** |
| | | * 如果Integer为null返回0 |
| | | * */ |
| | | public static Integer stringToInteger(String number) { |
| | | if(ObjectUtils.isEmpty(number)|| "null".equals(number)) { |
| | | return 0; |
| | | } |
| | | return Integer.valueOf(number); |
| | | } |
| | | |
| | | /** |
| | | * double保留对应的小数点,并且去掉小数点后面多余的0 |
| | | * 进阶规则:四舍五入 |
| | | * */ |
| | | public static String stringDelZero(String number,Integer scale) { |
| | | if(ObjectUtils.isEmpty(number)) { |
| | | return "0"; |
| | | } |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | String result = noZeros.toPlainString(); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * double转Integer |
| | | * 进阶规则:向上取整 |
| | | * */ |
| | | public static Integer doubleToIntegerUp(Double number) { |
| | | BigDecimal numberD =new BigDecimal(number).setScale(0, BigDecimal.ROUND_UP); |
| | | //去掉小数点后面的0 |
| | | return numberD.intValue(); |
| | | } |
| | | |
| | | /** |
| | | * double保留对应的小数点,并且去掉小数点后面多余的0 |
| | | * 进阶规则:四舍五入 |
| | | * */ |
| | | public static Double doubleUp(Double number,Integer scale) { |
| | | if(ObjectUtils.isEmpty(number)) { |
| | | return 0d; |
| | | } |
| | | BigDecimal numberD =new BigDecimal(number).setScale(scale, BigDecimal.ROUND_HALF_UP); |
| | | //去掉小数点后面的0 |
| | | BigDecimal noZeros = numberD.stripTrailingZeros(); |
| | | return noZeros.doubleValue(); |
| | | } |
| | | |
| | | public static Integer dellNull(Integer number){ |
| | | if(ObjectUtils.isEmpty(number)) { |
| | | return 0; |
| | | } |
| | | return number; |
| | | } |
| | | |
| | | public static Double dellNull(Double number){ |
| | | if(ObjectUtils.isEmpty(number)) { |
| | | return 0d; |
| | | } |
| | | return number; |
| | | } |
| | | |
| | | public static void main(String args[]) { |
| | | int a = 2*100; |
| | | int b = 37; |
| | | |
| | | // String calResult = divideScale("2", "519", 3, BigDecimal.ROUND_HALF_UP); |
| | | // |
| | | // System.out.println(integerDivideDelZero(1111, 100, 2)); |
| | | System.out.println(stringDelZero("202.23000000000002",2)); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private CaseInfoService service; |
| | | |
| | | private Map<String,Object> getParameterAll() { |
| | | Map<String, Object> terms = getParameter(); |
| | | // // 来访时间 |
| | | String visitTimeStart = request.getParameter("visitTimeStart"); |
| | | String visitTimeEnd = request.getParameter("visitTimeEnd"); |
| | | if(StringUtils.isNotBlank(visitTimeStart) && StringUtils.isNotBlank(visitTimeEnd)) { |
| | | terms.put("visitTimeStart", visitTimeStart + " 00:00:00"); |
| | | terms.put("visitTimeEnd", visitTimeEnd + " 23:59:59"); |
| | | } |
| | | String createStart = request.getParameter("createStart"); |
| | | String createEnd = request.getParameter("createEnd"); |
| | | if(StringUtils.isNotBlank(createStart) && StringUtils.isNotBlank(createEnd)) { |
| | | terms.put("createStart", createStart+ " 00:00:00"); |
| | | terms.put("createEnd", createEnd+ " 23:59:59"); |
| | | } |
| | | String closeStart = request.getParameter("closeStart"); |
| | | String closeEnd = request.getParameter("closeEnd"); |
| | | if(StringUtils.isNotBlank(closeStart) && StringUtils.isNotBlank(closeEnd)) { |
| | | terms.put("createStart", closeStart+ " 00:00:00"); |
| | | terms.put("createEnd", closeEnd+ " 23:59:59"); |
| | | } |
| | | String fileStart = request.getParameter("fileStart"); |
| | | String fileEnd = request.getParameter("fileEnd"); |
| | | if(StringUtils.isNotBlank(fileStart) && StringUtils.isNotBlank(fileEnd)) { |
| | | terms.put("createStart", fileStart+ " 00:00:00"); |
| | | terms.put("createEnd", fileEnd+ " 23:59:59"); |
| | | } |
| | | return terms; |
| | | } |
| | | |
| | | /** |
| | | * 获取请求URL参数 |
| | | * @return Map<String, Object> |
| | |
| | | @GetMapping("/pageQueryAll") |
| | | public Object pageQueryAll(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) { |
| | | try { |
| | | Map<String, Object> terms = getParameter(); |
| | | // // 来访时间 |
| | | String visitTimeStart = request.getParameter("visitTimeStart"); |
| | | String visitTimeEnd = request.getParameter("visitTimeEnd"); |
| | | if(StringUtils.isNotBlank(visitTimeStart) && StringUtils.isNotBlank(visitTimeEnd)) { |
| | | terms.put("visitTimeStart", visitTimeStart + " 00:00:00"); |
| | | terms.put("visitTimeEnd", visitTimeEnd + " 23:59:59"); |
| | | } |
| | | String createStart = request.getParameter("createStart"); |
| | | String createEnd = request.getParameter("createEnd"); |
| | | if(StringUtils.isNotBlank(createStart) && StringUtils.isNotBlank(createEnd)) { |
| | | terms.put("createStart", createStart+ " 00:00:00"); |
| | | terms.put("createEnd", createEnd+ " 23:59:59"); |
| | | } |
| | | String closeStart = request.getParameter("closeStart"); |
| | | String closeEnd = request.getParameter("closeEnd"); |
| | | if(StringUtils.isNotBlank(closeStart) && StringUtils.isNotBlank(closeEnd)) { |
| | | terms.put("createStart", closeStart+ " 00:00:00"); |
| | | terms.put("createEnd", closeEnd+ " 23:59:59"); |
| | | } |
| | | String fileStart = request.getParameter("fileStart"); |
| | | String fileEnd = request.getParameter("fileEnd"); |
| | | if(StringUtils.isNotBlank(fileStart) && StringUtils.isNotBlank(fileEnd)) { |
| | | terms.put("createStart", fileStart+ " 00:00:00"); |
| | | terms.put("createEnd", fileEnd+ " 23:59:59"); |
| | | } |
| | | |
| | | Map<String, Object> terms = getParameterAll(); |
| | | 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); |
| | |
| | | @RequestMapping("/exportQueryAll") |
| | | public void exportQueryAll(HttpServletResponse response) { |
| | | try { |
| | | Map<String, Object> terms = getParameter(); |
| | | Map<String, Object> terms = getParameterAll(); |
| | | Sort sort = Sort.by(Sort.Direction.DESC, "a.create_time"); |
| | | PageRequest pageRequest = PageRequest.of(0, 1000000, sort); |
| | | Page<CasePageDTO> caseInfoPage = service.pageQueryAll(pageRequest, terms); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 综合查询 |
| | | * @url {ctx}/api/web/caseInfo/statistics |
| | | * @return Object |
| | | * @CurrentUser String userId |
| | | */ |
| | | @GetMapping("/statistics") |
| | | public Object statistics() { |
| | | try { |
| | | Map<String, Object> terms = getParameterAll(); |
| | | return ReturnSucUtils.getRepInfo( "处理成功", service.statistics(terms)); |
| | | } catch (Exception e) { |
| | | log.error("Controller接口[CaseInfoWebController.statistics]请求异常:"+e, e); |
| | | return ReturnFailUtils.getRepInfo(); |
| | | } |
| | | } |
| | | } |
| | |
| | | package cn.huge.module.cases.dao.mapper; |
| | | |
| | | import cn.huge.module.cases.domain.dto.CasePageDTO; |
| | | import cn.huge.module.cases.domain.dto.*; |
| | | import cn.huge.module.cases.domain.po.CaseInfo; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | |
| | | */ |
| | | List<CasePageDTO> pageTermsAll(@Param("page") PageRequest page, @Param("terms") Map<String, Object> terms); |
| | | |
| | | List<CaseStatisticsAreaDTO> statisticsArea(@Param("terms") Map<String, Object> terms); |
| | | |
| | | CaseStatisticsBaseDTO statisticsBase(@Param("terms") Map<String, Object> terms); |
| | | |
| | | List<CaseStatisticsTypeDTO> statisticsType(@Param("terms") Map<String, Object> terms); |
| | | |
| | | CaseStatisticsSourceDTO statisticsSource(@Param("terms") Map<String, Object> terms); |
| | | } |
| | |
| | | <result property="agreeType" column="agree_type"/> |
| | | <result property="agreeTypeName" column="agree_type_name"/> |
| | | <result property="agreeContent" column="agree_content"/> |
| | | <result property="createTime" column="create_time"/> |
| | | </resultMap> |
| | | <!-- 表 --> |
| | | <sql id='table-name'>dyh_case_info</sql> |
| | |
| | | a.case_type_name, |
| | | a.input_unit_id, |
| | | a.input_unit_name, |
| | | a.create_time, |
| | | b.medi_result, |
| | | b.medi_result_name, |
| | | b.mediate_unit_id, |
| | |
| | | <!-- 条件 --> |
| | | <sql id="where-part-all"> |
| | | <if test="terms != null"> |
| | | <where> |
| | | <if test="terms.status != null and terms.status !=''"> |
| | | and a.status = #{terms.status} |
| | | </if> |
| | |
| | | and (DATE_FORMAT(b.file_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{terms.fileStart} |
| | | and DATE_FORMAT(b.file_time,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{terms.fileEnd}) |
| | | </if> |
| | | |
| | | <if test="terms.queProv != null and terms.queProv !=''"> |
| | | and a.que_prov = #{terms.queProv} |
| | | </if> |
| | | <if test="terms.queCity != null and terms.queCity !=''"> |
| | | and a.que_city = #{terms.queCity} |
| | | </if> |
| | | <if test="terms.queArea != null and terms.queArea !=''"> |
| | | and a.que_area = #{terms.queArea} |
| | | </if> |
| | | <if test="terms.queRoad != null and terms.queRoad !=''"> |
| | | and a.que_road = #{terms.queRoad} |
| | | </if> |
| | | <if test="terms.isArea != null and terms.isArea !=''"> |
| | | and a.que_city is not null |
| | | </if> |
| | | </where> |
| | | </if> |
| | | </sql> |
| | | <!-- 条件 --> |
| | |
| | | limit #{page.offset}, #{page.size} |
| | | </select> |
| | | |
| | | <!-- 统计分析(区域) --> |
| | | <select id="statisticsArea" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsAreaDTO"> |
| | | SELECT |
| | | a.que_area as areaCode,a.que_area_name as areaName,count(1) as caseNum, |
| | | sum(case when b.medi_result = '22_00025-1' then 1 else 0 end) as resolveNum, |
| | | sum(case when b.medi_result is null and a.info_process <![CDATA[ < ]]> 4 then 1 else 0 end) as resolveingNum, |
| | | sum(case when b.medi_result = '22_00025-2' then 1 else 0 end) as unResolveNum |
| | | FROM |
| | | dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id |
| | | <include refid="where-part-all"/> |
| | | group by a.que_area |
| | | </select> |
| | | <!-- 统计分析(基础) --> |
| | | <select id="statisticsBase" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsBaseDTO"> |
| | | SELECT |
| | | count(1) as totalNum, |
| | | sum(case when b.medi_result = '22_00025-1' then 1 else 0 end) as resolveNum, |
| | | sum(case when b.medi_result is null and a.info_process <![CDATA[ < ]]> 4 then 1 else 0 end) as resolveingNum, |
| | | sum(case when b.medi_result = '22_00025-2' then 1 else 0 end) as unResolveNum, |
| | | sum(case when a.case_level = 1 then 1 else 0 end) as oneLevelNum, |
| | | sum(case when a.case_level = 2 then 1 else 0 end) as twoLevelNum, |
| | | sum(case when a.case_level = 3 then 1 else 0 end) as threeLevelNum, |
| | | sum(case when a.info_process <![CDATA[ < ]]> 3 then 1 else 0 end) as processNum, |
| | | sum(case when a.info_process = 3 then 1 else 0 end) as finishNum, |
| | | sum(case when a.info_process = 4 then 1 else 0 end) as rejectNum |
| | | FROM |
| | | dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id |
| | | <include refid="where-part-all"/> |
| | | </select> |
| | | <!-- 统计分析(类型) --> |
| | | <select id="statisticsType" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsTypeDTO"> |
| | | SELECT |
| | | a.case_type as caseType,a.case_type_name as caseTypeName,count(1) as caseNum |
| | | FROM |
| | | dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id |
| | | <include refid="where-part-all"/> |
| | | group by a.case_type |
| | | </select> |
| | | |
| | | <!-- 统计分析(来源) --> |
| | | <select id="statisticsSource" resultType="cn.huge.module.cases.domain.dto.CaseStatisticsSourceDTO"> |
| | | SELECT |
| | | a.canal,a.canal_name as canalName,count(1) as caseNum, |
| | | sum(case when b.medi_result = '22_00025-1' then 1 else 0 end) as resolveNum, |
| | | sum(case when b.medi_result is null and a.info_process <![CDATA[ < ]]> 4 then 1 else 0 end) as resolveingNum, |
| | | sum(case when b.medi_result = '22_00025-2' then 1 else 0 end) as unResolveNum, |
| | | sum(case when a.info_process = 4 then 1 else 0 end) as rejectNum |
| | | FROM |
| | | dyh_case_info a LEFT JOIN dyh_case_info_unfold b on a.id = b.id |
| | | <include refid="where-part-all"/> |
| | | group by a.canal |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | */ |
| | | private Date closeTime; |
| | | /** |
| | | * 登记时间 |
| | | */ |
| | | private Date createTime; |
| | | /** |
| | | * 达成协议类型 |
| | | */ |
| | | private String agreeType; |
| New file |
| | |
| | | package cn.huge.module.cases.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhouxiantao |
| | | * @create 2024-09-18 15:13 |
| | | */ |
| | | @Data |
| | | public class CaseStatisticsAreaDTO { |
| | | private String areaName;//区域名称 |
| | | private String areaCode;//区域编码 |
| | | private Integer caseNum=0;//案件总量 |
| | | private Integer resolveNum=0;//化解成功数量 |
| | | private Integer resolveingNum=0;//化解中数量 |
| | | private Integer unResolveNum=0;//化解不成功数量 |
| | | } |
| New file |
| | |
| | | package cn.huge.module.cases.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhouxiantao |
| | | * @create 2024-09-18 15:04 |
| | | */ |
| | | @Data |
| | | public class CaseStatisticsBaseDTO { |
| | | private Integer totalNum=0;//总记录数 |
| | | private Integer processNum=0;//办理中数量 |
| | | private Integer finishNum=0;//已结案数量 |
| | | private Integer rejectNum=0;//不予受理数量 |
| | | private Integer resolveNum=0;//化解成功数量 |
| | | private String resolveRate;//化解成功率 |
| | | private Integer unResolveNum=0;//化解不成功数量 |
| | | private String unResolveRate;//化解不成功率 |
| | | private Integer resolveingNum=0;//化解中数量 |
| | | private String resolveingRate;//化解中率 |
| | | |
| | | private Integer oneLevelNum=0;//1级事件数量 |
| | | private Integer twoLevelNum=0;//2级事件数量 |
| | | private Integer threeLevelNum=0;//3级事件数量 |
| | | private String oneLevelRate;//1级事件数量百分比 |
| | | private String twoLevelRate;//2级事件数量百分比 |
| | | private String threeLevelRate;//3级事件数量百分比 |
| | | |
| | | private List<CaseStatisticsAreaDTO> areaList;//区域集合 |
| | | private CaseStatisticsSourceDTO oneSource;//大厅来访 |
| | | private CaseStatisticsSourceDTO twoSource;//线上来访 |
| | | private CaseStatisticsSourceDTO threeSource;//自行排查 |
| | | private CaseStatisticsSourceDTO fourSource;//协同推送 |
| | | private List<CaseStatisticsTypeDTO> typeList;//纠纷类型集合 |
| | | |
| | | private List<CasePageDTO> caseList;//案件集合(实时动态) |
| | | } |
| New file |
| | |
| | | package cn.huge.module.cases.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhouxiantao |
| | | * @create 2024-09-18 15:23 |
| | | */ |
| | | @Data |
| | | public class CaseStatisticsSourceDTO { |
| | | private String canal;//事项来源 |
| | | private String canalName;//事项来源名称 |
| | | private Integer caseNum=0;//案件数量 |
| | | private String caseRate;//案件数量占比 |
| | | private Integer resolveNum=0;//化解成功数量 |
| | | private Integer resolveingNum=0;//化解中数量 |
| | | private Integer unResolveNum=0;//化解不成功数量 |
| | | private String resolveRate;//化解成功率 |
| | | private Integer rejectNum=0;//不予受理数量 |
| | | } |
| New file |
| | |
| | | package cn.huge.module.cases.domain.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhouxiantao |
| | | * @create 2024-09-18 15:28 |
| | | */ |
| | | @Data |
| | | public class CaseStatisticsTypeDTO { |
| | | private String caseType;//纠纷类型 |
| | | private String caseTypeName;//纠纷类型名称 |
| | | private Integer caseNum=0;//案件数量 |
| | | private String caseRate;//百分比 |
| | | } |
| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.domain.Page; |
| | |
| | | } |
| | | return new PageImpl<CasePageDTO>(content, page, total); |
| | | } |
| | | |
| | | public CaseStatisticsBaseDTO statistics(Map<String, Object> terms){ |
| | | //基础数据统计 |
| | | CaseStatisticsBaseDTO caseStatisticsBaseDTO = mapper.statisticsBase(terms); |
| | | Integer baseTotalNum = dellNull(caseStatisticsBaseDTO.getResolveNum()) + dellNull(caseStatisticsBaseDTO.getUnResolveNum())+ dellNull(caseStatisticsBaseDTO.getResolveingNum()); |
| | | caseStatisticsBaseDTO.setResolveRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getResolveNum()*100, baseTotalNum,1)); |
| | | caseStatisticsBaseDTO.setUnResolveRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getUnResolveNum()*100, baseTotalNum,1)); |
| | | caseStatisticsBaseDTO.setResolveingRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getResolveingNum()*100, baseTotalNum,1)); |
| | | Integer levelTotalNum = caseStatisticsBaseDTO.getOneLevelNum() + caseStatisticsBaseDTO.getTwoLevelNum() + caseStatisticsBaseDTO.getThreeLevelNum(); |
| | | caseStatisticsBaseDTO.setOneLevelRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getOneLevelNum()*100, levelTotalNum,1)); |
| | | caseStatisticsBaseDTO.setTwoLevelRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getTwoLevelNum()*100, levelTotalNum,1)); |
| | | caseStatisticsBaseDTO.setThreeLevelRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsBaseDTO.getThreeLevelNum()*100, levelTotalNum,1)); |
| | | //区域数据统计 |
| | | terms.put("isArea","1"); |
| | | List<CaseStatisticsAreaDTO> caseStatisticsAreaDTOS = mapper.statisticsArea(terms); |
| | | if(ObjectUtils.isEmpty(caseStatisticsAreaDTOS)){ |
| | | caseStatisticsAreaDTOS = new ArrayList<>(); |
| | | } |
| | | CaseStatisticsAreaDTO allArea = new CaseStatisticsAreaDTO(); |
| | | allArea.setAreaName("本级"); |
| | | allArea.setAreaCode("1"); |
| | | for (CaseStatisticsAreaDTO caseStatisticsAreaDTO : caseStatisticsAreaDTOS) { |
| | | allArea.setCaseNum(dellNull(caseStatisticsAreaDTO.getCaseNum()) + dellNull(allArea.getCaseNum())); |
| | | allArea.setResolveNum(dellNull(caseStatisticsAreaDTO.getResolveNum()) + dellNull(allArea.getResolveNum())); |
| | | allArea.setUnResolveNum(dellNull(caseStatisticsAreaDTO.getUnResolveNum()) + dellNull(allArea.getUnResolveNum())); |
| | | allArea.setResolveingNum(dellNull(caseStatisticsAreaDTO.getResolveingNum()) + dellNull(allArea.getResolveingNum())); |
| | | } |
| | | caseStatisticsAreaDTOS.add(allArea); |
| | | if(ObjectUtils.isNotEmpty(caseStatisticsAreaDTOS)){ |
| | | sortArea(caseStatisticsAreaDTOS); |
| | | } |
| | | caseStatisticsBaseDTO.setAreaList(caseStatisticsAreaDTOS); |
| | | terms.remove("isArea"); |
| | | //纠纷类型统计 |
| | | List<CaseStatisticsTypeDTO> caseStatisticsTypeDTOS = mapper.statisticsType(terms); |
| | | if(ObjectUtils.isNotEmpty(caseStatisticsTypeDTOS)){ |
| | | sortType(caseStatisticsTypeDTOS); |
| | | } |
| | | Integer typeTotalNum = 0; |
| | | Integer otherCaseNum = 0; |
| | | int i = 1; |
| | | List<CaseStatisticsTypeDTO> typeList = new ArrayList<>(); |
| | | for (CaseStatisticsTypeDTO caseStatisticsTypeDTO : caseStatisticsTypeDTOS) { |
| | | typeTotalNum = typeTotalNum + dellNull(caseStatisticsTypeDTO.getCaseNum()); |
| | | if(i > 5){ |
| | | otherCaseNum = otherCaseNum + dellNull(caseStatisticsTypeDTO.getCaseNum()); |
| | | }else{ |
| | | typeList.add(caseStatisticsTypeDTO); |
| | | } |
| | | i++; |
| | | } |
| | | for (CaseStatisticsTypeDTO caseStatisticsTypeDTO : typeList) { |
| | | caseStatisticsTypeDTO.setCaseRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsTypeDTO.getCaseNum()*100, typeTotalNum,1)); |
| | | } |
| | | CaseStatisticsTypeDTO caseStatisticsTypeDTO = new CaseStatisticsTypeDTO(); |
| | | caseStatisticsTypeDTO.setCaseTypeName("其他"); |
| | | caseStatisticsTypeDTO.setCaseNum(otherCaseNum); |
| | | caseStatisticsTypeDTO.setCaseRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsTypeDTO.getCaseNum()*100, typeTotalNum,1)); |
| | | typeList.add(caseStatisticsTypeDTO); |
| | | caseStatisticsBaseDTO.setTypeList(typeList); |
| | | //事项来源 |
| | | terms.put("canal",CaseBaseConstsEnum.CASE_CANAL_1.getIndex()); |
| | | CaseStatisticsSourceDTO oneSource = mapper.statisticsSource(terms); |
| | | oneSource.setCanalName(CaseBaseConstsEnum.CASE_CANAL_1.getDes()); |
| | | terms.put("canal",CaseBaseConstsEnum.CASE_CANAL_2.getIndex()); |
| | | CaseStatisticsSourceDTO twoSource = mapper.statisticsSource(terms); |
| | | twoSource.setCanalName(CaseBaseConstsEnum.CASE_CANAL_2.getDes()); |
| | | |
| | | Integer sourceTotalNum = dellNull(oneSource.getCaseNum()) + dellNull(oneSource.getCaseNum()); |
| | | oneSource.setCaseRate(BigDecimalUtil.integerDivideDelZero(oneSource.getCaseNum()*100, sourceTotalNum,1)); |
| | | oneSource.setResolveRate(BigDecimalUtil.integerDivideDelZero(oneSource.getResolveNum()*100, oneSource.getCaseNum(),1)); |
| | | twoSource.setCaseRate(BigDecimalUtil.integerDivideDelZero(twoSource.getCaseNum()*100, sourceTotalNum,1)); |
| | | twoSource.setResolveRate(BigDecimalUtil.integerDivideDelZero(twoSource.getResolveNum()*100, twoSource.getCaseNum(),1)); |
| | | |
| | | CaseStatisticsSourceDTO threeSource = new CaseStatisticsSourceDTO(); |
| | | threeSource.setCanalName("自行排查"); |
| | | threeSource.setResolveRate("0"); |
| | | threeSource.setCaseRate("0"); |
| | | CaseStatisticsSourceDTO fourSource = new CaseStatisticsSourceDTO(); |
| | | fourSource.setCanalName("协同推送"); |
| | | fourSource.setResolveRate("0"); |
| | | fourSource.setCaseRate("0"); |
| | | caseStatisticsBaseDTO.setOneSource(oneSource); |
| | | caseStatisticsBaseDTO.setTwoSource(twoSource); |
| | | caseStatisticsBaseDTO.setThreeSource(threeSource); |
| | | caseStatisticsBaseDTO.setFourSource(fourSource); |
| | | |
| | | //案件集合 |
| | | Sort sort = Sort.by(Sort.Direction.DESC, "a.create_time"); |
| | | PageRequest pageRequest = PageRequest.of(0, 5, sort); |
| | | Page<CasePageDTO> casePageDTOS = pageQueryAll(pageRequest, terms); |
| | | if(ObjectUtils.isNotEmpty(casePageDTOS.getContent())){ |
| | | caseStatisticsBaseDTO.setCaseList(casePageDTOS.getContent()); |
| | | }else{ |
| | | caseStatisticsBaseDTO.setCaseList(new ArrayList<>()); |
| | | } |
| | | return caseStatisticsBaseDTO; |
| | | } |
| | | |
| | | public List<CaseStatisticsTypeDTO> sortType(List<CaseStatisticsTypeDTO> caseStatisticsTypeDTOS){ |
| | | caseStatisticsTypeDTOS.sort((o1, o2)->{ |
| | | Integer totalScore1 = o1.getCaseNum(); |
| | | Integer totalScore2 = o2.getCaseNum(); |
| | | if(totalScore1 < totalScore2) { |
| | | return 1; |
| | | }else if (totalScore1.equals(totalScore2)){ |
| | | return 0; |
| | | }else{ |
| | | return -1; |
| | | } |
| | | }); |
| | | return caseStatisticsTypeDTOS; |
| | | } |
| | | |
| | | public List<CaseStatisticsAreaDTO> sortArea(List<CaseStatisticsAreaDTO> caseStatisticsAreaDTOS){ |
| | | caseStatisticsAreaDTOS.sort((o1, o2)->{ |
| | | Integer totalScore1 = Integer.valueOf(o1.getAreaCode()); |
| | | Integer totalScore2 = Integer.valueOf(o2.getAreaCode()); |
| | | if(totalScore1 > totalScore2) { |
| | | return 1; |
| | | }else if (totalScore1.equals(totalScore2)){ |
| | | return 0; |
| | | }else{ |
| | | return -1; |
| | | } |
| | | }); |
| | | return caseStatisticsAreaDTOS; |
| | | } |
| | | |
| | | public Integer dellNull(Integer number){ |
| | | if(ObjectUtils.isEmpty(number)){ |
| | | return 0; |
| | | } |
| | | return number; |
| | | } |
| | | } |