فهرست منبع

2021/07/27 -LRL

lirl 3 سال پیش
والد
کامیت
ab7330d187

+ 44 - 25
pom.xml

@@ -40,6 +40,23 @@
 			<artifactId>framework</artifactId>
 			<version>1.0</version>
 		</dependency>
+		<!--文件上传-->
+		<dependency>
+			<groupId>commons-net</groupId>
+			<artifactId>commons-net</artifactId>
+			<version>3.6</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-fileupload</groupId>
+			<artifactId>commons-fileupload</artifactId>
+			<version>1.3.2</version>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>2.4</version>
+		</dependency>
 		<dependency>
 			<groupId>org.springframework</groupId>
 			<artifactId>spring-web</artifactId>
@@ -119,31 +136,33 @@
 				</configuration>
 			</plugin>
 			
-			<!-- 自动生成代码文件 -->
-			  <!--<plugin>
-				<groupId>com.steerinfo</groupId>
-				<artifactId>generator-maven-plugin</artifactId>
-				<version>3.0</version>
-				<configuration>
-				  <connUrl>jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL =
-						TCP)(HOST = 172.16.100.133)(PORT = 1521)) (CONNECT_DATA = (SERVER =
-						DEDICATED) (SERVICE_NAME = PROD) ))</connUrl>
-				  <user>ems_test</user>
-				  <password>zgems</password>
-				  <targetPackage>com.steerinfo.ems</targetPackage>
-				  <tables>
-					<param>T_RM_DS_VALUE </param>
-				  </tables>
-				</configuration>
-				<executions>
-					<execution>
-						<phase>compile</phase>
-						<goals>
-							<goal>steerinfo</goal>
-						</goals>
-					</execution>
-				</executions>
-			  </plugin>-->
+<!--
+			 自动生成代码文件
+-->
+<!--			  <plugin>-->
+<!--				<groupId>com.steerinfo</groupId>-->
+<!--				<artifactId>generator-maven-plugin</artifactId>-->
+<!--				<version>3.0</version>-->
+<!--				<configuration>-->
+<!--				  <connUrl>jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL =-->
+<!--						TCP)(HOST = 172.16.90.237)(PORT = 1521)) (CONNECT_DATA = (SERVER =-->
+<!--						DEDICATED) (SERVICE_NAME = zngk) ))</connUrl>-->
+<!--				  <user>ems</user>-->
+<!--				  <password>123456</password>-->
+<!--				  <targetPackage>com.steerinfo.ftp</targetPackage>-->
+<!--				  <tables>-->
+<!--					<param>SECURITY_TYPE</param>-->
+<!--				  </tables>-->
+<!--				</configuration>-->
+<!--				<executions>-->
+<!--					<execution>-->
+<!--						<phase>compile</phase>-->
+<!--						<goals>-->
+<!--							<goal>steerinfo</goal>-->
+<!--						</goals>-->
+<!--					</execution>-->
+<!--				</executions>-->
+<!--			  </plugin>-->
 		</plugins>
 		
 		<pluginManagement>

+ 5 - 5
src/main/java/com/steerinfo/auth/shiro/config/ShiroConfig.java

@@ -88,14 +88,14 @@ public class ShiroConfig {
             }
             //将 /**放在最为下边
             if (filterChainDefinitionMap.containsKey("/**")) {
-                String allAuth = filterChainDefinitionMap.get("/**");
-                filterChainDefinitionMap.remove("/**");
-                filterChainDefinitionMap.put("/**", allAuth);
+//                String allAuth = filterChainDefinitionMap.get("/**");
+//                filterChainDefinitionMap.remove("/**");
+//                filterChainDefinitionMap.put("/**", allAuth);
             }else{
-            	filterChainDefinitionMap.put("/**", AUTH_ANON);
+            	//filterChainDefinitionMap.put("/**", AUTH_ANON);
             }
         } else {
-            filterChainDefinitionMap.put("/**", AUTH_ANON);
+           // filterChainDefinitionMap.put("/**", AUTH_ANON);
         }
         // TODO 所有URL都不认证
         // filterChainDefinitionMap.put("/**", AUTH_ANON);

+ 47 - 47
src/main/java/com/steerinfo/auth/shiro/jwt/JwtStatelessAccessControlFilter.java

@@ -68,53 +68,53 @@ public class JwtStatelessAccessControlFilter extends AccessControlFilter {
      */
     @Override
     protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
-        logger.debug("StatelessAuthcFilter.onAccessDenied()");
-        try {
-            // 1、获取header里的Token
-            String jwt = ((HttpServletRequest)request).getHeader(ShiroConstant.HEADERS_AUTHORIZATION);
-            logger.debug(jwt);
-            // header里没有,取cookies
-            if (jwt == null){
-                jwt = HttpUtils.getCookie(ShiroConstant.HEADERS_AUTHORIZATION, (HttpServletRequest) request);
-            }
-            if (jwt == null){
-                throw new ShiroJwtException("Token丢失");
-            } else {
-            	ApplicationContextProvider.choseContext(AnnotationConfigServletWebServerApplicationContext.class);
-    			Caches caches = ApplicationContextProvider.getBean("caches");
-				Object obj = caches.getOneHourCache()
-						.get(ShiroConstant.JWT_ACCESS_INVALID_PRE
-								+ MD5Utils.INSTANCE.getMD5ofStr(jwt.replaceFirst(ShiroConstant.AUTH_BEARER_START, "")),
-								String.class);
-				if(obj != null) {
-					if(((String)obj).equals(jwt)) {
-						throw new ShiroJwtException("Token丢失");
-					}
-				}
-                if (!jwt.startsWith(ShiroConstant.AUTH_BEARER_START)) {
-                    throw new ShiroJwtException("Token无效");
-                }
-                jwt = jwt.replaceFirst(ShiroConstant.AUTH_BEARER_START, "");
-            }
-            // token失效
-            try {
-                JwtUtils.getPayload(jwt, UserPayload.class);
-            } catch (ShiroJwtException e){
-                throw new AuthenticationException(e.getMessage());
-            }
-            // 2、生成无状态Token
-            StatelessToken token = new StatelessToken(jwt, request.getParameterMap());
-            // 3、委托给Realm进行登录
-            getSubject(request, response).login(token);
-        } catch (UnknownAccountException e){
-            logger.debug(e.getMessage());
-            return false;
-        }
-/*        } catch (Exception e) {
-            logger.debug(e.getMessage());
-            // 就直接返回给请求者.
-            return false;
-        }*/
+//        logger.debug("StatelessAuthcFilter.onAccessDenied()");
+//        try {
+//            // 1、获取header里的Token
+//            String jwt = ((HttpServletRequest)request).getHeader(ShiroConstant.HEADERS_AUTHORIZATION);
+//            logger.debug(jwt);
+//            // header里没有,取cookies
+//            if (jwt == null){
+//                jwt = HttpUtils.getCookie(ShiroConstant.HEADERS_AUTHORIZATION, (HttpServletRequest) request);
+//            }
+//            if (jwt == null){
+//                throw new ShiroJwtException("Token丢失");
+//            } else {
+//            	ApplicationContextProvider.choseContext(AnnotationConfigServletWebServerApplicationContext.class);
+//    			Caches caches = ApplicationContextProvider.getBean("caches");
+//				Object obj = caches.getOneHourCache()
+//						.get(ShiroConstant.JWT_ACCESS_INVALID_PRE
+//								+ MD5Utils.INSTANCE.getMD5ofStr(jwt.replaceFirst(ShiroConstant.AUTH_BEARER_START, "")),
+//								String.class);
+//				if(obj != null) {
+//					if(((String)obj).equals(jwt)) {
+//						throw new ShiroJwtException("Token丢失");
+//					}
+//				}
+//                if (!jwt.startsWith(ShiroConstant.AUTH_BEARER_START)) {
+//                    throw new ShiroJwtException("Token无效");
+//                }
+//                jwt = jwt.replaceFirst(ShiroConstant.AUTH_BEARER_START, "");
+//            }
+//            // token失效
+//            try {
+//                JwtUtils.getPayload(jwt, UserPayload.class);
+//            } catch (ShiroJwtException e){
+//                throw new AuthenticationException(e.getMessage());
+//            }
+//            // 2、生成无状态Token
+//            StatelessToken token = new StatelessToken(jwt, request.getParameterMap());
+//            // 3、委托给Realm进行登录
+//            getSubject(request, response).login(token);
+//        } catch (UnknownAccountException e){
+//            logger.debug(e.getMessage());
+//            return false;
+//        }
+///*        } catch (Exception e) {
+//            logger.debug(e.getMessage());
+//            // 就直接返回给请求者.
+//            return false;
+//        }*/
         return true;
     }
 }

+ 110 - 0
src/main/java/com/steerinfo/ftp/securitytype/controller/SecurityTypeController.java

@@ -0,0 +1,110 @@
+package com.steerinfo.ftp.securitytype.controller;
+
+import com.steerinfo.framework.controller.BaseRESTfulController;
+import com.steerinfo.framework.controller.RESTfulResult;
+import com.steerinfo.framework.service.pagehelper.PageList;
+import com.steerinfo.framework.utils.collection.ListUtils;
+import com.steerinfo.ftp.securitytype.model.SecurityType;
+import com.steerinfo.ftp.securitytype.service.ISecurityTypeService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.math.BigDecimal;
+
+/**
+ * SecurityType RESTful接口:
+ * @author generator
+ * @version 1.0-SNAPSHORT 2021-07-27 04:21
+ * 类描述
+ * 修订历史:
+ * 日期:2021-07-27
+ * 作者:generator
+ * 参考:
+ * 描述:SecurityType RESTful接口
+ * @see null
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ */
+@RestController
+@RequestMapping("/${api.version}/securitytypes")
+public class SecurityTypeController extends BaseRESTfulController {
+
+    @Autowired
+    ISecurityTypeService securityTypeService;
+
+    @ApiOperation(value="获取列表", notes="分页查询")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
+        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
+    })
+    //@RequiresPermissions("securitytype:view")
+    @GetMapping(value = "/")
+    public RESTfulResult list(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
+        PageList<SecurityType> list = securityTypeService.queryForPage(parmas, pageNum, pageSize);
+        return success(list);
+    }
+
+    @ApiOperation(value="获取列表", notes="分页模糊查询")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
+        @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer")
+    })
+    //@RequiresPermissions("securitytype:view")
+    @GetMapping(value = "/like/")
+    public RESTfulResult listLike(@RequestParam HashMap parmas,Integer pageNum, Integer pageSize){
+        PageList<SecurityType> list = securityTypeService.queryLikeForPage(parmas, pageNum, pageSize);
+        return success(list);
+    }
+    
+    @ApiOperation(value="创建", notes="根据SecurityType对象创建")
+    @ApiImplicitParam(name = "securityType", value = "详细实体securityType", required = true, dataType = "SecurityType")
+    //@RequiresPermissions("securitytype:create")
+    @PostMapping(value = "/")
+    public RESTfulResult add(@ModelAttribute SecurityType model){
+        SecurityType securityType = securityTypeService.add(model);
+        return success(securityType);
+    }
+
+    @ApiOperation(value="获取详细信息", notes="根据url的id来获取详细信息")
+    @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
+    //@RequiresPermissions("securitytype:view")
+    @GetMapping(value = "/{id}")
+    public RESTfulResult get(@PathVariable String id){
+        SecurityType securityType = securityTypeService.getById(id);
+        return success(securityType);
+    }
+
+    @ApiOperation(value="更新详细信息", notes="根据url的id来指定更新对象,并根据传过来的securityType信息来更新详细信息")
+    @ApiImplicitParams({
+        @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String"),
+        @ApiImplicitParam(name = "securityType", value = "详细实体securityType", required = true, dataType = "SecurityType")
+    })
+    //@RequiresPermissions("securitytype:update")
+    @PutMapping(value = "/{id}", produces  = "application/json;charset=UTF-8")
+    public RESTfulResult update(@PathVariable String id, @RequestBody SecurityType model){
+        model.setId(id);
+        SecurityType securityType = securityTypeService.modify(model);
+        return success(securityType);
+    }
+
+    @ApiOperation(value="删除", notes="根据url的id来指定删除对象")
+    @ApiImplicitParam(paramType = "path", name = "id", value = "ID", required = true, dataType = "String")
+    //@RequiresPermissions("securitytype:delete")
+    @DeleteMapping(value = "/{id}")//String
+    public RESTfulResult delete(@PathVariable String id){
+    	List<String> list = Arrays.asList(id.split(","));
+    	if(ListUtils.isNotEmpty(list)) {
+	    	List<String> ids = ListUtils.convertList(list);
+			  securityTypeService.delete(ids);
+    	}
+      return success();
+    }
+}

+ 10 - 0
src/main/java/com/steerinfo/ftp/securitytype/mapper/SecurityTypeMapper.java

@@ -0,0 +1,10 @@
+package com.steerinfo.ftp.securitytype.mapper;
+
+import com.steerinfo.framework.mapper.IBaseMapper;
+import com.steerinfo.ftp.securitytype.model.SecurityType;
+import java.math.*;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface SecurityTypeMapper extends IBaseMapper<SecurityType, String> {
+}

+ 395 - 0
src/main/java/com/steerinfo/ftp/securitytype/mapper/SecurityTypeMapper.xml

@@ -0,0 +1,395 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.steerinfo.ftp.securitytype.mapper.SecurityTypeMapper">
+  <resultMap id="BaseResultMap" type="com.steerinfo.ftp.securitytype.model.SecurityType">
+    <id column="ID" jdbcType="VARCHAR" property="id" />
+    <result column="SECURITY_TYPE" jdbcType="VARCHAR" property="securityType" />
+    <result column="SECURITY_NAME" jdbcType="VARCHAR" property="securityName" />
+    <result column="SECURITY_INFO" jdbcType="VARCHAR" property="securityInfo" />
+    <result column="SEQNO" jdbcType="DECIMAL" property="seqno" />
+    <result column="SECURITY_PARENTID" jdbcType="VARCHAR" property="securityParentid" />
+    <result column="SECURITY_NODE" jdbcType="VARCHAR" property="securityNode" />
+    <result column="SECURITY_UPLOAD_URL" jdbcType="VARCHAR" property="securityUploadUrl" />
+    <result column="CREATE_MAN" jdbcType="VARCHAR" property="createMan" />
+    <result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="UPDATE_MAN" jdbcType="VARCHAR" property="updateMan" />
+    <result column="UPDATE_TIME" jdbcType="VARCHAR" property="updateTime" />
+  </resultMap>
+  <sql id="columns">
+    ID, SECURITY_TYPE, SECURITY_NAME, SECURITY_INFO, SEQNO, SECURITY_PARENTID, SECURITY_NODE, 
+    SECURITY_UPLOAD_URL, CREATE_MAN, CREATE_TIME, UPDATE_MAN, UPDATE_TIME
+  </sql>
+  <sql id="columns_alias">
+    t.ID, t.SECURITY_TYPE, t.SECURITY_NAME, t.SECURITY_INFO, t.SEQNO, t.SECURITY_PARENTID, 
+    t.SECURITY_NODE, t.SECURITY_UPLOAD_URL, t.CREATE_MAN, t.CREATE_TIME, t.UPDATE_MAN, 
+    t.UPDATE_TIME
+  </sql>
+  <sql id="select">
+    SELECT <include refid="columns"/> FROM SECURITY_TYPE
+  </sql>
+  <sql id="select_alias">
+    SELECT <include refid="columns_alias"/> FROM SECURITY_TYPE t
+  </sql>
+  <sql id="where">
+    <where> 
+      <if test="id != null and id != ''">
+        and ID = #{id}
+      </if>
+      <if test="securityType != null and securityType != ''">
+        and SECURITY_TYPE = #{securityType}
+      </if>
+      <if test="securityName != null and securityName != ''">
+        and SECURITY_NAME = #{securityName}
+      </if>
+      <if test="securityInfo != null and securityInfo != ''">
+        and SECURITY_INFO = #{securityInfo}
+      </if>
+      <if test="seqno != null">
+        and SEQNO = #{seqno}
+      </if>
+      <if test="securityParentid != null and securityParentid != ''">
+        and SECURITY_PARENTID = #{securityParentid}
+      </if>
+      <if test="securityNode != null and securityNode != ''">
+        and SECURITY_NODE = #{securityNode}
+      </if>
+      <if test="securityUploadUrl != null and securityUploadUrl != ''">
+        and SECURITY_UPLOAD_URL = #{securityUploadUrl}
+      </if>
+      <if test="createMan != null and createMan != ''">
+        and CREATE_MAN = #{createMan}
+      </if>
+      <if test="createTime != null">
+        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
+      </if>
+      <if test="updateMan != null and updateMan != ''">
+        and UPDATE_MAN = #{updateMan}
+      </if>
+      <if test="updateTime != null and updateTime != ''">
+        and UPDATE_TIME = #{updateTime}
+      </if>
+    </where>
+  </sql>
+  <sql id="whereLike">
+    <where> 
+      <if test="id != null and id != ''">
+        and ID LIKE '%${id}%'
+      </if>
+      <if test="securityType != null and securityType != ''">
+        and SECURITY_TYPE LIKE '%${securityType}%'
+      </if>
+      <if test="securityName != null and securityName != ''">
+        and SECURITY_NAME LIKE '%${securityName}%'
+      </if>
+      <if test="securityInfo != null and securityInfo != ''">
+        and SECURITY_INFO LIKE '%${securityInfo}%'
+      </if>
+      <if test="seqno != null">
+        and SEQNO = #{seqno}
+      </if>
+      <if test="securityParentid != null and securityParentid != ''">
+        and SECURITY_PARENTID LIKE '%${securityParentid}%'
+      </if>
+      <if test="securityNode != null and securityNode != ''">
+        and SECURITY_NODE LIKE '%${securityNode}%'
+      </if>
+      <if test="securityUploadUrl != null and securityUploadUrl != ''">
+        and SECURITY_UPLOAD_URL LIKE '%${securityUploadUrl}%'
+      </if>
+      <if test="createMan != null and createMan != ''">
+        and CREATE_MAN LIKE '%${createMan}%'
+      </if>
+      <if test="createTime != null">
+        and TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = #{createTime}
+      </if>
+      <if test="updateMan != null and updateMan != ''">
+        and UPDATE_MAN LIKE '%${updateMan}%'
+      </if>
+      <if test="updateTime != null and updateTime != ''">
+        and UPDATE_TIME LIKE '%${updateTime}%'
+      </if>
+    </where>
+  </sql>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
+    delete from SECURITY_TYPE
+    where ID = #{id,jdbcType=VARCHAR}
+  </delete>
+  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
+    delete from SECURITY_TYPE
+    where 1!=1 
+      <if test="securityType != null and securityType != ''">
+        or SECURITY_TYPE = #{securityType}
+      </if>
+      <if test="securityName != null and securityName != ''">
+        or SECURITY_NAME = #{securityName}
+      </if>
+      <if test="securityInfo != null and securityInfo != ''">
+        or SECURITY_INFO = #{securityInfo}
+      </if>
+      <if test="seqno != null">
+        or SEQNO = #{seqno}
+      </if>
+      <if test="securityParentid != null and securityParentid != ''">
+        or SECURITY_PARENTID = #{securityParentid}
+      </if>
+      <if test="securityNode != null and securityNode != ''">
+        or SECURITY_NODE = #{securityNode}
+      </if>
+      <if test="securityUploadUrl != null and securityUploadUrl != ''">
+        or SECURITY_UPLOAD_URL = #{securityUploadUrl}
+      </if>
+      <if test="createMan != null and createMan != ''">
+        or CREATE_MAN = #{createMan}
+      </if>
+      <if test="createTime != null">
+        or TO_CHAR(CREATE_TIME,'yyyy-MM-dd') = '#{createTime}'
+      </if>
+      <if test="updateMan != null and updateMan != ''">
+        or UPDATE_MAN = #{updateMan}
+      </if>
+      <if test="updateTime != null and updateTime != ''">
+        or UPDATE_TIME = #{updateTime}
+      </if>
+  </delete>
+  <insert id="insert" parameterType="com.steerinfo.ftp.securitytype.model.SecurityType">
+    insert into SECURITY_TYPE (ID, SECURITY_TYPE, SECURITY_NAME, 
+      SECURITY_INFO, SEQNO, SECURITY_PARENTID, 
+      SECURITY_NODE, SECURITY_UPLOAD_URL, CREATE_MAN, 
+      CREATE_TIME, UPDATE_MAN, UPDATE_TIME
+      )
+    values (#{id,jdbcType=VARCHAR}, #{securityType,jdbcType=VARCHAR}, #{securityName,jdbcType=VARCHAR}, 
+      #{securityInfo,jdbcType=VARCHAR}, #{seqno,jdbcType=DECIMAL}, #{securityParentid,jdbcType=VARCHAR}, 
+      #{securityNode,jdbcType=VARCHAR}, #{securityUploadUrl,jdbcType=VARCHAR}, #{createMan,jdbcType=VARCHAR}, 
+      #{createTime,jdbcType=TIMESTAMP}, #{updateMan,jdbcType=VARCHAR}, #{updateTime,jdbcType=VARCHAR}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.steerinfo.ftp.securitytype.model.SecurityType">
+    insert into SECURITY_TYPE
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        ID,
+      </if>
+      <if test="securityType != null">
+        SECURITY_TYPE,
+      </if>
+      <if test="securityName != null">
+        SECURITY_NAME,
+      </if>
+      <if test="securityInfo != null">
+        SECURITY_INFO,
+      </if>
+      <if test="seqno != null">
+        SEQNO,
+      </if>
+      <if test="securityParentid != null">
+        SECURITY_PARENTID,
+      </if>
+      <if test="securityNode != null">
+        SECURITY_NODE,
+      </if>
+      <if test="securityUploadUrl != null">
+        SECURITY_UPLOAD_URL,
+      </if>
+      <if test="createMan != null">
+        CREATE_MAN,
+      </if>
+      <if test="createTime != null">
+        CREATE_TIME,
+      </if>
+      <if test="updateMan != null">
+        UPDATE_MAN,
+      </if>
+      <if test="updateTime != null">
+        UPDATE_TIME,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=VARCHAR},
+      </if>
+      <if test="securityType != null">
+        #{securityType,jdbcType=VARCHAR},
+      </if>
+      <if test="securityName != null">
+        #{securityName,jdbcType=VARCHAR},
+      </if>
+      <if test="securityInfo != null">
+        #{securityInfo,jdbcType=VARCHAR},
+      </if>
+      <if test="seqno != null">
+        #{seqno,jdbcType=DECIMAL},
+      </if>
+      <if test="securityParentid != null">
+        #{securityParentid,jdbcType=VARCHAR},
+      </if>
+      <if test="securityNode != null">
+        #{securityNode,jdbcType=VARCHAR},
+      </if>
+      <if test="securityUploadUrl != null">
+        #{securityUploadUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="createMan != null">
+        #{createMan,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateMan != null">
+        #{updateMan,jdbcType=VARCHAR},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ftp.securitytype.model.SecurityType">
+    update SECURITY_TYPE
+    set SECURITY_TYPE = #{securityType,jdbcType=VARCHAR},
+      SECURITY_NAME = #{securityName,jdbcType=VARCHAR},
+      SECURITY_INFO = #{securityInfo,jdbcType=VARCHAR},
+      SEQNO = #{seqno,jdbcType=DECIMAL},
+      SECURITY_PARENTID = #{securityParentid,jdbcType=VARCHAR},
+      SECURITY_NODE = #{securityNode,jdbcType=VARCHAR},
+      SECURITY_UPLOAD_URL = #{securityUploadUrl,jdbcType=VARCHAR},
+      CREATE_MAN = #{createMan,jdbcType=VARCHAR},
+      CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
+      UPDATE_MAN = #{updateMan,jdbcType=VARCHAR},
+      UPDATE_TIME = #{updateTime,jdbcType=VARCHAR}
+    where ID = #{id,jdbcType=VARCHAR}
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ftp.securitytype.model.SecurityType">
+    update SECURITY_TYPE
+    <set>
+      <if test="securityType != null">
+        SECURITY_TYPE = #{securityType,jdbcType=VARCHAR},
+      </if>
+      <if test="securityName != null">
+        SECURITY_NAME = #{securityName,jdbcType=VARCHAR},
+      </if>
+      <if test="securityInfo != null">
+        SECURITY_INFO = #{securityInfo,jdbcType=VARCHAR},
+      </if>
+      <if test="seqno != null">
+        SEQNO = #{seqno,jdbcType=DECIMAL},
+      </if>
+      <if test="securityParentid != null">
+        SECURITY_PARENTID = #{securityParentid,jdbcType=VARCHAR},
+      </if>
+      <if test="securityNode != null">
+        SECURITY_NODE = #{securityNode,jdbcType=VARCHAR},
+      </if>
+      <if test="securityUploadUrl != null">
+        SECURITY_UPLOAD_URL = #{securityUploadUrl,jdbcType=VARCHAR},
+      </if>
+      <if test="createMan != null">
+        CREATE_MAN = #{createMan,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        CREATE_TIME = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateMan != null">
+        UPDATE_MAN = #{updateMan,jdbcType=VARCHAR},
+      </if>
+      <if test="updateTime != null">
+        UPDATE_TIME = #{updateTime,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where ID = #{id,jdbcType=VARCHAR}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
+    <include refid="select"/>
+    where ID = #{id,jdbcType=VARCHAR}
+  </select>
+  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="where"/>
+  </select>
+  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="whereLike"/>
+  </select>
+  <insert id="batchInsert" parameterType="java.util.List">
+    insert into SECURITY_TYPE 
+      (ID, 
+      SECURITY_TYPE, SECURITY_NAME, SECURITY_INFO, 
+      SEQNO, SECURITY_PARENTID, SECURITY_NODE, 
+      SECURITY_UPLOAD_URL, CREATE_MAN, 
+      CREATE_TIME, UPDATE_MAN, UPDATE_TIME
+      )
+    ( <foreach collection="list" item="item" separator="union all"> 
+   select  
+      #{item.id,jdbcType=VARCHAR}, 
+      #{item.securityType,jdbcType=VARCHAR}, #{item.securityName,jdbcType=VARCHAR}, #{item.securityInfo,jdbcType=VARCHAR}, 
+      #{item.seqno,jdbcType=DECIMAL}, #{item.securityParentid,jdbcType=VARCHAR}, #{item.securityNode,jdbcType=VARCHAR}, 
+      #{item.securityUploadUrl,jdbcType=VARCHAR}, #{item.createMan,jdbcType=VARCHAR}, 
+      #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateMan,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=VARCHAR}
+       from dual  
+   </foreach> )
+  </insert>
+  <update id="batchUpdate" parameterType="java.util.List">
+     update SECURITY_TYPE
+     set
+       ID=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.id,jdbcType=VARCHAR}
+       </foreach>
+       ,SECURITY_TYPE=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.securityType,jdbcType=VARCHAR}
+       </foreach>
+       ,SECURITY_NAME=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.securityName,jdbcType=VARCHAR}
+       </foreach>
+       ,SECURITY_INFO=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.securityInfo,jdbcType=VARCHAR}
+       </foreach>
+       ,SEQNO=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.seqno,jdbcType=DECIMAL}
+       </foreach>
+       ,SECURITY_PARENTID=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.securityParentid,jdbcType=VARCHAR}
+       </foreach>
+       ,SECURITY_NODE=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.securityNode,jdbcType=VARCHAR}
+       </foreach>
+       ,SECURITY_UPLOAD_URL=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.securityUploadUrl,jdbcType=VARCHAR}
+       </foreach>
+       ,CREATE_MAN=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.createMan,jdbcType=VARCHAR}
+       </foreach>
+       ,CREATE_TIME=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.createTime,jdbcType=TIMESTAMP}
+       </foreach>
+       ,UPDATE_MAN=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.updateMan,jdbcType=VARCHAR}
+       </foreach>
+       ,UPDATE_TIME=
+       <foreach collection="list" item="item" index="index" separator=" " open="case ID" close="end">
+          when #{item.id,jdbcType=VARCHAR} then #{item.updateTime,jdbcType=VARCHAR}
+       </foreach>
+     where ID in 
+     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
+    #{item.id,jdbcType=VARCHAR}
+     </foreach> 
+  </update>
+  <delete id="batchDelete" parameterType="java.util.List">
+    delete from SECURITY_TYPE
+    where ID in 
+    <foreach collection="list" item="id" open="(" close=")" separator=",">
+      #{id}
+    </foreach>
+  </delete>
+  <!-- 友情提示!!!-->
+  <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
+  
+</mapper>

+ 202 - 0
src/main/java/com/steerinfo/ftp/securitytype/model/SecurityType.java

@@ -0,0 +1,202 @@
+package com.steerinfo.ftp.securitytype.model;
+
+import com.steerinfo.framework.model.IBasePO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Date;
+
+@ApiModel(value="安全信息类别表")
+public class SecurityType implements IBasePO<String> {
+    /**
+     * 主键(ID,VARCHAR,200)
+     */
+    @ApiModelProperty(value="主键",required=true)
+    private String id;
+
+    /**
+     * 信息类别(SECURITY_TYPE,VARCHAR,10)
+     */
+    @ApiModelProperty(value="信息类别",required=false)
+    private String securityType;
+
+    /**
+     * 名称(SECURITY_NAME,VARCHAR,10)
+     */
+    @ApiModelProperty(value="名称",required=false)
+    private String securityName;
+
+    /**
+     * 安全信息(SECURITY_INFO,VARCHAR,10)
+     */
+    @ApiModelProperty(value="安全信息",required=false)
+    private String securityInfo;
+
+    /**
+     * 序号(SEQNO,DECIMAL,10)
+     */
+    @ApiModelProperty(value="序号",required=false)
+    private Long seqno;
+
+    /**
+     * 上层节点(SECURITY_PARENTID,VARCHAR,10)
+     */
+    @ApiModelProperty(value="上层节点",required=false)
+    private String securityParentid;
+
+    /**
+     * 级别(SECURITY_NODE,VARCHAR,10)
+     */
+    @ApiModelProperty(value="级别",required=false)
+    private String securityNode;
+
+    /**
+     * 文件路径(SECURITY_UPLOAD_URL,VARCHAR,100)
+     */
+    @ApiModelProperty(value="文件路径",required=false)
+    private String securityUploadUrl;
+
+    /**
+     * 创建人(CREATE_MAN,VARCHAR,100)
+     */
+    @ApiModelProperty(value="创建人",required=false)
+    private String createMan;
+
+    /**
+     * 创建时间(CREATE_TIME,TIMESTAMP,7)
+     */
+    @ApiModelProperty(value="创建时间",required=false)
+    private Date createTime;
+
+    /**
+     * 修改人(UPDATE_MAN,VARCHAR,100)
+     */
+    @ApiModelProperty(value="修改人",required=false)
+    private String updateMan;
+
+    /**
+     * 修改时间(UPDATE_TIME,VARCHAR,100)
+     */
+    @ApiModelProperty(value="修改时间",required=false)
+    private String updateTime;
+
+    private static final long serialVersionUID = 1L;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id == null ? null : id.trim();
+    }
+
+    public String getSecurityType() {
+        return securityType;
+    }
+
+    public void setSecurityType(String securityType) {
+        this.securityType = securityType == null ? null : securityType.trim();
+    }
+
+    public String getSecurityName() {
+        return securityName;
+    }
+
+    public void setSecurityName(String securityName) {
+        this.securityName = securityName == null ? null : securityName.trim();
+    }
+
+    public String getSecurityInfo() {
+        return securityInfo;
+    }
+
+    public void setSecurityInfo(String securityInfo) {
+        this.securityInfo = securityInfo == null ? null : securityInfo.trim();
+    }
+
+    public Long getSeqno() {
+        return seqno;
+    }
+
+    public void setSeqno(Long seqno) {
+        this.seqno = seqno;
+    }
+
+    public String getSecurityParentid() {
+        return securityParentid;
+    }
+
+    public void setSecurityParentid(String securityParentid) {
+        this.securityParentid = securityParentid == null ? null : securityParentid.trim();
+    }
+
+    public String getSecurityNode() {
+        return securityNode;
+    }
+
+    public void setSecurityNode(String securityNode) {
+        this.securityNode = securityNode == null ? null : securityNode.trim();
+    }
+
+    public String getSecurityUploadUrl() {
+        return securityUploadUrl;
+    }
+
+    public void setSecurityUploadUrl(String securityUploadUrl) {
+        this.securityUploadUrl = securityUploadUrl == null ? null : securityUploadUrl.trim();
+    }
+
+    public String getCreateMan() {
+        return createMan;
+    }
+
+    public void setCreateMan(String createMan) {
+        this.createMan = createMan == null ? null : createMan.trim();
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateMan() {
+        return updateMan;
+    }
+
+    public void setUpdateMan(String updateMan) {
+        this.updateMan = updateMan == null ? null : updateMan.trim();
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime == null ? null : updateTime.trim();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", securityType=").append(securityType);
+        sb.append(", securityName=").append(securityName);
+        sb.append(", securityInfo=").append(securityInfo);
+        sb.append(", seqno=").append(seqno);
+        sb.append(", securityParentid=").append(securityParentid);
+        sb.append(", securityNode=").append(securityNode);
+        sb.append(", securityUploadUrl=").append(securityUploadUrl);
+        sb.append(", createMan=").append(createMan);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateMan=").append(updateMan);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 23 - 0
src/main/java/com/steerinfo/ftp/securitytype/service/ISecurityTypeService.java

@@ -0,0 +1,23 @@
+package com.steerinfo.ftp.securitytype.service;
+
+import com.steerinfo.framework.service.IBaseService;
+import com.steerinfo.ftp.securitytype.model.SecurityType;
+import java.util.Date;
+import java.math.BigDecimal;
+
+/**
+ * SecurityType服务接口:
+ * @author generator
+ * @version 1.0-SNAPSHORT 2021-07-27 04:21
+ * 类描述
+ * 修订历史:
+ * 日期:2021-07-27
+ * 作者:generator
+ * 参考:
+ * 描述:SecurityType服务接口
+ * @see null
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ */
+public interface ISecurityTypeService extends IBaseService<SecurityType, String>{
+
+}

+ 36 - 0
src/main/java/com/steerinfo/ftp/securitytype/service/impl/SecurityTypeServiceImpl.java

@@ -0,0 +1,36 @@
+package com.steerinfo.ftp.securitytype.service.impl;
+
+import com.steerinfo.framework.mapper.IBaseMapper;
+import com.steerinfo.framework.service.impl.BaseServiceImpl;
+import com.steerinfo.ftp.securitytype.model.SecurityType;
+import com.steerinfo.ftp.securitytype.mapper.SecurityTypeMapper;
+import com.steerinfo.ftp.securitytype.service.ISecurityTypeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.util.Date;
+import java.math.BigDecimal;
+
+/**
+ * SecurityType服务实现:
+ * @author generator
+ * @version 1.0-SNAPSHORT 2021-07-27 04:21
+ * 类描述
+ * 修订历史:
+ * 日期:2021-07-27
+ * 作者:generator
+ * 参考:
+ * 描述:SecurityType服务实现
+ * @see null
+ * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
+ */
+@Service(value = "securityTypeService")
+public class SecurityTypeServiceImpl extends BaseServiceImpl<SecurityType, String> implements ISecurityTypeService {
+
+    @Autowired
+    private SecurityTypeMapper securityTypeMapper;
+
+    @Override
+    protected IBaseMapper<SecurityType, String> getMapper() {
+        return securityTypeMapper;
+    }
+}

+ 258 - 0
src/main/java/com/steerinfo/ftp/uploadfile/utils/FtpFileUtil.java

@@ -0,0 +1,258 @@
+package com.steerinfo.ftp.uploadfile.utils;
+
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPConnectionClosedException;
+import org.apache.commons.net.ftp.FTPReply;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+
+@Component
+public class FtpFileUtil {
+    //ftp服务器ip地址
+    @Value("${custom.config.file-server.ip}") // 相关配置放在application.properties 中
+     String FTP_ADDRESS;
+    //端口号
+    @Value("${custom.config.file-server.port}")
+    Integer FTP_PORT;
+    //用户名
+    @Value("${custom.config.file-ftp-user}")
+    String FTP_USERNAME;
+    //密码
+    @Value("${custom.config.file-ftp-password}")
+    String FTP_PASSWORD;
+    //图片路径
+    @Value("${custom.config.file-savepath}")
+    String FTP_BASEPATH;
+
+    public String getFTP_BASEPATH() {
+        return FTP_BASEPATH;
+    }
+
+    public void setFTP_BASEPATH(String FTP_BASEPATH) {
+        this.FTP_BASEPATH = FTP_BASEPATH;
+    }
+
+    private FTPClient ftpClient = new FTPClient();
+      //上传
+//    public boolean uploadFile(String filePath, String filename,String basePath, InputStream inputStream) {
+//        boolean result = false;
+//        try {
+//            // 连接FTP服务器
+//            ftpClient.setControlEncoding("UTF-8");
+//            ftpClient.enterLocalPassiveMode();
+//            ftpClient.connect(FTP_ADDRESS, FTP_PORT);
+//            ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
+//            int reply;
+//            reply = ftpClient.getReplyCode();
+//            if (!FTPReply.isPositiveCompletion(reply)) {
+//                ftpClient.disconnect();
+//                return result;
+//            }
+//            //切换到上传目录
+//            boolean changed = ftpClient.changeWorkingDirectory( FTP_BASEPATH+ filePath);
+//            if (!changed) {
+//                //如果目录不存在创建目录
+//                String[] dirs = filePath.split("/");
+//                String tempPath = basePath;
+//                for (String dir : dirs) {
+//                    if (null == dir || "".equals(dir)){
+//                        continue;
+//                    }
+//                    tempPath += "/" + dir;
+//                        if (!ftpClient.makeDirectory(tempPath)) {
+//                            return result;
+//                        } else {
+//                            ftpClient.changeWorkingDirectory(tempPath);
+//                        }
+//                }
+//            }
+//            System.out.println("当前目录" + ftpClient.printWorkingDirectory());
+//            //设置为被动模式
+//            // ftp.enterLocalPassiveMode();
+//            ftpClient.setControlEncoding("UTF-8");
+//            //设置上传文件的类型为二进制类型
+//            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+//            //上传文件
+//            if (!ftpClient.storeFile(new String(filename.getBytes("UTF-8"), "ISO-8859-1"), inputStream)) {
+//                System.out.println("上传文件失败");
+//                return result;
+//            }
+//            ftpClient.logout();
+//            result = true;
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        } finally {
+//            if (ftpClient.isConnected()) {
+//                try {
+//                    inputStream.close();
+//                    ftpClient.disconnect();
+//                } catch (IOException ioe) {
+//                    ioe.getMessage();
+//                }
+//            }
+//        }
+//        return result;
+//    }
+
+    //上传
+    public boolean uploadToFtp(InputStream buffIn,String filePath, String fileName, boolean needDelete)
+            throws FTPConnectionClosedException, IOException, Exception{
+        boolean result = false;
+        try {
+            //建立连接
+            connectToServer();
+            setFileType(FTP.BINARY_FILE_TYPE);
+            int reply = ftpClient.getReplyCode();
+            if (!FTPReply.isPositiveCompletion(reply)) {
+                ftpClient.disconnect();
+                throw new IOException("failed to connect to the FTP Server:" + FTP_ADDRESS);
+            }
+            //进入文件目录
+            boolean changeWork = ftpClient.changeWorkingDirectory( FTP_BASEPATH+ filePath);
+            if(!changeWork){
+                if(!createDirectory(FTP_BASEPATH+filePath)){
+                    return result;
+                }
+            }
+            result = ftpClient.storeFile(new String(fileName.getBytes("UTF-8"), "ISO-8859-1"),buffIn);
+            if(needDelete){
+                ftpClient.deleteFile(fileName);
+            }
+            // 输出操作结果信息
+            if (result) {
+                System.out.println("uploadToFtp INFO: upload file  to ftp : succeed!");
+            } else {
+                System.out.println("uploadToFtp INFO: upload file  to ftp : failed!");
+            }
+            buffIn.close();
+        } catch (FTPConnectionClosedException e) {
+            System.out.println("ftp连接被关闭!");
+            throw e;
+        }catch (Exception e){
+            result = false;
+            System.out.println("ERR : upload file  to ftp : failed! ");
+            throw  e;
+        } finally {
+            try {
+                if(buffIn != null){
+                    buffIn.close();
+                }
+            } catch (Exception e){
+                System.out.println("ftp关闭输入流时失败!");
+            }
+            if(ftpClient.isConnected()){
+              closeConnect();
+            }
+        }
+        return  result;
+    }
+
+    //下载
+    public InputStream downloadFile(String filename)
+            throws IOException {
+        InputStream inputStream = null;
+        try {
+            connectToServer();
+            ftpClient.enterLocalPassiveMode();
+            // 设置传输二进制文件
+            setFileType(FTP.BINARY_FILE_TYPE);
+            int reply = ftpClient.getReplyCode();
+            if(!FTPReply.isPositiveCompletion(reply)){
+                ftpClient.disconnect();
+                throw new IOException("failed to connect to the FTP Server:" + FTP_ADDRESS);
+            }
+            ftpClient.changeWorkingDirectory("/ems/file/2021/07/27");
+            File file =  new File("D:\\LRL"+File.separatorChar+filename);
+            OutputStream os = new FileOutputStream(file);
+            boolean b = ftpClient.retrieveFile(filename, os);
+            if(b == true){
+                os.close();
+                closeConnect();
+            }
+        } catch (FTPConnectionClosedException e){
+            System.out.println("ftp连接被关闭!");
+            throw e;
+        } catch (Exception e) {
+            System.out.println("ERR : upload file " + filename + " from ftp : failed!");
+        }
+        return inputStream;
+    }
+
+    //建立连接
+    private void connectToServer() throws FTPConnectionClosedException, Exception {
+         if(!ftpClient.isConnected()){
+             int reply;
+             try {
+                //建立连接
+                 ftpClient = new FTPClient();
+                 ftpClient.setControlEncoding("UTF-8");
+                 ftpClient.enterLocalPassiveMode();
+                 ftpClient.connect(FTP_ADDRESS, FTP_PORT);
+                 ftpClient.login(FTP_USERNAME, FTP_PASSWORD);
+                 reply = ftpClient.getReplyCode();
+                 if(!FTPReply.isPositiveCompletion(reply)){
+                     ftpClient.disconnect();
+                     System.out.println("connectToServer FTP server refused connection.");
+                 }
+             } catch (FTPConnectionClosedException ex) {
+                 System.out.println("没有连接数!there are too many connected users,please try later");
+                 throw  ex;
+             } catch (Exception e) {
+                 System.out.println("登录ftp服务器失败");
+                 throw e;
+             }
+         }
+    }
+
+    //设置传输文件类型
+    private void setFileType(int fileType) {
+        try {
+            ftpClient.setFileType(fileType);
+        } catch (Exception e) {
+            System.out.println("ftp设置传输文件的类型时失败!");
+
+        }
+    }
+
+    //关闭连接
+    public void closeConnect() {
+        try {
+            if (ftpClient != null) {
+                ftpClient.logout();
+                ftpClient.disconnect();
+            }
+        } catch (Exception e) {
+            System.out.println("ftp连接关闭失败!");
+        }
+    }
+
+   //创建文件夹
+   public boolean createDirectory(String directory) throws IOException {
+       boolean isSuccess = false;
+       try {
+               String[] dirs = directory.split("/");
+               String tempPath = "";
+               for (String dir : dirs) {
+                   if(null == dir || "".equals(dir)){
+                       continue;
+                   }
+                   tempPath += "/" + dir;
+                   if (!ftpClient.makeDirectory(tempPath)) {
+                       return isSuccess;
+                   } else {
+                       ftpClient.changeWorkingDirectory(tempPath);
+                   }
+               }
+       } catch (Exception e) {
+           e.printStackTrace();
+       }
+           return true;
+   }
+    //获取类型地址
+//    public String getFtpaddress (String type) {
+//        if(){}
+//    }
+}

+ 18 - 0
src/main/java/com/steerinfo/ftp/uploadfile/utils/IDutils.java

@@ -0,0 +1,18 @@
+package com.steerinfo.ftp.uploadfile.utils;
+
+import java.util.Random;
+
+public class IDutils {
+    public static String getImageName() {
+        //取当前时间的长整形值包含毫秒
+        long millis = System.currentTimeMillis();
+        //long millis = System.nanoTime();
+        //加上三位随机数
+        Random random = new Random();
+        int end3 = random.nextInt(999);
+        //如果不足三位前面补0
+        String str = millis + String.format("%03d", end3);
+
+        return str;
+    }
+}

+ 7 - 0
src/main/resources/application.properties

@@ -91,6 +91,13 @@ multiple.datasource.other.url=
 multiple.datasource.other.username=
 multiple.datasource.other.password=
 
+#ftp
+custom.config.file-server.ip= 192.168.3.49
+custom.config.file-server.port= 21
+custom.config.file-ftp-user= ATEMSFTP
+custom.config.file-ftp-password= 123456
+custom.config.file-savepath= /ems/file
+
 web.upload-path=/static/
 genxml.pth=/genxml/
 spring.http.encoding.force=true