From 4aba5c05fd1c525f2daaa004fbfec45d997b2e29 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 05 十二月 2023 18:27:49 +0800
Subject: [PATCH] 海康接口对接开发

---
 server/dmvisit_service/src/main/java/com/doumee/service/business/CarEventService.java                       |    1 
 server/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java                         |   18 +
 server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java                         |    1 
 .idea/libraries/Maven__commons_net_commons_net_3_8_0.xml                                                    |   13 
 server/dmvisit_service/src/main/java/com/doumee/dao/business/DeviceMapper.java                              |    4 
 server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceInfoResponse.java |   40 ++
 server/dmvisit_service/src/main/java/com/doumee/config/mybatis/EasySqlInjector.java                         |   22 +
 server/dmvisit_service/src/main/java/com/doumee/service/business/HkSyncService.java                         |   12 
 server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/BaseResponse.java                  |    1 
 server/dmvisit_service/src/main/java/com/doumee/core/utils/FtpUtil.java                                     |  652 ++++++++++++++++++++++++++++++++++++
 server/openapi/src/main/java/com/doumee/model/response/erp/UserListRespone.java                             |    2 
 server/dmvisit_service/src/main/java/com/doumee/service/business/impl/HkSyncServiceImpl.java                |  175 +++++++++
 server/pom.xml                                                                                              |    5 
 server/dmvisit_admin/src/main/java/com/doumee/api/business/HkSyncController.java                            |   45 ++
 .idea/compiler.xml                                                                                          |    1 
 server/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java                              |   10 
 server/dmvisit_service/src/main/java/com/doumee/config/mybatis/MyBatisPlusConfig.java                       |    5 
 server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/request/AcsDeviceListRequest.java  |   15 
 server/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java                         |    2 
 server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceListResponse.java |   15 
 server/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java                |   21 +
 21 files changed, 1,051 insertions(+), 9 deletions(-)

diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 97ecee6..92f4050 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -2,6 +2,7 @@
 <project version="4">
   <component name="CompilerConfiguration">
     <annotationProcessing>
+      <profile default="true" name="Default" enabled="true" />
       <profile name="Maven default annotation processors profile" enabled="true">
         <sourceOutputDir name="target/generated-sources/annotations" />
         <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
diff --git a/.idea/libraries/Maven__commons_net_commons_net_3_8_0.xml b/.idea/libraries/Maven__commons_net_commons_net_3_8_0.xml
new file mode 100644
index 0000000..d338100
--- /dev/null
+++ b/.idea/libraries/Maven__commons_net_commons_net_3_8_0.xml
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+  <library name="Maven: commons-net:commons-net:3.8.0">
+    <CLASSES>
+      <root url="jar://$MAVEN_REPOSITORY$/commons-net/commons-net/3.8.0/commons-net-3.8.0.jar!/" />
+    </CLASSES>
+    <JAVADOC>
+      <root url="jar://$MAVEN_REPOSITORY$/commons-net/commons-net/3.8.0/commons-net-3.8.0-javadoc.jar!/" />
+    </JAVADOC>
+    <SOURCES>
+      <root url="jar://$MAVEN_REPOSITORY$/commons-net/commons-net/3.8.0/commons-net-3.8.0-sources.jar!/" />
+    </SOURCES>
+  </library>
+</component>
\ No newline at end of file
diff --git a/server/dmvisit_admin/src/main/java/com/doumee/api/business/HkSyncController.java b/server/dmvisit_admin/src/main/java/com/doumee/api/business/HkSyncController.java
new file mode 100644
index 0000000..1a0ddb4
--- /dev/null
+++ b/server/dmvisit_admin/src/main/java/com/doumee/api/business/HkSyncController.java
@@ -0,0 +1,45 @@
+package com.doumee.api.business;
+
+import com.doumee.api.BaseController;
+import com.doumee.core.annotation.excel.ExcelExporter;
+import com.doumee.core.annotation.pr.PreventRepeat;
+import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest;
+import com.doumee.core.haikang.service.HKService;
+import com.doumee.core.model.ApiResponse;
+import com.doumee.core.model.PageData;
+import com.doumee.core.model.PageWrap;
+import com.doumee.dao.business.model.Device;
+import com.doumee.service.business.DeviceService;
+import com.doumee.service.business.HkSyncService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 姹熻箘韫�
+ * @date 2023/11/30 15:33
+ */
+@Api(tags = "娴峰悍鏁版嵁鍚屾鎺ュ彛")
+@RestController
+@RequestMapping("/business/hksync")
+public class HkSyncController extends BaseController {
+
+    @Autowired
+    private HkSyncService hkSyncService;
+
+    @PreventRepeat
+    @ApiOperation("鍏ㄩ噺鍚屾闂ㄧ璁惧鎺ュ彛")
+    @PostMapping("/getDevices")
+    @RequiresPermissions("business:hksync:device")
+    public ApiResponse getDevices(@RequestBody AcsDeviceListRequest param) {
+        hkSyncService.syncHkDevices(param);
+        return ApiResponse.success(null);
+    }
+
+}
diff --git a/server/dmvisit_service/src/main/java/com/doumee/config/mybatis/EasySqlInjector.java b/server/dmvisit_service/src/main/java/com/doumee/config/mybatis/EasySqlInjector.java
new file mode 100644
index 0000000..748bbf2
--- /dev/null
+++ b/server/dmvisit_service/src/main/java/com/doumee/config/mybatis/EasySqlInjector.java
@@ -0,0 +1,22 @@
+package com.doumee.config.mybatis;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.core.injector.AbstractMethod;
+import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
+import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
+
+import java.util.List;
+
+public class EasySqlInjector extends DefaultSqlInjector {
+
+
+    @Override
+    public List<AbstractMethod> getMethodList(Class<?> mapperClass ) {
+        // 娉ㄦ剰锛氭SQL娉ㄥ叆鍣ㄧ户鎵夸簡DefaultSqlInjector(榛樿娉ㄥ叆鍣�)锛岃皟鐢ㄤ簡DefaultSqlInjector鐨刧etMethodList鏂规硶锛屼繚鐣欎簡mybatis-plus鐨勮嚜甯︽柟娉�
+        List<AbstractMethod> methodList = super.getMethodList(mapperClass);
+        methodList.add(new InsertBatchSomeColumn(i -> i.getFieldFill() != FieldFill.UPDATE));
+        return methodList;
+    }
+
+}
\ No newline at end of file
diff --git a/server/dmvisit_service/src/main/java/com/doumee/config/mybatis/MyBatisPlusConfig.java b/server/dmvisit_service/src/main/java/com/doumee/config/mybatis/MyBatisPlusConfig.java
index 18165ef..e91bb1e 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/config/mybatis/MyBatisPlusConfig.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/config/mybatis/MyBatisPlusConfig.java
@@ -20,4 +20,9 @@
         interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
         return interceptor;
     }
+    @Bean
+    public EasySqlInjector sqlInjector() {
+        return new EasySqlInjector();
+    }
+
 }
diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java
index d38d9c5..d0145f5 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/HKConstants.java
@@ -9,6 +9,7 @@
 public class HKConstants {
     private Logger logger = LoggerFactory.getLogger(HKConstants.class);
     //娴峰悍骞冲彴鏍规嵁鐜板満鐜閰嶇疆http杩樻槸https
+    public static final String RESPONSE_SUCCEE = "0";
     public static String https ;
     /**
      * 鑳藉姏寮�鏀惧钩鍙扮殑缃戠珯璺緞   璺緞涓嶇敤淇敼锛屽氨鏄�/artemis
diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/BaseResponse.java b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/BaseResponse.java
index af0a146..3f4800c 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/BaseResponse.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/BaseResponse.java
@@ -4,6 +4,7 @@
 
 @Data
 public class BaseResponse<T> {
+
     /**
      * 杩斿洖鐮�
      * 0锛氭垚鍔�
diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/request/AcsDeviceListRequest.java b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/request/AcsDeviceListRequest.java
new file mode 100644
index 0000000..e7565da
--- /dev/null
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/request/AcsDeviceListRequest.java
@@ -0,0 +1,15 @@
+package com.doumee.core.haikang.model.param.request;
+
+import lombok.Data;
+
+@Data
+public class AcsDeviceListRequest {
+
+ private String   name	;//string	False	鍚嶇О锛屾ā绯婃悳绱紝鏈�澶ч暱搴�32锛岃嫢鍖呭惈涓枃锛屾渶澶ч暱搴︽寚涓嶈秴杩囨寜鐓ф寚瀹氱紪鐮佺殑瀛楄妭闀垮害锛屽嵆getBytes(鈥渦tf-8鈥�).length
+    private String[]        regionIndexCodes	;//string[]	False	鍖哄煙缂栧彿,鍙互涓虹┖; String[]锛屾敮鎸佹牴鎹尯鍩熸壒閲忔煡璇紱鍖哄煙缂栧彿涓暟<=1000涓紱鍗曚釜闀垮害<=64Byte锛涳紝鍙粠鏌ヨ鍖哄煙鍒楄〃v2鎺ュ彛鑾峰彇杩斿洖鍙傛暟indexCode
+    private Boolean      isSubRegion;//	boolean	False	true鏃讹紝鎼滅储regionIndexCodes鍙婂叾瀛愬瓩鍖哄煙鐨勮祫婧愶紱  false鏃讹紝鍙悳绱� regionIndexCodes鐨勮祫婧�
+    private Integer      pageNo	;//integer	True	褰撳墠椤电爜
+    private Integer      pageSize;//	integer	True	鍒嗛〉澶у皬
+    private String[]     authCodes	;//string[]	False	鏉冮檺鐮侀泦鍚堬紝璇﹁闄勫綍A.3 璧勬簮鏉冮檺鐮佷腑闂ㄧ璁惧瀵瑰簲鐨勮祫婧愭潈闄愮爜
+
+}
diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceInfoResponse.java b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceInfoResponse.java
new file mode 100644
index 0000000..5b4d61a
--- /dev/null
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceInfoResponse.java
@@ -0,0 +1,40 @@
+package com.doumee.core.haikang.model.param.respose;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class AcsDeviceInfoResponse {
+
+ private String   indexCode	;//string	False	璧勬簮鍞竴缂栫爜
+private String   resourceType;//	string	False	璧勬簮绫诲瀷锛岃瑙侀檮褰旳.2 璧勬簮绫诲瀷
+private String   name;//	string	False	璧勬簮鍚嶇О
+private String   parentIndexCode;//	string	False	鐖剁骇璧勬簮缂栧彿
+private String   devTypeCode;//	string	False	闂ㄧ璁惧绫诲瀷缂栫爜锛岃瑙侀檮褰旳.7 闂ㄧ璁惧绫诲瀷涓棬绂佽澶囩被鍨嬬紪鍙�
+private String   devTypeDesc;//	string	False	闂ㄧ璁惧绫诲瀷鍨嬪彿锛岃瑙侀檮褰旳.7 闂ㄧ璁惧绫诲瀷涓棬绂佽澶囩被鍨�
+private String   deviceCode	;//string	False	涓诲姩璁惧缂栧彿
+private String   manufacturer;//	string	False	鍘傚晢
+private String   regionIndexCode;//	string	False	鎵�灞炲尯鍩�
+private String   regionPath	;//string	False	鎵�灞炲尯鍩熻矾寰�,浠绗﹀彿鍒嗗壊锛屽寘鍚湰鑺傜偣
+private String   treatyType;//	string	False	鎺ュ叆鍗忚锛岃瑙侀檮褰旳.6 缂栫爜璁惧鎺ュ叆鍗忚
+private Integer   cardCapacity;//	number	False	璁惧鍗″閲�
+private Integer   fingerCapacity;//	number	False	鎸囩汗瀹归噺
+private Integer   veinCapacity;//	number	False	鎸囬潤鑴夊閲�
+private Integer faceCapacity	;//number	False	浜鸿劯瀹归噺
+private Integer   doorCapacity;//	number	False	闂ㄥ閲�
+private String   deployId	;//string	False	鎷ㄧ爜
+private String   createTime	;//string	False	鍒涘缓鏃堕棿
+private String   updateTime	;//string	False	鏇存柊鏃堕棿
+private String   description;//	string	False	鎻忚堪
+private String   netZoneId	;//string	False	鎵�灞炵綉鍩�
+private String   acsReaderVerifyModeAbility	;//string	False	鏀寔璁よ瘉鏂瑰紡锛屾暟鎹负鍗佽繘鍒�
+private String   regionName	;//string	False	鍖哄煙鍚嶇О
+private String   regionPathName;//	string	False	鎵�灞炲尯鍩熻矾寰勫悕锛屼互"/"鍒嗛殧
+private String   ip	;//string	False	闂ㄧ璁惧IP
+private String   port;//	string	False	闂ㄧ璁惧绔彛
+private String   capability;//	string	False	璁惧鑳藉姏闆�(鍚澶囦笂鐨勬櫤鑳借兘鍔�)锛岃瑙侀檮褰旳.44 璁惧鑳藉姏闆�
+private String   devSerialNum;//	string	False	璁惧搴忓垪鍙�
+private String   dataVersion;//	string	False	鐗堟湰鍙�
+}
diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceListResponse.java b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceListResponse.java
new file mode 100644
index 0000000..c162fec
--- /dev/null
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/model/param/respose/AcsDeviceListResponse.java
@@ -0,0 +1,15 @@
+package com.doumee.core.haikang.model.param.respose;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class AcsDeviceListResponse {
+
+   private int total;//	number	False	鏌ヨ鏁版嵁璁板綍鎬绘暟
+   private int pageSize;//	number	False	姣忛〉璁板綍鎬绘暟
+   private int pageNo	;// number	False	褰撳墠椤电爜
+   private List<AcsDeviceInfoResponse> list	;// object[]	False	鏉冮檺缁勫璞″垪琛�
+
+}
diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java
index 3b332ac..4e57687 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java
@@ -417,6 +417,24 @@
         }
         return  null;
     }
+    /**
+     *闂ㄧ璁惧鏌ヨ锛堝垎椤碉級
+     * @return
+     */
+    public  BaseResponse<AcsDeviceListResponse>   acsDeviceList(AcsDeviceListRequest param){
+        log.error("銆愭捣搴烽棬绂佽澶囨煡璇€��================寮�濮�===="+JSONObject.toJSONString(param));
+        try {
+            String res = HKTools.acsDeviceList(JSONObject.toJSONString(param));
+            TypeReference typeReference =
+                    new TypeReference< BaseResponse<AcsDeviceListResponse> >(){};
+            BaseResponse<AcsDeviceListResponse>   result = JSONObject.parseObject(res, typeReference.getType());
+            log.error("銆愭捣搴烽棬绂佽澶囨煡璇€��================鎴愬姛====\n"+res);
+            return  result;
+        }catch (Exception e){
+            log.error("銆愭捣搴烽棬绂佽澶囨煡璇€��================澶辫触====锛歕n"+ e.getMessage());
+        }
+        return  null;
+    }
 
 }
 
diff --git a/server/dmvisit_service/src/main/java/com/doumee/core/utils/FtpUtil.java b/server/dmvisit_service/src/main/java/com/doumee/core/utils/FtpUtil.java
new file mode 100644
index 0000000..f158543
--- /dev/null
+++ b/server/dmvisit_service/src/main/java/com/doumee/core/utils/FtpUtil.java
@@ -0,0 +1,652 @@
+package com.doumee.core.utils;
+
+import java.io.*;
+import java.util.UUID;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.net.PrintCommandListener;
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import sun.misc.BASE64Encoder;
+
+/** */
+/**
+ * 鏀寔鏂偣缁紶鐨凢TP瀹炵敤绫�
+ *
+ * @author BenZhou http://www.bt285.cn
+ * @version 0.1 瀹炵幇鍩烘湰鏂偣涓婁紶涓嬭浇
+ * @version 0.2 瀹炵幇涓婁紶涓嬭浇杩涘害姹囨姤
+ * @version 0.3 瀹炵幇涓枃鐩綍鍒涘缓鍙婁腑鏂囨枃浠跺垱寤猴紝娣诲姞瀵逛簬涓枃鐨勬敮鎸�
+ */
+@Slf4j
+public class FtpUtil {
+	public FTPClient ftpClient = new FTPClient();
+
+	public FtpUtil() {
+		// 璁剧疆灏嗚繃绋嬩腑浣跨敤鍒扮殑鍛戒护杈撳嚭鍒版帶鍒跺彴
+		this.ftpClient.addProtocolCommandListener(new PrintCommandListener(
+				new PrintWriter(System.out)));
+	}
+
+	public FtpUtil(String hostname, int port, String username, String password)
+			throws IOException {
+		// 璁剧疆灏嗚繃绋嬩腑浣跨敤鍒扮殑鍛戒护杈撳嚭鍒版帶鍒跺彴
+		connect(hostname, port, username, password);
+	}
+
+	/** */
+	/**
+	 * 杩炴帴鍒癋TP鏈嶅姟鍣�
+	 *
+	 * @param hostname
+	 *            涓绘満鍚�
+	 * @param port
+	 *            绔彛
+	 * @param username
+	 *            鐢ㄦ埛鍚�
+	 * @param password
+	 *            瀵嗙爜
+	 * @return 鏄惁杩炴帴鎴愬姛
+	 * @throws IOException
+	 */
+	public boolean connect(String hostname, int port, String username,
+			String password) throws IOException {
+		ftpClient.connect(hostname, port);
+		ftpClient.setControlEncoding("GBK");
+		if (FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
+			if (ftpClient.login(username, password)) {
+				return true;
+			}
+		}
+		disconnect();
+		return false;
+	}
+
+	/** */
+	/**
+	 * 浠嶧TP鏈嶅姟鍣ㄤ笂涓嬭浇鏂囦欢,鏀寔鏂偣缁紶锛屼笂浼犵櫨鍒嗘瘮姹囨姤
+	 *
+	 * @param remote
+	 *            杩滅▼鏂囦欢璺緞
+	 * @param local
+	 *            鏈湴鏂囦欢璺緞
+	 * @return 涓婁紶鐨勭姸鎬�
+	 * @throws IOException
+	 */
+	public String download(String remote, String local) throws IOException {
+		// 璁剧疆琚姩妯″紡
+		ftpClient.enterLocalPassiveMode();
+		// 璁剧疆浠ヤ簩杩涘埗鏂瑰紡浼犺緭
+		ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+
+		String result;
+
+		// 妫�鏌ヨ繙绋嬫枃浠舵槸鍚﹀瓨鍦�
+		FTPFile[] files = ftpClient.listFiles(new String(
+				remote.getBytes("GBK"), "iso-8859-1"));
+		if (files.length != 1) {
+			// System.out.println("杩滅▼鏂囦欢涓嶅瓨鍦�");
+			return "杩滅▼鏂囦欢涓嶅瓨鍦�";
+		}
+
+		long lRemoteSize = files[0].getSize();
+		File f = new File(local);
+		// 鏈湴瀛樺湪鏂囦欢锛岃繘琛屾柇鐐逛笅杞�
+		if (f.exists()) {
+			long localSize = f.length();
+			// 鍒ゆ柇鏈湴鏂囦欢澶у皬鏄惁澶т簬杩滅▼鏂囦欢澶у皬
+			if (localSize >= lRemoteSize) {
+				// System.out.println("鏈湴鏂囦欢澶т簬杩滅▼鏂囦欢锛屼笅杞戒腑姝�");
+				// return "鏈湴鏂囦欢澶т簬杩滅▼鏂囦欢锛屼笅杞戒腑姝�";
+			}
+
+			// 杩涜鏂偣缁紶锛屽苟璁板綍鐘舵��
+			FileOutputStream out = new FileOutputStream(f, true);
+			ftpClient.setRestartOffset(localSize);
+			InputStream in = ftpClient.retrieveFileStream(new String(remote
+					.getBytes("GBK"), "iso-8859-1"));
+			byte[] bytes = new byte[1024];
+			long step = lRemoteSize / 100;
+			long process = localSize / step;
+			int c;
+			while ((c = in.read(bytes)) != -1) {
+				out.write(bytes, 0, c);
+				localSize += c;
+				long nowProcess = localSize / step;
+				if (nowProcess > process) {
+					process = nowProcess;
+					if (process % 10 == 0)
+						System.out.println("涓嬭浇杩涘害锛�" + process);
+					// TODO 鏇存柊鏂囦欢涓嬭浇杩涘害,鍊煎瓨鏀惧湪process鍙橀噺涓�
+				}
+			}
+			in.close();
+			out.close();
+			boolean isDo = ftpClient.completePendingCommand();
+			if (isDo) {
+				result = "300";
+				// result = DownloadStatus.Download_From_Break_Success;
+			} else {
+				result = "400";
+				// result = DownloadStatus.Download_From_Break_Failed;
+			}
+		} else {
+			OutputStream out = new FileOutputStream(f);
+			InputStream in = ftpClient.retrieveFileStream(new String(remote
+					.getBytes("GBK"), "iso-8859-1"));
+			byte[] bytes = new byte[1024];
+			long step = lRemoteSize / 100;
+			long process = 0;
+			long localSize = 0L;
+			int c;
+			while ((c = in.read(bytes)) != -1) {
+				out.write(bytes, 0, c);
+				localSize += c;
+				long nowProcess = localSize / step;
+				if (nowProcess > process) {
+					process = nowProcess;
+					if (process % 10 == 0)
+						System.out.println("涓嬭浇杩涘害锛�" + process);
+					// TODO 鏇存柊鏂囦欢涓嬭浇杩涘害,鍊煎瓨鏀惧湪process鍙橀噺涓�
+				}
+			}
+			in.close();
+			out.close();
+			boolean upNewStatus = ftpClient.completePendingCommand();
+			if (upNewStatus) {
+				result = "500";
+				// result = DownloadStatus.Download_New_Success;
+			} else {
+				// result = DownloadStatus.Download_New_Failed;
+				result = "600";
+			}
+		}
+		return result;
+	}
+
+	/** */
+	/**
+	 * 涓婁紶鏂囦欢鍒癋TP鏈嶅姟鍣紝鏀寔鏂偣缁紶
+	 *
+	 * @param local
+	 *            鏈湴鏂囦欢鍚嶇О锛岀粷瀵硅矾寰�
+	 * @param remote
+	 *            杩滅▼鏂囦欢璺緞锛屼娇鐢�/home/directory1/subdirectory/file.ext鎴栨槸
+	 *            http://www.guihua.org /subdirectory/file.ext
+	 *            鎸夌収Linux涓婄殑璺緞鎸囧畾鏂瑰紡锛屾敮鎸佸绾х洰褰曞祵濂楋紝鏀寔閫掑綊鍒涘缓涓嶅瓨鍦ㄧ殑鐩綍缁撴瀯
+	 * @return 涓婁紶缁撴灉
+	 * @throws IOException
+	 */
+	public String upload(String local, String remote) throws IOException {
+		// 璁剧疆PassiveMode浼犺緭
+		ftpClient.enterLocalPassiveMode();
+
+		// 璁剧疆浠ヤ簩杩涘埗娴佺殑鏂瑰紡浼犺緭
+		ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+		ftpClient.setControlEncoding("GBK");
+		String result;
+		// 瀵硅繙绋嬬洰褰曠殑澶勭悊
+		String remoteFileName = remote;
+		if (remote.contains(File.separator)) {
+			remoteFileName = remote.substring(remote.lastIndexOf(File.separator) + 1);
+			// 鍒涘缓鏈嶅姟鍣ㄨ繙绋嬬洰褰曠粨鏋勶紝鍒涘缓澶辫触鐩存帴杩斿洖
+			if (StringUtils.equals(CreateDirecroty(remote, ftpClient), "2")) {
+				return "2";
+			}
+		}
+
+ 	// 妫�鏌ヨ繙绋嬫槸鍚﹀瓨鍦ㄦ枃浠�
+		FTPFile[] files = ftpClient.listFiles(new String(remoteFileName
+				.getBytes("GBK"), "iso-8859-1"));
+		if (files.length == 1) {
+			long remoteSize = files[0].getSize();
+			File f = new File(local);
+			long localSize = f.length();
+			if (remoteSize == localSize) {
+				return "700";
+				// return UploadStatus.File_Exits;
+			} else if (remoteSize > localSize) {
+				return "800";
+				// return UploadStatus.Remote_Bigger_Local;
+			}
+
+			// 灏濊瘯绉诲姩鏂囦欢鍐呰鍙栨寚閽�,瀹炵幇鏂偣缁紶
+			result = uploadFile(remoteFileName, f, ftpClient, remoteSize);
+
+			// 濡傛灉鏂偣缁紶娌℃湁鎴愬姛锛屽垯鍒犻櫎鏈嶅姟鍣ㄤ笂鏂囦欢锛岄噸鏂颁笂浼�
+			if (StringUtils.equals(result, "1")) {
+				if (!ftpClient.deleteFile(remoteFileName)) {
+					return "1";
+				}
+				result = uploadFile(remoteFileName, f, ftpClient, 0);
+			}
+		} else {
+			result = uploadFile(remoteFileName, new File(local), ftpClient, 0);
+		}
+		return result;
+	}
+	public int getNumFromStr(String str,char searchstr) {
+		int count = 0;
+		char[] charArray = str.toCharArray();
+		for (char param : charArray) {
+			if (param == searchstr) {
+				count++;
+			}
+		}
+		return count;
+	}
+	/** */
+	/**
+	 * 涓婁紶鏂囦欢鍒癋TP鏈嶅姟鍣紝鏀寔鏂偣缁紶
+	 *
+	 * @param localFile
+	 *            鏈湴鏂囦欢娴�
+	 * @param remote
+	 *            杩滅▼鏂囦欢璺緞锛屼娇鐢�/home/directory1/subdirectory/file.ext鎴栨槸
+	 *            http://www.guihua.org /subdirectory/file.ext
+	 *            鎸夌収Linux涓婄殑璺緞鎸囧畾鏂瑰紡锛屾敮鎸佸绾х洰褰曞祵濂楋紝鏀寔閫掑綊鍒涘缓涓嶅瓨鍦ㄧ殑鐩綍缁撴瀯
+	 * @return 涓婁紶缁撴灉
+	 * @throws IOException
+	 */
+	public String uploadFile(File localFile, String remote) throws IOException {
+		// 璁剧疆PassiveMode浼犺緭
+		ftpClient.enterLocalPassiveMode();
+		// 璁剧疆浠ヤ簩杩涘埗娴佺殑鏂瑰紡浼犺緭
+		ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+		ftpClient.setControlEncoding("GBK");
+		String result;
+		// 瀵硅繙绋嬬洰褰曠殑澶勭悊
+		String remoteFileName = remote ;
+		 if (remote.contains(File.separator)) {
+			remoteFileName = remote.substring(remote.lastIndexOf(File.separator) + 1);
+			// 鍒涘缓鏈嶅姟鍣ㄨ繙绋嬬洰褰曠粨鏋勶紝鍒涘缓澶辫触鐩存帴杩斿洖
+			if (StringUtils.equals(CreateDirecroty(remote, ftpClient), "2")) {
+				return "2";
+			}
+		}
+
+		// 妫�鏌ヨ繙绋嬫槸鍚﹀瓨鍦ㄦ枃浠�
+		FTPFile[] files = ftpClient.listFiles(new String(remoteFileName
+				.getBytes("GBK"), "iso-8859-1"));
+		if (files.length == 1) {
+			long remoteSize = files[0].getSize();
+
+			long localSize = localFile.length();
+			if (remoteSize == localSize) {
+				return "700";
+				// return UploadStatus.File_Exits;
+			} else if (remoteSize > localSize) {
+				return "800";
+				// return UploadStatus.Remote_Bigger_Local;
+			}
+
+			// 灏濊瘯绉诲姩鏂囦欢鍐呰鍙栨寚閽�,瀹炵幇鏂偣缁紶
+			result = uploadFile(remoteFileName, localFile, ftpClient,
+					remoteSize);
+
+			// 濡傛灉鏂偣缁紶娌℃湁鎴愬姛锛屽垯鍒犻櫎鏈嶅姟鍣ㄤ笂鏂囦欢锛岄噸鏂颁笂浼�
+			if (StringUtils.equals(result, "1")) {
+				if (!ftpClient.deleteFile(remoteFileName)) {
+					return "1";
+				}
+				result = uploadFile(remoteFileName, localFile, ftpClient, 0);
+			}
+			// if (result == UploadStatus.Upload_From_Break_Failed) {
+			// if (!ftpClient.deleteFile(remoteFileName)) {
+			// return UploadStatus.Delete_Remote_Faild;
+			// }
+			// result = uploadFile(remoteFileName, f, ftpClient, 0);
+			// }
+		} else {
+			result = uploadFile(remoteFileName, localFile, ftpClient, 0);
+		}
+
+		return result;
+	}
+
+	/** */
+	/**
+	 * 鏂紑涓庤繙绋嬫湇鍔″櫒鐨勮繛鎺�
+	 *
+	 * @throws IOException
+	 */
+	public void disconnect() throws IOException {
+		if (ftpClient.isConnected()) {
+			ftpClient.disconnect();
+		}
+	}
+
+	/** */
+	/**
+	 * 閫掑綊鍒涘缓杩滅▼鏈嶅姟鍣ㄧ洰褰�
+	 *
+	 * @param remote
+	 *            杩滅▼鏈嶅姟鍣ㄦ枃浠剁粷瀵硅矾寰�
+	 * @param ftpClient
+	 *            FTPClient瀵硅薄
+	 * @return 鐩綍鍒涘缓鏄惁鎴愬姛
+	 * @throws IOException
+	 */
+	public String CreateDirecroty(String remote, FTPClient ftpClient)
+			throws IOException {
+		String status = "1";
+		// UploadStatus status = UploadStatus.Create_Directory_Success;
+		String directory = remote.substring(0, remote.lastIndexOf(File.separator) + 1);
+		if (!directory.equalsIgnoreCase(File.separator)
+				&& !ftpClient.changeWorkingDirectory(new String(directory
+				.getBytes("GBK"), "iso-8859-1"))) {
+			// 濡傛灉杩滅▼鐩綍涓嶅瓨鍦紝鍒欓�掑綊鍒涘缓杩滅▼鏈嶅姟鍣ㄧ洰褰�
+			int start = 0;
+			int end = 0;
+			if (directory.startsWith(File.separator)) {
+				start = 1;
+			} else {
+				start = 0;
+			}
+			end = directory
+					.indexOf(File.separator, start);
+			while (true) {
+				String subDirectory = new String(remote.substring(start, end)
+						.getBytes("GBK"), "iso-8859-1");
+				if (!ftpClient.changeWorkingDirectory(subDirectory)) {
+					if (ftpClient.makeDirectory(subDirectory)) {
+						ftpClient.changeWorkingDirectory(subDirectory);
+					} else {
+						System.out.println("鍒涘缓鐩綍澶辫触");
+						return "2";
+						// return UploadStatus.Create_Directory_Fail;
+					}
+				}
+
+				start = end + 1;
+				end = directory.indexOf(File.separator,
+						start);
+
+				// 妫�鏌ユ墍鏈夌洰褰曟槸鍚﹀垱寤哄畬姣�
+				if (end <= start) {
+					break;
+				}
+			}
+		}
+		return status;
+	}
+
+	/**
+	 * 涓婁紶鏂囦欢鍒版湇鍔″櫒,鏂颁笂浼犲拰鏂偣缁紶
+	 *
+	 * @param remoteFile
+	 *            杩滅▼鏂囦欢鍚嶏紝鍦ㄤ笂浼犱箣鍓嶅凡缁忓皢鏈嶅姟鍣ㄥ伐浣滅洰褰曞仛浜嗘敼鍙�
+	 * @param localFile
+	 *            鏈湴鏂囦欢File鍙ユ焺锛岀粷瀵硅矾寰�
+	 *            闇�瑕佹樉绀虹殑澶勭悊杩涘害姝ヨ繘鍊�
+	 * @param ftpClient
+	 *            FTPClient寮曠敤
+	 * @return
+	 * @throws IOException
+	 */
+	public String uploadFile(String remoteFile, File localFile,
+			FTPClient ftpClient, long remoteSize) throws IOException {
+		String status;
+		// 鏄剧ず杩涘害鐨勪笂浼�
+		long step = localFile.length() / 100;
+		step=step ==0?1:step;
+		long process = 0;
+		long localreadbytes = 0L;
+//		System.out.println(remoteFile +"-------------------------"+localFile.getPath().toString());
+		RandomAccessFile raf = new RandomAccessFile(localFile, "r");
+		OutputStream out = ftpClient.appendFileStream(new String(remoteFile
+				.getBytes("GBK"), "iso-8859-1"));
+		// 鏂偣缁紶
+		if (remoteSize > 0) {
+			ftpClient.setRestartOffset(remoteSize);
+			process = remoteSize / step;
+			raf.seek(remoteSize);
+			localreadbytes = remoteSize;
+		}
+		byte[] bytes = new byte[1024];
+		int c;
+		while ((c = raf.read(bytes)) != -1) {
+			out.write(bytes, 0, c);
+			localreadbytes += c;
+			if (localreadbytes / step != process) {
+				process = localreadbytes / step;
+				System.out.println("涓婁紶杩涘害:" + process);
+				// TODO 姹囨姤涓婁紶鐘舵��
+			}
+		}
+		out.flush();
+		raf.close();
+		out.close();
+		boolean result = ftpClient.completePendingCommand();
+		if (remoteSize > 0) {
+			status = result ? "0" : "1";
+			// status = result ? UploadStatus.Upload_From_Break_Success
+			// : UploadStatus.Upload_From_Break_Failed;
+		} else {
+			status = result ? "0" : "1";
+			// status = result ? UploadStatus.Upload_New_File_Success
+			// : UploadStatus.Upload_New_File_Failed;
+		}
+		return status;
+	}
+
+	public byte[] getOnlineInputsteam(String url){
+		try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
+			HttpGet httpGet = new HttpGet(url);
+			CloseableHttpResponse resp = httpClient.execute(httpGet);// 璋冪敤鏈嶅姟鍣ㄦ帴鍙�
+//			return  resp.getEntity().getContent();
+			byte[] data = EntityUtils.toByteArray(resp.getEntity());// 灏嗚繑鍥炵殑鍥剧墖鎴栬�呮枃浠惰浆鍖栨垚瀛楄妭鏁扮粍鐨勫舰寮�
+	//		BASE64Encoder encoder = new BASE64Encoder();
+	//		String imageBase64 = encoder.encode(data);
+	//            String imageBase64 = "data:image/jpg;base64," + encoder.encodeBuffer(data).trim();
+	//            imageBase64 = imageBase64.replaceAll("\n", "").replaceAll("\r", "").replaceAll(" ", "");//鍒犻櫎 \r\n
+			return data;
+		} catch (Exception e) {
+			log.error("鑾峰彇鍥剧墖寮傚父:{}",e.getMessage());
+		}
+		return  null;
+	}
+	public boolean uploadOnlineFile(String url,String ftpPath, String fileName) throws Exception
+	{
+		byte[] buf = getOnlineInputsteam(url);
+		if(buf == null){
+			return  false;
+		}
+		try
+		{
+			ftpClient.enterLocalPassiveMode();// 寮�鍚鍔ㄦā寮�
+			ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
+			CreateDirecroty( ftpPath,ftpClient);
+			String printWorkingDirectory = ftpClient.printWorkingDirectory();
+			System.out.println("鑾峰彇褰撳墠鐩綍:" + printWorkingDirectory);
+			boolean flag = ftpClient.storeFile(new String(fileName.getBytes("GBK"), "iso-8859-1"), new ByteArrayInputStream(buf));
+			// 閫氳繃鍙戦�� QUIT 鍛戒护娉ㄩ攢 FTP 鏈嶅姟鍣�
+			ftpClient.logout();
+			return  flag;
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		finally
+		{
+			if (ftpClient.isConnected()){
+					ftpClient.disconnect();
+			}
+
+		}
+		return false;
+	}
+
+	/**
+	 * 鍒犻櫎涓�涓枃浠�
+	 */
+	public boolean deleteFile(String filename) {
+		boolean flag = true;
+		try {
+
+			flag = ftpClient.deleteFile(filename);
+			if (flag) {
+				System.out.println("鍒犻櫎鏂囦欢鎴愬姛锛�");
+			} else {
+				System.out.println("鍒犻櫎鏂囦欢澶辫触锛�");
+			}
+		} catch (IOException ioe) {
+			ioe.printStackTrace();
+		}
+		return flag;
+	}
+
+	public static void main(String[] args) throws Exception {
+		try {
+			FtpUtil ftpUtil = new FtpUtil("175.27.187.84", 21, "ftpuser","doumee168" );
+			ftpUtil.uploadOnlineFile("https://profile-avatar.csdnimg.cn/default.jpg!1", "test"+File.separator, UUID.randomUUID().toString()+"test.jpg");
+			/*FtpUtil myFtp = new FtpUtil("106.15.54.228", 21, "ftptlg",
+					"tlg168.com");
+			System.out.println(myFtp.upload("D:\\devices.sql", "/1111/devices.sql"));
+
+			// myFtp.ftpClient.makeDirectory(new String("鐢佃鍓�".getBytes("GBK"),
+			// "iso-8859-1"));
+			// myFtp.ftpClient.changeWorkingDirectory(new String("鐢佃鍓�"
+			// .getBytes("GBK"), "iso-8859-1"));
+			// myFtp.ftpClient.makeDirectory(new String("璧拌タ鍙�".getBytes("GBK"),
+			// "iso-8859-1"));
+			// System.out.println(myFtp.upload("http://www.5a520.cn /yw.flv",
+			// "/yw.flv", 5));
+			// System.out.println(myFtp.upload("http://www.5a520.cn /璧拌タ鍙�24.mp4",
+			// "/澶璧拌タ鍙�/鏂版氮缃�/璧拌タ鍙�24.mp4"));
+			*//**
+			 * t.connect("pengtu", "61.191.61.226", 2122, "yangnet",
+			 * "yanglong@doumee.com"); File file = new File(
+			 * "D:\\lib/commons-net-3.3-bin/commons-net-3.3/NOTICE.txt");
+			 *
+			 *
+			 *//*
+
+			System.out.println(myFtp.download("/1/2/NOTICE.txt", "D:\\鍝�.txt"));
+
+			myFtp.deleteFile("/1/2/NOTICE.txt");
+			myFtp.disconnect();
+
+			System.out.println("java鐗堟湰鍙凤細" + System.getProperty("java.version")); // java鐗堟湰鍙�
+			System.out
+					.println("Java鎻愪緵鍟嗗悕绉帮細" + System.getProperty("java.vendor")); // Java鎻愪緵鍟嗗悕绉�
+			System.out.println("Java鎻愪緵鍟嗙綉绔欙細"
+					+ System.getProperty("java.vendor.url")); // Java鎻愪緵鍟嗙綉绔�
+			System.out.println("jre鐩綍锛�" + System.getProperty("java.home")); // Java锛屽摝锛屽簲璇ユ槸jre鐩綍
+			System.out.println("Java铏氭嫙鏈鸿鑼冪増鏈彿锛�"
+					+ System.getProperty("java.vm.specification.version")); // Java铏氭嫙鏈鸿鑼冪増鏈彿
+			System.out.println("Java铏氭嫙鏈鸿鑼冩彁渚涘晢锛�"
+					+ System.getProperty("java.vm.specification.vendor")); // Java铏氭嫙鏈鸿鑼冩彁渚涘晢
+			System.out.println("Java铏氭嫙鏈鸿鑼冨悕绉帮細"
+					+ System.getProperty("java.vm.specification.name")); // Java铏氭嫙鏈鸿鑼冨悕绉�
+			System.out.println("Java铏氭嫙鏈虹増鏈彿锛�"
+					+ System.getProperty("java.vm.version")); // Java铏氭嫙鏈虹増鏈彿
+			System.out.println("Java铏氭嫙鏈烘彁渚涘晢锛�"
+					+ System.getProperty("java.vm.vendor")); // Java铏氭嫙鏈烘彁渚涘晢
+			System.out.println("Java铏氭嫙鏈哄悕绉帮細"
+					+ System.getProperty("java.vm.name")); // Java铏氭嫙鏈哄悕绉�
+			System.out.println("Java瑙勮寖鐗堟湰鍙凤細"
+					+ System.getProperty("java.specification.version")); // Java瑙勮寖鐗堟湰鍙�
+			System.out.println("Java瑙勮寖鎻愪緵鍟嗭細"
+					+ System.getProperty("java.specification.vendor")); // Java瑙勮寖鎻愪緵鍟�
+			System.out.println("Java瑙勮寖鍚嶇О锛�"
+					+ System.getProperty("java.specification.name")); // Java瑙勮寖鍚嶇О
+			System.out.println("Java绫荤増鏈彿锛�"
+					+ System.getProperty("java.class.version")); // Java绫荤増鏈彿
+			System.out.println("Java绫昏矾寰勶細"
+					+ System.getProperty("java.class.path")); // Java绫昏矾寰�
+			System.out.println("Java lib璺緞锛�"
+					+ System.getProperty("java.library.path")); // Java lib璺緞
+			System.out.println("Java杈撳叆杈撳嚭涓存椂璺緞锛�"
+					+ System.getProperty("java.io.tmpdir")); // Java杈撳叆杈撳嚭涓存椂璺緞
+			System.out
+					.println("Java缂栬瘧鍣細" + System.getProperty("java.compiler")); // Java缂栬瘧鍣�
+			System.out.println("Java鎵ц璺緞锛�"
+					+ System.getProperty("java.ext.dirs")); // Java鎵ц璺緞
+			System.out.println("鎿嶄綔绯荤粺鍚嶇О锛�" + System.getProperty("os.name")); // 鎿嶄綔绯荤粺鍚嶇О
+			System.out.println("鎿嶄綔绯荤粺鐨勬灦鏋勶細" + System.getProperty("os.arch")); // 鎿嶄綔绯荤粺鐨勬灦鏋�
+			System.out.println("鎿嶄綔绯荤粺鐗堟湰鍙凤細" + System.getProperty("os.version")); // 鎿嶄綔绯荤粺鐗堟湰鍙�
+			System.out.println("鏂囦欢鍒嗛殧绗︼細" + System.getProperty("file.separator")); // 鏂囦欢鍒嗛殧绗�
+			System.out.println("璺緞鍒嗛殧绗︼細" + System.getProperty("path.separator")); // 璺緞鍒嗛殧绗�
+			System.out.println("鐩寸嚎鍒嗛殧绗︼細" + System.getProperty("line.separator")); // 鐩寸嚎鍒嗛殧绗�
+			System.out.println("鎿嶄綔绯荤粺鐢ㄦ埛鍚嶏細" + System.getProperty("user.name")); // 鐢ㄦ埛鍚�
+			System.out.println("鎿嶄綔绯荤粺鐢ㄦ埛鐨勪富鐩綍锛�" + System.getProperty("user.home")); // 鐢ㄦ埛鐨勪富鐩綍
+			System.out.println("褰撳墠绋嬪簭鎵�鍦ㄧ洰褰曪細" + System.getProperty("user.dir")); // 褰撳墠绋嬪簭鎵�鍦ㄧ洰褰�*/
+
+		} catch (IOException e) {
+			System.out.println("杩炴帴FTP鍑洪敊锛�" + e.getMessage());
+		}
+	}
+
+	/***
+	 * @涓婁紶鏂囦欢澶�
+	 * @param localDirectory
+	 *            褰撳湴鏂囦欢澶�
+	 * @param remoteDirectoryPath
+	 *            Ftp 鏈嶅姟鍣ㄨ矾寰� 浠ョ洰褰旻ile.separator缁撴潫
+	 * */
+	public boolean uploadDirectory(String localDirectory,
+			String remoteDirectoryPath) throws Exception {
+		File src = new File(localDirectory);
+		try {
+			remoteDirectoryPath =  remoteDirectoryPath  + File.separator;
+
+//			System.out.println(remoteDirectoryPath+":===============鍒涘缓鐩綍=================");
+			boolean makeDirFlag = this.ftpClient.makeDirectory(remoteDirectoryPath);
+		}catch (IOException e) {
+			e.printStackTrace();
+			log.info(remoteDirectoryPath + "鐩綍鍒涘缓澶辫触");
+			return false;
+		}
+		File[] allFile = src.listFiles();
+		for (int currentFile = 0;currentFile < allFile.length;currentFile++) {
+			File f =allFile[currentFile];
+			String srcName=	f.getPath().toString();
+//			System.out.println(srcName+":====================璇诲彇鏂囦欢======================");
+			String tPath = remoteDirectoryPath+f.getName();
+			if (!f.isDirectory()) {
+
+//				System.out.println(srcName+":====================寮�濮嬩紶杈撴枃浠�======================");
+				int dNum = getNumFromStr(tPath,File.separator.toCharArray()[0]);
+				uploadFile(f, tPath);
+				if(dNum -2>=0){
+					for (int i = 0; i < dNum-1; i++) {
+						this.ftpClient.changeToParentDirectory();
+					}
+				}
+			}else{
+//				System.out.println(srcName+":====================鍒涘缓瀛愮洰褰�======================");
+				uploadDirectory(srcName,
+						tPath+File.separator);
+			}
+//			System.out.println(srcName+":====================涓婁紶瀹屾瘯======================");
+		}
+		return true;
+	}
+	/***
+	 * @涓婁紶鏂囦欢澶�
+	 * @param pathName
+	 *             鏂囦欢澶�
+	 * */
+	public boolean delDirectory(String pathName ) throws Exception {
+		try {
+			this.ftpClient.changeWorkingDirectory( pathName.substring(0, pathName.lastIndexOf(File.separator)) );
+			ftpClient.removeDirectory(pathName);
+		}catch (IOException e) {
+			e.printStackTrace();
+			log.info(pathName + "鐩綍鍒犻櫎澶辫触");
+			return  false;
+		}
+
+		return true;
+	}
+}
diff --git a/server/dmvisit_service/src/main/java/com/doumee/dao/business/DeviceMapper.java b/server/dmvisit_service/src/main/java/com/doumee/dao/business/DeviceMapper.java
index 02a419c..1bb0a15 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/dao/business/DeviceMapper.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/dao/business/DeviceMapper.java
@@ -3,10 +3,14 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.doumee.dao.business.model.Device;
 
+import java.util.Collection;
+
 /**
  * @author 姹熻箘韫�
  * @date 2023/11/30 15:33
  */
 public interface DeviceMapper extends BaseMapper<Device> {
 
+    Integer insertBatchSomeColumn(Collection<Device> entityList);
+
 }
diff --git a/server/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java b/server/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
index 0e8cd14..569d570 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/dao/business/model/Device.java
@@ -52,13 +52,13 @@
     @ExcelColumn(name="澶囨敞")
     private String remark;
 
-    @ApiModelProperty(value = "棰樼洰")
-    @ExcelColumn(name="棰樼洰")
-    private String title;
+    @ApiModelProperty(value = "璁惧埆鍚�")
+    @ExcelColumn(name="璁惧埆鍚�")
+    private String name;
 
     @ApiModelProperty(value = "娴峰悍鏍囪瘑", example = "1")
     @ExcelColumn(name="娴峰悍鏍囪瘑")
-    private Integer hkId;
+    private String hkId;
 
     @ApiModelProperty(value = "娴峰悍鍚屾鐘舵�� 0鏈悓姝� 1宸插悓姝�", example = "1")
     @ExcelColumn(name="娴峰悍鍚屾鐘舵�� 0鏈悓姝� 1宸插悓姝�")
@@ -79,7 +79,7 @@
 
     @ApiModelProperty(value = "璧勬簮绫诲瀷", example = "1")
     @ExcelColumn(name="璧勬簮绫诲瀷")
-    private BigDecimal resourceType;
+    private String resourceType;
 
     @ApiModelProperty(value = "缂栧彿")
     @ExcelColumn(name="缂栧彿")
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/CarEventService.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/CarEventService.java
index 1415373..73284d4 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/CarEventService.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/CarEventService.java
@@ -26,7 +26,6 @@
      * @param id 涓婚敭
      */
     void deleteById(Integer id);
-
     /**
      * 鍒犻櫎
      *
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
index 47d30bc..229c4b8 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/DeviceService.java
@@ -1,5 +1,6 @@
 package com.doumee.service.business;
 
+import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest;
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
 import com.doumee.dao.business.model.Device;
@@ -94,4 +95,5 @@
      * @return long
      */
     long count(Device device);
+
 }
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/HkSyncService.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/HkSyncService.java
new file mode 100644
index 0000000..7aca817
--- /dev/null
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/HkSyncService.java
@@ -0,0 +1,12 @@
+package com.doumee.service.business;
+
+import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest;
+
+/**
+ * 鍋滆溅鍦轰簨浠舵帹閫佽褰曡〃Service瀹氫箟
+ * @author 姹熻箘韫�
+ * @date 2023/11/30 15:33
+ */
+public interface HkSyncService {
+    String syncHkDevices(AcsDeviceListRequest param);
+}
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
index 6d46aff..f2e9eb6 100644
--- a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/DeviceServiceImpl.java
@@ -1,7 +1,16 @@
 package com.doumee.service.business.impl;
 
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.haikang.model.HKConstants;
+import com.doumee.core.haikang.model.param.BaseResponse;
+import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest;
+import com.doumee.core.haikang.model.param.respose.AcsDeviceInfoResponse;
+import com.doumee.core.haikang.model.param.respose.AcsDeviceListResponse;
+import com.doumee.core.haikang.service.HKService;
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Constants;
 import com.doumee.core.utils.Utils;
 import com.doumee.dao.business.DeviceMapper;
 import com.doumee.dao.business.model.Device;
@@ -10,10 +19,14 @@
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -26,6 +39,9 @@
 
     @Autowired
     private DeviceMapper deviceMapper;
+
+    @Autowired
+    private HKService hkService;
 
     @Override
     public Integer create(Device device) {
@@ -112,8 +128,8 @@
         if (pageWrap.getModel().getRemark() != null) {
             queryWrapper.lambda().eq(Device::getRemark, pageWrap.getModel().getRemark());
         }
-        if (pageWrap.getModel().getTitle() != null) {
-            queryWrapper.lambda().eq(Device::getTitle, pageWrap.getModel().getTitle());
+        if (pageWrap.getModel().getName() != null) {
+            queryWrapper.lambda().eq(Device::getName, pageWrap.getModel().getName());
         }
         if (pageWrap.getModel().getHkId() != null) {
             queryWrapper.lambda().eq(Device::getHkId, pageWrap.getModel().getHkId());
@@ -185,4 +201,5 @@
         QueryWrapper<Device> wrapper = new QueryWrapper<>(device);
         return deviceMapper.selectCount(wrapper);
     }
+
 }
diff --git a/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/HkSyncServiceImpl.java b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/HkSyncServiceImpl.java
new file mode 100644
index 0000000..fe25c11
--- /dev/null
+++ b/server/dmvisit_service/src/main/java/com/doumee/service/business/impl/HkSyncServiceImpl.java
@@ -0,0 +1,175 @@
+package com.doumee.service.business.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.haikang.model.HKConstants;
+import com.doumee.core.haikang.model.param.BaseResponse;
+import com.doumee.core.haikang.model.param.request.AcsDeviceListRequest;
+import com.doumee.core.haikang.model.param.respose.AcsDeviceInfoResponse;
+import com.doumee.core.haikang.model.param.respose.AcsDeviceListResponse;
+import com.doumee.core.haikang.service.HKService;
+import com.doumee.core.model.PageData;
+import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Constants;
+import com.doumee.core.utils.DateUtil;
+import com.doumee.core.utils.Utils;
+import com.doumee.dao.business.DeviceMapper;
+import com.doumee.dao.business.model.Device;
+import com.doumee.service.business.DeviceService;
+import com.doumee.service.business.HkSyncService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 璁惧淇℃伅琛⊿ervice瀹炵幇
+ * @author 姹熻箘韫�
+ * @date 2023/11/30 15:33
+ */
+@Service
+public class HkSyncServiceImpl implements HkSyncService {
+
+    @Autowired
+    private DeviceMapper deviceMapper;
+
+    @Autowired
+    private HKService hkService;
+    @Override
+//    @Async
+    public String syncHkDevices(AcsDeviceListRequest param){
+        List<Device> deleteList = new ArrayList<>();
+        List<Device> addList = new ArrayList<>();
+        List<Device> editList = new ArrayList<>();
+        List<AcsDeviceInfoResponse> allHkList = new ArrayList<>();
+        Date date = new Date();
+        //鏌ヨ鍏ㄩ儴闂ㄧ璁惧鏁版嵁
+        List<Device> allList = deviceMapper.selectList(null);
+        boolean hasNext = true;
+        int curTotal = 0;
+        while (hasNext){
+            //鍒嗛〉閬嶅巻寰幆鏌ヨ鎵�鏈夐棬绂佽澶囨暟鎹�
+            param = new AcsDeviceListRequest();
+            param.setPageNo(1);
+            param.setPageSize(10000);
+            BaseResponse<AcsDeviceListResponse> response = hkService.acsDeviceList(param);
+            if(response == null || !StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
+                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(), "瀵逛笉璧凤紝娴峰悍鍚屾鏁版嵁澶辫触~");
+            }
+            AcsDeviceListResponse r = response.getData();
+            curTotal += 10000;
+            if(curTotal >= r.getTotal()){
+                hasNext = false;
+            }
+            List<AcsDeviceInfoResponse> tlist = r.getList();
+        }
+        //鍒ゆ柇鑾峰彇鍒犻櫎鐨勯棬绂佽澶囷紝閫昏緫鍒犻櫎
+        getAddAndEditList(allList,allHkList,addList,editList,date);
+        getDeleteList(allList,allHkList,deleteList,date);
+        if(deleteList.size()>0){
+            //閫昏緫鍒犻櫎
+            for(Device d : deleteList){
+                deviceMapper.updateById(d);
+            }
+        }
+        if(addList.size()>0){
+            deviceMapper.insertBatchSomeColumn(addList);
+        }
+        if(editList.size()>0){
+            for(Device d : editList){
+                deviceMapper.updateById(d);
+            }
+        }
+        return "鍚屾闂ㄧ鏁版嵁锛氭柊澧炪��"+addList.size()+"銆戞潯锛屾洿鏂般��"+editList.size()+"銆戞潯锛屽垹闄ゃ��"+deleteList.size()+"銆戞潯";
+    }
+
+    private void getAddAndEditList(List<Device> allList, List<AcsDeviceInfoResponse> allHkList, List<Device> addList, List<Device> editList, Date date) {
+        if(allHkList!=null && allHkList.size()>0){
+            for(AcsDeviceInfoResponse device : allHkList){
+                Device model = getExistedDevice(device,allList);
+                if(model !=null){
+                    //濡傛灉宸插瓨鍦紝鍒欐洿鏂版暟鎹�
+                    model =  initDeviceByHkData(model,device,date);
+                    editList.add(model);
+                }else{
+                    //濡傛灉涓嶅瓨鍦紝鍒欐柊澧炴暟鎹�
+                    model = new Device();
+                    model =  initDeviceByHkData(model,device,date);
+                    addList.add(model);
+                }
+            }
+        }
+    }
+
+    /**
+     * 鍒濆鍖栨捣搴峰叆搴撴暟鎹�
+     * @param model
+     * @param device
+     * @param date
+     * @return
+     */
+    private Device initDeviceByHkData(Device model, AcsDeviceInfoResponse device,Date date) {
+        model.setIsdeleted(Constants.ZERO);
+        model.setIp(device.getIp());
+        model.setHkDate(date);
+        model.setCreateDate(DateUtil.StringToDate2(device.getCreateTime()));
+        model.setEditDate(DateUtil.StringToDate2(device.getUpdateTime()));
+        model.setNo(device.getDeviceCode());
+        model.setHkId(device.getIndexCode());
+        model.setName(device.getName());
+        model.setHkStatus(Constants.ONE);
+        model.setType(Constants.ZERO);
+        model.setResourceType(device.getResourceType());
+        model.setDevTypeCode(device.getDevTypeCode());
+        model.setManufature(device.getManufacturer());
+        model.setPort(device.getPort());
+        return  model;
+    }
+
+    private Device getExistedDevice(AcsDeviceInfoResponse device, List<Device> allList) {
+        if(allList.size()>0){
+            for(Device r : allList){
+                if(StringUtils.equals(r.getHkId(), device.getIndexCode())){
+                    //琛ㄧず鏈垹闄�
+                    return  r;
+                }
+            }
+        }
+        return  null;
+    }
+
+    private void getDeleteList(List<Device> allList, List<AcsDeviceInfoResponse> allHkList,List<Device> deleteList ,Date date) {
+        if(allList!=null && allList.size()>0){
+            for(Device device : allList){
+                if(isDeletedDevice(device,allHkList)){
+                    device.setIsdeleted(Constants.ONE);
+                    device.setEditDate(date);
+                    deleteList.add(device);
+                }
+            }
+        }
+    }
+
+    private boolean isDeletedDevice(Device device, List<AcsDeviceInfoResponse> allHkList) {
+        if(allHkList.size()>0){
+            for(AcsDeviceInfoResponse r : allHkList){
+                if(StringUtils.equals(device.getHkId(), r.getIndexCode())){
+                    //琛ㄧず鏈垹闄�
+                    return  false;
+                }
+            }
+        }
+        return  true;
+
+    }
+    
+}
diff --git a/server/openapi/src/main/java/com/doumee/model/response/erp/UserListRespone.java b/server/openapi/src/main/java/com/doumee/model/response/erp/UserListRespone.java
index d7ed6f1..459130f 100644
--- a/server/openapi/src/main/java/com/doumee/model/response/erp/UserListRespone.java
+++ b/server/openapi/src/main/java/com/doumee/model/response/erp/UserListRespone.java
@@ -34,7 +34,7 @@
     private Date editDate;
     @ApiModelProperty(value = "鎵�灞炵粍缁囩紪鐮�")
     private String orgId;
-    @ApiModelProperty(value = "浜鸿劯鐓х墖鍦板潃")
+    @ApiModelProperty(value = "浜鸿劯鐓х墖鍦板潃,鍥剧墖鍏綉璁块棶鍦板潃")
     private String faceImg;
     @ApiModelProperty(value = "宸ュ彿")
     private String code;
diff --git a/server/pom.xml b/server/pom.xml
index 32c3e98..034ad1c 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -271,6 +271,11 @@
       <artifactId>artemis-http-client</artifactId>
       <version>1.1.3</version>
     </dependency>
+    <dependency>
+      <groupId>commons-net</groupId>
+      <artifactId>commons-net</artifactId>
+      <version>3.8.0</version>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

--
Gitblit v1.9.3