| | |
| | | import cn.huge.module.client.api.impl.UtilsClientImpl; |
| | | import cn.huge.module.cases.dao.mapper.CaseInfoMapper; |
| | | import cn.huge.module.constant.BaseConsts; |
| | | import cn.huge.module.cust.dto.CtUnitDTO; |
| | | import cn.huge.module.cust.dto.PaUserDTO; |
| | | import cn.huge.module.mediate.constant.*; |
| | | import cn.huge.module.cust.dto.CtUserDTO; |
| | |
| | | //复制填装案件表 |
| | | CaseInfo caseInfo = new CaseInfo(); |
| | | BeanUtils.copyProperties(registerSaveDTO, caseInfo); |
| | | // 是否自行受理 |
| | | if (1 == registerSaveDTO.getIsSelfAccept()) { |
| | | // 是 |
| | | caseInfo.setZxslStatus(CaseBaseConsts.ZXSL_STATUS_1); |
| | | }else { |
| | | // 否 |
| | | caseInfo.setZxslStatus(CaseBaseConsts.ZXSL_STATUS_0); |
| | | } |
| | | caseInfo.setUpdateTime(nowDate); |
| | | |
| | | // 常规登记-保存当事人 |
| | |
| | | caseInfo.setDefendants(defendants.toString()); |
| | | caseInfo.setDagents(dagents.toString()); |
| | | caseInfo.setCaseRef(utilsClient.createCaseRef()); |
| | | caseInfo.setVisitWay(CaseBaseConstsEnum.VISIT_WAY_1.getIndex()); |
| | | caseInfo.setVisitWayName(CaseBaseConstsEnum.VISIT_WAY_1.getDes()); |
| | | caseInfo.setVisitWay(CaseBaseConstsEnum.getVisitWayByCanal(caseInfo.getCanal()).getIndex()); |
| | | caseInfo.setVisitWayName(CaseBaseConstsEnum.getVisitWayByCanal(caseInfo.getCanal()).getDes()); |
| | | //默认小程序可见 |
| | | if(ObjectUtils.isNotEmpty(caseInfo.getCanal())){ |
| | | if(CaseBaseConstsEnum.CASE_CANAL_1.getIndex().equals(caseInfo.getCanal())){ |
| | |
| | | break; |
| | | } |
| | | } |
| | | 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); |
| | | //如果是导出调用,不查询extend信息 |
| | | if(ObjectUtils.isEmpty(terms.get("report"))){ |
| | | QueryWrapper<CasePerson> personWrapper1 = new QueryWrapper<>(); |
| | | personWrapper1.eq("case_id", casePageDTO.getId()); |
| | | List<CasePerson> casePersonList1 = personService.list(personWrapper1); |
| | | 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); |
| | |
| | | return new PageImpl<CasePageDTO>(content, page, total); |
| | | } |
| | | |
| | | |
| | | public CaseStatisticsBaseDTO statistics(Map<String, Object> terms) throws IOException { |
| | | /** |
| | | * 纠纷态势 |
| | | * 筛选范围:如果已经有承办部门,就按承办部门的区域筛选。如果没有承办部门按问题归属区域筛选 |
| | | * */ |
| | | public CaseStatisticsBaseDTO statistics(Map<String, Object> terms,String userId) throws IOException { |
| | | Object canal = null; |
| | | if(ObjectUtils.isNotEmpty(terms.get("canal"))){ |
| | | canal = terms.get("canal"); |
| | | } |
| | | terms.put("statistics", "1"); |
| | | //根据用户筛选区域范围 |
| | | CtUnitDTO ctUnitDTO = custClient.getUnitByUserId(userId); |
| | | String areaCode = null; |
| | | //目前没有村居数据,所以单位等级是4的也归集到3里面 |
| | | List<Integer> unitGrades = new ArrayList<>(); |
| | | |
| | | if(ctUnitDTO.getUnitGrade().equals(1)){ |
| | | terms.put("queCity", ctUnitDTO.getCity()); |
| | | areaCode = ctUnitDTO.getCity(); |
| | | unitGrades.add(ctUnitDTO.getUnitGrade()); |
| | | }else if(ctUnitDTO.getUnitGrade().equals(2)){ |
| | | terms.put("queArea", ctUnitDTO.getArea()); |
| | | areaCode = ctUnitDTO.getArea(); |
| | | unitGrades.add(ctUnitDTO.getUnitGrade()); |
| | | }else if(ctUnitDTO.getUnitGrade().equals(3) || ctUnitDTO.getUnitGrade().equals(4)){ |
| | | terms.put("queRoad", ctUnitDTO.getRoad()); |
| | | areaCode = ctUnitDTO.getRoad(); |
| | | unitGrades.add(3); |
| | | unitGrades.add(4); |
| | | } |
| | | //目前没有村居,所以区和街道进来都是按街道展示 |
| | | String areaType = null;//兼容白云数据 |
| | | if(ObjectUtils.isNotEmpty(terms.get("queRoad")) || ObjectUtils.isNotEmpty(terms.get("queArea"))){ |
| | | terms.put("areaType","2"); |
| | | areaType = "2"; |
| | | }else{ |
| | | areaType = "1"; |
| | | } |
| | | //基础数据统计 |
| | | CaseStatisticsBaseDTO caseStatisticsBaseDTO = mapper.statisticsBase(terms); |
| | |
| | | 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<>(); |
| | |
| | | allArea.setAreaName("本级"); |
| | | allArea.setAreaCode("1"); |
| | | List<String> areaCodeList = new ArrayList<>(); |
| | | List<CaseStatisticsAreaDTO> areaList = new ArrayList<>(); |
| | | List<String> areaNames = new ArrayList<>();//为兼容白云区数据 |
| | | 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())); |
| | | areaCodeList.add(caseStatisticsAreaDTO.getAreaCode()); |
| | | areaNames.add(caseStatisticsAreaDTO.getAreaName()); |
| | | //本及:承办单位是本及和没有承办单位并且没有下级区域编码 |
| | | if(ObjectUtils.isEmpty(caseStatisticsAreaDTO.getAreaCode()) || unitGrades.contains(caseStatisticsAreaDTO.getUnitGrade())){ |
| | | 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())); |
| | | }else{ |
| | | areaList.add(caseStatisticsAreaDTO); |
| | | areaCodeList.add(caseStatisticsAreaDTO.getAreaCode()); |
| | | } |
| | | } |
| | | caseStatisticsAreaDTOS.add(allArea); |
| | | List<QueAreaDTO> queArea = listAreaByType(terms.get("queArea")); |
| | | areaList.add(allArea); |
| | | if("1".equals(areaType)){ |
| | | Map<String, String> area = getArea(); |
| | | for (String areaName : area.keySet()) { |
| | | if(!areaNames.contains(areaName)){ |
| | | CaseStatisticsAreaDTO areaChild = new CaseStatisticsAreaDTO(); |
| | | areaChild.setAreaCode(area.get(areaName)); |
| | | areaChild.setAreaName(areaName); |
| | | areaList.add(areaChild); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<QueAreaDTO> queArea = listAreaByType(areaCode); |
| | | log.info("listAreaByType {}", JSON.toJSONString(queArea)); |
| | | for (QueAreaDTO caseAreaDTO : queArea) { |
| | | if (!areaCodeList.contains(caseAreaDTO.getAreaCode())) { |
| | |
| | | areaChild.setResolveNum(0); |
| | | areaChild.setUnResolveNum(0); |
| | | areaChild.setResolveingNum(0); |
| | | caseStatisticsAreaDTOS.add(areaChild); |
| | | areaList.add(areaChild); |
| | | } |
| | | } |
| | | |
| | | if (ObjectUtils.isNotEmpty(caseStatisticsAreaDTOS)) { |
| | | sortArea(caseStatisticsAreaDTOS); |
| | | if (ObjectUtils.isNotEmpty(areaList)) { |
| | | sortArea(areaList); |
| | | } |
| | | caseStatisticsBaseDTO.setAreaList(caseStatisticsAreaDTOS); |
| | | terms.remove("isArea"); |
| | | caseStatisticsBaseDTO.setAreaList(areaList); |
| | | //纠纷类型统计 |
| | | List<CaseStatisticsTypeDTO> caseStatisticsTypeDTOS = mapper.statisticsType(terms); |
| | | List<CaseStatisticsTypeDTO> caseStatisticsTypeDTOS = mapper.statisticsTypeFirst(terms); |
| | | if (ObjectUtils.isNotEmpty(caseStatisticsTypeDTOS)) { |
| | | sortType(caseStatisticsTypeDTOS); |
| | | } |
| | |
| | | terms.put("canal", canal); |
| | | } |
| | | Sort sort = Sort.by(Sort.Direction.DESC, "a.create_time"); |
| | | PageRequest pageRequest = PageRequest.of(0, 5, sort); |
| | | PageRequest pageRequest = PageRequest.of(0, 30, sort); |
| | | terms.remove("statistics"); |
| | | Page<CasePageDTO> casePageDTOS = pageQueryAll(pageRequest, terms); |
| | | if (ObjectUtils.isNotEmpty(casePageDTOS.getContent())) { |
| | | caseStatisticsBaseDTO.setCaseList(casePageDTOS.getContent()); |
| | |
| | | return caseStatisticsTypeDTOS; |
| | | } |
| | | |
| | | public List<CaseStatisticsAreaDTO> sortArea(List<CaseStatisticsAreaDTO> caseStatisticsAreaDTOS) { |
| | | public Map<String, String> getArea(){ |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("越秀区","2"); |
| | | map.put("海珠区","3"); |
| | |
| | | map.put("南沙区","10"); |
| | | map.put("从化区","11"); |
| | | map.put("增城区","12"); |
| | | return map; |
| | | } |
| | | |
| | | public List<CaseStatisticsAreaDTO> sortArea(List<CaseStatisticsAreaDTO> caseStatisticsAreaDTOS) { |
| | | Map<String, String> map = getArea(); |
| | | for (CaseStatisticsAreaDTO caseStatisticsAreaDTO : caseStatisticsAreaDTOS) { |
| | | caseStatisticsAreaDTO.setAreaCode(caseStatisticsAreaDTO.getAreaCode().replace("-","")); |
| | | if(map.containsKey(caseStatisticsAreaDTO.getAreaName())){ |
| | | caseStatisticsAreaDTO.setAreaCode(map.get(caseStatisticsAreaDTO.getAreaName())); |
| | | } |
| | | } |
| | | caseStatisticsAreaDTOS.sort((o1, o2) -> { |
| | | Integer totalScore1 = Integer.valueOf(o1.getAreaCode()); |
| | | Integer totalScore2 = Integer.valueOf(o2.getAreaCode()); |
| | | Long totalScore1 = Long.valueOf(o1.getAreaCode()); |
| | | Long totalScore2 = Long.valueOf(o2.getAreaCode()); |
| | | if (totalScore1 > totalScore2) { |
| | | return 1; |
| | | } else if (totalScore1.equals(totalScore2)) { |
| | |
| | | return casePersonCountBO; |
| | | } |
| | | |
| | | public List<CaseStatisticsTypeDTO> statisticsCaseType(Map<String, Object> terms,String userId){ |
| | | //根据用户筛选区域范围 |
| | | CtUnitDTO ctUnitDTO = custClient.getUnitByUserId(userId); |
| | | if(ctUnitDTO.getUnitGrade().equals(2)){ |
| | | terms.put("queArea", ctUnitDTO.getArea()); |
| | | }else if(ctUnitDTO.getUnitGrade().equals(3) || ctUnitDTO.getUnitGrade().equals(4)){ |
| | | terms.put("queRoad", ctUnitDTO.getRoad()); |
| | | } |
| | | if(ObjectUtils.isEmpty(terms.get("caseTypeFirst"))){ |
| | | //筛选一级为其他的纠纷类型 |
| | | List<CaseStatisticsTypeDTO> caseStatisticsTypeDTOS = mapper.statisticsTypeFirst(terms); |
| | | if (ObjectUtils.isNotEmpty(caseStatisticsTypeDTOS)) { |
| | | sortType(caseStatisticsTypeDTOS); |
| | | } |
| | | int i = 1; |
| | | List<String> caseTypeList = new ArrayList<>(); |
| | | for (CaseStatisticsTypeDTO caseStatisticsTypeDTO : caseStatisticsTypeDTOS) { |
| | | if (i > 5) { |
| | | caseTypeList.add(caseStatisticsTypeDTO.getCaseType()); |
| | | } |
| | | i++; |
| | | } |
| | | if(ObjectUtils.isEmpty(caseTypeList)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | terms.put("caseTypeFirstList", caseTypeList); |
| | | } |
| | | List<CaseStatisticsTypeDTO> caseStatisticsTypeDTOS = mapper.statisticsType(terms); |
| | | if (ObjectUtils.isNotEmpty(caseStatisticsTypeDTOS)) { |
| | | sortType(caseStatisticsTypeDTOS); |
| | | } |
| | | Integer typeTotalNum = 0; |
| | | for (CaseStatisticsTypeDTO caseStatisticsTypeDTO : caseStatisticsTypeDTOS) { |
| | | typeTotalNum = typeTotalNum + dellNull(caseStatisticsTypeDTO.getCaseNum()); |
| | | } |
| | | for (CaseStatisticsTypeDTO caseStatisticsTypeDTO : caseStatisticsTypeDTOS) { |
| | | caseStatisticsTypeDTO.setCaseRate(BigDecimalUtil.integerDivideDelZero(caseStatisticsTypeDTO.getCaseNum() * 100, typeTotalNum, 1)); |
| | | } |
| | | return caseStatisticsTypeDTOS; |
| | | } |
| | | } |