123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- package com.example.controller.gdc;
- import com.example.config.annotation.IgnoreAuth;
- import com.example.pojo.gdc.OtnAreaEntity;
- import com.example.pojo.gdc.WzHouseArrearsManageEntity;
- import com.example.service.gdc.WzHouseArrearsManageService;
- import com.example.service.gdc.WzOtnAreaService;
- import com.example.utils.PageMap;
- import com.example.utils.PageUtils;
- import com.example.utils.Query;
- import com.example.utils.R;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * 房屋出租(合同管理)
- */
- @RestController
- @RequestMapping("/house-car/house/dist/api/wzHouseArrearsManage")
- public class WzHouseArrearsManageController {
- @Autowired
- private WzOtnAreaService otnAreaService;
- @Autowired
- private WzHouseArrearsManageService wzHouseArrearsManageService;
- @RequestMapping("/list")
- @IgnoreAuth
- public R list(@RequestBody PageMap pageMap) {
- //查询列表数据
- Query query = new Query(pageMap);
- List<WzHouseArrearsManageEntity> list = wzHouseArrearsManageService.queryList(query);
- int total = wzHouseArrearsManageService.queryTotal(query);
- PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
- return R.ok().put("page", pageUtil);
- }
- @RequestMapping("/echartList")
- @IgnoreAuth
- public R echartList(@RequestBody PageMap pageMap) {
- //查询列表数据
- Query query = new Query(pageMap);
- List<WzHouseArrearsManageEntity> wzHouseContracEntityList = wzHouseArrearsManageService.queryList(query);
- WzHouseArrearsManageEntity province=new WzHouseArrearsManageEntity();
- province.setCity("全省");
- Map<String,List<WzHouseArrearsManageEntity>> map=new HashMap<>();
- for (WzHouseArrearsManageEntity leaveUseVo : wzHouseContracEntityList) {
- List<WzHouseArrearsManageEntity> list;
- if(map.get(leaveUseVo.getCity())!=null){
- list=map.get(leaveUseVo.getCity());
- list.add(leaveUseVo);
- }else{
- list=new ArrayList<>();
- list.add(leaveUseVo);
- }
- map.put(leaveUseVo.getCity(),list);
- }
- List<WzHouseArrearsManageEntity> resultList=new ArrayList<>();
- List<WzHouseArrearsManageEntity> cityList=new ArrayList<>();
- double allAccumulateArrears=0l;
- double allmoreThanThreeMonths=0l;
- double allmoreThanOneYears=0l;
- double allyearCumulativeNewAdditions=0l;
- double allyearCumulativeWithdrawal=0l;
- for(Map.Entry<String,List<WzHouseArrearsManageEntity>> entry:map.entrySet()){
- List<WzHouseArrearsManageEntity> list=entry.getValue();
- //县的Map集合
- Map<String,List<WzHouseArrearsManageEntity>> countyMap=new HashMap<>();
- for (WzHouseArrearsManageEntity leaveUseVo : list) {
- if (leaveUseVo.getCounty() == null || leaveUseVo.getCounty().equals("")) {
- continue;
- }
- if (countyMap.get(leaveUseVo.getCounty()) != null) {
- list = countyMap.get(leaveUseVo.getCounty());
- list.add(leaveUseVo);
- } else {
- list = new ArrayList<>();
- list.add(leaveUseVo);
- }
- countyMap.put(leaveUseVo.getCounty(), list);
- }
- double cityaccumulateArrears=0l;
- double citymoreThanThreeMonths=0l;
- double citymoreThanOneYears=0l;
- double cityyearCumulativeNewAdditions=0l;
- double cityyearCumulativeWithdrawal=0l;
- List<WzHouseArrearsManageEntity> countyList=new ArrayList<>();
- for (Map.Entry<String, List<WzHouseArrearsManageEntity>> countyEntry : countyMap.entrySet()) {
- double accumulateArrears=0l;
- double moreThanThreeMonths=0l;
- double moreThanOneYears=0l;
- double yearCumulativeNewAdditions=0l;
- double yearCumulativeWithdrawal=0l;
- for (WzHouseArrearsManageEntity leaveUseVo : countyEntry.getValue()) {
- if(leaveUseVo.getAccumulateArrears()!=null){
- accumulateArrears+=leaveUseVo.getAccumulateArrears();
- cityaccumulateArrears+=leaveUseVo.getAccumulateArrears();
- allAccumulateArrears+=leaveUseVo.getAccumulateArrears();
- }
- if(leaveUseVo.getMoreThanThreeMonths()!=null){
- moreThanThreeMonths+=leaveUseVo.getMoreThanThreeMonths();
- citymoreThanThreeMonths+=leaveUseVo.getMoreThanThreeMonths();
- allmoreThanThreeMonths+=leaveUseVo.getMoreThanThreeMonths();
- }
- if(leaveUseVo.getMoreThanOneYears()!=null){
- moreThanOneYears+=leaveUseVo.getMoreThanOneYears();
- citymoreThanOneYears+=leaveUseVo.getMoreThanOneYears();
- allmoreThanOneYears+=leaveUseVo.getMoreThanOneYears();
- }
- if(leaveUseVo.getYearCumulativeNewAdditions()!=null){
- yearCumulativeNewAdditions+=leaveUseVo.getYearCumulativeNewAdditions();
- cityyearCumulativeNewAdditions+=leaveUseVo.getYearCumulativeNewAdditions();
- allyearCumulativeNewAdditions+=leaveUseVo.getYearCumulativeNewAdditions();
- }
- if(leaveUseVo.getYearCumulativeWithdrawal()!=null){
- yearCumulativeWithdrawal+=leaveUseVo.getYearCumulativeWithdrawal();
- cityyearCumulativeWithdrawal+=leaveUseVo.getYearCumulativeWithdrawal();
- allyearCumulativeWithdrawal+=leaveUseVo.getYearCumulativeWithdrawal();
- }
- }
- WzHouseArrearsManageEntity countyEntity=new WzHouseArrearsManageEntity();
- countyEntity.setAccumulateArrears(formatDouble(accumulateArrears));
- countyEntity.setYearCumulativeNewAdditions(formatDouble(yearCumulativeNewAdditions));
- countyEntity.setYearCumulativeWithdrawal(formatDouble(yearCumulativeWithdrawal));
- countyEntity.setMoreThanOneYears(formatDouble(moreThanOneYears));
- countyEntity.setMoreThanThreeMonths(formatDouble(moreThanThreeMonths));
- countyEntity.setCity(countyEntry.getValue().get(0).getCounty());
- countyList.add(countyEntity);
- }
- List<WzHouseArrearsManageEntity> orderCountyList=new ArrayList<>();
- try{
- //对countList 进行排序
- String city=list.get(0).getCity();
- if(city.contains("市")){
- city=city.split("市")[0];
- }
- OtnAreaEntity area=otnAreaService.queryObject(city);
- List<OtnAreaEntity> countyAreaList=otnAreaService.getCityOption(area.getId());
- int i=0;
- for (OtnAreaEntity otnAreaEntity : countyAreaList) {
- for (WzHouseArrearsManageEntity wzCity : countyList) {
- if(wzCity.getCity().contains(otnAreaEntity.getName())){
- i++;
- wzCity.setFlag(i%2==0);
- orderCountyList.add(wzCity);
- }
- }
- }
- }catch (Exception e){
- orderCountyList=countyList;
- e.printStackTrace();
- }
- WzHouseArrearsManageEntity cityEntity=new WzHouseArrearsManageEntity();
- cityEntity.setAccumulateArrears(formatDouble(cityaccumulateArrears));
- cityEntity.setYearCumulativeNewAdditions(formatDouble(cityyearCumulativeNewAdditions));
- cityEntity.setYearCumulativeWithdrawal(formatDouble(cityyearCumulativeWithdrawal));
- cityEntity.setMoreThanOneYears(formatDouble(citymoreThanOneYears));
- cityEntity.setMoreThanThreeMonths(formatDouble(citymoreThanThreeMonths));
- cityEntity.setCity(list.get(0).getCity());
- cityEntity.setChildren(orderCountyList);
- cityList.add(cityEntity);
- }
- //对cityList 进行排序
- List<OtnAreaEntity> areaList=otnAreaService.getCityOption("018");
- List<WzHouseArrearsManageEntity> orderList=new ArrayList<>();
- int i=0;
- for (OtnAreaEntity otnAreaEntity : areaList) {
- for (WzHouseArrearsManageEntity wzCity : cityList) {
- if(wzCity.getCity().contains(otnAreaEntity.getName())){
- wzCity.setFlag(i%2==0);
- i++;
- orderList.add(wzCity);
- }
- }
- }
- province.setAccumulateArrears(formatDouble(allAccumulateArrears));
- province.setMoreThanOneYears(formatDouble(allmoreThanOneYears));
- province.setMoreThanThreeMonths(formatDouble(allmoreThanThreeMonths));
- province.setYearCumulativeNewAdditions(formatDouble(allyearCumulativeNewAdditions));
- province.setYearCumulativeWithdrawal(formatDouble(allyearCumulativeWithdrawal));
- province.setChildren(orderList);
- if(orderList.size()>0){
- resultList.add(province);
- }
- PageUtils pageUtil = new PageUtils(resultList, 0, query.getLimit(), query.getPage());
- return R.ok().put("page", pageUtil);
- }
- public double formatDouble(double num){
- double avera=0l;
- try{
- DecimalFormat format2 = new DecimalFormat("#.00");
- String str2 = format2.format(num);
- avera = Double.parseDouble(str2);
- }catch (Exception e){
- e.printStackTrace();
- }
- return avera;
- }
- }
|