ParkService.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. package platform.modules.carrier.service;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.stereotype.Service;
  6. import org.springframework.transaction.annotation.Transactional;
  7. import platform.common.Constant;
  8. import platform.common.base.model.DictionaryItem;
  9. import platform.common.base.service.BaseService;
  10. import platform.common.base.service.DictionaryItemService;
  11. import platform.common.util.Reflections;
  12. import platform.common.util.ShiroUtils;
  13. import platform.modules.carrier.dao.ParkDao;
  14. import platform.modules.carrier.dto.CarrierLibraryResult;
  15. import platform.modules.carrier.dto.CustomSearchCondition;
  16. import platform.modules.carrier.dto.ParkDto;
  17. import platform.modules.carrier.dto.SearchCondition;
  18. import platform.modules.carrier.entity.*;
  19. import platform.modules.government.entity.Attachment;
  20. import platform.modules.government.entity.Street;
  21. import platform.modules.government.entity.User;
  22. import platform.modules.government.service.AttachmentService;
  23. import platform.modules.government.service.StreetService;
  24. import platform.modules.sys.web.ResponseMessage;
  25. import tk.mybatis.mapper.entity.Example;
  26. import java.math.BigDecimal;
  27. import java.util.ArrayList;
  28. import java.util.List;
  29. import java.util.Map;
  30. /**
  31. * @author kevin
  32. * @since 2019/3/31 3:04 PM
  33. */
  34. @Service
  35. @Transactional
  36. public class ParkService extends BaseService<Park> {
  37. @Autowired
  38. private ParkDao parkDao;
  39. @Autowired
  40. private StreetService streetService;
  41. @Autowired
  42. private AttachmentService attachmentService;
  43. @Autowired
  44. private ParkAttachmentService parkAttachmentService;
  45. @Autowired
  46. private ParkSupportService parkSupportService;
  47. @Autowired
  48. private ParkSupportAttachmentService parkSupportAttachmentService;
  49. @Autowired
  50. private ParkTypicalCompanyService parkTypicalCompanyService;
  51. @Autowired
  52. private ParkTypicalCompanyAttachmentService parkTypicalCompanyAttachmentService;
  53. @Autowired
  54. private DictionaryItemService dictionaryItemService;
  55. @Autowired
  56. private CarrierStatisticService carrierStatisticService;
  57. @Autowired
  58. private BuildingService buildingService;
  59. @Autowired
  60. private ParkDraftService parkDraftService;
  61. /**
  62. * 通过组合条件查询工业小区,返回符合条件的id集合
  63. *
  64. * @param condition
  65. * @return
  66. */
  67. public List<Park> getParkListByCondition(SearchCondition condition) {
  68. return parkDao.getParkListByCondition(condition);
  69. }
  70. /**
  71. * 获取所有园区
  72. *
  73. * @param pageNum
  74. * @param pageSize
  75. * @return
  76. */
  77. public PageInfo<Park> findParkList(Integer pageNum, Integer pageSize, SearchCondition condition) {
  78. if (!condition.getIs_front()) {
  79. User user = ShiroUtils.getUserEntity();
  80. if (user.getUser_type() != null && user.getUser_type().equals(Constant.UserType.STREET)) {
  81. condition.setStreetId(user.getStreet_id());
  82. }
  83. if (user.getUser_type() != null && user.getUser_type().equals(Constant.UserType.BUILD)) {
  84. condition.setParkId(user.getBuild_id());
  85. }
  86. }
  87. PageHelper.startPage(pageNum, pageSize);
  88. List<Park> parkList = parkDao.findParkList(condition);
  89. for (Park park : parkList) {
  90. double sumBuildingArea = carrierStatisticService.getSumParkBuildingArea(park.getId());
  91. park.setSumBuildArea(sumBuildingArea);
  92. park.setFile_down_url(condition.getFileUrl());
  93. Attachment attachment = attachmentService.findMainPicture(park.getId());
  94. if (attachment != null) {
  95. park.setMain_pic_url(attachment.getFile_url());
  96. }
  97. Double sumRentArea = getParkRentAreaStatistic(park.getId());
  98. park.setSumRentArea(sumRentArea);
  99. if (park.getType() != null){
  100. park.setType_desc(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PARK_TYPE, park.getType().toString()));
  101. }
  102. }
  103. return new PageInfo<>(parkList);
  104. }
  105. /**
  106. * 获取小区信息
  107. *
  108. * @param id
  109. * @return
  110. */
  111. public Park parkDetailById(Integer id) {
  112. ParkDraft draft = parkDraftService.findById(id);
  113. if (draft != null){
  114. Park park = new Park();
  115. Reflections.copyFieldToBean(draft, park);
  116. park.setId(id);
  117. park.setStreetName(streetService.findById(park.getStreet_id()).getName());
  118. getParkDraftInfo(park);
  119. return park;
  120. }
  121. Park park = this.findById(id);
  122. if (park != null) {
  123. getParkInfo(park);
  124. park.setStreetName(streetService.findById(park.getStreet_id()).getName());
  125. }
  126. return park;
  127. }
  128. /**
  129. * 获取小区其他草稿信息
  130. *
  131. * @param park
  132. */
  133. private void getParkDraftInfo(Park park) {
  134. Street street = streetService.findById(park.getStreet_id());
  135. park.setStreetName(street.getName());
  136. if (park.getType() != null){
  137. park.setType_desc(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PARK_TYPE, park.getType().toString()));
  138. }
  139. //获取小区图片
  140. List<ParkAttachmentDraft> attachmentList = parkDraftService.findParkAttachmentDraftList(park.getId());
  141. List<FileDown> fileDownList = new ArrayList<>();
  142. for (ParkAttachmentDraft parkAtt : attachmentList) {
  143. Attachment attachment = attachmentService.findById(parkAtt.getAttachment_id());
  144. if (attachment != null) {
  145. FileDown fileDown = new FileDown();
  146. fileDown.setFile_id(attachment.getId());
  147. fileDown.setDownload_uri(attachment.getDownload_uri());
  148. fileDown.setFile_url(attachment.getFile_url());
  149. fileDown.setFile_name(attachment.getFile_name());
  150. fileDown.setIs_main(parkAtt.getIs_main());
  151. fileDownList.add(fileDown);
  152. }
  153. }
  154. park.setFileDowns(fileDownList);
  155. // 获取小区配套
  156. List<ParkSupport> supportList = new ArrayList<>();
  157. List<ParkSupportDraft> draftList = parkDraftService.findSupportDraftByParkId(park.getId());
  158. for (ParkSupportDraft draft : draftList) {
  159. ParkSupport support = new ParkSupport();
  160. Reflections.copyFieldToBean(draft, support);
  161. String attachmentType = Constant.Attachment.PARK_SUPPORT_DRAFT;
  162. List<Attachment> attachments =
  163. attachmentService.findListBySupport(draft.getId(), draft.getType(), attachmentType);
  164. support.setFileDowns(getFileDownList(attachments));
  165. //获取item
  166. DictionaryItem item = dictionaryItemService.
  167. findByTypeAndValue(Constant.DictionaryType.PARK_SUPPORT, draft.getType().toString());
  168. support.setType_desc(item.getName());
  169. supportList.add(support);
  170. }
  171. park.setSupportList(supportList);
  172. //获取典型企业
  173. List<ParkTypicalCompany> companyList = new ArrayList<>();
  174. List<ParkTypicalCompanyDraft> companyDraftList = parkDraftService.findTypicalCompanyDraft(park.getId());
  175. for (ParkTypicalCompanyDraft draft : companyDraftList) {
  176. ParkTypicalCompany company = new ParkTypicalCompany();
  177. Reflections.copyFieldToBean(draft, company);
  178. String attachmentType = Constant.Attachment.TYPICAL_COMPANY_DRAFT;
  179. List<Attachment> attachments =
  180. attachmentService.findListByTypicalCompany(draft.getId(), attachmentType);
  181. company.setFileDowns(getFileDownList(attachments));
  182. companyList.add(company);
  183. }
  184. park.setTypicalCompanyList(companyList);
  185. }
  186. /**
  187. * 获取小区信息
  188. *
  189. * @param id
  190. * @return
  191. */
  192. public Park frontParkDetailById(Integer id) {
  193. Park park = findById(id);
  194. if (park != null) {
  195. double sumBuildingArea = carrierStatisticService.getSumParkBuildingArea(id);
  196. park.setBuild_area(sumBuildingArea);
  197. park.setRest_area(findParkRemainArea(id));
  198. park.setBuild_num(parkDao.findBuildingNum(id));
  199. this.updateSelective(park);
  200. //获取其他信息
  201. getParkInfo(park);
  202. }
  203. return park;
  204. }
  205. /**
  206. * 获取园区剩余面积
  207. *
  208. * @param park_id
  209. */
  210. public Double findParkRemainArea(Integer park_id) {
  211. return parkDao.findParkRemainArea(park_id);
  212. }
  213. /**
  214. * 获取小区其他信息
  215. *
  216. * @param park
  217. */
  218. public void getParkInfo(Park park) {
  219. Street street = streetService.findById(park.getStreet_id());
  220. park.setStreetName(street.getName());
  221. if (park.getType() != null){
  222. park.setType_desc(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.PARK_TYPE, park.getType().toString()));
  223. }
  224. //获取小区图片
  225. ParkAttachment parkAttachment = new ParkAttachment();
  226. parkAttachment.setPark_id(park.getId());
  227. List<ParkAttachment> attachmentList = parkAttachmentService.findListByWhere(parkAttachment);
  228. List<FileDown> fileDownList = new ArrayList<>();
  229. for (ParkAttachment parkAtt : attachmentList) {
  230. Attachment attachment = attachmentService.findById(parkAtt.getAttachment_id());
  231. if (attachment != null) {
  232. FileDown fileDown = new FileDown();
  233. fileDown.setFile_id(attachment.getId());
  234. fileDown.setDownload_uri(attachment.getDownload_uri());
  235. fileDown.setFile_url(attachment.getFile_url());
  236. fileDown.setFile_name(attachment.getFile_name());
  237. fileDown.setIs_main(parkAtt.getIs_main());
  238. fileDownList.add(fileDown);
  239. }
  240. }
  241. park.setFileDowns(fileDownList);
  242. // 获取小区配套
  243. ParkSupport support = new ParkSupport();
  244. support.setPark_id(park.getId());
  245. List<ParkSupport> supportList = parkSupportService.findListByWhere(support);
  246. if (supportList != null && supportList.size() > 0) {
  247. for (ParkSupport parkSupport : supportList) {
  248. String attachmentType = Constant.Attachment.PARK_SUPPORT;
  249. List<Attachment> attachments =
  250. attachmentService.findListBySupport(parkSupport.getId(), parkSupport.getType(), attachmentType);
  251. parkSupport.setFileDowns(getFileDownList(attachments));
  252. //获取item
  253. DictionaryItem item = dictionaryItemService.
  254. findByTypeAndValue(Constant.DictionaryType.PARK_SUPPORT, parkSupport.getType().toString());
  255. parkSupport.setType_desc(item.getName());
  256. }
  257. }
  258. park.setSupportList(supportList);
  259. //获取典型企业
  260. ParkTypicalCompany typicalCompany = new ParkTypicalCompany();
  261. typicalCompany.setPark_id(park.getId());
  262. List<ParkTypicalCompany> companyList = parkTypicalCompanyService.findListByWhere(typicalCompany);
  263. if (companyList != null && companyList.size() > 0) {
  264. for (ParkTypicalCompany company : companyList) {
  265. String attachmentType = Constant.Attachment.TYPICAL_COMPANY;
  266. List<Attachment> attachments =
  267. attachmentService.findListByTypicalCompany(company.getId(), attachmentType);
  268. company.setFileDowns(getFileDownList(attachments));
  269. }
  270. }
  271. park.setTypicalCompanyList(companyList);
  272. }
  273. /**
  274. * 编辑小区信息
  275. *
  276. * @param park
  277. */
  278. public void editParkInfo(Park park) {
  279. if (park.getId() != null) {
  280. // this.updateSelective(park);
  281. if (park.getIs_draft()){
  282. this.updateSelective(park);
  283. ParkDraft draft = parkDraftService.findById(park.getId());
  284. if (draft != null){
  285. parkDraftService.deleteById(draft.getId());
  286. }
  287. parkAttachmentService.deleteByParkId(park.getId());
  288. saveAttachment(park);
  289. //删除图片草稿
  290. deleteDraftAttachment(park);
  291. //配套信息
  292. parkSupportService.deleteParkSupport(park.getId());
  293. if (park.getSupportList() != null && park.getSupportList().size() > 0) {
  294. saveParkSupport(park.getSupportList(), park.getId());
  295. }
  296. //删除草稿中的园区配套及图片
  297. parkDraftService.deleteDraftSupport(park.getId());
  298. //典型企业
  299. ParkTypicalCompany typical = new ParkTypicalCompany();
  300. typical.setPark_id(park.getId());
  301. List<ParkTypicalCompany> typicalCompanys = parkTypicalCompanyService.findListByWhere(typical);
  302. for (ParkTypicalCompany company : typicalCompanys) {
  303. parkTypicalCompanyService.deleteById(company.getId());
  304. parkTypicalCompanyAttachmentService.deleteByTypicalCompanyId(company.getId());
  305. }
  306. if (park.getTypicalCompanyList() != null && park.getTypicalCompanyList().size() > 0) {
  307. saveparkTypicalCompany(park.getTypicalCompanyList(), park.getId());
  308. }
  309. //删除草稿中的典型企业及图片
  310. parkDraftService.deleteDraftTypicalCompany(park.getId());
  311. }
  312. else {//保存草稿
  313. ParkDraft draft = parkDraftService.findById(park.getId());
  314. if (draft != null){
  315. Reflections.copyFieldToBean(park, draft);
  316. parkDraftService.updateSelective(draft);
  317. }
  318. else {
  319. ParkDraft insert = new ParkDraft();
  320. Reflections.copyFieldToBean(park, insert);
  321. insert.setId(park.getId());
  322. insert.setIs_draft(true);
  323. parkDraftService.save(insert);
  324. }
  325. deleteDraftAttachment(park);
  326. //园区图片草稿
  327. if (park.getFileDowns() != null && park.getFileDowns().size() > 0) {
  328. saveAttachmentDraft(park.getFileDowns(), park.getId());
  329. }
  330. parkDraftService.deleteDraftSupport(park.getId());
  331. //配套信息
  332. if (park.getSupportList() != null && park.getSupportList().size() > 0) {
  333. saveParkSupportDraft(park.getSupportList(), park.getId());
  334. }
  335. parkDraftService.deleteDraftTypicalCompany(park.getId());
  336. //典型企业
  337. if (park.getTypicalCompanyList() != null && park.getTypicalCompanyList().size() > 0) {
  338. saveparkTypicalCompanyDraft(park.getTypicalCompanyList(), park.getId());
  339. }
  340. }
  341. }
  342. }
  343. /**
  344. * 保存典型企业草稿
  345. */
  346. private void saveparkTypicalCompanyDraft(List<ParkTypicalCompany> typicalCompanyList, Integer id) {
  347. for (ParkTypicalCompany parkTypicalCompany : typicalCompanyList) {
  348. parkTypicalCompany.setPark_id(id);
  349. parkDraftService.insertTypicalCompanyDraft(parkTypicalCompany);
  350. }
  351. }
  352. /**
  353. * 保存配套信息草稿
  354. */
  355. private void saveParkSupportDraft(List<ParkSupport> supportList, Integer id) {
  356. for (ParkSupport parkSupport : supportList) {
  357. parkSupport.setPark_id(id);
  358. parkDraftService.insertSupportDraft(parkSupport);
  359. }
  360. }
  361. /**
  362. * 保存园区图片草稿
  363. */
  364. private void saveAttachmentDraft(List<FileDown> fileDowns, Integer park_id) {
  365. for (FileDown fileDown : fileDowns) {
  366. int fileId = fileDown.getFile_id();
  367. ParkAttachmentDraft newAttach = new ParkAttachmentDraft();
  368. newAttach.setPark_id(park_id);
  369. newAttach.setAttachment_id(fileId);
  370. newAttach.setIs_main(fileDown.getIs_main());
  371. int newAttachId = parkDraftService.insertAttachmentDraft(newAttach);
  372. //图片已存在
  373. Attachment attachment = attachmentService.findById(fileId);
  374. if (attachment != null){
  375. attachment.setBusiness_id(newAttachId);
  376. attachment.setBusiness_type(Constant.Attachment.PARK_DRAFT);
  377. attachmentService.updateSelective(attachment);
  378. }
  379. }
  380. }
  381. /**
  382. * 保存园区典型企业
  383. */
  384. private void saveparkTypicalCompany(List<ParkTypicalCompany> typicalCompanyList, Integer park_id) {
  385. for (ParkTypicalCompany typicalCompany : typicalCompanyList) {
  386. typicalCompany.setPark_id(park_id);
  387. int id = parkTypicalCompanyService.insertAndGetId(typicalCompany);
  388. //删除原来图片
  389. ParkTypicalCompanyAttachment companyAttachment = new ParkTypicalCompanyAttachment();
  390. companyAttachment.setTypical_company_id(id);
  391. //保存新图片
  392. List<FileDown> fileDowns = typicalCompany.getFileDowns();
  393. if (fileDowns != null && fileDowns.size() > 0) {
  394. for (FileDown fileDown : fileDowns) {
  395. int fileId = fileDown.getFile_id();
  396. companyAttachment.setAttachment_id(fileId);
  397. int typicalCompanyId = parkTypicalCompanyAttachmentService.insertAndGetId(companyAttachment);
  398. Attachment attachment = attachmentService.findById(fileDown.getFile_id());
  399. if (attachment != null) {
  400. attachment.setBusiness_type(Constant.Attachment.TYPICAL_COMPANY);
  401. attachment.setBusiness_id(typicalCompanyId);
  402. attachmentService.updateSelective(attachment);
  403. }
  404. }
  405. }
  406. }
  407. }
  408. /**
  409. * 保存园区配套
  410. */
  411. private void saveParkSupport(List<ParkSupport> supportList, Integer park_id) {
  412. for (ParkSupport parkSupport : supportList) {
  413. Integer supportId = parkSupport.getId();
  414. parkSupport.setPark_id(park_id);
  415. ParkSupportAttachment oldAttachment = new ParkSupportAttachment();
  416. oldAttachment.setType(parkSupport.getType());
  417. if (parkSupport.getId() != null) {
  418. parkSupportService.updateSelective(parkSupport);
  419. } else {
  420. supportId = parkSupportService.insertAndGetId(parkSupport);
  421. }
  422. //删除原来图片
  423. oldAttachment.setSupport_id(supportId);
  424. List<ParkSupportAttachment> supportAttachments = parkSupportAttachmentService.findListByWhere(oldAttachment);
  425. if (supportAttachments != null && supportAttachments.size() > 0) {
  426. for (ParkSupportAttachment attachment : supportAttachments) {
  427. attachment.setDel_flag(true);
  428. parkSupportAttachmentService.updateSelective(attachment);
  429. }
  430. }
  431. //保存新图片
  432. List<FileDown> fileDowns = parkSupport.getFileDowns();
  433. if (fileDowns != null && fileDowns.size() > 0) {
  434. for (FileDown fileDown : fileDowns) {
  435. ParkSupportAttachment supportAttachment = new ParkSupportAttachment();
  436. supportAttachment.setSupport_id(supportId);
  437. supportAttachment.setType(parkSupport.getType());
  438. supportAttachment.setAttachment_id(fileDown.getFile_id());
  439. parkSupportAttachmentService.insertAndGetId(supportAttachment);
  440. //更新配套图片信息
  441. Attachment attachment = new Attachment();
  442. attachment.setId(fileDown.getFile_id());
  443. attachment.setBusiness_id(supportAttachment.getId());
  444. attachment.setBusiness_type(Constant.Attachment.PARK_SUPPORT);
  445. attachmentService.updateSelective(attachment);
  446. }
  447. }
  448. }
  449. }
  450. /**
  451. * 删除草稿图片
  452. */
  453. private void deleteDraftAttachment(Park park) {
  454. parkDraftService.deleteDraftAttachment(park.getId());
  455. }
  456. /**
  457. * 保存园区图片
  458. */
  459. private void saveAttachment(Park park) {
  460. if (park.getFileDowns() != null && park.getFileDowns().size() > 0) {
  461. //保存新图片
  462. for (FileDown fileDown : park.getFileDowns()) {
  463. int fileId = fileDown.getFile_id();
  464. ParkAttachment newAttach = new ParkAttachment();
  465. newAttach.setPark_id(park.getId());
  466. newAttach.setAttachment_id(fileId);
  467. newAttach.setIs_main(fileDown.getIs_main());
  468. int newAttachId = parkAttachmentService.insertAndGetId(newAttach);
  469. //图片已存在
  470. if (attachmentService.findById(fileId) != null) {
  471. continue;
  472. }
  473. Attachment attachment = new Attachment();
  474. attachment.setId(fileId);
  475. attachment.setBusiness_id(newAttachId);
  476. attachment.setBusiness_type(Constant.Attachment.PARK);
  477. attachmentService.updateSelective(attachment);
  478. }
  479. }
  480. }
  481. /**
  482. * 获取fileDowns
  483. *
  484. * @param attachmentList
  485. * @return
  486. */
  487. public List<FileDown> getFileDownList(List<Attachment> attachmentList) {
  488. List<FileDown> fileDowns = new ArrayList<>();
  489. if (attachmentList != null && attachmentList.size() > 0) {
  490. for (Attachment attachment : attachmentList) {
  491. FileDown fileDown = new FileDown();
  492. fileDown.setFile_url(attachment.getFile_url());
  493. fileDown.setFile_id(attachment.getId());
  494. fileDown.setDownload_uri(attachment.getDownload_uri());
  495. fileDown.setFile_name(attachment.getFile_name());
  496. fileDowns.add(fileDown);
  497. }
  498. }
  499. return fileDowns;
  500. }
  501. public List<Park> findParkListByStreetId(Integer streetId) {
  502. SearchCondition condition = new SearchCondition();
  503. condition.setStreetId(streetId);
  504. return parkDao.findParkList(condition);
  505. }
  506. @Transactional(readOnly = true)
  507. public List<Park> findList() {
  508. Example example = new Example(Park.class);
  509. Example.Criteria criteria = example.createCriteria();
  510. criteria.andEqualTo("del_flag", 0);
  511. //倒序
  512. //example.orderBy("create_time").desc();
  513. example.setOrderByClause("id");
  514. List<Park> parks = this.selectByExample(example);
  515. return parks;
  516. }
  517. @Transactional(readOnly = true)
  518. public List<Park> findParkOnUseList() {
  519. Example example = new Example(Park.class);
  520. Example.Criteria criteria = example.createCriteria();
  521. criteria.andEqualTo("del_flag", 0);
  522. criteria.andEqualTo("is_start", 1);
  523. criteria.andEqualTo("is_draft", 1);
  524. //倒序
  525. //example.orderBy("create_time").desc();
  526. example.setOrderByClause("id");
  527. List<Park> parks = this.selectByExample(example);
  528. return parks;
  529. }
  530. public int updateNoBatch(List<Park> parks) {
  531. return parkDao.updateNoBatch(parks);
  532. }
  533. /**
  534. * 载体库园区列表
  535. *
  536. * @param id
  537. * @return
  538. */
  539. public List<CarrierLibraryResult> getParkStatistic(Integer id) {
  540. return parkDao.getParkStatistic(id);
  541. }
  542. public CarrierLibraryResult getParkAreaStatistic(Integer id) {
  543. return parkDao.getParkAreaStatistic(id);
  544. }
  545. public List<ParkDto> findParkBuildingList(CustomSearchCondition customSearchCondition) {
  546. return parkDao.findParkBuildingList(customSearchCondition);
  547. }
  548. public List<Park> findByStreetId(Integer id) {
  549. return parkDao.findByStreetId(id);
  550. }
  551. public Double getParkRentAreaStatistic(Integer id) {
  552. return parkDao.getParkRentAreaStatistic(id);
  553. }
  554. /**
  555. * 更具园区名字查找园区
  556. *
  557. * @param name
  558. * @return
  559. */
  560. public Park findByName(String name) {
  561. Example example = new Example(Park.class);
  562. Example.Criteria criteria = example.createCriteria();
  563. criteria.andEqualTo("del_flag", 0);
  564. criteria.andEqualTo("name", name);
  565. List<Park> parks = this.selectByExample(example);
  566. if (parks.size() > 0){
  567. return parks.get(0);
  568. }
  569. return null;
  570. }
  571. public PageInfo<Park> findParkNames(SearchCondition condition) {
  572. if (!condition.getIs_front()) {
  573. User user = ShiroUtils.getUserEntity();
  574. if (user.getUser_type() != null && user.getUser_type().equals(Constant.UserType.STREET)) {
  575. condition.setStreetId(user.getStreet_id());
  576. }
  577. if (user.getUser_type() != null && user.getUser_type().equals(Constant.UserType.BUILD)) {
  578. condition.setParkId(user.getBuild_id());
  579. }
  580. }
  581. PageHelper.startPage(condition.getPageNum(), condition.getPageSize());
  582. List<Park> parkList = parkDao.findParkNames(condition);
  583. return new PageInfo<>(parkList);
  584. }
  585. /**
  586. * 找到子园区
  587. *
  588. * @param park_id
  589. * @return
  590. */
  591. public List<SubPark> findParentParkById(String park_id) {
  592. return parkDao.findParentParkById(park_id);
  593. }
  594. }