From b88a288f4f787b509463678e3cd9ccfa3f37014b Mon Sep 17 00:00:00 2001
From: chengf <cgf12138@163.com>
Date: 星期三, 11 三月 2026 12:01:05 +0800
Subject: [PATCH] 导入测试

---
 service-api/src/main/java/com/java110/api/importData/adapt/ImportPropertyWhiteListfFlowAdapt.java |  207 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 162 insertions(+), 45 deletions(-)

diff --git a/service-api/src/main/java/com/java110/api/importData/adapt/ImportPropertyWhiteListfFlowAdapt.java b/service-api/src/main/java/com/java110/api/importData/adapt/ImportPropertyWhiteListfFlowAdapt.java
index c7dd316..7d31b27 100644
--- a/service-api/src/main/java/com/java110/api/importData/adapt/ImportPropertyWhiteListfFlowAdapt.java
+++ b/service-api/src/main/java/com/java110/api/importData/adapt/ImportPropertyWhiteListfFlowAdapt.java
@@ -1,26 +1,36 @@
 package com.java110.api.importData.adapt;
 
 import com.alibaba.fastjson.JSONObject;
+import com.java110.api.components.ValueUtil;
 import com.java110.api.importData.DefaultImportDataAdapt;
 import com.java110.api.importData.IImportDataCleaningAdapt;
 import com.java110.dto.PropertyWhiteListFlowDto;
+import com.java110.dto.community.CommunityDto;
 import com.java110.dto.importData.ImportRoomFee;
+import com.java110.dto.importData.Vtil;
 import com.java110.dto.system.ComponentValidateResult;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
 import com.java110.intf.fee.IPayFeeBatchV1InnerServiceSMO;
 import com.java110.intf.user.IUserInnerServiceSMO;
-import com.java110.utils.util.Assert;
-import com.java110.utils.util.DateUtil;
-import com.java110.utils.util.ImportExcelUtils;
-import com.java110.utils.util.StringUtil;
+import com.java110.po.meter.MeterWaterPo;
+import com.java110.utils.util.*;
+import org.apache.commons.lang.time.DateUtils;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.List;
+import java.util.Map;
 
-@Service("importPropertyWhiteListfFlowDataCleaning")
+@Service("importPropertyWhiteListFlowDataCleaning")
 public class ImportPropertyWhiteListfFlowAdapt extends DefaultImportDataAdapt implements IImportDataCleaningAdapt {
 
 
@@ -29,6 +39,9 @@
 
     @Autowired
     private IUserInnerServiceSMO userInnerServiceSMOImpl;
+
+    @Autowired
+    private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
 
 
     @Override
@@ -39,60 +52,99 @@
         //鑾峰彇杞﹁締淇℃伅
         getPropertyWhiteListFlowDtos(workbook, whiteLists);
 
-        for (PropertyWhiteListFlowDto whiteList : whiteLists){
-            whiteList.setCommunityId(paramIn.getString("communityId"));
-        }
         return whiteLists;
+    }
+
+
+
+    public void setCommunityId(PropertyWhiteListFlowDto po, Object[] os, List<Map<String, Object>> maps) {
+        for (Map<String, Object> map : maps) {
+            if (ValueUtil.defaultValue(os[1]).isEmpty() && ValueUtil.defaultValue(os[2]).isEmpty()){
+                throw new IllegalArgumentException("灏忓尯鍚嶇О鍜屽皬鍖虹紪鍙峰潎涓虹┖");
+            }
+            if (ValueUtil.defaultValue(os[1]).isEmpty()) {
+                if (Vtil.defaultValue(map.get("name")).contains(ValueUtil.defaultValue(os[2]))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            } else if (ValueUtil.defaultValue(os[2]).isEmpty()){
+                if (Vtil.defaultValue(map.get("communityCode")).equals(ValueUtil.defaultValue(os[1]))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            } else {
+                if (Vtil.defaultValue(map.get("communityCode")).equals(ValueUtil.defaultValue(os[1])) && Vtil.defaultValue(map.get("name")).contains(ValueUtil.defaultValue(os[2]))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            }
+        }
+        throw new IllegalArgumentException("鏈煡璇㈠埌灏忓尯锛�" + Vtil.appendHyphenToRight(ValueUtil.defaultValue(os[1])) + ValueUtil.defaultValue(os[2]));
+    }
+
+
+    public String defaultValue(Object o) {
+        return o == null ? "" : o.toString();
     }
 
     private void getPropertyWhiteListFlowDtos(Workbook workbook, List<PropertyWhiteListFlowDto> whiteLists) {
         Sheet sheet = null;
-        sheet = ImportExcelUtils.getSheet(workbook, "鐧藉崟娴佹按锛堝綊妗f暟鎹級");
+        sheet = ImportExcelUtils.getSheet(workbook, "鐧藉崟娴佹按  瀵煎叆鏂版ā鏉�");
         List<Object[]> oList = ImportExcelUtils.listFromSheet(sheet);
         PropertyWhiteListFlowDto white = null;
+        List<Map<String, Object>> maps = BeanConvertUtil.beanCovertMapListC(communityInnerServiceSMOImpl.queryCommunitys(new CommunityDto()));
         for (int osIndex = 0; osIndex < oList.size(); osIndex++) {
             Object[] os = oList.get(osIndex);
             if (osIndex == 0) { // 绗竴琛屾槸 澶撮儴淇℃伅 鐩存帴璺宠繃
                 continue;
             }
-            if (StringUtil.isNullOrNone(os[0])) {
+            if (StringUtil.isNullOrNone(os[3])) {
                 continue;
             }
-            Assert.hasValue(os[0], (osIndex + 1) + "琛屾敹璐规棩鏈熶笉鑳戒负绌�");
+            Assert.hasValue(os[3], (osIndex + 1) + "琛屾敹璐规棩鏈熶笉鑳戒负绌�");
+
 
             white = new PropertyWhiteListFlowDto();
-            String chargeTime = excelDoubleToDate(os[0].toString());
-            String changeStart = os[21] == null ? null : excelDoubleToDate(os[21].toString());
-            String changeEnd = os[22] == null ? null : excelDoubleToDate(os[22].toString());
-            String bankDepositDate =  os[8] == null ? null : excelDoubleToDate(os[8].toString());
+            String chargeTime = excelDoubleToDate(os[3].toString());
+            String changeStart = Vtil.defaultValueToDate(os[11],"start");
+            String changeEnd = Vtil.defaultValueToDate(os[12],"end");
+            String bankDepositDate =  Vtil.defaultValueToDate(os[16]);
             String inputTime = null;
-            if(os[16] != null){
-                inputTime = excelDoubleToDate(os[16].toString().split("\\.")[0]);
+            if(os[24] != null){
+                inputTime = Vtil.defaultValueToDate(os[24]);
             }
-            white.setChargeTime(chargeTime);
-            white.setInvoiceReceiptNo(os[1] == null ? null : os[1].toString());
-            white.setRoomId(os[2] == null ? null : os[2].toString());
-            white.setPropertyAddress(os[3] == null ? null : os[3].toString());
-            white.setDoorRoomNum(os[4] == null ? null : os[4].toString());
-            white.setSecondaryFeeTypeCd(os[5] == null ? null : os[5].toString());
-            white.setChargeAmount(os[6] == null ? null : os[6].toString());
-            white.setCharger(os[7] == null ? null : os[7].toString());
-            white.setBankDepositDate(bankDepositDate);
-            white.setBankDepositor(os[9] == null ? null : os[9].toString());
-            white.setSplitBankDepositAmount(os[10] == null ? null : os[10].toString());
-            white.setBankDepositAmount(os[11] == null ? null : os[11].toString());
-            white.setCheckAmount(os[12] == null ? null : os[12].toString());
-            white.setWhiteListArchiveNo(os[13] == null ? null : os[13].toString());
-            white.setSheetCount(os[14] == null ? null : os[14].toString());
-            white.setFinancialReceiver(os[15] == null ? null : os[15].toString());
-            white.setInputTime(inputTime);
-            white.setInputPerson(os[17] == null ? null : os[17].toString());
-            white.setOrderNo(os[18] == null ? null : os[18].toString());
-            white.setLicensePlate(os[19] == null ? null : os[19].toString());
-            white.setCategory22(os[20] == null ? null : os[20].toString());
-            if (os.length > 23){
-                white.setFrequency(os[23] == null ? null : os[23].toString());
+            white.setChargeTime(chargeTime);//鏀惰垂鏃堕棿
+            white.setInvoiceReceiptNo(Vtil.defaultValue(os[4]));//鍙戠エ
+            white.setRoomId(os[5] == null ? null : os[5].toString());//鎴垮彿
+            white.setPropertyAddress(os[5] == null ? null : os[5].toString());//涓氫富鍦板潃
+            white.setDoorRoomNum((os[6] == null ? "" : os[6].toString() + "-") + (os[7] == null ? "" : os[7].toString() + "-") + (os[8] == null ? "" : os[8].toString()) );//闂ㄥ競鍙�
+            if (white.getDoorRoomNum().isEmpty()){
+                white.setDoorRoomNum(null);
             }
+            setCommunityId(white, os, maps);
+            white.setSecondaryFeeTypeCd(os[13] == null ? null : os[13].toString());//鏀惰垂鍐呭
+            white.setChargeAmount(os[14] == null ? null : os[14].toString());//鏀惰垂閲戦
+            white.setCharger(os[15] == null ? null : os[15].toString());//鏀惰垂浜�
+            white.setBankDepositDate(bankDepositDate);//閾惰瑙f鏃ユ湡
+            white.setBankDepositor(os[17] == null ? null : os[17].toString());//閾惰瑙f浜�
+            white.setSplitBankDepositAmount(os[18] == null ? null : os[18].toString());//鎷嗗垎鍚庨摱琛岃В娆鹃噾棰�
+            white.setBankDepositAmount(os[19] == null ? null : os[19].toString());//閾惰瑙f閲戦
+            white.setCheckAmount(os[20] == null ? null : os[20].toString());//鏍稿閲戦
+            white.setWhiteListArchiveNo(os[21] == null ? null : os[21].toString());//鐧藉崟瀛樻。缂栧彿
+            white.setSheetCount(os[22] == null ? null : os[22].toString());//寮犳暟
+            white.setFinancialReceiver(os[23] == null ? null : os[23].toString());//璐㈠姟鏀惰处浜�
+            white.setInputTime(inputTime);//杈撳叆鏃堕棿
+            white.setInputPerson(os[25] == null ? null : os[25].toString());//杈撳叆浜哄憳
+            white.setOrderNo(os[28] == null ? null : os[28].toString());//鍗曞彿
+            white.setLicensePlate(os[29] == null ? null : os[29].toString());//杞︾墝鍙�
+            white.setCategory22(os[31] == null ? null : os[31].toString());//25椤规敹璐瑰垎绫�
+            white.setRoomNumber(os[9] == null ? null : os[9].toString());
+            white.setReceiptYear(os[27] == null ? null : os[27].toString());
+            white.setReceiptYearMonth(Vtil.defaultValueToDate(os[26]));
+            white.setPendingProblem(os[30] == null ? null : os[30].toString());
+//            if (os.length > 23){
+//                white.setFrequency(os[23] == null ? null : os[23].toString());
+//            }
             white.setChargeStart(changeStart);
             white.setChargeEnd(changeEnd);
             white.setRow(osIndex + 1);
@@ -100,11 +152,76 @@
         }
     }
 
-    /**
-     * 鐢熸垚鎵规鍙�
-     *
-     * @param reqJson
-     */
+    public static Object[] removeElement(Object[] original, int index) {
+        // 鏍¢獙鍘熸暟缁勬槸鍚︿负绌烘垨绱㈠紩瓒婄晫
+        if (original == null || index < 0 || index >= original.length) {
+            return original; // 鎴栨姏鍑哄紓甯革紝鏍规嵁闇�姹傚鐞�
+        }
 
+        // 鍒涘缓鏂版暟缁勶紙闀垮害 = 鍘熸暟缁勯暱搴� - 1锛�
+        Object[] newArray = new Object[original.length - 1];
 
+        // 澶嶅埗绱㈠紩4涔嬪墠鐨勫厓绱狅紙0~3锛�
+        System.arraycopy(original, 0, newArray, 0, index);
+
+        // 澶嶅埗绱㈠紩4涔嬪悗鐨勫厓绱狅紙5~鏈熬锛夛紝浠庢柊鏁扮粍鐨刬ndex浣嶇疆寮�濮�
+        System.arraycopy(original, index + 1, newArray, index, original.length - index - 1);
+
+        return newArray;
+    }
+//
+//    private void getPropertyWhiteListFlowDtosV1(Workbook workbook, List<PropertyWhiteListFlowDto> whiteLists) {
+//        Sheet sheet = null;
+//        sheet = ImportExcelUtils.getSheet(workbook, "鐧藉崟娴佹按锛堝綊妗f暟鎹級");
+//        List<Object[]> oList = ImportExcelUtils.listFromSheet(sheet);
+//        PropertyWhiteListFlowDto white = null;
+//        for (int osIndex = 0; osIndex < oList.size(); osIndex++) {
+//            Object[] os = oList.get(osIndex);
+//            if (osIndex == 0) { // 绗竴琛屾槸 澶撮儴淇℃伅 鐩存帴璺宠繃
+//                continue;
+//            }
+//            if (StringUtil.isNullOrNone(os[0])) {
+//                continue;
+//            }
+//            Assert.hasValue(os[0], (osIndex + 1) + "琛屾敹璐规棩鏈熶笉鑳戒负绌�");
+//
+//            white = new PropertyWhiteListFlowDto();
+//            String chargeTime = excelDoubleToDate(os[0].toString());
+//            String changeStart = os[21] == null ? null : excelDoubleToDate(os[21].toString());
+//            String changeEnd = os[22] == null ? null : excelDoubleToDate(os[22].toString());
+//            String bankDepositDate =  os[8] == null ? null : excelDoubleToDate(os[8].toString());
+//            String inputTime = null;
+//            if(os[16] != null){
+//                inputTime = excelDoubleToDate(os[16].toString().split("\\.")[0]);
+//            }
+//            white.setChargeTime(chargeTime);
+//            white.setInvoiceReceiptNo(os[1] == null ? null : os[1].toString());
+//            white.setRoomId(os[2] == null ? null : os[2].toString());
+//            white.setPropertyAddress(os[3] == null ? null : os[3].toString());
+//            white.setDoorRoomNum(defaultValueToDate(os[4]));
+//            white.setSecondaryFeeTypeCd(os[5] == null ? null : os[5].toString());
+//            white.setChargeAmount(os[6] == null ? null : os[6].toString());
+//            white.setCharger(os[7] == null ? null : os[7].toString());
+//            white.setBankDepositDate(bankDepositDate);
+//            white.setBankDepositor(os[9] == null ? null : os[9].toString());
+//            white.setSplitBankDepositAmount(os[10] == null ? null : os[10].toString());
+//            white.setBankDepositAmount(os[11] == null ? null : os[11].toString());
+//            white.setCheckAmount(os[12] == null ? null : os[12].toString());
+//            white.setWhiteListArchiveNo(os[13] == null ? null : os[13].toString());
+//            white.setSheetCount(os[14] == null ? null : os[14].toString());
+//            white.setFinancialReceiver(os[15] == null ? null : os[15].toString());
+//            white.setInputTime(inputTime);
+//            white.setInputPerson(os[17] == null ? null : os[17].toString());
+//            white.setOrderNo(os[18] == null ? null : os[18].toString());
+//            white.setLicensePlate(os[19] == null ? null : os[19].toString());
+//            white.setCategory22(os[20] == null ? null : os[20].toString());
+//            if (os.length > 23){
+//                white.setFrequency(os[23] == null ? null : os[23].toString());
+//            }
+//            white.setChargeStart(changeStart);
+//            white.setChargeEnd(changeEnd);
+//            white.setRow(osIndex + 1);
+//            whiteLists.add(white);
+//        }
+//    }
 }

--
Gitblit v1.8.0