From 8a2a463d46b3dce73015462c9f6a2a258dd25f5b Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期五, 25 二月 2022 11:40:11 +0800
Subject: [PATCH] 优化diamante

---
 service-api/src/main/java/com/java110/api/smo/assetImport/impl/AssetImportSMOImpl.java |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 54 insertions(+), 27 deletions(-)

diff --git a/service-api/src/main/java/com/java110/api/smo/assetImport/impl/AssetImportSMOImpl.java b/service-api/src/main/java/com/java110/api/smo/assetImport/impl/AssetImportSMOImpl.java
index 0d23fc9..744aedd 100644
--- a/service-api/src/main/java/com/java110/api/smo/assetImport/impl/AssetImportSMOImpl.java
+++ b/service-api/src/main/java/com/java110/api/smo/assetImport/impl/AssetImportSMOImpl.java
@@ -3,22 +3,21 @@
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.api.smo.DefaultAbstractComponentSMO;
-import com.java110.core.component.BaseComponentSMO;
+import com.java110.api.smo.assetImport.IAssetImportSMO;
 import com.java110.core.context.IPageData;
 import com.java110.core.smo.ISaveTransactionLogSMO;
 import com.java110.dto.RoomDto;
 import com.java110.dto.assetImportLog.AssetImportLogDto;
 import com.java110.dto.assetImportLogDetail.AssetImportLogDetailDto;
+import com.java110.dto.owner.OwnerDto;
 import com.java110.entity.assetImport.*;
 import com.java110.entity.component.ComponentValidateResult;
-import com.java110.api.smo.assetImport.IAssetImportSMO;
-import com.java110.utils.constant.ServiceConstant;
 import com.java110.utils.util.*;
 import com.java110.vo.ResultVo;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.java110.core.log.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
@@ -171,7 +170,7 @@
                 //paramIn = new JSONObject();
                 //淇濆瓨 璐圭敤椤�
 
-                apiUrl = ServiceConstant.SERVICE_API_URL + "/api/feeConfig.saveFeeConfig";
+                apiUrl = "feeConfig.saveFeeConfig";
 
                 paramIn = JSONObject.parseObject(JSONObject.toJSONString(fee));
                 paramIn.put("communityId", result.getCommunityId());
@@ -246,7 +245,7 @@
                 paramIn = new JSONObject();
                 // 濡傛灉涓嶅瓨鍦紝鎵嶆彃鍏�
                 if (savedParkingAreaInfo == null) {
-                    apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingArea.saveParkingArea";
+                    apiUrl = "parkingArea.saveParkingArea";
                     paramIn.put("communityId", result.getCommunityId());
                     paramIn.put("typeCd", parkingSpace.getTypeCd());
                     paramIn.put("num", parkingSpace.getPaNum());
@@ -296,7 +295,7 @@
                     continue;
                 }
 
-                apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.saveParkingSpace";
+                apiUrl = "parkingSpace.saveParkingSpace";
 
                 paramIn.put("paId", savedParkingAreaInfo.getString("paId"));
                 paramIn.put("communityId", result.getCommunityId());
@@ -373,7 +372,7 @@
                     paramIn.put("cycles", "0");
                 }
 
-                apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.sellParkingSpace";
+                apiUrl = "parkingSpace.sellParkingSpace";
                 responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
 
                 if (responseEntity.getStatusCode() != HttpStatus.OK) {
@@ -445,16 +444,27 @@
         AssetImportLogDetailDto assetImportLogDetailDto = null;
         try {
             for (ImportRoom room : rooms) {
+                paramIn = new JSONObject();
                 JSONObject savedRoomInfo = getExistsRoom(pd, result, room);
                 if (savedRoomInfo != null) {
+                    //濡傛灉绌洪棽鍏ヤ綇涓�涓�
+                    if (RoomDto.STATE_FREE.equals(savedRoomInfo.getString("state")) && room.getImportOwner() != null) {
+                        paramIn.clear();
+                        apiUrl = "room.sellRoom";
+                        paramIn.put("communityId", result.getCommunityId());
+                        paramIn.put("ownerId", room.getImportOwner().getOwnerId());
+                        paramIn.put("roomId", savedRoomInfo.getString("roomId"));
+                        paramIn.put("state", "2001");
+                        paramIn.put("storeId", result.getStoreId());
+                        if (!StringUtil.isEmpty(room.getRoomFeeId()) && "0".equals(room.getRoomFeeId())) {
+                            paramIn.put("feeEndDate", room.getFeeEndDate());
+                        }
+                        responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
+                    }
                     continue;
                 }
-
-                paramIn = new JSONObject();
-
-
                 //淇濆瓨 鎴垮眿
-                apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.saveRoom";
+                apiUrl = "room.saveRoom";
 
                 paramIn.put("communityId", result.getCommunityId());
                 paramIn.put("unitId", room.getFloor().getUnitId());
@@ -517,7 +527,7 @@
                     continue;
                 }
                 paramIn.clear();
-                apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.sellRoom";
+                apiUrl = "room.sellRoom";
                 paramIn.put("communityId", result.getCommunityId());
                 paramIn.put("ownerId", room.getImportOwner().getOwnerId());
                 paramIn.put("roomId", savedRoomInfo.getString("roomId"));
@@ -578,7 +588,7 @@
                         continue;//娌℃湁璐圭敤椤癸紝鍙兘鍐欓敊浜�
                     }
 
-                    apiUrl = ServiceConstant.SERVICE_API_URL + "/api/fee.saveRoomCreateFee";
+                    apiUrl = "fee.saveRoomCreateFee";
                     paramIn.put("communityId", result.getCommunityId());
                     paramIn.put("locationTypeCd", "3000");
                     paramIn.put("locationObjId", savedRoomInfo.getString("roomId"));
@@ -644,7 +654,7 @@
     private JSONObject getExistsParkSpace(IPageData pd, ComponentValidateResult result, ImportParkingSpace parkingSpace) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingSpace.queryParkingSpaces?page=1&row=1&communityId=" + result.getCommunityId()
+        apiUrl = "parkingSpace.queryParkingSpaces?page=1&row=1&communityId=" + result.getCommunityId()
                 + "&num=" + parkingSpace.getPsNum() + "&areaNum=" + parkingSpace.getPaNum();
         responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
@@ -677,7 +687,7 @@
     private JSONObject getExistsFee(IPageData pd, ComponentValidateResult result, ImportFee fee) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/feeConfig.listFeeConfigs?page=1&row=1&communityId=" + result.getCommunityId()
+        apiUrl = "feeConfig.listFeeConfigs?page=1&row=1&communityId=" + result.getCommunityId()
                 + "&feeName=" + fee.getFeeName();
         responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
@@ -711,7 +721,7 @@
     private JSONObject getExistsRoom(IPageData pd, ComponentValidateResult result, ImportRoom room) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.queryRooms?page=1&row=1&communityId=" + result.getCommunityId()
+        apiUrl = "room.queryRooms?page=1&row=1&communityId=" + result.getCommunityId()
                 + "&floorId=" + room.getFloor().getFloorId() + "&unitId=" + room.getFloor().getUnitId() + "&roomNum=" + room.getRoomNum();
         responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
@@ -764,7 +774,7 @@
                 }
                 paramIn = new JSONObject();
 
-                apiUrl = ServiceConstant.SERVICE_API_URL + "/api/owner.saveOwner";
+                apiUrl = "owner.saveOwner";
 
                 paramIn.put("communityId", result.getCommunityId());
                 paramIn.put("userId", result.getUserId());
@@ -772,9 +782,13 @@
                 paramIn.put("age", owner.getAge());
                 paramIn.put("link", owner.getTel());
                 paramIn.put("sex", owner.getSex());
-                paramIn.put("ownerTypeCd", "1001");
+                paramIn.put("ownerTypeCd", owner.getOwnerTypeCd());
                 paramIn.put("idCard", owner.getIdCard());
                 paramIn.put("source", "BatchImport");
+                if (!OwnerDto.OWNER_TYPE_CD_OWNER.equals(owner.getOwnerTypeCd())) {
+                    //鏌ヨ涓氫富ID
+                    paramIn.put("ownerId", getOwnerId(owners, owner));
+                }
                 responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(), apiUrl, HttpMethod.POST);
 
                 /***************************************瀵煎叆鏃ュ織璁板綍****************************************************/
@@ -820,6 +834,15 @@
         return responseEntity;
     }
 
+    private String getOwnerId(List<ImportOwner> owners, ImportOwner owner) {
+        for (ImportOwner owner1 : owners) {
+            if (owner1.getOwnerNum().equals(owner.getParentOwnerId())) {
+                return owner1.getOwnerId();
+            }
+        }
+        throw new IllegalArgumentException("璇峰皢涓氫富鎴愬憳鏀惧埌涓氫富鍚庨潰,鎴栬�呬笟涓绘垚鍛樻湭鎵惧埌瀵瑰簲鐨勪笟涓�");
+    }
+
     /**
      * 淇濆瓨 妤兼爧鍜� 鍗曞厓淇℃伅
      *
@@ -850,7 +873,7 @@
                 JSONObject savedFloorInfo = getExistsFloor(pd, result, importFloor);
                 // 濡傛灉涓嶅瓨鍦紝鎵嶆彃鍏�
                 if (savedFloorInfo == null) {
-                    apiUrl = ServiceConstant.SERVICE_API_URL + "/api/floor.saveFloor";
+                    apiUrl = "floor.saveFloor";
                     paramIn.put("communityId", result.getCommunityId());
                     paramIn.put("floorNum", importFloor.getFloorNum());
                     paramIn.put("userId", result.getUserId());
@@ -898,7 +921,7 @@
                     continue;
                 }
 
-                apiUrl = ServiceConstant.SERVICE_API_URL + "/api/unit.saveUnit";
+                apiUrl = "unit.saveUnit";
 
                 paramIn.put("communityId", result.getCommunityId());
                 paramIn.put("floorId", savedFloorInfo.getString("floorId"));
@@ -954,7 +977,7 @@
     private JSONObject getExistsUnit(IPageData pd, ComponentValidateResult result, ImportFloor importFloor) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/unit.queryUnits?communityId=" + result.getCommunityId()
+        apiUrl = "unit.queryUnits?communityId=" + result.getCommunityId()
                 + "&floorId=" + importFloor.getFloorId() + "&unitNum=" + importFloor.getUnitNum();
         responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
@@ -976,7 +999,7 @@
     private JSONObject getExistsFloor(IPageData pd, ComponentValidateResult result, ImportFloor importFloor) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/floor.queryFloors?page=1&row=1&communityId=" + result.getCommunityId() + "&floorNum=" + importFloor.getFloorNum();
+        apiUrl = "floor.queryFloors?page=1&row=1&communityId=" + result.getCommunityId() + "&floorNum=" + importFloor.getFloorNum();
         responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
         if (responseEntity.getStatusCode() != HttpStatus.OK) { //璺宠繃 淇濆瓨鍗曞厓淇℃伅
@@ -1005,8 +1028,8 @@
     private JSONObject getExistsOwner(IPageData pd, ComponentValidateResult result, ImportOwner importOwner) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/owner.queryOwners?page=1&row=1&communityId=" + result.getCommunityId()
-                + "&ownerTypeCd=1001&name=" + importOwner.getOwnerName() + "&link=" + importOwner.getTel();
+        apiUrl = "owner.queryOwners?page=1&row=1&communityId=" + result.getCommunityId()
+                + "&ownerTypeCd=" + importOwner.getOwnerTypeCd() + "&name=" + importOwner.getOwnerName() + "&link=" + importOwner.getTel();
         responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
         if (responseEntity.getStatusCode() != HttpStatus.OK) { //璺宠繃 淇濆瓨鍗曞厓淇℃伅
@@ -1035,7 +1058,7 @@
     private JSONObject getExistsParkingArea(IPageData pd, ComponentValidateResult result, ImportParkingSpace parkingSpace) {
         String apiUrl = "";
         ResponseEntity<String> responseEntity = null;
-        apiUrl = ServiceConstant.SERVICE_API_URL + "/api/parkingArea.listParkingAreas?page=1&row=1&communityId=" + result.getCommunityId()
+        apiUrl = "parkingArea.listParkingAreas?page=1&row=1&communityId=" + result.getCommunityId()
                 + "&num=" + parkingSpace.getPaNum();
         responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET);
 
@@ -1327,6 +1350,8 @@
                 Assert.hasValue(os[2], "涓氫富淇℃伅閫夐」涓�" + (osIndex + 1) + "琛屼笟涓绘�у埆涓虹┖");
                 String tel = StringUtil.isNullOrNone(os[4]) ? "19999999999" : os[4].toString();
                 String idCard = StringUtil.isNullOrNone(os[5]) ? "10000000000000000001" : os[5].toString();
+                String ownerTypeCd = StringUtil.isNullOrNone(os[6]) ? "1001" : os[6].toString();
+                String parentOwnerId = StringUtil.isNullOrNone(os[7]) ? os[0].toString() : os[7].toString();
 
                 if (os[4].toString().length() > 11) {
                     throw new IllegalArgumentException(os[1].toString() + " 鐨勬墜鏈哄彿瓒呰繃11浣�,璇锋牳瀹�");
@@ -1343,6 +1368,8 @@
                 importOwner.setAge(Integer.parseInt(age));
                 importOwner.setTel(tel);
                 importOwner.setIdCard(idCard);
+                importOwner.setOwnerTypeCd(ownerTypeCd);
+                importOwner.setParentOwnerId(parentOwnerId);
                 owners.add(importOwner);
             } catch (Exception e) {
                 logger.error("绗�" + (osIndex + 1) + "琛屾暟鎹嚭鐜伴棶棰�", e);

--
Gitblit v1.8.0