From b8bf2507bc7b23c90bc6dc71ea2460e277d3800a Mon Sep 17 00:00:00 2001
From: chengf <cgf12138@163.com>
Date: 星期五, 30 一月 2026 19:23:44 +0800
Subject: [PATCH] 导入测试

---
 service-api/src/main/java/com/java110/api/importData/adapt/ImportPropertyWhiteListfFlowAdapt.java |   88 +++++++++++++++++++-------------------------
 1 files changed, 38 insertions(+), 50 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 a3f299d..6813571 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,29 +1,34 @@
 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.po.meter.MeterWaterPo;
-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.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("importPropertyWhiteListFlowDataCleaning")
 public class ImportPropertyWhiteListfFlowAdapt extends DefaultImportDataAdapt implements IImportDataCleaningAdapt {
@@ -54,18 +59,27 @@
     }
 
 
-    public String getCommunityId(Object[] os) {
-        CommunityDto d = new CommunityDto();
-        d.setCommunityCode(defaultValue(os[1]));
-        d.setName(defaultValue(os[2]));
-        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(d);
-        if (communityDtos.isEmpty()) {
-            throw new IllegalArgumentException("鏈煡璇㈠埌灏忓尯锛�" + d.getCommunityCode() + d.getName());
+
+    public void setCommunityId(PropertyWhiteListFlowDto po, Object[] os, List<Map<String, Object>> maps) {
+        for (Map<String, Object> map : maps) {
+            if (ValueUtil.defaultValue(os[1]).isEmpty()) {
+                if (ValueUtil.defaultValue(os[2]).equals(map.get("name"))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            } else if (ValueUtil.defaultValue(os[2]).isEmpty()){
+                if (ValueUtil.defaultValue(os[1]).equals(map.get("communityCode"))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            } else {
+                if (ValueUtil.defaultValue(os[1]).equals(map.get("communityCode")) && ValueUtil.defaultValue(os[1]).equals(map.get("name"))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            }
         }
-        else if (communityDtos.size() > 1) {
-            throw new IllegalArgumentException("鏌ヨ灏忓尯寮傚父:瀛樺湪澶氫釜绗﹀悎鏉′欢鐨勫皬鍖猴細" + d.getCommunityCode() + d.getName());
-        }
-        return communityDtos.get(0).getCommunityId();
+        throw new IllegalArgumentException("鏈煡璇㈠埌灏忓尯锛�" + Vtil.appendHyphenToRight(ValueUtil.defaultValue(os[1])) + ValueUtil.defaultValue(os[2]));
     }
 
 
@@ -80,7 +94,7 @@
         PropertyWhiteListFlowDto white = null;
         for (int osIndex = 0; osIndex < oList.size(); osIndex++) {
             Object[] os = oList.get(osIndex);
-            if (osIndex == 1) { // 绗竴琛屾槸 澶撮儴淇℃伅 鐩存帴璺宠繃
+            if (osIndex == 0) { // 绗竴琛屾槸 澶撮儴淇℃伅 鐩存帴璺宠繃
                 continue;
             }
             if (StringUtil.isNullOrNone(os[3])) {
@@ -91,22 +105,23 @@
 
             white = new PropertyWhiteListFlowDto();
             String chargeTime = excelDoubleToDate(os[3].toString());
-            String changeStart = defaultValueToDate(os[11]);
-            String changeEnd = defaultValueToDate(os[12]);
-            String bankDepositDate =  defaultValueToDate(os[16]);
+            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[24] != null){
-                inputTime = defaultValueToDate(os[24]);
+                inputTime = Vtil.defaultValueToDate(os[24]);
             }
             white.setChargeTime(chargeTime);//鏀惰垂鏃堕棿
-            white.setInvoiceReceiptNo(defaultValueToDate(os[4]));//鍙戠エ
+            white.setInvoiceReceiptNo(Vtil.defaultValueToDate(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);
             }
-            white.setCommunityId(getCommunityId(os));
+            List<Map<String, Object>> maps = BeanConvertUtil.beanCovertMapListC(communityInnerServiceSMOImpl.queryCommunitys(new CommunityDto()));
+            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());//鏀惰垂浜�
@@ -125,7 +140,7 @@
             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(defaultValueToDate(os[26]));
+            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());
@@ -209,31 +224,4 @@
 //            whiteLists.add(white);
 //        }
 //    }
-
-    private String defaultValueToDate(Object o) {
-        // 绌哄�肩洿鎺ヨ繑鍥瀗ull锛堝師鏈夐�昏緫锛�
-        if (o == null) {
-            return null;
-        }
-
-        try {
-            // 灏濊瘯灏嗗璞¤浆鎹负鏁板瓧锛堝吋瀹笶xcel鏃ユ湡搴忓垪鍙凤紝濡�44747锛�
-            double excelDateNum = Double.parseDouble(o.toString());
-
-            // Excel 1900鏃ユ湡绯荤粺鍩哄噯锛堜慨姝i棸鏃ug锛屽疄闄呭熀鍑嗘槸1899-12-30锛�
-            Calendar calendar = Calendar.getInstance();
-            calendar.set(1899, 11, 30, 0, 0, 0); // 鏈堜唤浠�0寮�濮嬶紝11浠h〃12鏈�
-            calendar.set(Calendar.MILLISECOND, 0);
-
-            // 璁$畻瀵瑰簲鐨勫疄闄呮棩鏈�
-            calendar.add(Calendar.DAY_OF_MONTH, (int) excelDateNum);
-
-            // 鏍煎紡鍖栦负yyyy-MM-dd鐨勬棩鏈熷瓧绗︿覆
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-            return sdf.format(calendar.getTime());
-        } catch (NumberFormatException e) {
-            // 闈炴暟瀛楃被鍨嬶紝鎵ц鍘熸湁閫昏緫杩斿洖toString()
-            return o.toString();
-        }
-    }
 }

--
Gitblit v1.8.0