|
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
24
|
24
|
import java.util.HashMap;
|
25
|
25
|
import java.util.List;
|
26
|
26
|
import java.util.Map;
|
|
27
|
+import java.util.stream.Collectors;
|
27
|
28
|
|
28
|
29
|
/**
|
29
|
30
|
* <p>
|
|
@@ -80,6 +81,9 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
80
|
81
|
@Autowired
|
81
|
82
|
private TaShareActivityMapper taShareActivityMapper;
|
82
|
83
|
|
|
84
|
+ @Autowired
|
|
85
|
+ private TaOrgMapper taOrgMapper;
|
|
86
|
+
|
83
|
87
|
@Override
|
84
|
88
|
public ResponseBean buildingList(Integer pageNum, Integer pageSize, String name, String code, LocalDateTime startDate, String buildingStatus, String marketStatus, Integer cityId, Integer isMain, Integer orgId) {
|
85
|
89
|
Page<TaBuilding> page = new Page<>();
|
|
@@ -278,7 +282,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
278
|
282
|
if (CollectionUtils.isNotEmpty(buildingProjectTypeArray)) {
|
279
|
283
|
taBuildingProjectTypeMapper.insertBuildingProjectTypeBatch(buildingProjectTypeArray, building.getBuildingId());
|
280
|
284
|
}
|
281
|
|
- return ResponseBean.success("");
|
|
285
|
+ return ResponseBean.success(building);
|
282
|
286
|
}
|
283
|
287
|
|
284
|
288
|
@Override
|
|
@@ -289,6 +293,16 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
289
|
293
|
@Override
|
290
|
294
|
public ResponseBean buildingAdd(String parameter, Integer orgId) {
|
291
|
295
|
JSONObject object= JSONObject.parseObject(parameter);
|
|
296
|
+ // 根据orgId查询当前楼盘最大数
|
|
297
|
+ TaOrg taOrg = taOrgMapper.selectById(orgId);
|
|
298
|
+ // 查询当前org楼盘总数
|
|
299
|
+ QueryWrapper<TaBuilding> taBuildingQuery = new QueryWrapper<>();
|
|
300
|
+ taBuildingQuery.eq("org_id",orgId);
|
|
301
|
+ taBuildingQuery.gt("status",-1);
|
|
302
|
+ int orgNum= taBuildingMapper.selectCount(taBuildingQuery);
|
|
303
|
+ if (orgNum >= taOrg.getOrgNum()){
|
|
304
|
+ return ResponseBean.error("楼盘已超过最大限制", ResponseBean.ERROR_UNAVAILABLE);
|
|
305
|
+ }
|
292
|
306
|
|
293
|
307
|
TaBuilding building = JSONObject.parseObject(parameter,TaBuilding.class);
|
294
|
308
|
if(null!= object.getDate("openingDate")){
|
|
@@ -311,13 +325,13 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
311
|
325
|
List<TaBuildingImg> buildingImgs = JSONObject.parseArray(imgStr, TaBuildingImg.class);
|
312
|
326
|
|
313
|
327
|
if (CollectionUtils.isNotEmpty(buildingImgs)) {
|
314
|
|
- insertImgBatch(buildingImgs, building.getBuildingId());
|
|
328
|
+ buildingImgs = insertImgBatch(buildingImgs, building.getBuildingId());
|
315
|
329
|
}
|
316
|
330
|
|
317
|
331
|
String tagStr = object.getString("tag");
|
318
|
332
|
List<TaBuildingTag> buildingTags = JSONObject.parseArray(tagStr, TaBuildingTag.class);
|
319
|
333
|
if (CollectionUtils.isNotEmpty(buildingTags)) {
|
320
|
|
- insertTagBatch(buildingTags, building.getBuildingId());
|
|
334
|
+ buildingTags = insertTagBatch(buildingTags, building.getBuildingId());
|
321
|
335
|
}
|
322
|
336
|
|
323
|
337
|
// 项目类型
|
|
@@ -326,7 +340,7 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
326
|
340
|
taBuildingProjectTypeMapper.insertBuildingProjectTypeBatch(buildingProjectTypeArray, building.getBuildingId());
|
327
|
341
|
}
|
328
|
342
|
|
329
|
|
- return ResponseBean.success("");
|
|
343
|
+ return ResponseBean.success(building);
|
330
|
344
|
}
|
331
|
345
|
|
332
|
346
|
@Override
|
|
@@ -637,9 +651,8 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
637
|
651
|
}
|
638
|
652
|
|
639
|
653
|
|
640
|
|
- int insertImgBatch(List<TaBuildingImg> imgs, String buildingId) {
|
641
|
|
- int rows = 0;
|
642
|
|
- for (TaBuildingImg img: imgs){
|
|
654
|
+ private List<TaBuildingImg> insertImgBatch(List<TaBuildingImg> imgs, String buildingId) {
|
|
655
|
+ return imgs.stream().map(img -> {
|
643
|
656
|
TaBuildingImg Images = new TaBuildingImg();
|
644
|
657
|
Images.setBuildingId(buildingId);
|
645
|
658
|
Images.setImgType(img.getImgType());
|
|
@@ -647,21 +660,20 @@ public class TaBuildingServiceImpl extends ServiceImpl<TaBuildingMapper, TaBuild
|
647
|
660
|
Images.setOrderNo(Integer.valueOf(img.getOrderNo()));
|
648
|
661
|
Images.setStatus(1);
|
649
|
662
|
Images.setCreateDate(LocalDateTime.now());
|
650
|
|
- rows += taBuildingImgMapper.insert(Images);
|
651
|
|
- }
|
|
663
|
+ taBuildingImgMapper.insert(Images);
|
652
|
664
|
|
653
|
|
- return rows;
|
|
665
|
+ return Images;
|
|
666
|
+ }).collect(Collectors.toList());
|
654
|
667
|
}
|
655
|
668
|
|
656
|
|
- int insertTagBatch(List<TaBuildingTag> tags, String buildingId) {
|
657
|
|
- int rows = 0;
|
658
|
|
- for (TaBuildingTag tag:tags){
|
|
669
|
+ private List<TaBuildingTag> insertTagBatch(List<TaBuildingTag> tags, String buildingId) {
|
|
670
|
+ return tags.stream().map(tag -> {
|
659
|
671
|
TaBuildingTag btag = new TaBuildingTag();
|
660
|
672
|
btag.setBuildingId(buildingId);
|
661
|
673
|
btag.setTagName(tag.getTagName());
|
662
|
|
- rows += taBuildingTagMapper.insert(btag);
|
663
|
|
- }
|
664
|
|
- return rows;
|
|
674
|
+ taBuildingTagMapper.insert(btag);
|
|
675
|
+ return btag;
|
|
676
|
+ }).collect(Collectors.toList());
|
665
|
677
|
}
|
666
|
678
|
|
667
|
679
|
int insertApartmentImgBatch(List<TaBuildingImg> imgs, String buildingId, String apartmentId) {
|