From d0b19298e28a9b8b50c778704b77160f17e73950 Mon Sep 17 00:00:00 2001
From: jialh <1972868360@qq.com>
Date: 星期五, 17 四月 2026 18:20:38 +0800
Subject: [PATCH] 水电话费

---
 service-api/src/main/java/com/java110/api/importData/adapt/ImportPropertyWhiteListfFlowAdapt.java |  108 ++++++++++++++++++++++++-----------------------------
 1 files changed, 49 insertions(+), 59 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..c7a0be4 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
@@ -6,24 +6,28 @@
 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 {
@@ -47,25 +51,34 @@
         //鑾峰彇杞﹁締淇℃伅
         getPropertyWhiteListFlowDtos(workbook, whiteLists);
 
-        for (PropertyWhiteListFlowDto whiteList : whiteLists){
-            whiteList.setCommunityId(paramIn.getString("communityId"));
-        }
         return whiteLists;
     }
 
 
-    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 (Vtil.defaultValue(os[1]) == null && Vtil.defaultValue(os[2]) == null){
+                throw new IllegalArgumentException("灏忓尯鍚嶇О鍜屽皬鍖虹紪鍙峰潎涓虹┖");
+            }
+            if (Vtil.defaultValue(os[1]) == null) {
+                if (Vtil.defaultValue(map.get("name")).contains(Vtil.defaultValue(os[2]))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            } else if (Vtil.defaultValue(os[2]) == null){
+                if (Vtil.defaultValue(map.get("communityCode")).equals(Vtil.defaultValue(os[1]))) {
+                    po.setCommunityId(map.get("communityId").toString());
+                    return;
+                }
+            } else {
+                if (Vtil.defaultValue(map.get("communityCode")).equals(Vtil.defaultValue(os[1])) && Vtil.defaultValue(map.get("name")).contains(Vtil.defaultValue(os[2]))) {
+                    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(Vtil.defaultValue(os[1])) + Vtil.defaultValue(os[2]));
     }
 
 
@@ -75,15 +88,22 @@
 
     private void getPropertyWhiteListFlowDtos(Workbook workbook, List<PropertyWhiteListFlowDto> whiteLists) {
         Sheet sheet = null;
-        sheet = ImportExcelUtils.getSheet(workbook, "鐧藉崟娴佹按  瀵煎叆鏂版ā鏉�");
-        List<Object[]> oList = ImportExcelUtils.listFromSheet(sheet);
+        List<Object[]> oList;
+        try {
+            sheet = ImportExcelUtils.getSheet(workbook, "鐧藉崟娴佹按  瀵煎叆鏂版ā鏉�");
+            oList = ImportExcelUtils.listFromSheet(sheet);
+        } catch (IllegalArgumentException e) {
+            sheet = ImportExcelUtils.getSheet(workbook, "Sheet1");
+            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 == 1) { // 绗竴琛屾槸 澶撮儴淇℃伅 鐩存帴璺宠繃
+            if (osIndex == 0) { // 绗竴琛屾槸 澶撮儴淇℃伅 鐩存帴璺宠繃
                 continue;
             }
-            if (StringUtil.isNullOrNone(os[3])) {
+            if (os == null || os.length < 4 || StringUtil.isNullOrNone(os[3])) {
                 continue;
             }
             Assert.hasValue(os[3], (osIndex + 1) + "琛屾敹璐规棩鏈熶笉鑳戒负绌�");
@@ -91,22 +111,19 @@
 
             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.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);
-            }
-            white.setCommunityId(getCommunityId(os));
+            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 +142,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 +226,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