package com.example.controller.gdc; import com.example.config.annotation.IgnoreAuth; import com.example.pojo.gdc.OtnAreaEntity; import com.example.pojo.gdc.WzHouseCustomerEntity; import com.example.service.gdc.WzHouseCustomerService; 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.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 房屋出租(合同管理) */ @RestController @RequestMapping("/house-car/house/dist/api/wzHouseCustomer") public class WzHouseCustomerController { @Autowired private WzHouseCustomerService wzHouseCustomerService; @Autowired private WzOtnAreaService otnAreaService; @RequestMapping("/list") @IgnoreAuth public R list(@RequestBody PageMap pageMap) { //查询列表数据 Query query = new Query(pageMap); List list = wzHouseCustomerService.queryList(query); int total = wzHouseCustomerService.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 wzHouseContracEntityList = wzHouseCustomerService.queryList(query); WzHouseCustomerEntity province=new WzHouseCustomerEntity(); province.setCity("全省"); Map> map=new HashMap<>(); for (WzHouseCustomerEntity leaveUseVo : wzHouseContracEntityList) { List 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 resultList=new ArrayList<>(); List cityList=new ArrayList<>(); Integer allPerson=0; Integer allPersonPrivate=0; Integer allStateOwnedEnterprises=0; Integer allGovernment=0; Integer allAllNum=0; for(Map.Entry> entry:map.entrySet()){ List list=entry.getValue(); if(list.get(0).getCity().equals("全省")){ continue; } Integer person=0; Integer personPrivate=0; Integer stateOwnedEnterprises=0; Integer government=0; Integer allNum=0; for (WzHouseCustomerEntity leaveUseVo : list) { if(leaveUseVo.getPerson()!=null){ person+=leaveUseVo.getPerson(); allPerson+=leaveUseVo.getPerson(); } if(leaveUseVo.getPersonPrivate()!=null){ personPrivate+=leaveUseVo.getPersonPrivate(); allPersonPrivate+=leaveUseVo.getPersonPrivate(); } if(leaveUseVo.getStateOwnedEnterprises()!=null){ stateOwnedEnterprises+=leaveUseVo.getStateOwnedEnterprises(); allStateOwnedEnterprises+=leaveUseVo.getStateOwnedEnterprises(); } if(leaveUseVo.getGovernment()!=null){ government+=leaveUseVo.getGovernment(); allGovernment+=leaveUseVo.getGovernment(); } allNum=person+personPrivate+stateOwnedEnterprises+government; allAllNum+=allNum; leaveUseVo.setAllNum(allNum); } cityList.add(list.get(0)); } //对cityList 进行排序 List areaList=otnAreaService.getCityOption("018"); List orderList=new ArrayList<>(); for (OtnAreaEntity otnAreaEntity : areaList) { for (WzHouseCustomerEntity wzCity : cityList) { if(wzCity.getCity().contains(otnAreaEntity.getName())){ orderList.add(wzCity); } } } province.setPerson(allPerson); province.setPersonPrivate(allPersonPrivate); province.setStateOwnedEnterprises(allStateOwnedEnterprises); province.setGovernment(allGovernment); province.setChildren(orderList); province.setAllNum(allAllNum); if(orderList.size()>0){ resultList.add(province); } int total = wzHouseCustomerService.queryTotal(query); PageUtils pageUtil = new PageUtils(resultList, total, query.getLimit(), query.getPage()); return R.ok().put("page", pageUtil); } }