WzHouseArrearsManageController.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. package com.example.controller.gdc;
  2. import com.example.config.annotation.IgnoreAuth;
  3. import com.example.pojo.gdc.OtnAreaEntity;
  4. import com.example.pojo.gdc.WzHouseArrearsManageEntity;
  5. import com.example.service.gdc.WzHouseArrearsManageService;
  6. import com.example.service.gdc.WzOtnAreaService;
  7. import com.example.utils.PageMap;
  8. import com.example.utils.PageUtils;
  9. import com.example.utils.Query;
  10. import com.example.utils.R;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.web.bind.annotation.RequestBody;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RestController;
  15. import java.text.DecimalFormat;
  16. import java.util.ArrayList;
  17. import java.util.HashMap;
  18. import java.util.List;
  19. import java.util.Map;
  20. /**
  21. * 房屋出租(合同管理)
  22. */
  23. @RestController
  24. @RequestMapping("/house-car/house/dist/api/wzHouseArrearsManage")
  25. public class WzHouseArrearsManageController {
  26. @Autowired
  27. private WzOtnAreaService otnAreaService;
  28. @Autowired
  29. private WzHouseArrearsManageService wzHouseArrearsManageService;
  30. @RequestMapping("/list")
  31. @IgnoreAuth
  32. public R list(@RequestBody PageMap pageMap) {
  33. //查询列表数据
  34. Query query = new Query(pageMap);
  35. List<WzHouseArrearsManageEntity> list = wzHouseArrearsManageService.queryList(query);
  36. int total = wzHouseArrearsManageService.queryTotal(query);
  37. PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
  38. return R.ok().put("page", pageUtil);
  39. }
  40. @RequestMapping("/echartList")
  41. @IgnoreAuth
  42. public R echartList(@RequestBody PageMap pageMap) {
  43. //查询列表数据
  44. Query query = new Query(pageMap);
  45. List<WzHouseArrearsManageEntity> wzHouseContracEntityList = wzHouseArrearsManageService.queryList(query);
  46. WzHouseArrearsManageEntity province=new WzHouseArrearsManageEntity();
  47. province.setCity("全省");
  48. Map<String,List<WzHouseArrearsManageEntity>> map=new HashMap<>();
  49. for (WzHouseArrearsManageEntity leaveUseVo : wzHouseContracEntityList) {
  50. List<WzHouseArrearsManageEntity> list;
  51. if(map.get(leaveUseVo.getCity())!=null){
  52. list=map.get(leaveUseVo.getCity());
  53. list.add(leaveUseVo);
  54. }else{
  55. list=new ArrayList<>();
  56. list.add(leaveUseVo);
  57. }
  58. map.put(leaveUseVo.getCity(),list);
  59. }
  60. List<WzHouseArrearsManageEntity> resultList=new ArrayList<>();
  61. List<WzHouseArrearsManageEntity> cityList=new ArrayList<>();
  62. double allAccumulateArrears=0l;
  63. double allmoreThanThreeMonths=0l;
  64. double allmoreThanOneYears=0l;
  65. double allyearCumulativeNewAdditions=0l;
  66. double allyearCumulativeWithdrawal=0l;
  67. for(Map.Entry<String,List<WzHouseArrearsManageEntity>> entry:map.entrySet()){
  68. List<WzHouseArrearsManageEntity> list=entry.getValue();
  69. //县的Map集合
  70. Map<String,List<WzHouseArrearsManageEntity>> countyMap=new HashMap<>();
  71. for (WzHouseArrearsManageEntity leaveUseVo : list) {
  72. if (leaveUseVo.getCounty() == null || leaveUseVo.getCounty().equals("")) {
  73. continue;
  74. }
  75. if (countyMap.get(leaveUseVo.getCounty()) != null) {
  76. list = countyMap.get(leaveUseVo.getCounty());
  77. list.add(leaveUseVo);
  78. } else {
  79. list = new ArrayList<>();
  80. list.add(leaveUseVo);
  81. }
  82. countyMap.put(leaveUseVo.getCounty(), list);
  83. }
  84. double cityaccumulateArrears=0l;
  85. double citymoreThanThreeMonths=0l;
  86. double citymoreThanOneYears=0l;
  87. double cityyearCumulativeNewAdditions=0l;
  88. double cityyearCumulativeWithdrawal=0l;
  89. List<WzHouseArrearsManageEntity> countyList=new ArrayList<>();
  90. for (Map.Entry<String, List<WzHouseArrearsManageEntity>> countyEntry : countyMap.entrySet()) {
  91. double accumulateArrears=0l;
  92. double moreThanThreeMonths=0l;
  93. double moreThanOneYears=0l;
  94. double yearCumulativeNewAdditions=0l;
  95. double yearCumulativeWithdrawal=0l;
  96. for (WzHouseArrearsManageEntity leaveUseVo : countyEntry.getValue()) {
  97. if(leaveUseVo.getAccumulateArrears()!=null){
  98. accumulateArrears+=leaveUseVo.getAccumulateArrears();
  99. cityaccumulateArrears+=leaveUseVo.getAccumulateArrears();
  100. allAccumulateArrears+=leaveUseVo.getAccumulateArrears();
  101. }
  102. if(leaveUseVo.getMoreThanThreeMonths()!=null){
  103. moreThanThreeMonths+=leaveUseVo.getMoreThanThreeMonths();
  104. citymoreThanThreeMonths+=leaveUseVo.getMoreThanThreeMonths();
  105. allmoreThanThreeMonths+=leaveUseVo.getMoreThanThreeMonths();
  106. }
  107. if(leaveUseVo.getMoreThanOneYears()!=null){
  108. moreThanOneYears+=leaveUseVo.getMoreThanOneYears();
  109. citymoreThanOneYears+=leaveUseVo.getMoreThanOneYears();
  110. allmoreThanOneYears+=leaveUseVo.getMoreThanOneYears();
  111. }
  112. if(leaveUseVo.getYearCumulativeNewAdditions()!=null){
  113. yearCumulativeNewAdditions+=leaveUseVo.getYearCumulativeNewAdditions();
  114. cityyearCumulativeNewAdditions+=leaveUseVo.getYearCumulativeNewAdditions();
  115. allyearCumulativeNewAdditions+=leaveUseVo.getYearCumulativeNewAdditions();
  116. }
  117. if(leaveUseVo.getYearCumulativeWithdrawal()!=null){
  118. yearCumulativeWithdrawal+=leaveUseVo.getYearCumulativeWithdrawal();
  119. cityyearCumulativeWithdrawal+=leaveUseVo.getYearCumulativeWithdrawal();
  120. allyearCumulativeWithdrawal+=leaveUseVo.getYearCumulativeWithdrawal();
  121. }
  122. }
  123. WzHouseArrearsManageEntity countyEntity=new WzHouseArrearsManageEntity();
  124. countyEntity.setAccumulateArrears(formatDouble(accumulateArrears));
  125. countyEntity.setYearCumulativeNewAdditions(formatDouble(yearCumulativeNewAdditions));
  126. countyEntity.setYearCumulativeWithdrawal(formatDouble(yearCumulativeWithdrawal));
  127. countyEntity.setMoreThanOneYears(formatDouble(moreThanOneYears));
  128. countyEntity.setMoreThanThreeMonths(formatDouble(moreThanThreeMonths));
  129. countyEntity.setCity(countyEntry.getValue().get(0).getCounty());
  130. countyList.add(countyEntity);
  131. }
  132. List<WzHouseArrearsManageEntity> orderCountyList=new ArrayList<>();
  133. try{
  134. //对countList 进行排序
  135. String city=list.get(0).getCity();
  136. if(city.contains("市")){
  137. city=city.split("市")[0];
  138. }
  139. OtnAreaEntity area=otnAreaService.queryObject(city);
  140. List<OtnAreaEntity> countyAreaList=otnAreaService.getCityOption(area.getId());
  141. int i=0;
  142. for (OtnAreaEntity otnAreaEntity : countyAreaList) {
  143. for (WzHouseArrearsManageEntity wzCity : countyList) {
  144. if(wzCity.getCity().contains(otnAreaEntity.getName())){
  145. i++;
  146. wzCity.setFlag(i%2==0);
  147. orderCountyList.add(wzCity);
  148. }
  149. }
  150. }
  151. }catch (Exception e){
  152. orderCountyList=countyList;
  153. e.printStackTrace();
  154. }
  155. WzHouseArrearsManageEntity cityEntity=new WzHouseArrearsManageEntity();
  156. cityEntity.setAccumulateArrears(formatDouble(cityaccumulateArrears));
  157. cityEntity.setYearCumulativeNewAdditions(formatDouble(cityyearCumulativeNewAdditions));
  158. cityEntity.setYearCumulativeWithdrawal(formatDouble(cityyearCumulativeWithdrawal));
  159. cityEntity.setMoreThanOneYears(formatDouble(citymoreThanOneYears));
  160. cityEntity.setMoreThanThreeMonths(formatDouble(citymoreThanThreeMonths));
  161. cityEntity.setCity(list.get(0).getCity());
  162. cityEntity.setChildren(orderCountyList);
  163. cityList.add(cityEntity);
  164. }
  165. //对cityList 进行排序
  166. List<OtnAreaEntity> areaList=otnAreaService.getCityOption("018");
  167. List<WzHouseArrearsManageEntity> orderList=new ArrayList<>();
  168. int i=0;
  169. for (OtnAreaEntity otnAreaEntity : areaList) {
  170. for (WzHouseArrearsManageEntity wzCity : cityList) {
  171. if(wzCity.getCity().contains(otnAreaEntity.getName())){
  172. wzCity.setFlag(i%2==0);
  173. i++;
  174. orderList.add(wzCity);
  175. }
  176. }
  177. }
  178. province.setAccumulateArrears(formatDouble(allAccumulateArrears));
  179. province.setMoreThanOneYears(formatDouble(allmoreThanOneYears));
  180. province.setMoreThanThreeMonths(formatDouble(allmoreThanThreeMonths));
  181. province.setYearCumulativeNewAdditions(formatDouble(allyearCumulativeNewAdditions));
  182. province.setYearCumulativeWithdrawal(formatDouble(allyearCumulativeWithdrawal));
  183. province.setChildren(orderList);
  184. if(orderList.size()>0){
  185. resultList.add(province);
  186. }
  187. PageUtils pageUtil = new PageUtils(resultList, 0, query.getLimit(), query.getPage());
  188. return R.ok().put("page", pageUtil);
  189. }
  190. public double formatDouble(double num){
  191. double avera=0l;
  192. try{
  193. DecimalFormat format2 = new DecimalFormat("#.00");
  194. String str2 = format2.format(num);
  195. avera = Double.parseDouble(str2);
  196. }catch (Exception e){
  197. e.printStackTrace();
  198. }
  199. return avera;
  200. }
  201. }