Forráskód Böngészése

[chg]增加消息工具类Messageutils和日志切面ControllerAspect

别傲 5 éve
szülő
commit
1a8d38cc52

+ 520 - 0
lift-manager-service/src/main/java/cn/com/ty/lift/manager/framework/BusinessBasicException.java

@@ -0,0 +1,520 @@
+package cn.com.ty.lift.manager.framework;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * @author bieao
+ * @date 2019/12/3 10:30 AM
+ * @description 业务异常捕获
+ */
+public class BusinessBasicException extends RuntimeException {
+
+    /**
+     * 错误码
+     */
+    public Integer result;
+    /**
+     * 错误描述
+     */
+    public String msg;
+    /**
+     * 错误后缀描述
+     */
+    public String suffix;
+
+    public BusinessBasicException getExceptionType(Integer status) {
+        return this;
+    }
+
+    public String addSuffix(String msg) {
+        return msg + "(" + setSuffix("") + ")";
+    }
+
+    /**
+     * Constructs a new runtime exception with {@code null} as its
+     * detail message.  The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause}.
+     */
+    public BusinessBasicException() {
+        this.result = 0;
+    }
+
+    /**
+     * Constructs a new runtime exception with the specified cause and a
+     * detail message of <tt>(cause==null ? null : cause.toString())</tt>
+     * (which typically contains the class and detail message of
+     * <tt>cause</tt>).  This constructor is useful for runtime exceptions
+     * that are little more than wrappers for other throwables.
+     *
+     * @param cause the cause (which is saved for later retrieval by the
+     *              {@link #getCause()} method).  (A <tt>null</tt> value is
+     *              permitted, and indicates that the cause is nonexistent or
+     *              unknown.)
+     * @since 1.4
+     */
+    public BusinessBasicException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Constructs a new runtime exception with {@code null} as its
+     * detail message.  The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause}.
+     */
+    public BusinessBasicException(String msg) {
+        this.result = 0;
+        this.msg = msg;
+    }
+
+    /**
+     * Constructs a new runtime exception with {@code null} as its
+     * detail message.  The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause}.
+     */
+    public BusinessBasicException(Integer result, String msg) {
+        this.msg = msg;
+        this.result = result;
+    }
+
+    /**
+     * Constructs a new runtime exception with the specified cause and a
+     * detail message of <tt>(cause==null ? null : cause.toString())</tt>
+     * (which typically contains the class and detail message of
+     * <tt>cause</tt>).  This constructor is useful for runtime exceptions
+     * that are little more than wrappers for other throwables.
+     *
+     * @param cause the cause (which is saved for later retrieval by the
+     *              {@link #getCause()} method).  (A <tt>null</tt> value is
+     *              permitted, and indicates that the cause is nonexistent or
+     *              unknown.)
+     * @since 1.4
+     */
+    public BusinessBasicException(Throwable cause, Integer result, String msg) {
+        super(cause);
+        this.msg = msg;
+        this.result = result;
+    }
+
+    /**
+     * Constructs a new runtime exception with the specified detail message.
+     * The cause is not initialized, and may subsequently be initialized by a
+     * call to {@link #initCause}.
+     *
+     * @param message the detail message. The detail message is saved for
+     *                later retrieval by the {@link #getMessage()} method.
+     */
+    public BusinessBasicException(String message, Integer result, String msg) {
+        super(message);
+        this.msg = msg;
+        this.result = result;
+    }
+
+    /**
+     * Constructs a new runtime exception with the specified detail message and
+     * cause.  <p>Note that the detail message associated with
+     * {@code cause} is <i>not</i> automatically incorporated in
+     * this runtime exception's detail message.
+     *
+     * @param message the detail message (which is saved for later retrieval
+     *                by the {@link #getMessage()} method).
+     * @param cause   the cause (which is saved for later retrieval by the
+     *                {@link #getCause()} method).  (A <tt>null</tt> value is
+     *                permitted, and indicates that the cause is nonexistent or
+     *                unknown.)
+     * @since 1.4
+     */
+    public BusinessBasicException(String message, Throwable cause, Integer result, String msg) {
+        super(message, cause);
+        this.msg = msg;
+        this.result = result;
+    }
+
+    /**
+     * Constructs a new runtime exception with the specified detail
+     * message, cause, suppression enabled or disabled, and writable
+     * stack trace enabled or disabled.
+     *
+     * @param message            the detail message.
+     * @param cause              the cause.  (A {@code null} value is permitted,
+     *                           and indicates that the cause is nonexistent or unknown.)
+     * @param enableSuppression  whether or not suppression is enabled
+     *                           or disabled
+     * @param writableStackTrace whether or not the stack trace should
+     *                           be writable
+     * @since 1.7
+     */
+    public BusinessBasicException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Integer result, String msg) {
+        super(message, cause, enableSuppression, writableStackTrace);
+        this.msg = msg;
+        this.result = result;
+    }
+
+    /**
+     * Fills in the execution stack trace. This method records within this
+     * {@code Throwable} object information about the current state of
+     * the stack frames for the current thread.
+     * <p>
+     * <p>If the stack trace of this {@code Throwable} {@linkplain
+     * Throwable#Throwable(String, Throwable, boolean, boolean) is not
+     * writable}, calling this method has no effect.
+     *
+     * @return a reference to this {@code Throwable} instance.
+     * @see Throwable#printStackTrace()
+     */
+    @Override
+    public synchronized Throwable fillInStackTrace() {
+        return super.fillInStackTrace();
+    }
+
+    /**
+     * Returns the cause of this throwable or {@code null} if the
+     * cause is nonexistent or unknown.  (The cause is the throwable that
+     * caused this throwable to get thrown.)
+     * <p>
+     * <p>This implementation returns the cause that was supplied via one of
+     * the constructors requiring a {@code Throwable}, or that was set after
+     * creation with the {@link #initCause(Throwable)} method.  While it is
+     * typically unnecessary to override this method, a subclass can override
+     * it to return a cause set by some other means.  This is appropriate for
+     * a "legacy chained throwable" that predates the addition of chained
+     * exceptions to {@code Throwable}.  Note that it is <i>not</i>
+     * necessary to override any of the {@code PrintStackTrace} methods,
+     * all of which invoke the {@code getCause} method to determine the
+     * cause of a throwable.
+     *
+     * @return the cause of this throwable or {@code null} if the
+     * cause is nonexistent or unknown.
+     * @since 1.4
+     */
+    @Override
+    public synchronized Throwable getCause() {
+        return super.getCause();
+    }
+
+    /**
+     * Creates a localized description of this throwable.
+     * Subclasses may override this method in order to produce a
+     * locale-specific message.  For subclasses that do not override this
+     * method, the default implementation returns the same result as
+     * {@code getMessage()}.
+     *
+     * @return The localized description of this throwable.
+     * @since JDK1.1
+     */
+    @Override
+    public String getLocalizedMessage() {
+        return super.getLocalizedMessage();
+    }
+
+    /**
+     * Returns the detail message string of this throwable.
+     *
+     * @return the detail message string of this {@code Throwable} instance
+     * (which may be {@code null}).
+     */
+    @Override
+    public String getMessage() {
+        return super.getMessage();
+    }
+
+    /**
+     * Provides programmatic access to the stack trace information printed by
+     * {@link #printStackTrace()}.  Returns an array of stack trace elements,
+     * each representing one stack frame.  The zeroth element of the array
+     * (assuming the array's length is non-zero) represents the top of the
+     * stack, which is the last method invocation in the sequence.  Typically,
+     * this is the point at which this throwable was created and thrown.
+     * The last element of the array (assuming the array's length is non-zero)
+     * represents the bottom of the stack, which is the first method invocation
+     * in the sequence.
+     * <p>
+     * <p>Some virtual machines may, under some circumstances, omit one
+     * or more stack frames from the stack trace.  In the extreme case,
+     * a virtual machine that has no stack trace information concerning
+     * this throwable is permitted to return a zero-length array from this
+     * method.  Generally speaking, the array returned by this method will
+     * contain one element for every frame that would be printed by
+     * {@code printStackTrace}.  Writes to the returned array do not
+     * affect future calls to this method.
+     *
+     * @return an array of stack trace elements representing the stack trace
+     * pertaining to this throwable.
+     * @since 1.4
+     */
+    @Override
+    public StackTraceElement[] getStackTrace() {
+        return super.getStackTrace();
+    }
+
+    /**
+     * Initializes the <i>cause</i> of this throwable to the specified value.
+     * (The cause is the throwable that caused this throwable to get thrown.)
+     * <p>
+     * <p>This method can be called at most once.  It is generally called from
+     * within the constructor, or immediately after creating the
+     * throwable.  If this throwable was created
+     * with {@link #Throwable(Throwable)} or
+     * {@link #Throwable(String, Throwable)}, this method cannot be called
+     * even once.
+     * <p>
+     * <p>An example of using this method on a legacy throwable type
+     * without other support for setting the cause is:
+     * <p>
+     * <pre>
+     * try {
+     *     lowLevelOp();
+     * } catch (LowLevelException le) {
+     *     throw (HighLevelException)
+     *           new HighLevelException().initCause(le); // Legacy constructor
+     * }
+     * </pre>
+     *
+     * @param cause the cause (which is saved for later retrieval by the
+     *              {@link #getCause()} method).  (A {@code null} value is
+     *              permitted, and indicates that the cause is nonexistent or
+     *              unknown.)
+     * @return a reference to this {@code Throwable} instance.
+     * @throws IllegalArgumentException if {@code cause} is this
+     *                                  throwable.  (A throwable cannot be its own cause.)
+     * @throws IllegalStateException    if this throwable was
+     *                                  created with {@link #Throwable(Throwable)} or
+     *                                  {@link #Throwable(String, Throwable)}, or this method has already
+     *                                  been called on this throwable.
+     * @since 1.4
+     */
+    @Override
+    public synchronized Throwable initCause(Throwable cause) {
+        return super.initCause(cause);
+    }
+
+    /**
+     * Prints this throwable and its backtrace to the
+     * standard error stream. This method prints a stack trace for this
+     * {@code Throwable} object on the error output stream that is
+     * the value of the field {@code System.err}. The first line of
+     * output contains the result of the {@link #toString()} method for
+     * this object.  Remaining lines represent data previously recorded by
+     * the method {@link #fillInStackTrace()}. The format of this
+     * information depends on the implementation, but the following
+     * example may be regarded as typical:
+     * <blockquote><pre>
+     * java.lang.NullPointerException
+     *         at MyClass.mash(MyClass.java:9)
+     *         at MyClass.crunch(MyClass.java:6)
+     *         at MyClass.main(MyClass.java:3)
+     * </pre></blockquote>
+     * This example was produced by running the program:
+     * <pre>
+     * class MyClass {
+     *     public static void main(String[] args) {
+     *         crunch(null);
+     *     }
+     *     static void crunch(int[] a) {
+     *         mash(a);
+     *     }
+     *     static void mash(int[] b) {
+     *         System.out.println(b[0]);
+     *     }
+     * }
+     * </pre>
+     * The backtrace for a throwable with an initialized, non-null cause
+     * should generally include the backtrace for the cause.  The format
+     * of this information depends on the implementation, but the following
+     * example may be regarded as typical:
+     * <pre>
+     * HighLevelException: MidLevelException: LowLevelException
+     *         at Junk.a(Junk.java:13)
+     *         at Junk.main(Junk.java:4)
+     * Caused by: MidLevelException: LowLevelException
+     *         at Junk.c(Junk.java:23)
+     *         at Junk.b(Junk.java:17)
+     *         at Junk.a(Junk.java:11)
+     *         ... 1 more
+     * Caused by: LowLevelException
+     *         at Junk.e(Junk.java:30)
+     *         at Junk.d(Junk.java:27)
+     *         at Junk.c(Junk.java:21)
+     *         ... 3 more
+     * </pre>
+     * Note the presence of lines containing the characters {@code "..."}.
+     * These lines indicate that the remainder of the stack trace for this
+     * exception matches the indicated number of frames from the bottom of the
+     * stack trace of the exception that was caused by this exception (the
+     * "enclosing" exception).  This shorthand can greatly reduce the length
+     * of the output in the common case where a wrapped exception is thrown
+     * from same method as the "causative exception" is caught.  The above
+     * example was produced by running the program:
+     * <pre>
+     * public class Junk {
+     *     public static void main(String args[]) {
+     *         try {
+     *             a();
+     *         } catch(HighLevelException e) {
+     *             e.printStackTrace();
+     *         }
+     *     }
+     *     static void a() throws HighLevelException {
+     *         try {
+     *             b();
+     *         } catch(MidLevelException e) {
+     *             throw new HighLevelException(e);
+     *         }
+     *     }
+     *     static void b() throws MidLevelException {
+     *         c();
+     *     }
+     *     static void c() throws MidLevelException {
+     *         try {
+     *             d();
+     *         } catch(LowLevelException e) {
+     *             throw new MidLevelException(e);
+     *         }
+     *     }
+     *     static void d() throws LowLevelException {
+     *        e();
+     *     }
+     *     static void e() throws LowLevelException {
+     *         throw new LowLevelException();
+     *     }
+     * }
+     *
+     * class HighLevelException extends Exception {
+     *     HighLevelException(Throwable cause) { super(cause); }
+     * }
+     *
+     * class MidLevelException extends Exception {
+     *     MidLevelException(Throwable cause)  { super(cause); }
+     * }
+     *
+     * class LowLevelException extends Exception {
+     * }
+     * </pre>
+     * As of release 7, the platform supports the notion of
+     * <i>suppressed exceptions</i> (in conjunction with the {@code
+     * try}-with-resources statement). Any exceptions that were
+     * suppressed in order to deliver an exception are printed out
+     * beneath the stack trace.  The format of this information
+     * depends on the implementation, but the following example may be
+     * regarded as typical:
+     * <p>
+     * <pre>
+     * Exception in thread "main" java.lang.Exception: Something happened
+     *  at Foo.bar(Foo.java:10)
+     *  at Foo.main(Foo.java:5)
+     *  Suppressed: Resource$CloseFailException: Resource ID = 0
+     *          at Resource.close(Resource.java:26)
+     *          at Foo.bar(Foo.java:9)
+     *          ... 1 more
+     * </pre>
+     * Note that the "... n more" notation is used on suppressed exceptions
+     * just at it is used on causes. Unlike causes, suppressed exceptions are
+     * indented beyond their "containing exceptions."
+     * <p>
+     * <p>An exception can have both a cause and one or more suppressed
+     * exceptions:
+     * <pre>
+     * Exception in thread "main" java.lang.Exception: Main block
+     *  at Foo3.main(Foo3.java:7)
+     *  Suppressed: Resource$CloseFailException: Resource ID = 2
+     *          at Resource.close(Resource.java:26)
+     *          at Foo3.main(Foo3.java:5)
+     *  Suppressed: Resource$CloseFailException: Resource ID = 1
+     *          at Resource.close(Resource.java:26)
+     *          at Foo3.main(Foo3.java:5)
+     * Caused by: java.lang.Exception: I did it
+     *  at Foo3.main(Foo3.java:8)
+     * </pre>
+     * Likewise, a suppressed exception can have a cause:
+     * <pre>
+     * Exception in thread "main" java.lang.Exception: Main block
+     *  at Foo4.main(Foo4.java:6)
+     *  Suppressed: Resource2$CloseFailException: Resource ID = 1
+     *          at Resource2.close(Resource2.java:20)
+     *          at Foo4.main(Foo4.java:5)
+     *  Caused by: java.lang.Exception: Rats, you caught me
+     *          at Resource2$CloseFailException.<init>(Resource2.java:45)
+     *          ... 2 more
+     * </pre>
+     */
+    @Override
+    public void printStackTrace() {
+        super.printStackTrace();
+    }
+
+    /**
+     * Prints this throwable and its backtrace to the specified print stream.
+     *
+     * @param s {@code PrintStream} to use for output
+     */
+    @Override
+    public void printStackTrace(PrintStream s) {
+        super.printStackTrace(s);
+    }
+
+    /**
+     * Prints this throwable and its backtrace to the specified
+     * print writer.
+     *
+     * @param s {@code PrintWriter} to use for output
+     * @since JDK1.1
+     */
+    @Override
+    public void printStackTrace(PrintWriter s) {
+        super.printStackTrace(s);
+    }
+
+    /**
+     * Sets the stack trace elements that will be returned by
+     * {@link #getStackTrace()} and printed by {@link #printStackTrace()}
+     * and related methods.
+     * <p>
+     * This method, which is designed for use by RPC frameworks and other
+     * advanced systems, allows the client to override the default
+     * stack trace that is either generated by {@link #fillInStackTrace()}
+     * when a throwable is constructed or deserialized when a throwable is
+     * read from a serialization stream.
+     * <p>
+     * <p>If the stack trace of this {@code Throwable} {@linkplain
+     * Throwable#Throwable(String, Throwable, boolean, boolean) is not
+     * writable}, calling this method has no effect other than
+     * validating its argument.
+     *
+     * @param stackTrace the stack trace elements to be associated with
+     *                   this {@code Throwable}.  The specified array is copied by this
+     *                   call; changes in the specified array after the method invocation
+     *                   returns will have no affect on this {@code Throwable}'s stack
+     *                   trace.
+     * @throws NullPointerException if {@code stackTrace} is
+     *                              {@code null} or if any of the elements of
+     *                              {@code stackTrace} are {@code null}
+     * @since 1.4
+     */
+    @Override
+    public void setStackTrace(StackTraceElement[] stackTrace) {
+        super.setStackTrace(stackTrace);
+    }
+
+    /**
+     * Returns a short description of this throwable.
+     * The result is the concatenation of:
+     * <ul>
+     * <li> the {@linkplain Class#getName() name} of the class of this object
+     * <li> ": " (a colon and a space)
+     * <li> the result of invoking this object's {@link #getLocalizedMessage}
+     * method
+     * </ul>
+     * If {@code getLocalizedMessage} returns {@code null}, then just
+     * the class name is returned.
+     *
+     * @return a string representation of this throwable.
+     */
+    @Override
+    public String toString() {
+        return super.toString();
+    }
+
+    public String setSuffix(String suffix) {
+        return suffix;
+    }
+}

+ 69 - 0
lift-manager-service/src/main/java/cn/com/ty/lift/manager/framework/aspect/ControllerAspect.java

@@ -0,0 +1,69 @@
+package cn.com.ty.lift.manager.framework.aspect;
+
+import cn.com.ty.lift.manager.framework.BusinessBasicException;
+import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.json.JSONUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.*;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+/**
+ * @author bieao
+ * @date 2019/12/3 10:30 AM
+ * @description 日志切面
+ */
+@Slf4j
+@Aspect
+@Component
+public class ControllerAspect {
+
+    private static final String head = "##########|\t";
+
+    @Pointcut("execution(* cn.com.ty.lift.manager.*.controller..*(..))")
+    public void controllerPointCut() {
+    }
+
+    @Before("controllerPointCut()")
+    public void doBefore(JoinPoint joinPoint) throws Throwable {
+        // Receives the request and get request content
+        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+        HttpServletRequest request = attributes.getRequest();
+
+        log.info(head + "URL : " + request.getRequestURL().toString());
+        log.info(head + "HTTP_METHOD : " + request.getMethod());
+        log.info(head + "IP : " + request.getRemoteAddr());
+        log.info(head + "CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
+        log.info(head + "ARGS : " + Arrays.toString(joinPoint.getArgs()));
+
+    }
+
+    @AfterReturning(returning = "response", pointcut = "controllerPointCut()")
+    public void doAfterReturning(RestResponse response) throws Throwable {
+        // Processes the request and returns the content
+        log.info(head + "RESPONSE : " + JSONUtil.parse(response));
+        log.info("====================================================");
+    }
+
+    @AfterThrowing(throwing = "ex", pointcut = "controllerPointCut()")
+    public void doAfterThrowing(BusinessBasicException ex) throws Throwable {
+        final String msg = ex.getMessage();
+        // Processes the request and returns the content
+        log.info(head + "RESPONSE : " +  ex.addSuffix(msg).replace("()", ""));
+        log.info("====================================================");
+    }
+
+
+    @Around("controllerPointCut()")
+    public Object interceptor(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
+        log.info("====================================================");
+        return proceedingJoinPoint.proceed();
+    }
+
+}

+ 60 - 0
lift-manager-service/src/main/java/cn/com/ty/lift/manager/framework/util/MessageUtils.java

@@ -0,0 +1,60 @@
+package cn.com.ty.lift.manager.framework.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.util.StringUtils;
+
+import java.text.MessageFormat;
+import java.util.*;
+
+/**
+ * @author bieao
+ * @description 消息工具类
+ * @date 2019/12/3 11:02 AM
+ */
+@Slf4j
+public final class MessageUtils {
+
+    /**
+     *  Message 格式化工具
+     */
+    public final static MessageFormat FORMAT = new MessageFormat("");
+    /**
+     * Message cache 中文
+     */
+    public final static Map<String, String> MESSAGE_CACHE_CHMAP = new HashMap<>();
+
+
+    static {
+        //Load Business Message
+        Locale.setDefault(new Locale("zh", "CN"));
+        ResourceBundle rb = ResourceBundle.getBundle("locale/response");
+        Set<String> keySet = rb.keySet();
+        for (String keyStr : keySet) {
+            MESSAGE_CACHE_CHMAP.put(keyStr, rb.getString(keyStr));
+        }
+    }
+
+    /**
+     * @param key message.properties 存在的key
+     * @date 2019/12/3 11:02 AM
+     * @description 获取il8n下存在的value
+     */
+    public static String get(String key) {
+        return get(key, (String[]) null);
+    }
+
+    /**
+     * @param key  message.properties 存在的key
+     * @param arg0 填充参数
+     * @date 2019/12/3 11:02 AM
+     * @description 获取il8n下存在的携带参数的value
+     */
+    public static String get(String key, String... arg0) {
+        String message = MESSAGE_CACHE_CHMAP.get(key);
+        log.info("####| 获取配置文件:{},值:{}", key, message);
+        if (StringUtils.isEmpty(message)) return "{}";
+        FORMAT.applyPattern(message);
+        return FORMAT.format(arg0);
+    }
+
+}

+ 215 - 74
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/entity/Lift.java

@@ -7,83 +7,224 @@ import lombok.Data;
 
 /**
  * 实体类 - 表:lift 电梯
+ *
  * @since 2019-11-25 17:37:16
  */
 @Data
 public class Lift {
-	private Long id;
 
-	private String registrationCode;
-
-	private Byte category;
-
-	private Integer liftType;
-
-	private String liftCode;
-
-	private Date manufactureDate;
-
-	private String factoryCode;
-
-	private Byte deviceUsage;
-
-	private String liftBrand;
-
-	private String installCompany;
-
-	private String liftModel;
-
-	private BigDecimal pulleyDiameter;
-
-	private Integer ropeNum;
-
-	private String lockModel;
-
-	private Integer ratedLoad;
-
-	private BigDecimal promoteHeight;
-
-	private BigDecimal stepWidth;
-
-	private BigDecimal sidewalkLength;
-
-	private BigDecimal tiltAngle;
-
-	private BigDecimal motorPower;
-
-	private BigDecimal ratedSpeed;
-
-	private String layerStationDoor;
-
-	private Byte clampType;
-
-	private String reformCompany;
-
-	private String devicePosition;
-
-	private String coordinate;
-
-	private String remarks;
-
-	private Long creatorId;
-
-	private Date createDate;
-
-	private Integer steelBelt;
-
-	private String cylinderType;
-
-	private Integer cylinderNum;
-
-	private Byte topType;
-
-	private String controlType;
-
-	private Integer mpa;
-
-	private String factory;
-
-	private String customNumber;
-
-	private String companyCode;
+    /**
+     * 电梯id
+     */
+    private Long id;
+
+    /**
+     * 注册代码
+     */
+    private String registrationCode;
+
+    /**
+     * 电梯类别(1:曳引梯;2:液压梯;3:杂物梯;4:自动扶梯;5:自动人行道)
+     */
+    private Byte category;
+
+    /**
+     * 电梯类型(1:直梯;2:扶梯)
+     */
+    private Integer liftType;
+
+    /**
+     * 电梯编号
+     */
+    private String liftCode;
+
+    /**
+     * 出厂日期
+     */
+    private Date manufactureDate;
+
+    /**
+     * 出厂编号
+     */
+    private String factoryCode;
+
+    /**
+     * 设备用途(11:货梯;12:客梯;13:医梯;14:观光梯;15:杂物梯;16:别墅梯;21:扶梯;22:人行道)
+     */
+    private Byte deviceUsage;
+
+    /**
+     * 电梯品牌
+     */
+    private String liftBrand;
+
+    /**
+     * 安装单位
+     */
+    private String installCompany;
+
+    /**
+     * 电梯型号
+     */
+    private String liftModel;
+
+    /**
+     * 曳引轮直径
+     */
+    private BigDecimal pulleyDiameter;
+
+    /**
+     * 曳引绳根数
+     */
+    private Integer ropeNum;
+
+    /**
+     * 门锁型号
+     */
+    private String lockModel;
+
+    /**
+     * 电梯载重
+     */
+    private Integer ratedLoad;
+
+    /**
+     * 提升高度m
+     */
+    private BigDecimal promoteHeight;
+
+    /**
+     * 梯级宽度
+     */
+    private BigDecimal stepWidth;
+
+    /**
+     * 人行道长度m
+     */
+    private BigDecimal sidewalkLength;
+
+    /**
+     * 倾斜角度°
+     */
+    private BigDecimal tiltAngle;
+
+    /**
+     * 电动机功率kw
+     */
+    private BigDecimal motorPower;
+
+    /**
+     * 额定速度m/s
+     */
+    private BigDecimal ratedSpeed;
+
+    /**
+     * 层站门
+     */
+    private String layerStationDoor;
+
+    /**
+     * 安全钳类型(1:瞬时式安全钳;2:渐进式安全钳)
+     */
+    private Byte clampType;
+
+    /**
+     * 改造单位
+     */
+    private String reformCompany;
+
+    /**
+     * 设备使用地点
+     */
+    private String devicePosition;
+
+    /**
+     * 经纬度
+     */
+    private String coordinate;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
+     * 创建人ID
+     */
+    private Long creatorId;
+
+    /**
+     * 创建时间
+     */
+    private Date createDate;
+
+    /**
+     * 钢带
+     */
+    private Integer steelBelt;
+
+    /**
+     * 油缸型式
+     */
+    private String cylinderType;
+
+    /**
+     * 油缸数量
+     */
+    private Integer cylinderNum;
+
+    /**
+     * 顶升型式
+     */
+    private Byte topType;
+
+    /**
+     * 控制方式
+     */
+    private String controlType;
+
+    /**
+     * 液压系统满负荷值
+     */
+    private Integer mpa;
+
+    /**
+     * 厂商
+     */
+    private String factory;
+
+    /**
+     * 自定义编号
+     */
+    private String customNumber;
+
+    /**
+     * 单位设备编号
+     */
+    private String useCompanyCode;
+
+    /**
+     * 设备位置码
+     */
+    private String devicePositionCode;
+
+    /**
+     * 进口设备代理商
+     */
+    private String agency;
+
+    /**
+     * 设备改造日期
+     */
+    private Date reformDate;
+
+    /**
+     * 设备安装日期
+     */
+    private Date installDate;
+
+    /**
+     * 显示楼层
+     */
+    private Byte innerFloor;
 }

+ 10 - 5
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/entity/model/LiftRequest.java

@@ -10,6 +10,11 @@ import lombok.Data;
 @Data
 public class LiftRequest {
 
+    /**
+     * 电梯状态
+     */
+    private Integer liftStatus;
+
     /**
      * 区域
      */
@@ -23,7 +28,7 @@ public class LiftRequest {
     /**
      * 电梯号
      */
-    private Long liftCode;
+    private String liftCode;
 
     /**
      * 电梯品牌
@@ -33,20 +38,20 @@ public class LiftRequest {
     /**
      * 电梯类型
      */
-    private String liftType;
+    private Integer liftType;
 
     /**
      * 维保工
      */
-    private String maintenanceWorker;
+    private Integer workerId;
 
     /**
      * 当前第几页
      */
-    private int pageNum;
+    private Integer pageNum;
 
     /**
      * 每页条数
      */
-    private int pageSize;
+    private Integer pageSize;
 }

+ 20 - 0
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/dao/entity/model/LiftResponse.java

@@ -9,9 +9,29 @@ import lombok.Data;
  */
 @Data
 public class LiftResponse {
+
+    /**
+     * 电梯号
+     */
     private String liftCode;
+
+    /**
+     * 注册代码
+     */
     private String registrationCode;
+
+    /**
+     * 电梯品牌
+     */
     private String liftBrand;
+
+    /**
+     * 电梯类型
+     */
     private String liftType;
+
+    /**
+     * 设备使用地点
+     */
     private String devicePosition;
 }

+ 7 - 6
lift-manager-service/src/main/java/cn/com/ty/lift/manager/library/service/LibraryService.java

@@ -3,6 +3,7 @@ package cn.com.ty.lift.manager.library.service;
 import cn.com.ty.lift.common.base.ExportRequest;
 import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.ty.lift.common.export.ExportUtils;
+import cn.com.ty.lift.manager.framework.util.MessageUtils;
 import cn.com.ty.lift.manager.library.dao.entity.Lift;
 import cn.com.ty.lift.manager.library.dao.mapper.LiftMapper;
 import cn.com.ty.lift.manager.library.dao.entity.model.LiftRequest;
@@ -47,10 +48,10 @@ public class LibraryService {
         List<Lift> lifts = mapper.findByCondition(page, request);
         if (lifts.isEmpty()) {
             page.setRecords(new ArrayList<>());
-            return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "暂无数据");
+            return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, MessageUtils.get("msg.data.empty"));
         }
         page.setRecords(lifts);
-        return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, "查询列表成功");
+        return RestResponse.ok(page, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.query.success"));
     }
 
     /**
@@ -62,9 +63,9 @@ public class LibraryService {
     public RestResponse add(Lift lift) {
         Integer result = mapper.insertSelective(lift);
         if (result > 0) {
-            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, "新增成功");
+            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.add.success"));
         }
-        return RestResponse.error(ApiConstants.RESULT_ERROR, "新增失败");
+        return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.add.fail"));
     }
 
     /**
@@ -76,9 +77,9 @@ public class LibraryService {
     public RestResponse modify(Lift lift) {
         Integer result = mapper.updateByPrimaryKeySelective(lift);
         if (result > 0) {
-            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, "修改成功");
+            return RestResponse.ok(result, ApiConstants.RESULT_SUCCESS, MessageUtils.get("msg.modify.success"));
         }
-        return RestResponse.error(ApiConstants.RESULT_ERROR, "修改失败");
+        return RestResponse.error(ApiConstants.RESULT_ERROR, MessageUtils.get("msg.modify.fail"));
     }
 
     /**

+ 6 - 0
lift-manager-service/src/main/resources/locale/response.properties

@@ -0,0 +1,6 @@
+msg.data.empty=\u6682\u65E0\u6570\u636E
+msg.query.success=\u67E5\u8BE2\u5217\u8868\u6210\u529F
+msg.add.success=\u65B0\u589E\u6210\u529F
+msg.add.fail=\u65B0\u589E\u5931\u8D25
+msg.modify.success=\u4FEE\u6539\u6210\u529F
+msg.modify.fail=\u4FEE\u6539\u5931\u8D25

+ 100 - 40
lift-manager-service/src/main/resources/mapper/LiftMapper.xml

@@ -39,16 +39,22 @@
 		<result column="mpa" property="mpa" jdbcType="INTEGER" />
 		<result column="factory" property="factory" jdbcType="VARCHAR" />
 		<result column="custom_number" property="customNumber" jdbcType="VARCHAR" />
-		<result column="company_code" property="companyCode" jdbcType="VARCHAR" />
+		<result column="use_company_code" property="useCompanyCode" jdbcType="VARCHAR" />
+		<result column="device_position_code" property="devicePositionCode" jdbcType="CHAR" />
+		<result column="agency" property="agency" jdbcType="VARCHAR" />
+		<result column="reform_date" property="reformDate" jdbcType="TIMESTAMP" />
+		<result column="install_date" property="installDate" jdbcType="TIMESTAMP" />
+		<result column="inner_floor" property="innerFloor" jdbcType="TINYINT" />
 	</resultMap>
 
 	<sql id="Base_Column_List" >
-		id, registration_code, category, lift_type, lift_code, manufacture_date, factory_code,
-		device_usage, lift_brand, install_company, lift_model, pulley_diameter, rope_num,
-		lock_model, rated_load, promote_height, step_width, sidewalk_length, tilt_angle,
-		motor_power, rated_speed, layer_station_door, clamp_type, reform_company, device_position,
-		coordinate, remarks, creator_id, create_date, steel_belt, cylinder_type, cylinder_num,
-		top_type, control_type, mpa, factory, custom_number, company_code
+		id, registration_code, category, lift_type, lift_code, manufacture_date, factory_code, 
+		device_usage, lift_brand, install_company, lift_model, pulley_diameter, rope_num, 
+		lock_model, rated_load, promote_height, step_width, sidewalk_length, tilt_angle, 
+		motor_power, rated_speed, layer_station_door, clamp_type, reform_company, device_position, 
+		coordinate, remarks, creator_id, create_date, steel_belt, cylinder_type, cylinder_num, 
+		top_type, control_type, mpa, factory, custom_number, use_company_code, device_position_code, 
+		agency, reform_date, install_date, inner_floor
 	</sql>
 
 	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
@@ -82,32 +88,36 @@
 	</delete>
 
 	<insert id="insert" parameterType="cn.com.ty.lift.manager.library.dao.entity.Lift" >
-		insert into lift (id, registration_code, category,
-			lift_type, lift_code, manufacture_date,
-			factory_code, device_usage, lift_brand,
-			install_company, lift_model, pulley_diameter,
-			rope_num, lock_model, rated_load,
-			promote_height, step_width, sidewalk_length,
-			tilt_angle, motor_power, rated_speed,
-			layer_station_door, clamp_type, reform_company,
-			device_position, coordinate, remarks,
-			creator_id, create_date, steel_belt,
-			cylinder_type, cylinder_num, top_type,
-			control_type, mpa, factory,
-			custom_number, company_code)
-		values (#{id,jdbcType=BIGINT}, #{registrationCode,jdbcType=VARCHAR}, #{category,jdbcType=TINYINT},
-			#{liftType,jdbcType=INTEGER}, #{liftCode,jdbcType=CHAR}, #{manufactureDate,jdbcType=DATE},
-			#{factoryCode,jdbcType=VARCHAR}, #{deviceUsage,jdbcType=TINYINT}, #{liftBrand,jdbcType=VARCHAR},
-			#{installCompany,jdbcType=VARCHAR}, #{liftModel,jdbcType=VARCHAR}, #{pulleyDiameter,jdbcType=DECIMAL},
-			#{ropeNum,jdbcType=INTEGER}, #{lockModel,jdbcType=VARCHAR}, #{ratedLoad,jdbcType=INTEGER},
-			#{promoteHeight,jdbcType=DECIMAL}, #{stepWidth,jdbcType=DECIMAL}, #{sidewalkLength,jdbcType=DECIMAL},
-			#{tiltAngle,jdbcType=DECIMAL}, #{motorPower,jdbcType=DECIMAL}, #{ratedSpeed,jdbcType=DECIMAL},
-			#{layerStationDoor,jdbcType=VARCHAR}, #{clampType,jdbcType=TINYINT}, #{reformCompany,jdbcType=VARCHAR},
-			#{devicePosition,jdbcType=VARCHAR}, #{coordinate,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR},
-			#{creatorId,jdbcType=BIGINT}, #{createDate,jdbcType=TIMESTAMP}, #{steelBelt,jdbcType=INTEGER},
-			#{cylinderType,jdbcType=VARCHAR}, #{cylinderNum,jdbcType=INTEGER}, #{topType,jdbcType=TINYINT},
-			#{controlType,jdbcType=VARCHAR}, #{mpa,jdbcType=INTEGER}, #{factory,jdbcType=VARCHAR},
-			#{customNumber,jdbcType=VARCHAR}, #{companyCode,jdbcType=VARCHAR})
+		insert into lift (id, registration_code, category, 
+			lift_type, lift_code, manufacture_date, 
+			factory_code, device_usage, lift_brand, 
+			install_company, lift_model, pulley_diameter, 
+			rope_num, lock_model, rated_load, 
+			promote_height, step_width, sidewalk_length, 
+			tilt_angle, motor_power, rated_speed, 
+			layer_station_door, clamp_type, reform_company, 
+			device_position, coordinate, remarks, 
+			creator_id, create_date, steel_belt, 
+			cylinder_type, cylinder_num, top_type, 
+			control_type, mpa, factory, 
+			custom_number, use_company_code, device_position_code, 
+			agency, reform_date, install_date, 
+			inner_floor)
+		values (#{id,jdbcType=BIGINT}, #{registrationCode,jdbcType=VARCHAR}, #{category,jdbcType=TINYINT}, 
+			#{liftType,jdbcType=INTEGER}, #{liftCode,jdbcType=CHAR}, #{manufactureDate,jdbcType=DATE}, 
+			#{factoryCode,jdbcType=VARCHAR}, #{deviceUsage,jdbcType=TINYINT}, #{liftBrand,jdbcType=VARCHAR}, 
+			#{installCompany,jdbcType=VARCHAR}, #{liftModel,jdbcType=VARCHAR}, #{pulleyDiameter,jdbcType=DECIMAL}, 
+			#{ropeNum,jdbcType=INTEGER}, #{lockModel,jdbcType=VARCHAR}, #{ratedLoad,jdbcType=INTEGER}, 
+			#{promoteHeight,jdbcType=DECIMAL}, #{stepWidth,jdbcType=DECIMAL}, #{sidewalkLength,jdbcType=DECIMAL}, 
+			#{tiltAngle,jdbcType=DECIMAL}, #{motorPower,jdbcType=DECIMAL}, #{ratedSpeed,jdbcType=DECIMAL}, 
+			#{layerStationDoor,jdbcType=VARCHAR}, #{clampType,jdbcType=TINYINT}, #{reformCompany,jdbcType=VARCHAR}, 
+			#{devicePosition,jdbcType=VARCHAR}, #{coordinate,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, 
+			#{creatorId,jdbcType=BIGINT}, #{createDate,jdbcType=TIMESTAMP}, #{steelBelt,jdbcType=INTEGER}, 
+			#{cylinderType,jdbcType=VARCHAR}, #{cylinderNum,jdbcType=INTEGER}, #{topType,jdbcType=TINYINT}, 
+			#{controlType,jdbcType=VARCHAR}, #{mpa,jdbcType=INTEGER}, #{factory,jdbcType=VARCHAR}, 
+			#{customNumber,jdbcType=VARCHAR}, #{useCompanyCode,jdbcType=VARCHAR}, #{devicePositionCode,jdbcType=CHAR}, 
+			#{agency,jdbcType=VARCHAR}, #{reformDate,jdbcType=TIMESTAMP}, #{installDate,jdbcType=TIMESTAMP}, 
+			#{innerFloor,jdbcType=TINYINT})
 	</insert>
 
 	<insert id="insertSelective" parameterType="cn.com.ty.lift.manager.library.dao.entity.Lift" >
@@ -224,8 +234,23 @@
 			<if test="customNumber != null" >
 				custom_number,
 			</if>
-			<if test="companyCode != null" >
-				company_code,
+			<if test="useCompanyCode != null" >
+				use_company_code,
+			</if>
+			<if test="devicePositionCode != null" >
+				device_position_code,
+			</if>
+			<if test="agency != null" >
+				agency,
+			</if>
+			<if test="reformDate != null" >
+				reform_date,
+			</if>
+			<if test="installDate != null" >
+				install_date,
+			</if>
+			<if test="innerFloor != null" >
+				inner_floor,
 			</if>
 		</trim>
 		<trim prefix="values (" suffix=")" suffixOverrides="," >
@@ -340,8 +365,23 @@
 			<if test="customNumber != null" >
 				#{customNumber,jdbcType=VARCHAR},
 			</if>
-			<if test="companyCode != null" >
-				#{companyCode,jdbcType=VARCHAR},
+			<if test="useCompanyCode != null" >
+				#{useCompanyCode,jdbcType=VARCHAR},
+			</if>
+			<if test="devicePositionCode != null" >
+				#{devicePositionCode,jdbcType=CHAR},
+			</if>
+			<if test="agency != null" >
+				#{agency,jdbcType=VARCHAR},
+			</if>
+			<if test="reformDate != null" >
+				#{reformDate,jdbcType=TIMESTAMP},
+			</if>
+			<if test="installDate != null" >
+				#{installDate,jdbcType=TIMESTAMP},
+			</if>
+			<if test="innerFloor != null" >
+				#{innerFloor,jdbcType=TINYINT},
 			</if>
 		</trim>
 	</insert>
@@ -457,8 +497,23 @@
 			<if test="customNumber != null" >
 				custom_number = #{customNumber,jdbcType=VARCHAR},
 			</if>
-			<if test="companyCode != null" >
-				company_code = #{companyCode,jdbcType=VARCHAR},
+			<if test="useCompanyCode != null" >
+				use_company_code = #{useCompanyCode,jdbcType=VARCHAR},
+			</if>
+			<if test="devicePositionCode != null" >
+				device_position_code = #{devicePositionCode,jdbcType=CHAR},
+			</if>
+			<if test="agency != null" >
+				agency = #{agency,jdbcType=VARCHAR},
+			</if>
+			<if test="reformDate != null" >
+				reform_date = #{reformDate,jdbcType=TIMESTAMP},
+			</if>
+			<if test="installDate != null" >
+				install_date = #{installDate,jdbcType=TIMESTAMP},
+			</if>
+			<if test="innerFloor != null" >
+				inner_floor = #{innerFloor,jdbcType=TINYINT},
 			</if>
 		</set>
 		where id = #{id,jdbcType=BIGINT}
@@ -502,7 +557,12 @@
 			mpa = #{mpa,jdbcType=INTEGER},
 			factory = #{factory,jdbcType=VARCHAR},
 			custom_number = #{customNumber,jdbcType=VARCHAR},
-			company_code = #{companyCode,jdbcType=VARCHAR}
+			use_company_code = #{useCompanyCode,jdbcType=VARCHAR},
+			device_position_code = #{devicePositionCode,jdbcType=CHAR},
+			agency = #{agency,jdbcType=VARCHAR},
+			reform_date = #{reformDate,jdbcType=TIMESTAMP},
+			install_date = #{installDate,jdbcType=TIMESTAMP},
+			inner_floor = #{innerFloor,jdbcType=TINYINT}
 		where id = #{id,jdbcType=BIGINT}
 	</update>