|
@@ -25,8 +25,10 @@ import org.slf4j.Logger;
|
25
|
25
|
import org.slf4j.LoggerFactory;
|
26
|
26
|
import org.springframework.beans.factory.annotation.Autowired;
|
27
|
27
|
import org.springframework.stereotype.Service;
|
|
28
|
+import org.springframework.transaction.annotation.Transactional;
|
28
|
29
|
import org.springframework.web.multipart.MultipartFile;
|
29
|
30
|
|
|
31
|
+import java.math.BigDecimal;
|
30
|
32
|
import java.time.LocalDateTime;
|
31
|
33
|
import java.util.ArrayList;
|
32
|
34
|
import java.util.HashMap;
|
|
@@ -41,6 +43,7 @@ import java.util.Map;
|
41
|
43
|
* @author jobob
|
42
|
44
|
* @since 2020-02-10
|
43
|
45
|
*/
|
|
46
|
+@Transactional(rollbackFor = Exception.class)
|
44
|
47
|
@Service
|
45
|
48
|
public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResourcesMapper, TaHousingResources> implements ITaHousingResourcesService {
|
46
|
49
|
|
|
@@ -337,10 +340,13 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
337
|
340
|
* 获取表格中的数据
|
338
|
341
|
*
|
339
|
342
|
* @param file
|
|
343
|
+ * @param salesBatchId
|
|
344
|
+ * @param buildingId
|
|
345
|
+ * @param orgId
|
340
|
346
|
* @return
|
341
|
347
|
*/
|
342
|
348
|
@Override
|
343
|
|
- public ResponseBean getExcelData(MultipartFile file) {
|
|
349
|
+ public ResponseBean getExcelData(MultipartFile file, Integer salesBatchId, String buildingId, Integer orgId) {
|
344
|
350
|
ResponseBean responseBean = new ResponseBean();
|
345
|
351
|
List<TaHousingResources> list = new ArrayList<>();
|
346
|
352
|
if (file == null) {
|
|
@@ -380,28 +386,28 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
380
|
386
|
String unitName = row.getCell(2).getStringCellValue().trim();
|
381
|
387
|
String floorName = row.getCell(3).getStringCellValue().trim();
|
382
|
388
|
String roomName = row.getCell(4).getStringCellValue().trim();
|
383
|
|
- String price = row.getCell(5).getStringCellValue().trim();
|
384
|
|
- String heat = row.getCell(6).getStringCellValue().trim();
|
|
389
|
+ BigDecimal price = BigDecimal.valueOf(row.getCell(5).getNumericCellValue());
|
|
390
|
+ Integer heat = Integer.valueOf(String.valueOf(row.getCell(6).getNumericCellValue()).substring(0,1));
|
385
|
391
|
Integer status = row.getCell(7).getStringCellValue().trim().equals("是") ? 1 : 0;
|
386
|
392
|
|
387
|
393
|
int currentRow = j+1;
|
388
|
|
- if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(termName)){
|
|
394
|
+ if (StringUtils.isEmpty(termName)){
|
389
|
395
|
responseBean.addError("第" + currentRow + "行" + "期/区不能为空!");
|
390
|
396
|
return responseBean;
|
391
|
397
|
}
|
392
|
|
- if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(blockName)){
|
|
398
|
+ if (StringUtils.isEmpty(blockName)){
|
393
|
399
|
responseBean.addError("第" + currentRow + "行" + "楼栋不能为空!");
|
394
|
400
|
return responseBean;
|
395
|
401
|
}
|
396
|
|
- if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(unitName)){
|
|
402
|
+ if (StringUtils.isEmpty(unitName)){
|
397
|
403
|
responseBean.addError("第" + currentRow + "行" + "单元不能为空!");
|
398
|
404
|
return responseBean;
|
399
|
405
|
}
|
400
|
|
- if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(floorName)){
|
|
406
|
+ if (StringUtils.isEmpty(floorName)){
|
401
|
407
|
responseBean.addError("第" + currentRow + "行" + "层不能为空!");
|
402
|
408
|
return responseBean;
|
403
|
409
|
}
|
404
|
|
- if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isEmpty(roomName)){
|
|
410
|
+ if (StringUtils.isEmpty(roomName)){
|
405
|
411
|
responseBean.addError("第" + currentRow + "行" + "房号不能为空!");
|
406
|
412
|
return responseBean;
|
407
|
413
|
}
|
|
@@ -413,6 +419,23 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
413
|
419
|
return responseBean;
|
414
|
420
|
}
|
415
|
421
|
|
|
422
|
+ QueryWrapper<TaHousingResources> taHousingResourcesQueryWrapper = new QueryWrapper<>();
|
|
423
|
+ taHousingResourcesQueryWrapper.eq("sales_batch_id",salesBatchId);
|
|
424
|
+ taHousingResourcesQueryWrapper.eq("building_id",buildingId);
|
|
425
|
+ taHousingResourcesQueryWrapper.eq("org_id",orgId);
|
|
426
|
+ taHousingResourcesQueryWrapper.gt("status",CommConstant.STATUS_DELETE);
|
|
427
|
+ taHousingResourcesQueryWrapper.eq("term_name",termName);
|
|
428
|
+ taHousingResourcesQueryWrapper.eq("block_name",blockName);
|
|
429
|
+ taHousingResourcesQueryWrapper.eq("unit_name",unitName);
|
|
430
|
+ taHousingResourcesQueryWrapper.eq("floor_name",floorName);
|
|
431
|
+ taHousingResourcesQueryWrapper.eq("room_name",roomName);
|
|
432
|
+ TaHousingResources oldTaHouseingResources = taHousingResourcesMapper.selectOne(taHousingResourcesQueryWrapper);
|
|
433
|
+ if (null != oldTaHouseingResources){
|
|
434
|
+ logger.info("数据库存在重复房源:{}",houseInfo);
|
|
435
|
+ responseBean.addError("第"+ currentRow +"行与系统已录入房源"+ oldTaHouseingResources.getHouseId() +"重复");
|
|
436
|
+ return responseBean;
|
|
437
|
+ }
|
|
438
|
+
|
416
|
439
|
//把数据塞入temList校验是否有重复的数据
|
417
|
440
|
temHousingList.add(houseInfo);
|
418
|
441
|
//构建数据
|
|
@@ -421,6 +444,9 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
421
|
444
|
taHousingResources.setUnitName(unitName);
|
422
|
445
|
taHousingResources.setFloorName(floorName);
|
423
|
446
|
taHousingResources.setRoomName(roomName);
|
|
447
|
+ taHousingResources.setPrice(price);
|
|
448
|
+ taHousingResources.setHeat(heat);
|
|
449
|
+ taHousingResources.setStatus(status);
|
424
|
450
|
list.add(taHousingResources);
|
425
|
451
|
}
|
426
|
452
|
}
|
|
@@ -433,6 +459,35 @@ public class TaHousingResourcesServiceImpl extends ServiceImpl<TaHousingResource
|
433
|
459
|
return responseBean;
|
434
|
460
|
}
|
435
|
461
|
|
|
462
|
+ /**
|
|
463
|
+ * 保存文件
|
|
464
|
+ *
|
|
465
|
+ * @param file
|
|
466
|
+ * @param salesBatchId
|
|
467
|
+ * @param buildingId
|
|
468
|
+ * @param orgId
|
|
469
|
+ * @return
|
|
470
|
+ */
|
|
471
|
+ @Override
|
|
472
|
+ public ResponseBean saveExcelValue(MultipartFile file, Integer salesBatchId, String buildingId, Integer orgId) {
|
|
473
|
+ ResponseBean responseBean = new ResponseBean();
|
|
474
|
+ responseBean = getExcelData(file, salesBatchId, buildingId, orgId);
|
|
475
|
+ if (responseBean.getCode() != ResponseBean.CODE_SUCCESS){
|
|
476
|
+ return responseBean;
|
|
477
|
+ }
|
|
478
|
+
|
|
479
|
+ //获取校验成功的数据
|
|
480
|
+ Map<String,Object> data = (Map<String,Object>)responseBean.getData();
|
|
481
|
+ List<TaHousingResources> list = (List<TaHousingResources>)data.get("list");
|
|
482
|
+ list.forEach(e -> {
|
|
483
|
+ e.setOrgId(orgId);
|
|
484
|
+ e.setSalesBatchId(salesBatchId);
|
|
485
|
+ e.setBuildingId(buildingId);
|
|
486
|
+ addHouseResources(e);
|
|
487
|
+ });
|
|
488
|
+ return ResponseBean.success(list);
|
|
489
|
+ }
|
|
490
|
+
|
436
|
491
|
//更新房号
|
437
|
492
|
private void updateRoom(TaHousingResources taHousingResources) {
|
438
|
493
|
TaBuildingRoom taBuildingRoom = new TaBuildingRoom();
|