sunyj 8 years ago
commit
9eb10c3abb
49 changed files with 5406 additions and 0 deletions
  1. 50 0
      .gitignore
  2. 2 0
      README.md
  3. 75 0
      pom.xml
  4. 42 0
      src/main/java/com/uas/ps/product/Application.java
  5. 128 0
      src/main/java/com/uas/ps/product/DruidDBConfiguration.java
  6. 71 0
      src/main/java/com/uas/ps/product/WebAppConfiguration.java
  7. 107 0
      src/main/java/com/uas/ps/product/controller/ProductController.java
  8. 14 0
      src/main/java/com/uas/ps/product/dao/EnterpriseDao.java
  9. 28 0
      src/main/java/com/uas/ps/product/dao/ProductDao.java
  10. 22 0
      src/main/java/com/uas/ps/product/dao/ProductMatchResultDao.java
  11. 24 0
      src/main/java/com/uas/ps/product/dao/ProductStoreStatusDao.java
  12. 17 0
      src/main/java/com/uas/ps/product/dao/ProductUsersDao.java
  13. 15 0
      src/main/java/com/uas/ps/product/dao/UsageLogDao.java
  14. 14 0
      src/main/java/com/uas/ps/product/dao/UserDao.java
  15. 17 0
      src/main/java/com/uas/ps/product/logging/BufferedLogable.java
  16. 113 0
      src/main/java/com/uas/ps/product/logging/BufferedLogger.java
  17. 34 0
      src/main/java/com/uas/ps/product/logging/BufferedLoggerManager.java
  18. 12 0
      src/main/java/com/uas/ps/product/logging/LogService.java
  19. 65 0
      src/main/java/com/uas/ps/product/logging/UsageBufferedLogger.java
  20. 32 0
      src/main/java/com/uas/ps/product/logging/erp/ErpBufferedLogger.java
  21. 199 0
      src/main/java/com/uas/ps/product/logging/erp/ErpLog.java
  22. 15 0
      src/main/java/com/uas/ps/product/logging/erp/ErpLogDao.java
  23. 11 0
      src/main/java/com/uas/ps/product/logging/erp/ErpLogService.java
  24. 25 0
      src/main/java/com/uas/ps/product/logging/erp/ErpLogServiceImpl.java
  25. 194 0
      src/main/java/com/uas/ps/product/model/Attach.java
  26. 35 0
      src/main/java/com/uas/ps/product/model/Constant.java
  27. 721 0
      src/main/java/com/uas/ps/product/model/Enterprise.java
  28. 126 0
      src/main/java/com/uas/ps/product/model/EnterpriseInfo.java
  29. 359 0
      src/main/java/com/uas/ps/product/model/Prod.java
  30. 715 0
      src/main/java/com/uas/ps/product/model/Product.java
  31. 245 0
      src/main/java/com/uas/ps/product/model/ProductMatchResult.java
  32. 92 0
      src/main/java/com/uas/ps/product/model/ProductStoreStatus.java
  33. 98 0
      src/main/java/com/uas/ps/product/model/ProductUsers.java
  34. 84 0
      src/main/java/com/uas/ps/product/model/ResourceItem.java
  35. 195 0
      src/main/java/com/uas/ps/product/model/Role.java
  36. 130 0
      src/main/java/com/uas/ps/product/model/Status.java
  37. 232 0
      src/main/java/com/uas/ps/product/model/UsageLog.java
  38. 360 0
      src/main/java/com/uas/ps/product/model/User.java
  39. 99 0
      src/main/java/com/uas/ps/product/model/UserBaseInfo.java
  40. 48 0
      src/main/java/com/uas/ps/product/service/ProductService.java
  41. 11 0
      src/main/java/com/uas/ps/product/service/UsageLogService.java
  42. 122 0
      src/main/java/com/uas/ps/product/service/impl/ProductServiceImpl.java
  43. 29 0
      src/main/java/com/uas/ps/product/service/impl/UsageLogServiceImpl.java
  44. 72 0
      src/main/java/com/uas/ps/product/util/ContextUtils.java
  45. 133 0
      src/main/java/com/uas/ps/product/util/FileBuffer.java
  46. 79 0
      src/main/java/com/uas/ps/product/util/PathUtils.java
  47. 32 0
      src/main/resources/application.yml
  48. 19 0
      src/main/resources/config/application-dev.properties
  49. 44 0
      src/main/resources/logback.xml

+ 50 - 0
.gitignore

@@ -0,0 +1,50 @@
+# --------------------
+# idea
+.idea/
+*.iml
+
+# --------------------
+# eclipse
+.settings/
+.classpath
+.project
+
+# --------------------
+# Java
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+# --------------------
+# Maven
+target/
+pom.xml.tag
+pom.xml.releaseBackup
+pom.xml.versionsBackup
+pom.xml.next
+release.properties
+dependency-reduced-pom.xml
+buildNumber.properties
+.mvn/timing.properties
+
+# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
+!/.mvn/wrapper/maven-wrapper.jar

+ 2 - 0
README.md

@@ -0,0 +1,2 @@
+## Product Server
+* enUU and userUU must be specified when saveProducts

+ 75 - 0
pom.xml

@@ -0,0 +1,75 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>com.uas.ps</groupId>
+        <artifactId>ps-parent</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+    <artifactId>ps-product</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>com.uas.ps</groupId>
+            <artifactId>ps-core</artifactId>
+        </dependency>
+
+        <!-- spring boot -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-security</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.hibernate</groupId>
+            <artifactId>hibernate-ehcache</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 42 - 0
src/main/java/com/uas/ps/product/Application.java

@@ -0,0 +1,42 @@
+package com.uas.ps.product;
+
+import com.uas.ps.product.util.ContextUtils;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.event.ApplicationPreparedEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+
+
+/**
+ * 应用入口
+ *
+ * @author sunyj
+ * @since 2017年8月16日 下午4:00:03
+ */
+@EnableTransactionManagement
+@SpringBootApplication
+@EnableWebMvc
+public class Application {
+    public static void main(String[] args) throws FileNotFoundException {
+        File logFile = new File("logs/log.log");
+        if (!logFile.getParentFile().exists()) {
+            logFile.getParentFile().mkdir();
+        }
+        System.setErr(new PrintStream(new FileOutputStream(logFile, true)));
+        SpringApplication application = new SpringApplication(Application.class);
+        application.addListeners(new ApplicationListener<ApplicationPreparedEvent>() {
+            @Override
+            public void onApplicationEvent(ApplicationPreparedEvent event) {
+                ContextUtils.setApplicationContext(event.getApplicationContext());
+            }
+        });
+        application.run(args);
+    }
+}

+ 128 - 0
src/main/java/com/uas/ps/product/DruidDBConfiguration.java

@@ -0,0 +1,128 @@
+package com.uas.ps.product;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.support.http.StatViewServlet;
+import com.alibaba.druid.support.http.WebStatFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+import java.sql.SQLException;
+
+@Configuration
+public class DruidDBConfiguration {
+
+    private Logger logger = LoggerFactory.getLogger(DruidDBConfiguration.class);
+
+    @Value("${datasource.url}")
+    private String url;
+
+    @Value("${datasource.username}")
+    private String username;
+
+    @Value("${datasource.password}")
+    private String password;
+
+    @Value("${datasource.driverClassName}")
+    private String driverClassName;
+
+    @Value("${datasource.initialSize}")
+    private int initialSize;
+
+    @Value("${datasource.minIdle}")
+    private int minIdle;
+
+    @Value("${datasource.maxActive}")
+    private int maxActive;
+
+    @Value("${datasource.maxWait}")
+    private int maxWait;
+
+    @Value("${datasource.timeBetweenEvictionRunsMillis}")
+    private int timeBetweenEvictionRunsMillis;
+
+    @Value("${datasource.minEvictableIdleTimeMillis}")
+    private int minEvictableIdleTimeMillis;
+
+    @Value("${datasource.validationQuery}")
+    private String validationQuery;
+
+    @Value("${datasource.testWhileIdle}")
+    private boolean testWhileIdle;
+
+    @Value("${datasource.testOnBorrow}")
+    private boolean testOnBorrow;
+
+    @Value("${datasource.testOnReturn}")
+    private boolean testOnReturn;
+
+    @Value("${datasource.timeBetweenLogStatsMillis}")
+    private int timeBetweenLogStatsMillis;
+
+    @Value("${datasource.poolPreparedStatements}")
+    private boolean poolPreparedStatements;
+
+    @Value("${datasource.maxPoolPreparedStatementPerConnectionSize}")
+    private int maxPoolPreparedStatementPerConnectionSize;
+
+    @Value("${datasource.filters}")
+    private String filters;
+
+    @Value("${datasource.connectionProperties}")
+    private String connectionProperties;
+
+    @Bean
+    @Primary
+    public DataSource dataSource() {
+        DruidDataSource dataSource = new DruidDataSource();
+
+        dataSource.setUrl(url);
+        dataSource.setUsername(username);
+        dataSource.setPassword(password);
+        dataSource.setDriverClassName(driverClassName);
+
+        // configuration
+        dataSource.setInitialSize(initialSize);
+        dataSource.setMinIdle(minIdle);
+        dataSource.setMaxActive(maxActive);
+        dataSource.setMaxWait(maxWait);
+        dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+        dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
+        dataSource.setValidationQuery(validationQuery);
+        dataSource.setTestWhileIdle(testWhileIdle);
+        dataSource.setTestOnBorrow(testOnBorrow);
+        dataSource.setTestOnReturn(testOnReturn);
+        dataSource.setTimeBetweenLogStatsMillis(timeBetweenLogStatsMillis);
+        dataSource.setPoolPreparedStatements(poolPreparedStatements);
+        dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
+        try {
+            dataSource.setFilters(filters);
+        } catch (SQLException e) {
+            logger.error("数据源初始化失败: setFilters", e);
+        }
+        dataSource.setConnectionProperties(connectionProperties);
+        return dataSource;
+    }
+
+    @Bean
+    public ServletRegistrationBean servletRegistrationBean() {
+        return new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
+    }
+
+    @Bean
+    public FilterRegistrationBean filterRegistrationBean() {
+        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
+        filterRegistrationBean.setFilter(new WebStatFilter());
+        filterRegistrationBean.addUrlPatterns("/*");
+        filterRegistrationBean.addInitParameter("exclusions",
+                "*.js,*.gif,*.jpg,*.png,*.bmp,*.css,*.ico,*.html,/druid/*");
+        return filterRegistrationBean;
+    }
+
+}

+ 71 - 0
src/main/java/com/uas/ps/product/WebAppConfiguration.java

@@ -0,0 +1,71 @@
+package com.uas.ps.product;
+
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.alibaba.fastjson.support.config.FastJsonConfig;
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Web相关配置
+ *
+ * @author sunyj
+ * @since 2017年2月17日 下午5:45:38
+ */
+@Configuration
+@ComponentScan
+public class WebAppConfiguration extends WebMvcConfigurerAdapter {
+
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        // Spring boot默认资源路径在src/main/resources下,而非/src/main/webapp
+        // 使用/src/main/webapp下资源均需在此添加
+        registry.addResourceHandler("/static/**").addResourceLocations("/resources/");
+        registry.addResourceHandler("/WEB-INF/**").addResourceLocations("/WEB-INF/");
+        super.addResourceHandlers(registry);
+    }
+
+    @Override
+    public void configureViewResolvers(ViewResolverRegistry registry) {
+        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver("/WEB-INF/views/", ".html");
+        viewResolver.setContentType("text/html;charset=UTF-8");
+        registry.viewResolver(viewResolver);
+        super.configureViewResolvers(registry);
+    }
+
+    @Override
+    public void addViewControllers(ViewControllerRegistry registry) {
+        registry.addViewController("/").setViewName("index");
+        registry.addViewController("/index").setViewName("index");
+        super.addViewControllers(registry);
+    }
+
+    @Override
+    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
+        FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
+        fastJsonHttpMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));
+        FastJsonConfig fastJsonConfig = new FastJsonConfig();
+        fastJsonConfig.setSerializerFeatures(SerializerFeature.DisableCircularReferenceDetect);
+        fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
+        converters.add(fastJsonHttpMessageConverter);
+
+        StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(
+                Charset.forName("UTF-8"));
+        stringHttpMessageConverter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_HTML));
+        converters.add(stringHttpMessageConverter);
+        super.configureMessageConverters(converters);
+    }
+
+}

+ 107 - 0
src/main/java/com/uas/ps/product/controller/ProductController.java

@@ -0,0 +1,107 @@
+package com.uas.ps.product.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.ps.product.dao.UserDao;
+import com.uas.ps.product.logging.BufferedLoggerManager;
+import com.uas.ps.product.logging.erp.ErpBufferedLogger;
+import com.uas.ps.product.model.Prod;
+import com.uas.ps.product.model.User;
+import com.uas.ps.product.service.ProductService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.List;
+
+/**
+ * 物料处理
+ *
+ * @author sunyj
+ * @since 2018/1/6 16:49
+ */
+@Controller
+@RequestMapping("/product")
+public class ProductController {
+
+    private final static ErpBufferedLogger logger = BufferedLoggerManager.getLogger(ErpBufferedLogger.class);
+
+    @Autowired
+    private ProductService productService;
+
+    @Autowired
+    private UserDao userDao;
+
+    /**
+     * 将ERP的产品资料写到平台
+     *
+     * @param data
+     * @return
+     * @throws UnsupportedEncodingException
+     */
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    public void saveProducts(@RequestParam("data") String data) throws UnsupportedEncodingException {
+        String jsonStr = URLDecoder.decode(data, "UTF-8");
+        List<Prod> prods = JSONObject.parseArray(jsonStr, Prod.class);
+        productService.save(productService.convertProduct(prods));
+        log(prods, "上传物料资料");
+    }
+
+    /**
+     * 定时任务更新物料信息
+     *
+     * @param data
+     * @return
+     * @throws UnsupportedEncodingException
+     */
+    @RequestMapping(value = "/cycleupdate", method = RequestMethod.POST)
+    @ResponseBody
+    public void updateProducts(@RequestParam("data") String data) throws UnsupportedEncodingException {
+        String jsonStr = URLDecoder.decode(data, "UTF-8");
+        List<Prod> prods = JSONObject.parseArray(jsonStr, Prod.class);
+        productService.save(productService.convertProduct(prods));
+        log(prods, "定时任务更新物料资料");
+    }
+
+    private void log(List<Prod> prods, String message) {
+        if (prods.size() < 1) {
+            throw new IllegalArgumentException("物料资料为空");
+        }
+        Prod prod = prods.get(0);
+        Long enUU = prod.getEnUU();
+        Long userUU = prod.getUserUU();
+        User user = userDao.findOne(userUU);
+        logger.log(enUU, userUU, user.getIp(), "物料资料", message, prods.size());
+    }
+
+    /**
+     * 一键匹配
+     *
+     * @param enUU
+     * @param userUU
+     * @return
+     */
+    @RequestMapping("/match")
+    @ResponseBody
+    public ModelMap match(@RequestParam Long enUU, @RequestParam Long userUU) {
+        return productService.match(enUU, userUU);
+    }
+
+    /**
+     * 分配个人物料
+     *
+     * @param userUU
+     * @param productId
+     * @return
+     */
+    @RequestMapping("/assign")
+    @ResponseBody
+    public ModelMap assignPersonalProduct(@RequestParam Long userUU, @RequestParam Long productId) {
+        return productService.assignPersonalProduct(userUU, productId);
+    }
+}

+ 14 - 0
src/main/java/com/uas/ps/product/dao/EnterpriseDao.java

@@ -0,0 +1,14 @@
+package com.uas.ps.product.dao;
+
+import com.uas.ps.product.model.Enterprise;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sunyj
+ * @since 2018/1/8 11:44
+ */
+@Repository
+public interface EnterpriseDao extends JpaSpecificationExecutor<Enterprise>, JpaRepository<Enterprise, Long> {
+}

+ 28 - 0
src/main/java/com/uas/ps/product/dao/ProductDao.java

@@ -0,0 +1,28 @@
+package com.uas.ps.product.dao;
+
+import com.uas.ps.product.model.Product;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.QueryHints;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.QueryHint;
+import java.util.List;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:20
+ */
+@Repository
+public interface ProductDao extends JpaSpecificationExecutor<Product>, JpaRepository<Product, Long> {
+
+    /**
+     * 按所属企业的ID和产品的编号查找产品
+     *
+     * @param enUU
+     * @param code
+     * @return
+     */
+    @QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
+    public List<Product> findByEnUUAndCode(long enUU, String code);
+}

+ 22 - 0
src/main/java/com/uas/ps/product/dao/ProductMatchResultDao.java

@@ -0,0 +1,22 @@
+package com.uas.ps.product.dao;
+
+import com.uas.ps.product.model.ProductMatchResult;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sunyj
+ * @since 2018/1/9 15:11
+ */
+@Repository
+public interface ProductMatchResultDao extends JpaSpecificationExecutor<ProductMatchResult>, JpaRepository<ProductMatchResult, Long> {
+
+    /**
+     * 清除掉原来匹配的数据
+     *
+     * @param enuu
+     * @return
+     */
+    int deleteByEnuu(Long enuu);
+}

+ 24 - 0
src/main/java/com/uas/ps/product/dao/ProductStoreStatusDao.java

@@ -0,0 +1,24 @@
+package com.uas.ps.product.dao;
+
+import com.uas.ps.product.model.ProductStoreStatus;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sunyj
+ * @since 2018/1/9 15:15
+ */
+@Repository
+public interface ProductStoreStatusDao
+        extends JpaRepository<ProductStoreStatus, Long>, JpaSpecificationExecutor<ProductStoreStatus> {
+
+    /**
+     * 通过uu号查询当前操作状态
+     *
+     * @param enuu
+     * @return
+     */
+    ProductStoreStatus findByEnuu(Long enuu);
+
+}

+ 17 - 0
src/main/java/com/uas/ps/product/dao/ProductUsersDao.java

@@ -0,0 +1,17 @@
+package com.uas.ps.product.dao;
+
+import com.uas.ps.product.model.ProductUsers;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sunyj
+ * @since 2018/1/9 17:21
+ */
+@Repository
+public interface ProductUsersDao extends JpaSpecificationExecutor<ProductUsers>, JpaRepository<ProductUsers, Long> {
+
+    ProductUsers findByUserUUAndProductId(Long userUU, Long productId);
+
+}

+ 15 - 0
src/main/java/com/uas/ps/product/dao/UsageLogDao.java

@@ -0,0 +1,15 @@
+package com.uas.ps.product.dao;
+
+import com.uas.ps.product.model.UsageLog;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sunyj
+ * @since 2018/1/9 16:30
+ */
+@Repository
+public interface UsageLogDao extends JpaSpecificationExecutor<UsageLog>, JpaRepository<UsageLog, Long> {
+
+}

+ 14 - 0
src/main/java/com/uas/ps/product/dao/UserDao.java

@@ -0,0 +1,14 @@
+package com.uas.ps.product.dao;
+
+import com.uas.ps.product.model.User;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sunyj
+ * @since 2018/1/8 11:43
+ */
+@Repository
+public interface UserDao extends JpaSpecificationExecutor<User>, JpaRepository<User, Long> {
+}

+ 17 - 0
src/main/java/com/uas/ps/product/logging/BufferedLogable.java

@@ -0,0 +1,17 @@
+package com.uas.ps.product.logging;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:32
+ */
+public abstract class BufferedLogable {
+
+    protected static final String separator = "#";
+
+    public BufferedLogable() {
+    }
+
+    public abstract String bufferedMessage();
+
+    public abstract void bufferedLog(String var1);
+}

+ 113 - 0
src/main/java/com/uas/ps/product/logging/BufferedLogger.java

@@ -0,0 +1,113 @@
+package com.uas.ps.product.logging;
+
+import com.uas.ps.product.util.FileBuffer;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:38
+ */
+public abstract class BufferedLogger<T extends BufferedLogable> {
+    private String logPath;
+    private String currentLogFile;
+    private Class<T> logClass;
+    private FileBuffer fileBuffer;
+    private LogService<T> logService;
+
+    public BufferedLogger() {
+    }
+
+    public BufferedLogger(String basePath, Class<T> logClass, LogService<T> logService) {
+        this.logPath = basePath + File.separator + "buff_log" + File.separator + logClass.getName();
+        this.logClass = logClass;
+        this.fileBuffer = new FileBuffer(this.logPath, this.getFileName());
+        this.logService = logService;
+        this.leaveOver();
+    }
+
+    public void log(T bufferedLogable) {
+        if (!this.fileBuffer.append(bufferedLogable.bufferedMessage()) && this.logService != null) {
+            this.logService.save(bufferedLogable);
+        }
+
+    }
+
+    protected Set<T> read(FileBuffer buffer) {
+        Set<T> logs = new HashSet();
+        String bufferedMessage;
+
+        while ((bufferedMessage = buffer.readLine()) != null) {
+            try {
+                T instance = this.logClass.newInstance();
+                instance.bufferedLog(bufferedMessage);
+                logs.add(instance);
+            } catch (InstantiationException var5) {
+                ;
+            } catch (IllegalAccessException var6) {
+                ;
+            }
+        }
+
+        return logs;
+    }
+
+    protected String getFileName() {
+        this.currentLogFile = String.valueOf(System.currentTimeMillis());
+        return this.currentLogFile;
+    }
+
+    public void switchOver() {
+        FileBuffer oldFileBuffer = this.fileBuffer;
+        if (!oldFileBuffer.isEmpty()) {
+            this.fileBuffer = new FileBuffer(this.logPath, this.getFileName());
+            if (this.logService != null) {
+                this.logService.save(this.read(oldFileBuffer));
+            }
+
+            oldFileBuffer.delete();
+        }
+
+    }
+
+    protected void leaveOver() {
+        if (this.logService != null) {
+            File folder = new File(this.logPath);
+            if (folder.isDirectory()) {
+                File[] files = folder.listFiles();
+                if (files != null) {
+                    String fileName = null;
+                    File[] var4 = files;
+                    int var5 = files.length;
+
+                    for (int var6 = 0; var6 < var5; ++var6) {
+                        File file = var4[var6];
+                        fileName = file.getName();
+                        if (!fileName.equals(this.currentLogFile)) {
+                            FileBuffer buffer = new FileBuffer(this.logPath, fileName);
+
+                            try {
+                                this.logService.save(this.read(buffer));
+                            } catch (Exception var13) {
+                                ;
+                            } finally {
+                                buffer.delete();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+    }
+
+    protected void finalize() throws Throwable {
+        super.finalize();
+        if (this.fileBuffer != null) {
+            this.fileBuffer.close();
+        }
+
+    }
+}

+ 34 - 0
src/main/java/com/uas/ps/product/logging/BufferedLoggerManager.java

@@ -0,0 +1,34 @@
+package com.uas.ps.product.logging;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:41
+ */
+public class BufferedLoggerManager {
+    private static Map<String, BufferedLogger> loggers = new HashMap();
+
+    public BufferedLoggerManager() {
+    }
+
+    public static <T extends BufferedLogger<S>, S extends BufferedLogable> T getLogger(Class<T> cls) {
+        String clsName = cls.getName();
+        if (loggers.containsKey(clsName)) {
+            return (T) loggers.get(clsName);
+        } else {
+            try {
+                T instance = cls.newInstance();
+                loggers.put(clsName, instance);
+                return instance;
+            } catch (InstantiationException var3) {
+                ;
+            } catch (IllegalAccessException var4) {
+                ;
+            }
+
+            return null;
+        }
+    }
+}

+ 12 - 0
src/main/java/com/uas/ps/product/logging/LogService.java

@@ -0,0 +1,12 @@
+package com.uas.ps.product.logging;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:37
+ */
+public interface LogService<T extends BufferedLogable> {
+
+    void save(T var1);
+
+    void save(Iterable<T> var1);
+}

+ 65 - 0
src/main/java/com/uas/ps/product/logging/UsageBufferedLogger.java

@@ -0,0 +1,65 @@
+package com.uas.ps.product.logging;
+
+import com.uas.ps.product.model.UsageLog;
+import com.uas.ps.product.service.UsageLogService;
+import com.uas.ps.product.util.ContextUtils;
+import com.uas.ps.product.util.PathUtils;
+
+/**
+ * 平台的异步日志记录的工具
+ *
+ * @author sunyj
+ * @since 2018/1/9 15:17
+ */
+public class UsageBufferedLogger extends BufferedLogger<UsageLog> {
+
+    public UsageBufferedLogger() {
+        super(PathUtils.getFilePath(), UsageLog.class, ContextUtils.getBean(UsageLogService.class));
+    }
+
+    /**
+     * 记录平台使用日志
+     *
+     * @param title   消息标题
+     * @param message 消息
+     */
+    public void log(Long enUU, Long userUU, String ip, String title, String message) {
+        log(new UsageLog(enUU, userUU, ip, title, message, null, null, null));
+    }
+
+    /**
+     * 记录平台密码找回日志
+     *
+     * @param title   消息标题
+     * @param message 消息
+     */
+    public void log(String title, String message, Long userUU, String ip) {
+        log(new UsageLog(title, message, userUU, ip, null, null));
+    }
+
+    /**
+     * 记录平台使用日志
+     *
+     * @param title       消息标题
+     * @param message     消息
+     * @param description 消息详细描述
+     */
+    public void log(Long enUU, Long userUU, String ip, String title, String message, String description) {
+        log(new UsageLog(enUU, userUU, ip, title, message, description, null, null));
+    }
+
+    /**
+     * 记录平台使用日志
+     *
+     * @param title        消息标题
+     * @param message      消息
+     * @param description  消息详细描述
+     * @param relativeCode 相关单据号
+     * @param relativeKey  相关单据主键
+     */
+    public void log(Long enUU, Long userUU, String ip, String title, String message, String description,
+                    String relativeCode, Long relativeKey) {
+        log(new UsageLog(enUU, userUU, ip, title, message, description, relativeCode, relativeKey));
+    }
+
+}

+ 32 - 0
src/main/java/com/uas/ps/product/logging/erp/ErpBufferedLogger.java

@@ -0,0 +1,32 @@
+package com.uas.ps.product.logging.erp;
+
+import com.uas.ps.product.logging.BufferedLogger;
+import com.uas.ps.product.util.ContextUtils;
+import com.uas.ps.product.util.PathUtils;
+
+/**
+ * erp交互的异步日志记录的工具
+ *
+ * @author sunyj
+ * @since 2018/1/6 17:30
+ */
+public class ErpBufferedLogger extends BufferedLogger<ErpLog> {
+
+    public ErpBufferedLogger() {
+        super(PathUtils.getFilePath(), ErpLog.class, ContextUtils.getBean(ErpLogService.class));
+    }
+
+    /**
+     * 记录erp交互日志
+     *
+     * @param title   消息标题
+     * @param message 消息
+     * @param total   数据量
+     */
+    public void log(Long enUU, Long userUU, String ip, String title, String message, int total) {
+        // 有数据量才记录
+        if (total > 0)
+            log(new ErpLog(enUU, userUU, ip, title, message, total));
+    }
+
+}

+ 199 - 0
src/main/java/com/uas/ps/product/logging/erp/ErpLog.java

@@ -0,0 +1,199 @@
+package com.uas.ps.product.logging.erp;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.uas.ps.core.util.DateFormatUtils;
+import com.uas.ps.product.logging.BufferedLogable;
+import com.uas.ps.product.model.EnterpriseInfo;
+import com.uas.ps.product.model.User;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 与ERP交互的日志
+ *
+ * @author sunyj
+ * @since 2018/1/6 17:31
+ */
+@Entity
+@Table(name = "log$erp", indexes = {@Index(name = "log$erp_enuu_idx", columnList = "log_enuu")})
+public class ErpLog extends BufferedLogable implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "log_id")
+    private Long id;
+
+    @OneToOne(cascade = {CascadeType.REFRESH})
+    @JoinColumn(name = "log_enuu", insertable = false, updatable = false)
+    private EnterpriseInfo enterpriseInfo;
+
+    @Column(name = "log_enuu")
+    private Long enUU;
+
+    @OneToOne(cascade = {CascadeType.REFRESH})
+    @JoinColumn(name = "log_useruu", insertable = false, updatable = false)
+    private User user;
+
+    @NotNull
+    @Column(name = "log_useruu")
+    private Long userUU;
+
+    /**
+     * 日志时间
+     */
+    @Column(name = "log_time")
+    private Long time;
+
+    /**
+     * ip
+     */
+    @Column(name = "log_ip")
+    private String ip;
+
+    @Column(name = "log_title")
+    private String title;
+
+    @Column(name = "log_message")
+    private String message;
+
+    /**
+     * 传输的总数据量
+     */
+    @Column(name = "log_total")
+    private Integer total;
+
+    public ErpLog() {
+
+    }
+
+    public ErpLog(Long enUU, Long userUU, String ip, String title, String message, int total) {
+        this.enUU = enUU;
+        this.title = title;
+        this.message = message;
+        this.time = new Date().getTime();
+        this.total = total;
+        this.userUU = userUU;
+        this.ip = ip;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public Long getTime() {
+        return time;
+    }
+
+    public void setTime(Long time) {
+        this.time = time;
+    }
+
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public Integer getTotal() {
+        return total;
+    }
+
+    public void setTotal(Integer total) {
+        this.total = total;
+    }
+
+    public User getUser() {
+        return user;
+    }
+
+    public void setUser(User user) {
+        this.user = user;
+    }
+
+    public EnterpriseInfo getEnterpriseInfo() {
+        return enterpriseInfo;
+    }
+
+    public void setEnterpriseInfo(EnterpriseInfo enterpriseInfo) {
+        this.enterpriseInfo = enterpriseInfo;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getTimeString() {
+        return DateFormatUtils.DATETIME_FORMAT.format(getTime());
+    }
+
+    public void bufferedLog(String bufferedMessage) {
+        String[] strArray = bufferedMessage.split(separator);
+        if (strArray.length == 7) {
+            this.time = Long.parseLong(strArray[0]);
+            this.ip = strArray[1];
+            this.enUU = Long.parseLong(strArray[2]);
+            this.userUU = Long.parseLong(strArray[3]);
+            this.title = strArray[4];
+            this.message = strArray[5];
+            this.total = Integer.parseInt(strArray[6]);
+        }
+    }
+
+    @Override
+    public String bufferedMessage() {
+        StringBuffer sb = new StringBuffer();
+        sb.append(this.time).append(separator);
+        sb.append(this.ip).append(separator);
+        sb.append(this.enUU).append(separator);
+        sb.append(this.userUU).append(separator);
+        sb.append(this.title).append(separator);
+        sb.append(this.message).append(separator);
+        sb.append(this.total);
+        return sb.toString();
+    }
+
+}

+ 15 - 0
src/main/java/com/uas/ps/product/logging/erp/ErpLogDao.java

@@ -0,0 +1,15 @@
+package com.uas.ps.product.logging.erp;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sunyj
+ * @since 2018/1/8 14:37
+ */
+
+@Repository
+public interface ErpLogDao extends JpaSpecificationExecutor<ErpLog>, JpaRepository<ErpLog, Long> {
+
+}

+ 11 - 0
src/main/java/com/uas/ps/product/logging/erp/ErpLogService.java

@@ -0,0 +1,11 @@
+package com.uas.ps.product.logging.erp;
+
+
+import com.uas.ps.product.logging.LogService;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:37
+ */
+public interface ErpLogService extends LogService<ErpLog> {
+}

+ 25 - 0
src/main/java/com/uas/ps/product/logging/erp/ErpLogServiceImpl.java

@@ -0,0 +1,25 @@
+package com.uas.ps.product.logging.erp;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author sunyj
+ * @since 2018/1/8 14:35
+ */
+@Service
+public class ErpLogServiceImpl implements ErpLogService {
+
+    @Autowired
+    private ErpLogDao erpLogDao;
+
+    @Override
+    public void save(ErpLog log) {
+        erpLogDao.save(log);
+    }
+
+    @Override
+    public void save(Iterable<ErpLog> logs) {
+        erpLogDao.save(logs);
+    }
+}

+ 194 - 0
src/main/java/com/uas/ps/product/model/Attach.java

@@ -0,0 +1,194 @@
+package com.uas.ps.product.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 16:53
+ */
+@Entity
+@Table(name = "attachs")
+public class Attach implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "at_id")
+    private Long id;
+    /**
+     * 路径
+     */
+    @Column(name = "at_path")
+    private String path;
+    /**
+     * 描述语
+     */
+    @Column(name = "at_description")
+    private String description;
+    /**
+     * 文件名称
+     */
+    @Column(name = "at_name")
+    private String name;
+
+    /**
+     * 文件大小
+     */
+    @Column(name = "at_size")
+    private Long size;
+
+    /**
+     * 关联的表
+     */
+    @Column(name = "rel_table")
+    private String relativeTable;
+
+    /**
+     * 关联的数据主键值
+     */
+    @Column(name = "rel_key")
+    private Long relativeKey;
+
+    /**
+     * 保存时间
+     */
+    @Column(name = "at_date")
+    private Date date;
+
+    @Transient
+    private String sourceId;
+
+    public Attach() {
+    }
+
+    /**
+     * @param fileName    文件名
+     * @param filePath    文件物理路径
+     * @param description 描述
+     * @param size        大小
+     */
+    public Attach(String fileName, String filePath, String description, long size) {
+        this.name = fileName;
+        this.path = filePath;
+        this.description = description;
+        this.size = size;
+    }
+
+    /**
+     * @param fileName
+     * @param filePath
+     * @param description
+     * @param size
+     * @param date
+     */
+    public Attach(String fileName, String filePath, String description, long size, Date date) {
+        this.name = fileName;
+        this.path = filePath;
+        this.description = description;
+        this.size = size;
+        this.date = date;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    //	@JsonIgnore
+    //	@JSONField(serialize = false)
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Long getSize() {
+        return size;
+    }
+
+    public void setSize(Long size) {
+        this.size = size;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getSourceId() {
+        return sourceId;
+    }
+
+    public void setSourceId(String sourceId) {
+        this.sourceId = sourceId;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getRelativeTable() {
+        return relativeTable;
+    }
+
+    /**
+     * 不再用这种关联方式,如果一对一直接保存ID,如果一对多采用中间表 @since 2017年03月19日 suntg
+     *
+     * @param relativeTable
+     */
+    @Deprecated
+    public void setRelativeTable(String relativeTable) {
+        this.relativeTable = relativeTable;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Long getRelativeKey() {
+        return relativeKey;
+    }
+
+    /**
+     * 不再用这种关联方式,如果一对一直接保存ID,如果一对多采用中间表 @since 2017年03月19日 suntg
+     *
+     * @param relativeKey
+     */
+    @Deprecated
+    public void setRelativeKey(Long relativeKey) {
+        this.relativeKey = relativeKey;
+    }
+
+}

+ 35 - 0
src/main/java/com/uas/ps/product/model/Constant.java

@@ -0,0 +1,35 @@
+package com.uas.ps.product.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:05
+ */
+public class Constant {
+    public static final int PAGEMAX = 40;
+    public static final short YES = 1;
+    public static final short NO = 0;
+    public static final short TOP = 9;
+    public static final String ENV_PRODUCTION = "prod";
+    public static final String ENV_TEST = "test";
+    public static final String SUCCESS = "success";
+    public static final Map<String, String> defaultAddr = new HashMap();
+    public static final String testWeixinAccessToken = "o26W5l6ZoyAyxcyLx5xmU5Ia_hVryiwBpD3-0GALDL31EkXMGc-vEX6yilq8iB1nG_VyaF-Tly4BLrisYW5aoENFgSPXhOKqFsG1jGh94pbLqnsGqzs--Y2vClET0E7cCEGeABAWYA";
+
+    static {
+        defaultAddr.put("type", "1001");
+        defaultAddr.put("receivingName", "B2C平台");
+        defaultAddr.put("area", "广东省,深圳市,南山区");
+        defaultAddr.put("detailAddress", "广东省深圳市南山区英唐大厦");
+        defaultAddr.put("tel", "0755-26994808");
+        defaultAddr.put("email", "yingp@usoftchina.com");
+        defaultAddr.put("useruu", "");
+        defaultAddr.put("enuu", "10030994");
+        defaultAddr.put("num", "1");
+    }
+
+    public Constant() {
+    }
+}

+ 721 - 0
src/main/java/com/uas/ps/product/model/Enterprise.java

@@ -0,0 +1,721 @@
+package com.uas.ps.product.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 企业信息
+ *
+ * @author sunyj
+ * @since 2018/1/6 17:01
+ */
+@Entity
+@Table(name = "sec$enterprises")
+public class Enterprise implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "en_uu")
+    private Long uu;
+
+    /**
+     * 公司名称
+     */
+    @NotNull
+    @Column(name = "en_name")
+    private String enName;
+
+    /**
+     * 简称
+     */
+    @Column(name = "en_shortname")
+    private String enShortname;
+
+    /**
+     * 公司类型
+     */
+    @Column(name = "en_type")
+    private String enType;
+
+    /**
+     * 企业注册地区
+     */
+    @Column(name = "en_area")
+    private String enArea;
+
+    /**
+     * 状态
+     */
+    @Column(name = "en_status")
+    private Short enStatus;
+
+    /**
+     * 传输到管理平台的状态
+     */
+    @Column(name = "en_sendstatus")
+    private Short enSendStatus;
+
+    /**
+     * 注册地址
+     */
+    @Column(name = "en_address")
+    private String enAddress;
+
+    /**
+     * 默认送货地址
+     */
+    @Column(name = "en_deliveraddr")
+    private String enDeliverAddr;
+
+    /**
+     * 公司电话
+     */
+    @Column(name = "en_tel")
+    private String enTel;
+
+    /**
+     * 传真
+     */
+    @Column(name = "en_fax")
+    private String enFax;
+
+    /**
+     * 公司邮箱
+     */
+    @Column(name = "en_email")
+    private String enEmail;
+
+    /**
+     * 员工人数
+     */
+    @Column(name = "en_emcount")
+    private Integer emcount;
+
+    /**
+     * 开户银行
+     */
+    @Column(name = "en_enbank")
+    private String enbank;
+
+    /**
+     * 公司法人
+     */
+    @Column(name = "en_corporation")
+    private String enCorporation;
+
+    /**
+     * 商业登记证号
+     */
+    @Column(name = "en_businesscode")
+    private String enBussinessCode;
+
+    /**
+     * 营业执照号服务器路径,账户中心同步时同步过来
+     */
+    @Column(name = "en_businesscodeimg")
+    private String businesscodeimg;
+
+    /**
+     * 营业执照图片路径id
+     */
+    @OneToOne(cascade = {CascadeType.ALL})
+    @JoinColumn(name = "en_bussinesscodeattach")
+    private Attach enBussinessCodeAttach;
+
+    /**
+     * 纳税人识别号
+     */
+    @Column(name = "en_taxcode")
+    private String enTaxcode;
+
+    /**
+     * 注册资本
+     */
+    @Column(name = "en_registercapital")
+    private String enRegistercapital;
+
+    /**
+     * 公司主页地址
+     */
+    @Column(name = "en_url")
+    private String enUrl;
+
+    /**
+     * 注册时间
+     */
+    @Column(name = "en_time")
+    private Date enDate;
+
+    /**
+     * 管理员UU号
+     */
+    @Column(name = "en_adminuu")
+    private Long enAdminuu;
+
+    /**
+     * 所属行业
+     */
+    @Column(name = "en_industry")
+    private String enIndustry;
+
+    /**
+     * 优企云服域名
+     */
+    @Column(name = "en_saasurl")
+    private String enSaasUrl;
+
+    /**
+     * 优企云服状态
+     */
+    @Column(name = "en_saasstatus")
+    private Short enSaasStatus;
+
+    /**
+     * 优企云服传输状态
+     */
+    @Column(name = "en_saassendstatus")
+    private Short enSaasSendStatus;
+
+    /**
+     * enIsErp
+     */
+    @Column(name = "en_iserp")
+    private Short enIsErp;
+
+    /**
+     * log路径
+     */
+    @Column(name = "en_logurl")
+    private String logUrl;
+    /**
+     * en_management 经营模式
+     */
+    @Column(name = "en_management")
+    private String enManagement;
+    /**
+     * en_brands 主营品牌(多个用逗号分隔)
+     */
+    @Column(name = "en_brands")
+    private String enBrands;
+    /**
+     * en_products 主营产品
+     */
+    @Column(name = "en_products")
+    private String enProducts;
+    /**
+     * 记录产品的销售状态<br>
+     * 1. 开启<br>
+     * 0. 关闭
+     */
+    @Column(name = "en_prodsale")
+    private Short prodsale;
+    /**
+     * 记录物料的采购状态<br>
+     * 1. 开启<br>
+     * 0. 关闭
+     *
+     * @return
+     */
+    @Column(name = "en_prodpurc")
+    private Short prodpurc;
+    /**
+     * 行业
+     */
+    @Column(name = "en_profession")
+    private String profession;
+    /**
+     * 主营业务
+     */
+    @Column(name = "en_tags")
+    private String tags;
+    /**
+     * 联系人
+     */
+    @Column(name = "en_contactman")
+    private String contactMan;
+    /**
+     * 联系人电话
+     */
+    @Column(name = "en_contacttel")
+    private String contactTel;
+    /**
+     * 联系人邮箱
+     */
+    @Column(name = "en_contactemail")
+    private String contactEmail;
+    /**
+     * en_info 公司简介
+     */
+    @Column(name = "en_info")
+    private String enInfo;
+    /**
+     * 管理员密码
+     */
+    @Column(name = "en_adminpassword")
+    private String enAdminPassword;
+    @Transient
+    private User admin;// 管理员(前台页面显示)
+    @Transient
+    private Long enBussinesscodeImg;// 营业执照号附件id(转化传到管理平台)
+    @Transient
+    private String enAdminName;// 管理员名字(转化传到管理平台)
+    @Transient
+    private String enAdminTel;// 管理员手机号(转化传到管理平台)
+    @Transient
+    private String enAdminEmail;// 管理员邮箱(转化传到管理平台)
+    @Transient
+    private String enAuditRemark;// 审核(从管理平台传过来)
+    /**
+     * 私钥
+     */
+    @Column(name = "en_accesssecret")
+    private String accessSecret;
+    /**
+     * en_masterId 企业对应管理系统ID
+     */
+    @Column(name = "en_masterid")
+    private Long enMasterId;
+    private Short enable;
+
+    public Short getEnIsErp() {
+        return enIsErp;
+    }
+
+    public void setEnIsErp(Short enIsErp) {
+        this.enIsErp = enIsErp;
+    }
+
+    public String getEnManagement() {
+        return enManagement;
+    }
+
+    public void setEnManagement(String enManagement) {
+        this.enManagement = enManagement;
+    }
+
+    public String getEnProducts() {
+        return enProducts;
+    }
+
+    public void setEnProducts(String enProducts) {
+        this.enProducts = enProducts;
+    }
+
+    public String getEnInfo() {
+        return enInfo;
+    }
+
+    public void setEnInfo(String enInfo) {
+        this.enInfo = enInfo;
+    }
+
+    public Long getEnMasterId() {
+        return enMasterId;
+    }
+
+    public void setEnMasterId(Long enMasterId) {
+        this.enMasterId = enMasterId;
+    }
+
+    @JSONField(serialize = false)
+    @JsonIgnore
+    public String getEnAuditRemark() {
+        return enAuditRemark;
+    }
+
+    public void setEnAuditRemark(String enAuditRemark) {
+        this.enAuditRemark = enAuditRemark;
+    }
+
+    public Long getEnAdminuu() {
+        return enAdminuu;
+    }
+
+    public void setEnAdminuu(Long enAdminuu) {
+        this.enAdminuu = enAdminuu;
+    }
+
+    public Long getUu() {
+        return uu;
+    }
+
+    public void setUu(Long uu) {
+        this.uu = uu;
+    }
+
+    public String getEnName() {
+        return enName;
+    }
+
+    public void setEnName(String enName) {
+        this.enName = enName;
+    }
+
+    public String getEnShortname() {
+        return enShortname;
+    }
+
+    public void setEnShortname(String enShortname) {
+        this.enShortname = enShortname;
+    }
+
+    public String getEnType() {
+        return enType;
+    }
+
+    public void setEnType(String enType) {
+        this.enType = enType;
+    }
+
+    public Short getEnStatus() {
+        return enStatus;
+    }
+
+    public void setEnStatus(Short enStatus) {
+        this.enStatus = enStatus;
+    }
+
+    public String getEnAddress() {
+        return enAddress;
+    }
+
+    public void setEnAddress(String enAddress) {
+        this.enAddress = enAddress;
+    }
+
+    public String getEnDeliverAddr() {
+        return enDeliverAddr;
+    }
+
+    public void setEnDeliverAddr(String enDeliverAddr) {
+        this.enDeliverAddr = enDeliverAddr;
+    }
+
+    public String getEnTel() {
+        return enTel;
+    }
+
+    public void setEnTel(String enTel) {
+        this.enTel = enTel;
+    }
+
+    public String getEnFax() {
+        return enFax;
+    }
+
+    public void setEnFax(String enFax) {
+        this.enFax = enFax;
+    }
+
+    public String getEnCorporation() {
+        return enCorporation;
+    }
+
+    public void setEnCorporation(String enCorporation) {
+        this.enCorporation = enCorporation;
+    }
+
+    public String getEnBussinessCode() {
+        return enBussinessCode;
+    }
+
+    public void setEnBussinessCode(String enBussinessCode) {
+        this.enBussinessCode = enBussinessCode;
+    }
+
+    public String getEnBrands() {
+        return enBrands;
+    }
+
+    public void setEnBrands(String enBrands) {
+        this.enBrands = enBrands;
+    }
+
+    public String getEnTaxcode() {
+        return enTaxcode;
+    }
+
+    public void setEnTaxcode(String enTaxcode) {
+        this.enTaxcode = enTaxcode;
+    }
+
+    public String getEnRegistercapital() {
+        return enRegistercapital;
+    }
+
+    public void setEnRegistercapital(String enRegistercapital) {
+        this.enRegistercapital = enRegistercapital;
+    }
+
+    public String getEnUrl() {
+        return enUrl;
+    }
+
+    public void setEnUrl(String enUrl) {
+        this.enUrl = enUrl;
+    }
+
+    public Date getEnDate() {
+        return enDate;
+    }
+
+    public void setEnDate(Date enDate) {
+        this.enDate = enDate;
+    }
+
+    public Short getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Short enable) {
+        this.enable = enable;
+    }
+
+    public String getEnEmail() {
+        return enEmail;
+    }
+
+    public void setEnEmail(String enEmail) {
+        this.enEmail = enEmail;
+    }
+
+    public Attach getEnBussinessCodeAttach() {
+        return enBussinessCodeAttach;
+    }
+
+    public void setEnBussinessCodeAttach(Attach enBussinessCodeAttach) {
+        this.enBussinessCodeAttach = enBussinessCodeAttach;
+    }
+
+    public String getEnAdminTel() {
+        return enAdminTel;
+    }
+
+    public void setEnAdminTel(String enAdminTel) {
+        this.enAdminTel = enAdminTel;
+    }
+
+    public String getEnAdminEmail() {
+        return enAdminEmail;
+    }
+
+    public void setEnAdminEmail(String enAdminEmail) {
+        this.enAdminEmail = enAdminEmail;
+    }
+
+    public Long getEnBussinesscodeImg() {
+        return enBussinesscodeImg;
+    }
+
+    public void setEnBussinesscodeImg(Long enBussinesscodeImg) {
+        this.enBussinesscodeImg = enBussinesscodeImg;
+    }
+
+    public Short getEnSendStatus() {
+        return enSendStatus;
+    }
+
+    public void setEnSendStatus(Short enSendStatus) {
+        this.enSendStatus = enSendStatus;
+    }
+
+    public String getEnArea() {
+        return enArea;
+    }
+
+    public void setEnArea(String enArea) {
+        this.enArea = enArea;
+    }
+
+    public User getAdmin() {
+        return admin;
+    }
+
+    public void setAdmin(User admin) {
+        this.admin = admin;
+    }
+
+    public String getEnAdminName() {
+        return enAdminName;
+    }
+
+    public void setEnAdminName(String enAdminName) {
+        this.enAdminName = enAdminName;
+    }
+
+    public String getEnIndustry() {
+        return enIndustry;
+    }
+
+    public void setEnIndustry(String enIndustry) {
+        this.enIndustry = enIndustry;
+    }
+
+    public String getEnSaasUrl() {
+        return enSaasUrl;
+    }
+
+    public void setEnSaasUrl(String enSaasUrl) {
+        this.enSaasUrl = enSaasUrl;
+    }
+
+    public Short getEnSaasStatus() {
+        return enSaasStatus;
+    }
+
+    public void setEnSaasStatus(Short enSaasStatus) {
+        this.enSaasStatus = enSaasStatus;
+    }
+
+    public Short getEnSaasSendStatus() {
+        return enSaasSendStatus;
+    }
+
+    public void setEnSaasSendStatus(Short enSaasSendStatus) {
+        this.enSaasSendStatus = enSaasSendStatus;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getEnAdminPassword() {
+        return enAdminPassword;
+    }
+
+    public void setEnAdminPassword(String enAdminPassword) {
+        this.enAdminPassword = enAdminPassword;
+    }
+
+    public String getAccessSecret() {
+        return accessSecret;
+    }
+
+    public void setAccessSecret(String accessSecret) {
+        this.accessSecret = accessSecret;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public boolean isEnabled() {
+        return this.getEnable() != null && this.getEnable() == Constant.YES;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((uu == null) ? 0 : uu.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Enterprise other = (Enterprise) obj;
+        if (uu == null) {
+            if (other.uu != null)
+                return false;
+        } else if (!uu.equals(other.uu))
+            return false;
+        return true;
+    }
+
+    public String getLogUrl() {
+        return logUrl;
+    }
+
+    public void setLogUrl(String logUrl) {
+        this.logUrl = logUrl;
+    }
+
+    public Integer getEmcount() {
+        return emcount;
+    }
+
+    public void setEmcount(Integer emcount) {
+        this.emcount = emcount;
+    }
+
+    public String getEnbank() {
+        return enbank;
+    }
+
+    public void setEnbank(String enbank) {
+        this.enbank = enbank;
+    }
+
+    public Short getProdsale() {
+        return prodsale;
+    }
+
+    public void setProdsale(Short prodsale) {
+        this.prodsale = prodsale;
+    }
+
+    public Short getProdpurc() {
+        return prodpurc;
+    }
+
+    public void setProdpurc(Short prodpurc) {
+        this.prodpurc = prodpurc;
+    }
+
+    public String getBusinesscodeimg() {
+        return businesscodeimg;
+    }
+
+    public void setBusinesscodeimg(String businesscodeimg) {
+        this.businesscodeimg = businesscodeimg;
+    }
+
+    public String getProfession() {
+        return profession;
+    }
+
+    public void setProfession(String profession) {
+        this.profession = profession;
+    }
+
+    public String getTags() {
+        return tags;
+    }
+
+    public void setTags(String tags) {
+        this.tags = tags;
+    }
+
+    public String getContactMan() {
+        return contactMan;
+    }
+
+    public void setContactMan(String contactMan) {
+        this.contactMan = contactMan;
+    }
+
+    public String getContactTel() {
+        return contactTel;
+    }
+
+    public void setContactTel(String contactTel) {
+        this.contactTel = contactTel;
+    }
+
+    public String getContactEmail() {
+        return contactEmail;
+    }
+
+    public void setContactEmail(String contactEmail) {
+        this.contactEmail = contactEmail;
+    }
+}

+ 126 - 0
src/main/java/com/uas/ps/product/model/EnterpriseInfo.java

@@ -0,0 +1,126 @@
+package com.uas.ps.product.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * 企业简洁信息,只含UU号和企业名称
+ *
+ * @author sunyj
+ * @since 2018/1/6 17:33
+ */
+@Entity
+@Table(name = "sec$enterprises")
+public class EnterpriseInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "en_uu")
+    private Long uu;
+
+    /**
+     * 公司名称
+     */
+    @NotNull
+    @Column(name = "en_name")
+    private String enName;
+
+    /**
+     * 公司电话
+     */
+    @Column(name = "en_tel")
+    private String enTel;
+
+    /**
+     * 注册地址
+     */
+    @Column(name = "en_address")
+    private String enAddress;
+
+    /**
+     * 营业执照号
+     */
+    @Column(name = "en_businesscode")
+    private String businesscode;
+
+    public EnterpriseInfo(Enterprise enterprise) {
+        this.uu = enterprise.getUu();
+        this.enTel = enterprise.getEnTel();
+        this.enName = enterprise.getEnName();
+        this.enAddress = enterprise.getEnAddress();
+        this.businesscode = enterprise.getEnBussinessCode();
+    }
+
+    public EnterpriseInfo() {
+    }
+
+    public Long getUu() {
+        return uu;
+    }
+
+    public void setUu(Long uu) {
+        this.uu = uu;
+    }
+
+    public String getEnName() {
+        return enName;
+    }
+
+    public void setEnName(String enName) {
+        this.enName = enName;
+    }
+
+    public String getEnTel() {
+        return enTel;
+    }
+
+    public void setEnTel(String enTel) {
+        this.enTel = enTel;
+    }
+
+    public String getEnAddress() {
+        return enAddress;
+    }
+
+    public void setEnAddress(String enAddress) {
+        this.enAddress = enAddress;
+    }
+
+    public String getBusinesscode() {
+        return businesscode;
+    }
+
+    public void setBusinesscode(String businesscode) {
+        this.businesscode = businesscode;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((uu == null) ? 0 : uu.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        EnterpriseInfo other = (EnterpriseInfo) obj;
+        if (uu == null) {
+            if (other.uu != null)
+                return false;
+        } else if (!uu.equals(other.uu))
+            return false;
+        return true;
+    }
+}

+ 359 - 0
src/main/java/com/uas/ps/product/model/Prod.java

@@ -0,0 +1,359 @@
+package com.uas.ps.product.model;
+
+import com.uas.ps.product.dao.EnterpriseDao;
+import com.uas.ps.product.util.ContextUtils;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * ERP系统的产品
+ *
+ * @author sunyj
+ * @since 2018/1/6 16:52
+ */
+public class Prod implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Long pr_id;// 买方ERP物料ID
+    private String pr_code;
+    private String pr_detail;
+    private String pr_spec;
+    private String pr_unit;
+    private Double pr_zxbzs;
+    private Double pr_zxdhl;
+    private Double pr_leadtime;
+    private Double pr_ltinstock;// 备料提前期,天数
+    private String pr_brand;
+    private String pr_orispeccode;// 原厂型号
+    private String pr_uuid; // 标准料号
+    private String pr_status; // 状态: ‘已审核’->有效;‘已禁用’->失效
+    private Short pr_issale; // 可销售
+    private Short pr_ispurchase; // 可采购
+    private Short pr_isshow; // 开放采购物料
+    private Short pr_ispubsale; // 开发销售物料
+    private Long b2b_id; // 平台id
+    /**
+     * 类目(平台)
+     */
+    private String kind;
+
+    /**
+     * 品牌(平台)
+     */
+    private String pbrand;
+
+    /**
+     * 型号(平台)
+     */
+    private String pcmpcode;
+
+    /**
+     * 类目英文
+     */
+    private String kinden;
+
+    /**
+     * 品牌英文
+     */
+    private String pbranden;
+
+    /**
+     * 是否是标准
+     */
+    private Short standard;
+
+    /**
+     * 所属企业UU
+     */
+    private Long enUU;
+
+    /**
+     * 个人UU
+     */
+    private Long userUU;
+
+    public String getPr_code() {
+        return pr_code;
+    }
+
+    public void setPr_code(String pr_code) {
+        this.pr_code = pr_code;
+    }
+
+    public String getPr_detail() {
+        return pr_detail;
+    }
+
+    public void setPr_detail(String pr_detail) {
+        this.pr_detail = pr_detail;
+    }
+
+    public String getPr_spec() {
+        return pr_spec;
+    }
+
+    public void setPr_spec(String pr_spec) {
+        this.pr_spec = pr_spec;
+    }
+
+    public String getPr_unit() {
+        return pr_unit;
+    }
+
+    public void setPr_unit(String pr_unit) {
+        this.pr_unit = pr_unit;
+    }
+
+    public Double getPr_zxbzs() {
+        return pr_zxbzs;
+    }
+
+    public void setPr_zxbzs(Double pr_zxbzs) {
+        this.pr_zxbzs = pr_zxbzs;
+    }
+
+    public Double getPr_zxdhl() {
+        return pr_zxdhl;
+    }
+
+    public void setPr_zxdhl(Double pr_zxdhl) {
+        this.pr_zxdhl = pr_zxdhl;
+    }
+
+    public Double getPr_leadtime() {
+        return pr_leadtime;
+    }
+
+    public void setPr_leadtime(Double pr_leadtime) {
+        this.pr_leadtime = pr_leadtime;
+    }
+
+    public Double getPr_ltinstock() {
+        return pr_ltinstock;
+    }
+
+    public void setPr_ltinstock(Double pr_ltinstock) {
+        this.pr_ltinstock = pr_ltinstock;
+    }
+
+    public Long getPr_id() {
+        return pr_id;
+    }
+
+    public void setPr_id(Long pr_id) {
+        this.pr_id = pr_id;
+    }
+
+    public String getPr_orispeccode() {
+        return pr_orispeccode;
+    }
+
+    public void setPr_orispeccode(String pr_orispeccode) {
+        this.pr_orispeccode = pr_orispeccode;
+    }
+
+    public String getPr_uuid() {
+        return pr_uuid;
+    }
+
+    public void setPr_uuid(String pr_uuid) {
+        this.pr_uuid = pr_uuid;
+    }
+
+    public String getPr_status() {
+        return pr_status;
+    }
+
+    public void setPr_status(String pr_status) {
+        this.pr_status = pr_status;
+    }
+
+    public Short getPr_issale() {
+        return pr_issale;
+    }
+
+    public void setPr_issale(Short pr_issale) {
+        this.pr_issale = pr_issale;
+    }
+
+    public Short getPr_ispurchase() {
+        return pr_ispurchase;
+    }
+
+    public void setPr_ispurchase(Short pr_ispurchase) {
+        this.pr_ispurchase = pr_ispurchase;
+    }
+
+    public Short getPr_isshow() {
+        return pr_isshow;
+    }
+
+    public void setPr_isshow(Short pr_isshow) {
+        this.pr_isshow = pr_isshow;
+    }
+
+    public Short getPr_ispubsale() {
+        return pr_ispubsale;
+    }
+
+    public void setPr_ispubsale(Short pr_ispubsale) {
+        this.pr_ispubsale = pr_ispubsale;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    public String getPbrand() {
+        return pbrand;
+    }
+
+    public void setPbrand(String pbrand) {
+        this.pbrand = pbrand;
+    }
+
+    public String getPcmpcode() {
+        return pcmpcode;
+    }
+
+    public void setPcmpcode(String pcmpcode) {
+        this.pcmpcode = pcmpcode;
+    }
+
+    public String getPr_brand() {
+        return pr_brand;
+    }
+
+    public void setPr_brand(String pr_brand) {
+        this.pr_brand = pr_brand;
+    }
+
+    public String getKinden() {
+        return kinden;
+    }
+
+    public void setKinden(String kinden) {
+        this.kinden = kinden;
+    }
+
+    public String getPbranden() {
+        return pbranden;
+    }
+
+    public void setPbranden(String pbranden) {
+        this.pbranden = pbranden;
+    }
+
+    public Short getStandard() {
+        return standard;
+    }
+
+    public void setStandard(Short standard) {
+        this.standard = standard;
+    }
+
+    public Long getB2b_id() {
+        return b2b_id;
+    }
+
+    public void setB2b_id(Long b2b_id) {
+        this.b2b_id = b2b_id;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    /**
+     * 转为平台的产品
+     *
+     * @return
+     */
+    public Product convert() {
+        if (this.enUU == null || this.userUU == null) {
+            throw new IllegalArgumentException("enUU 或 userUU 为空");
+        }
+        Product product = new Product();
+        product.setCode(this.pr_code);
+        product.setEnUU(this.enUU);
+        product.setUserUU(this.userUU);
+        product.setTitle(this.pr_detail);
+        product.setSpec(this.pr_spec);
+        product.setUnit(this.pr_unit);
+        product.setMinPack(this.pr_zxbzs);
+        product.setMinOrder(this.pr_zxdhl);
+        product.setLeadtime(this.pr_leadtime);
+        product.setLtinstock(this.pr_ltinstock);
+        product.setSourceId(this.pr_id);
+        product.setBrand(this.pr_brand);
+        if (this.pr_status != null) {
+            if (this.pr_status.equals(Status.DISABLED.getPhrase())) {
+                product.setB2benabled(Constant.YES);
+            } else {
+                product.setB2benabled(null);
+            }
+
+//			if (this.pr_status.equals(Status.AUDITED.getPhrase())) {
+//				//product.setIsSale((short) 1);
+//			} else if (this.pr_status.equals(Status.DISABLED.getPhrase())) {
+//				//product.setIsSale((short) 0);
+//			}
+        }
+        if (this.pr_orispeccode != null) {
+            product.setCmpCode(this.pr_orispeccode);
+        } else {
+            product.setCmpCode(this.pr_spec);
+        }
+        // if (this.pr_uuid != null) {
+        // // 如果传过来的数据是有UUID,则把原来的信息赋值给标准信息上
+        // product.setStandard(Constant.YES);
+        // product.setPcmpcode(product.getCmpCode());
+        // product.setPbrand(product.getBrand());
+        // product.setKind(product.getTitle());
+        // } else {
+        // product.setStandard(Constant.NO);
+        // }
+        product.setStandard(Constant.NO);// 默认设置为非标准,到平台做匹配更新
+        Enterprise enter = ContextUtils.getBean(EnterpriseDao.class).findOne(this.enUU);
+        // 默认开启关闭状态都是开启
+        product.setIsPurchase(Constant.YES);
+        product.setIsSale(Constant.YES);
+        if (null != enter.getProdpurc() && enter.getProdpurc().equals(Constant.NO)) {
+            product.setIsPurchase(Constant.NO);
+        }
+        if (null != enter.getProdsale() && enter.getProdsale().equals(Constant.NO)) {
+            product.setIsSale(Constant.NO);
+        }
+        // erp上传的数据默认赋值给标准信息
+        product.setPbrand(product.getBrand());
+        product.setPcmpcode(product.getCmpCode());
+        product.setKind(product.getTitle());
+        product.setIsPubsale(this.pr_ispubsale);
+        product.setIsPurchase(this.pr_ispurchase);
+        product.setIsSale(this.pr_issale);
+        product.setIsShow(this.pr_isshow);
+        product.setStandard(this.standard);
+        product.setSourceApp("ERP");
+        product.setErpDate(new Date());
+        return product;
+    }
+
+}

+ 715 - 0
src/main/java/com/uas/ps/product/model/Product.java

@@ -0,0 +1,715 @@
+package com.uas.ps.product.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * 商品信息
+ *
+ * @author sunyj
+ * @since 2018/1/6 16:52
+ */
+@Entity
+@Table(name = "products")
+public class Product implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "pr_id")
+    private Long id;
+
+    /**
+     * 商品信息标题
+     */
+    @Column(name = "pr_title")
+    private String title;
+
+    /**
+     * 产品编号
+     */
+    @Column(name = "pr_code")
+    private String code;
+
+    /**
+     * 产品规格
+     */
+    @Column(name = "pr_spec")
+    private String spec;
+
+    /**
+     * 单位
+     */
+    @Column(name = "pr_unit")
+    private String unit;
+
+    /**
+     * 所属企业UU
+     */
+    @Column(name = "pr_enuu")
+    // TODO @EnterpriseUU
+    private Long enUU;
+
+    /**
+     * 个人UU
+     */
+    @Column(name = "pr_useruu")
+    // TODO @UserUU
+    private Long userUU;
+
+    /**
+     * 最小包装量
+     */
+    @Column(name = "pr_minpack")
+    private Double minPack;
+
+    /**
+     * 最小采购量
+     */
+    @Column(name = "pr_minorder")
+    private Double minOrder;
+
+    /**
+     * 采购提前期
+     */
+    @Column(name = "pr_leadtime")
+    private Double leadtime;
+
+    /**
+     * 备货提前期(天数)
+     */
+    @Column(name = "pr_ltinstock")
+    private Double ltinstock;
+
+    /**
+     * 状态
+     */
+    @Column(name = "pr_status")
+    // TODO @StatusColumn
+    private Integer status;
+
+    /**
+     * 库存数
+     */
+    @Column(name = "pr_stock")
+    private Double stock;
+
+    /**
+     * 价格
+     */
+    @Column(name = "pr_price")
+    private Double price;
+
+    /**
+     * 品牌(ERP)
+     */
+    @Column(name = "pr_brand")
+    private String brand;
+
+    /**
+     * 发货地址
+     */
+    @Column(name = "pr_shipaddr")
+    private String shipAddr;
+
+    /**
+     * 买方ERP物料ID
+     */
+    @Column(name = "pr_sourceid")
+    private Long sourceId;
+
+    /**
+     * 保存erp传入数据的时间
+     *
+     * @return
+     */
+    @Column(name = "pr_erpdate")
+    private Date erpDate;
+
+    /**
+     * 原厂型号(erp)
+     *
+     * @return
+     */
+    @Column(name = "pr_cmpcode")
+    private String cmpCode;
+
+    /**
+     * UUID 标准料号
+     *
+     * @return
+     */
+    @Column(name = "pr_cmpuuid")
+    private String cmpUuId;
+
+    /**
+     * 应用来源<br>
+     * 平台上传的为可以销售的
+     *
+     * @return
+     */
+    @Column(name = "pr_sourceapp")
+    private String sourceApp;
+
+    /**
+     * 是否可卖<br>
+     * 1. 可以卖 <br>
+     * 0. 不可
+     */
+    @Column(name = "pr_issale")
+    private Short isSale;
+
+    /**
+     * 是否可买<br>
+     * 1. 可以买<br>
+     * 0. 不可
+     */
+    @Column(name = "pr_ispurchase")
+    private Short isPurchase;
+
+    /**
+     * 公开展示<br>
+     * <p>
+     * 1. 是<br>
+     * 0. 否
+     */
+    @Column(name = "pr_isshow")
+    private Short isShow;
+
+    /**
+     * 公开销售 <br>
+     * 1. 是<br>
+     * 0. 否
+     */
+    @Column(name = "pr_ispubsale")
+    private Short isPubsale;
+
+    /**
+     * 附件
+     */
+    @OneToOne(cascade = {CascadeType.ALL})
+    @JoinColumn(name = "pr_attachment")
+    private Attach attach;
+
+    /**
+     * 类目(平台)(中文)
+     */
+    @Column(name = "pr_kind")
+    private String kind;
+
+    /**
+     * 品牌(平台)(中文)
+     */
+    @Column(name = "pr_pbrand")
+    private String pbrand;
+
+    /**
+     * 型号(平台)
+     */
+    @Column(name = "pr_pcmpcode")
+    private String pcmpcode;
+
+    /**
+     * 信息提示(导入物料时给出提示)
+     */
+    @Column(name = "pr_message")
+    private String message;
+
+    /**
+     * 是否是标准物料<br>
+     * 1.YES<br>
+     * 0.NO
+     */
+    @Column(name = "pr_standard")
+    private Short standard;
+
+    /**
+     * 类目(平台)(英文)
+     */
+    @Column(name = "pr_kinden")
+    private String kinden;
+
+    /**
+     * 品牌(平台)(英文)
+     */
+    @Column(name = "pr_pbranden")
+    private String pbranden;
+
+    /**
+     * 匹配状态(记录匹配状态,方便下次查看)
+     */
+    @Column(name = "pr_matchstatus")
+    private Integer matchstatus;
+
+    /**
+     * 匹配数量(用作排序)
+     */
+    @Column(name = "pr_matchsize")
+    private Integer matchsize;
+
+    /**
+     * 匹配结果
+     */
+    @OneToMany(mappedBy = "product", cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
+    private Set<ProductMatchResult> matchresults;
+
+    /**
+     * 下载状态,平台更新ERP的数据后,将数据回传回ERP更新
+     */
+    @Column(name = "pr_downloadstatus")
+    private Integer downloadstatus;
+
+    /**
+     * 是否有业务逻辑关系<br>
+     * 1. 是<br>
+     * 0. 否
+     */
+    @Column(name = "pr_isbusiness")
+    private Short isbusiness;
+
+    /**
+     * 图片
+     */
+    @Column(name = "pr_cmpimg")
+    private String img;
+
+    /**
+     * 包装
+     */
+    @Column(name = "pr_encapsulation")
+    private String encapsulation;
+
+    /**
+     * b2c可用状态;<br>
+     * 1 为不存在相同的记录。<br>
+     * 0 为已经存在相同的记录
+     */
+    @Column(name = "pr_b2cenabled")
+    private Short b2cenabled;
+
+    /**
+     * uas与b2b可用状态;<br>
+     * 1 已禁用 <br>
+     * 0 可用状态,未禁用
+     */
+    @Column(name = "pr_b2benabled")
+    private Short b2benabled;
+
+    /**
+     * 匹配成标准的日期
+     */
+    @Column(name = "pr_tostandard")
+    private Date tostandard;
+
+    /**
+     * 编码版本号
+     */
+    @Column(name = "pr_goodsnover")
+    private String goodsnover;
+
+    /**
+     * 税收分类编码
+     */
+    @Column(name = "pr_goodstaxno")
+    private String goodstaxno;
+
+    /**
+     * 是否享受优惠政策
+     */
+    @Column(name = "pr_taxpre")
+    private String taxpre;
+
+    /**
+     * 享受优惠政策内容
+     */
+    @Column(name = "pr_taxprecon")
+    private String taxprecon;
+
+
+    public Product() {
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getSpec() {
+        return spec;
+    }
+
+    public void setSpec(String spec) {
+        this.spec = spec;
+    }
+
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public Double getMinPack() {
+        return minPack;
+    }
+
+    public void setMinPack(Double minPack) {
+        this.minPack = minPack;
+    }
+
+    public Double getMinOrder() {
+        return minOrder;
+    }
+
+    public void setMinOrder(Double minOrder) {
+        this.minOrder = minOrder;
+    }
+
+    public Double getLeadtime() {
+        return leadtime;
+    }
+
+    public void setLeadtime(Double leadtime) {
+        this.leadtime = leadtime;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Double getStock() {
+        return stock;
+    }
+
+    public void setStock(Double stock) {
+        this.stock = stock;
+    }
+
+    public Double getPrice() {
+        return price;
+    }
+
+    public void setPrice(Double price) {
+        this.price = price;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getShipAddr() {
+        return shipAddr;
+    }
+
+    public void setShipAddr(String shipAddr) {
+        this.shipAddr = shipAddr;
+    }
+
+    public Double getLtinstock() {
+        return ltinstock;
+    }
+
+    public void setLtinstock(Double ltinstock) {
+        this.ltinstock = ltinstock;
+    }
+
+    public Long getSourceId() {
+        return sourceId;
+    }
+
+    public void setSourceId(Long sourceId) {
+        this.sourceId = sourceId;
+    }
+
+    public Date getErpDate() {
+        return erpDate;
+    }
+
+    public void setErpDate(Date erpDate) {
+        this.erpDate = erpDate;
+    }
+
+    public String getCmpCode() {
+        return cmpCode;
+    }
+
+    public void setCmpCode(String cmpCode) {
+        this.cmpCode = cmpCode;
+    }
+
+    public String getCmpUuId() {
+        return cmpUuId;
+    }
+
+    public void setCmpUuId(String cmpUuId) {
+        this.cmpUuId = cmpUuId;
+    }
+
+    @Override
+    public String toString() {
+        return "编号:" + getCode() + ",标题:" + getTitle() + ",规格型号:" + getSpec();
+    }
+
+    public String getSourceApp() {
+        return sourceApp;
+    }
+
+    public void setSourceApp(String sourceApp) {
+        this.sourceApp = sourceApp;
+    }
+
+    public Attach getAttach() {
+        return attach;
+    }
+
+    public void setAttach(Attach attach) {
+        this.attach = attach;
+    }
+
+    public Short getIsSale() {
+        return isSale;
+    }
+
+    public void setIsSale(Short isSale) {
+        this.isSale = isSale;
+    }
+
+    public Short getIsPurchase() {
+        return isPurchase;
+    }
+
+    public void setIsPurchase(Short isPurchase) {
+        this.isPurchase = isPurchase;
+    }
+
+    public Short getIsShow() {
+        return isShow;
+    }
+
+    public void setIsShow(Short isShow) {
+        this.isShow = isShow;
+    }
+
+    public Short getIsPubsale() {
+        return isPubsale;
+    }
+
+    public void setIsPubsale(Short isPubsale) {
+        this.isPubsale = isPubsale;
+    }
+
+    public String getKind() {
+        return kind;
+    }
+
+    public void setKind(String kind) {
+        this.kind = kind;
+    }
+
+    public String getPbrand() {
+        return pbrand;
+    }
+
+    public void setPbrand(String pbrand) {
+        this.pbrand = pbrand;
+    }
+
+    public String getPcmpcode() {
+        return pcmpcode;
+    }
+
+    public void setPcmpcode(String pcmpcode) {
+        this.pcmpcode = pcmpcode;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public Short getStandard() {
+        return standard;
+    }
+
+    public void setStandard(Short standard) {
+        this.standard = standard;
+    }
+
+    public String getKinden() {
+        return kinden;
+    }
+
+    public void setKinden(String kinden) {
+        this.kinden = kinden;
+    }
+
+    public String getPbranden() {
+        return pbranden;
+    }
+
+    public void setPbranden(String pbranden) {
+        this.pbranden = pbranden;
+    }
+
+    public Integer getMatchstatus() {
+        return matchstatus;
+    }
+
+    public void setMatchstatus(Integer matchstatus) {
+        this.matchstatus = matchstatus;
+    }
+
+    public Integer getMatchsize() {
+        return matchsize;
+    }
+
+    public void setMatchsize(Integer matchsize) {
+        this.matchsize = matchsize;
+    }
+
+    public Set<ProductMatchResult> getMatchresults() {
+        return matchresults;
+    }
+
+    public void setMatchresults(Set<ProductMatchResult> matchresults) {
+        this.matchresults = matchresults;
+    }
+
+    public Integer getDownloadstatus() {
+        return downloadstatus;
+    }
+
+    public void setDownloadstatus(Integer downloadstatus) {
+        this.downloadstatus = downloadstatus;
+    }
+
+    public Short getIsbusiness() {
+        return isbusiness;
+    }
+
+    public void setIsbusiness(Short isbusiness) {
+        this.isbusiness = isbusiness;
+    }
+
+    public String getImg() {
+        return img;
+    }
+
+    public void setImg(String img) {
+        this.img = img;
+    }
+
+    public String getEncapsulation() {
+        return encapsulation;
+    }
+
+    public void setEncapsulation(String encapsulation) {
+        this.encapsulation = encapsulation;
+    }
+
+    public Short getB2cenabled() {
+        return b2cenabled;
+    }
+
+    public void setB2cenabled(Short b2cenabled) {
+        this.b2cenabled = b2cenabled;
+    }
+
+    public Short getB2benabled() {
+        return b2benabled;
+    }
+
+    public void setB2benabled(Short b2benabled) {
+        this.b2benabled = b2benabled;
+    }
+
+    public Date getTostandard() {
+        return tostandard;
+    }
+
+    public void setTostandard(Date tostandard) {
+        this.tostandard = tostandard;
+    }
+
+    public String getGoodsnover() {
+        return goodsnover;
+    }
+
+    public void setGoodsnover(String goodsnover) {
+        this.goodsnover = goodsnover;
+    }
+
+    public String getGoodstaxno() {
+        return goodstaxno;
+    }
+
+    public void setGoodstaxno(String goodstaxno) {
+        this.goodstaxno = goodstaxno;
+    }
+
+    public String getTaxpre() {
+        return taxpre;
+    }
+
+    public void setTaxpre(String taxpre) {
+        this.taxpre = taxpre;
+    }
+
+    public String getTaxprecon() {
+        return taxprecon;
+    }
+
+    public void setTaxprecon(String taxprecon) {
+        this.taxprecon = taxprecon;
+    }
+}

+ 245 - 0
src/main/java/com/uas/ps/product/model/ProductMatchResult.java

@@ -0,0 +1,245 @@
+package com.uas.ps.product.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 16:55
+ */
+@Entity
+@Table(name = "productmatchresults")
+public class ProductMatchResult implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "pr_id")
+    private Long id;
+
+    /**
+     * 产品id
+     */
+    @Column(name = "pr_prid")
+    private Long prid;
+
+    /**
+     * 产品
+     */
+    @ManyToOne(cascade = {CascadeType.REFRESH})
+    @JoinColumn(name = "pr_prid", insertable = false, updatable = false)
+    private Product product;
+
+    /**
+     * 序号
+     */
+    @Column(name = "pr_number")
+    private Short number;
+
+    /**
+     * 品牌id
+     */
+    @Column(name = "pr_brid")
+    private Long brid;
+
+    /**
+     * 品牌英文
+     */
+    @Column(name = "pr_branden")
+    private String branden;
+
+    /**
+     * 品牌中文
+     */
+    @Column(name = "pr_brandcn")
+    private String brandcn;
+
+    /**
+     * 类目id
+     */
+    @Column(name = "pr_kindid")
+    private Long kindid;
+
+    /**
+     * 类目英文
+     */
+    @Column(name = "pr_kinden")
+    private String kinden;
+
+    /**
+     * 类目中文
+     */
+    @Column(name = "pr_kindcn")
+    private String kindcn;
+
+    /**
+     * uuid
+     */
+    @Column(name = "pr_uuid")
+    private String uuid;
+
+    /**
+     * 器件id
+     */
+    @Column(name = "pr_cmpid")
+    private Long cmpid;
+
+    /**
+     * 原厂型号
+     */
+    @Column(name = "pr_cmpcode")
+    private String cmpcode;
+
+    /**
+     * 企业uu
+     */
+    @Column(name = "pr_enuu")
+    private Long enuu;
+
+    /**
+     * 图片
+     */
+    @Column(name = "pr_cmpimg")
+    private String img;
+
+    /**
+     * 包装
+     */
+    @Column(name = "pr_encapsulation")
+    private String encapsulation;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getPrid() {
+        return prid;
+    }
+
+    public void setPrid(Long prid) {
+        this.prid = prid;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Product getProduct() {
+        return product;
+    }
+
+    public void setProduct(Product product) {
+        this.product = product;
+    }
+
+    public Short getNumber() {
+        return number;
+    }
+
+    public void setNumber(Short number) {
+        this.number = number;
+    }
+
+    public String getBranden() {
+        return branden;
+    }
+
+    public void setBranden(String branden) {
+        this.branden = branden;
+    }
+
+    public String getBrandcn() {
+        return brandcn;
+    }
+
+    public void setBrandcn(String brandcn) {
+        this.brandcn = brandcn;
+    }
+
+    public String getKinden() {
+        return kinden;
+    }
+
+    public void setKinden(String kinden) {
+        this.kinden = kinden;
+    }
+
+    public String getKindcn() {
+        return kindcn;
+    }
+
+    public void setKindcn(String kindcn) {
+        this.kindcn = kindcn;
+    }
+
+    public String getUuid() {
+        return uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getCmpcode() {
+        return cmpcode;
+    }
+
+    public void setCmpcode(String cmpcode) {
+        this.cmpcode = cmpcode;
+    }
+
+    public Long getBrid() {
+        return brid;
+    }
+
+    public void setBrid(Long brid) {
+        this.brid = brid;
+    }
+
+    public Long getKindid() {
+        return kindid;
+    }
+
+    public void setKindid(Long kindid) {
+        this.kindid = kindid;
+    }
+
+    public Long getCmpid() {
+        return cmpid;
+    }
+
+    public void setCmpid(Long cmpid) {
+        this.cmpid = cmpid;
+    }
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Long enuu) {
+        this.enuu = enuu;
+    }
+
+    public String getImg() {
+        return img;
+    }
+
+    public void setImg(String img) {
+        this.img = img;
+    }
+
+    public String getEncapsulation() {
+        return encapsulation;
+    }
+
+    public void setEncapsulation(String encapsulation) {
+        this.encapsulation = encapsulation;
+    }
+
+}

+ 92 - 0
src/main/java/com/uas/ps/product/model/ProductStoreStatus.java

@@ -0,0 +1,92 @@
+package com.uas.ps.product.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 产品物料存储状态<br>
+ * 如果一家企业有人操作单据,其他人不允许操作
+ *
+ * @author sunyj
+ * @since 2018/1/9 15:14
+ */
+@Entity
+@Table(name = "product$storestaus")
+public class ProductStoreStatus implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "pr_id")
+    private Long id;
+
+    /**
+     * 操作企业uu
+     */
+    @Column(name = "pr_enuu")
+    private Long enuu;
+
+    /**
+     * 操作人uu
+     */
+    @Column(name = "pr_useruu")
+    private Long useruu;
+
+    /**
+     * 操作时间
+     */
+    @Column(name = "pr_date")
+    private Date date;
+
+    /**
+     * 操作状态<br>
+     * RUNNING 351 运行中<br>
+     * FINISH 111 已结束
+     */
+    @Column(name = "pr_status")
+    private Integer status;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEnuu() {
+        return enuu;
+    }
+
+    public void setEnuu(Long enuu) {
+        this.enuu = enuu;
+    }
+
+    public Long getUseruu() {
+        return useruu;
+    }
+
+    public void setUseruu(Long useruu) {
+        this.useruu = useruu;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+}

+ 98 - 0
src/main/java/com/uas/ps/product/model/ProductUsers.java

@@ -0,0 +1,98 @@
+package com.uas.ps.product.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 个人物料
+ *
+ * @author sunyj
+ * @since 2018/1/9 17:13
+ */
+@Entity
+@Table(name = "product$users", indexes = {@Index(name = "product$users_useruu_prid", columnList = "pu_useruu,pu_prid", unique = true)})
+public class ProductUsers implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "pu_id")
+    private Long id;
+
+    @Column(name = "pu_useruu")
+    private Long userUU;
+
+    @JoinColumn(name = "pu_useruu", insertable = false, updatable = false)
+    private User user;
+
+    @Column(name = "pu_prid")
+    private Long productId;
+
+    @JoinColumn(name = "pu_prid", insertable = false, updatable = false)
+    private Product product;
+
+    @Column(name = "pu_date")
+    private Date date;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public User getUser() {
+        return user;
+    }
+
+    public void setUser(User user) {
+        this.user = user;
+    }
+
+    public Long getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Long productId) {
+        this.productId = productId;
+    }
+
+    public Product getProduct() {
+        return product;
+    }
+
+    public void setProduct(Product product) {
+        this.product = product;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    @Override
+    public String toString() {
+        return "ProductUsers{" +
+                "id=" + id +
+                ", userUU=" + userUU +
+                ", user=" + user +
+                ", productId=" + productId +
+                ", product=" + product +
+                ", date=" + date +
+                '}';
+    }
+}

+ 84 - 0
src/main/java/com/uas/ps/product/model/ResourceItem.java

@@ -0,0 +1,84 @@
+package com.uas.ps.product.model;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * 系统可请求资源
+ *
+ * @author sunyj
+ * @since 2018/1/6 17:04
+ */
+@Table(name = "sec$resourceitems")
+@Entity
+public class ResourceItem implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "item_id")
+    private Long id;
+
+    /**
+     * 资源名称
+     */
+    @Column(name = "item_name")
+    private String name;
+    /**
+     * 资源类型GET、POST、PUT、DELETE等
+     */
+    @Column(name = "item_method")
+    private String method;
+    /**
+     * 资源请求URL链接
+     */
+    @Column(name = "item_url")
+    private String url;
+    /**
+     * 对资源的具体操作对象及行为的描述
+     */
+    @Column(name = "item_desc")
+    private String desc;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getMethod() {
+        return method == null ? "" : method;
+    }
+
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+}

+ 195 - 0
src/main/java/com/uas/ps/product/model/Role.java

@@ -0,0 +1,195 @@
+package com.uas.ps.product.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.hibernate.annotations.Cache;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:04
+ */
+@Entity
+@Table(name = "sec$roles", indexes = {@Index(name = "sec$roles_enuu_name", columnList = "role_enuu,role_name", unique = true),
+        @Index(name = "sec$roles_enuu_desc", columnList = "role_enuu,role_desc", unique = true)})
+public class Role implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "role_id")
+    private Long id;
+
+    /**
+     * 角色名称
+     */
+    @Column(name = "role_name")
+    private String name;
+
+    /**
+     * 角色是否属于超级用户组
+     */
+    @Column(name = "issys")
+    private Short issys;
+
+    /**
+     * 角色是否系统默认创建
+     */
+    @Column(name = "isdefault")
+    private Short isdefault;
+
+    /**
+     * 角色详细描述
+     */
+    @Column(name = "role_desc")
+    private String desc;
+
+    /**
+     * 角色拥有的权限
+     */
+    @ManyToMany(cascade = {CascadeType.REFRESH}, fetch = FetchType.EAGER)
+    @JoinTable(name = "sec$roleresource", joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "role_id"), inverseJoinColumns = @JoinColumn(name = "res_id", referencedColumnName = "item_id"))
+    @OrderBy("id")
+    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
+    private Set<ResourceItem> resourceItems;
+
+    /**
+     * 所属企业UU
+     */
+    @Column(name = "role_enuu")
+    private Long enUU;
+
+    /**
+     * 职责
+     */
+    @Column(name = "role_duty")
+    private String duty;
+
+    /**
+     * 下标,用于排序
+     */
+    @Column(name = "role_index")
+    private Long index;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    public Short getIssys() {
+        return issys;
+    }
+
+    public void setIssys(Short issys) {
+        this.issys = issys;
+    }
+
+    public Set<ResourceItem> getResourceItems() {
+        return resourceItems;
+    }
+
+    public void setResourceItems(Set<ResourceItem> resourceItems) {
+        this.resourceItems = resourceItems;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Short getIsdefault() {
+        return isdefault;
+    }
+
+    public void setIsdefault(Short isdefault) {
+        this.isdefault = isdefault;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public boolean isSys() {
+        return getIssys() != null && getIssys() == Constant.YES;
+    }
+
+    public String getDuty() {
+        return duty;
+    }
+
+    public void setDuty(String duty) {
+        this.duty = duty;
+    }
+
+    public Long getIndex() {
+        return index;
+    }
+
+    public void setIndex(Long index) {
+        this.index = index;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Role other = (Role) obj;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "Role{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", issys=" + issys +
+                ", isdefault=" + isdefault +
+                ", desc='" + desc + '\'' +
+                ", resourceItems=" + resourceItems +
+                ", enUU=" + enUU +
+                ", duty='" + duty + '\'' +
+                '}';
+    }
+}

+ 130 - 0
src/main/java/com/uas/ps/product/model/Status.java

@@ -0,0 +1,130 @@
+package com.uas.ps.product.model;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:16
+ */
+public enum Status {
+    INPUTTING(100, "在录入"),
+    SUBMITTED(101, "已提交"),
+    AUDITED(102, "已审核"),
+    NOTALLOW(103, "未通过"),
+    ALLOW(104, "已通过"),
+    FINISH(111, "已结束"),
+    DELETED(112, "已删除"),
+    NOT_REPLY(200, "未回复"),
+    REPLIED(201, "已回复"),
+    NOT_UPLOAD(202, "待上传"),
+    DOWNLOADED(203, "已下载"),
+    NOT_READ(210, "未阅读"),
+    READ(211, "已阅读"),
+    AGREED(221, "已同意"),
+    NOTAGREED(222, "不同意"),
+    UNAPPLY(310, "未启用"),
+    UNAUDIT(311, "申请中"),
+    UNACT(312, "未激活"),
+    ENABLED(313, "已激活"),
+    DISABLED(314, "已禁用"),
+    CANCELLED(315, "已注销"),
+    CREATED(317, "已开账"),
+    PENDING(350, "未完成"),
+    RUNNING(351, "运行中"),
+    SEND(400, "已发货"),
+    UNSEND(401, "未发货"),
+    PART_SEND(402, "部分发货"),
+    SHIPPINGIN(403, "出货中"),
+    INBOUND(404, "待收货"),
+    RECEIVED(405, "已收货"),
+    TOBESHIPPED(406, "待出货"),
+    SHIPPED(407, "已出货"),
+    SENDING(408, "发货中"),
+    TOBESHIPPEDBACK(409, "待回寄"),
+    INSPECTING(410, "验货中"),
+    INSPECTED(411, "已验货"),
+    WAITSELLERCOMFIRM(412, "等待卖家同意"),
+    ORDERTAKE(413, "卖家接单"),
+    TOBECONFIRMED(501, "待确认"),
+    CONFIRMED(502, "已确认"),
+    TOBEPAID(503, "待付款"),
+    PAID(504, "已付款"),
+    MONEYRECEIVED(505, "已收款"),
+    TORECEIVEMONEY(506, "待收款"),
+    TOBEREFUNDED(507, "待退款"),
+    REFUNDED(508, "已退款"),
+    RETURNINGGOODS(509, "退货中"),
+    RETURN(521, "退货"),
+    EXCHANGEGOODS(510, "换货中"),
+    INAFTERSALES(511, "售后处理中"),
+    TOBEMADEOUTANINVOICE(512, "待开发票"),
+    MADEOUTANINVOICE(513, "已开发票"),
+    NOTSETTLED(514, "待结算"),
+    SETTLED(515, "已结算"),
+    CHECKDEADLINE(516, "已到结算期"),
+    NOCHECKDEADLINE(517, "未到结算期"),
+    PROOFED(518, "已送样"),
+    COMPLETED(520, "已完成"),
+    TO_BE_REVIEWED(521, "待评论"),
+    REVIEWED(522, "已评论"),
+    AVAILABLE(601, "有效地"),
+    UNAVAILABLE(602, "无效的(因库存不足而失效)"),
+    UNAVAILABLE_NOPAID(603, "无效的(因未按时付款)"),
+    UNAVAILABLE_DISAGREE(604, "无效的(因供应商拒绝)"),
+    UNAVAILABLE_RETURN(605, "无效的(因全部退货完成的)"),
+    UNAVAILABLE_PERSONAL(606, "无效的(因用户本人取消而失效)"),
+    CHARGE_APPLY(607, "申请议价中"),
+    CHARGE_ACCEPT(608, "议价结束(同意)"),
+    CHARGE_REFUSE(609, "议价结束(不同意)"),
+    COMFIRM_DISAGREE(610, " 确认状态取消(供应商拒绝取消)"),
+    PAIDED_DISAGREE(611, "已付款状态取消(供应商拒绝取消)"),
+    REMOVED(612, "已下架"),
+    PREPARE_BILL(699, "准备发票"),
+    TOBEMAKE_BILL(700, "待开发票"),
+    TOBERECEIVE_BILL(701, "待收发票"),
+    RECEIVED_BILL(702, "已收发票"),
+    NEEDNO_BILL(703, "不需开票"),
+    TOCONFIRM_BILL(704, "存在待收票的订单"),
+    OPENED_RECEIVED_BILL(705, "已开票的全部收票"),
+    TOBE_HANDLE(810, "未处理"),
+    HANDLED(811, "已处理"),
+    TO_CROWL(812, "未完成"),
+    CROWLED(813, "已完成"),
+    CROWLED_FAILED(814, "任务失败");
+
+    private final int value;
+    private final String phrase;
+
+    private Status(int value, String phrase) {
+        this.value = value;
+        this.phrase = phrase;
+    }
+
+    public static Status valueOf(int statusCode) {
+        Status[] var1 = values();
+        int var2 = var1.length;
+
+        for (int var3 = 0; var3 < var2; ++var3) {
+            Status status = var1[var3];
+            if (status.value == statusCode) {
+                return status;
+            }
+        }
+
+        throw new IllegalArgumentException("没有与编号 [" + statusCode + "]匹配的状态");
+    }
+
+    public static boolean isUnavailable(Integer status) {
+        return UNAVAILABLE.value() == status.intValue() || UNAVAILABLE_DISAGREE.value() == status.intValue() || UNAVAILABLE_NOPAID.value() == status.intValue() || UNAVAILABLE_PERSONAL.value() == status.intValue() || UNAVAILABLE_RETURN.value() == status.intValue() || RETURN.value() == status.intValue();
+    }
+
+    public int value() {
+        return this.value;
+    }
+
+    public String getPhrase() {
+        return this.phrase;
+    }
+
+    public String toString() {
+        return Integer.toString(this.value);
+    }
+}

+ 232 - 0
src/main/java/com/uas/ps/product/model/UsageLog.java

@@ -0,0 +1,232 @@
+package com.uas.ps.product.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.uas.ps.core.util.DateFormatUtils;
+import com.uas.ps.product.logging.BufferedLogable;
+import org.springframework.util.StringUtils;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 平台使用日志
+ *
+ * @author sunyj
+ * @since 2018/1/9 15:19
+ */
+@Entity
+@Table(name = "log$usage", indexes = {
+        @Index(name = "log$usage_enuu_idx", columnList = "log_enuu")})
+public class UsageLog extends BufferedLogable implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "log_id")
+    private Long id;
+
+    @Column(name = "log_enuu")
+    private Long enUU;
+
+    @OneToOne(cascade = {CascadeType.REFRESH})
+    @JoinColumn(name = "log_useruu", insertable = false, updatable = false)
+    private UserBaseInfo user;
+
+    @NotNull
+    @Column(name = "log_useruu")
+    private Long userUU;
+
+    /**
+     * 日志时间
+     */
+    @Column(name = "log_time")
+    private Long time;
+
+    /**
+     * ip
+     */
+    @Column(name = "log_ip")
+    private String ip;
+
+    @Column(name = "log_title")
+    private String title;
+
+    @Column(name = "log_message")
+    private String message;
+
+    @Column(name = "log_detail", length = 1000)
+    private String detail;
+
+    /**
+     * 相关单据号
+     */
+    @Column(name = "rel_code")
+    private String code;
+
+    /**
+     * 相关单据主键
+     */
+    @Column(name = "rel_key")
+    private Long key;
+
+    public UsageLog() {
+
+    }
+
+    public UsageLog(Long enUU, Long userUU, String ip, String title, String message, String detail, String code,
+                    Long key) {
+        this.enUU = enUU;
+        this.title = title;
+        this.message = message;
+        this.detail = detail;
+        this.code = code;
+        this.key = key;
+        this.time = new Date().getTime();
+        this.userUU = userUU;
+        this.ip = ip;
+    }
+
+    public UsageLog(String title, String message, Long userUU, String ip,
+                    String code, Long key) {
+        this.enUU = 0L;
+        this.title = title;
+        this.message = message;
+        this.code = code;
+        this.key = key;
+        this.time = new Date().getTime();
+        this.userUU = userUU;
+        this.ip = ip;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getEnUU() {
+        return enUU;
+    }
+
+    public void setEnUU(Long enUU) {
+        this.enUU = enUU;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public Long getTime() {
+        return time;
+    }
+
+    public void setTime(Long time) {
+        this.time = time;
+    }
+
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public String getDetail() {
+        return detail;
+    }
+
+    public void setDetail(String detail) {
+        this.detail = detail;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public Long getKey() {
+        return key;
+    }
+
+    public void setKey(Long key) {
+        this.key = key;
+    }
+
+    public UserBaseInfo getUser() {
+        return user;
+    }
+
+    public void setUser(UserBaseInfo user) {
+        this.user = user;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getTimeString() {
+        return DateFormatUtils.DATETIME_FORMAT.format(getTime());
+    }
+
+    public void bufferedLog(String bufferedMessage) {
+        String[] strArray = bufferedMessage.split(separator);
+        if (strArray.length == 9) {
+            this.time = Long.parseLong(strArray[0]);
+            this.ip = strArray[1];
+            this.enUU = Long.parseLong(strArray[2]);
+            this.userUU = Long.parseLong(strArray[3]);
+            this.title = strArray[4];
+            this.message = strArray[5];
+            this.detail = StringUtils.hasText(strArray[6]) ? strArray[6] : null;
+            this.code = StringUtils.hasText(strArray[7]) ? strArray[7] : null;
+            this.key = StringUtils.hasText(strArray[8]) ? Long
+                    .parseLong(strArray[8]) : null;
+        }
+    }
+
+    @Override
+    public String bufferedMessage() {
+        StringBuffer sb = new StringBuffer();
+        sb.append(this.time).append(separator);
+        sb.append(this.ip).append(separator);
+        sb.append(this.enUU).append(separator);
+        sb.append(this.userUU).append(separator);
+        sb.append(this.title).append(separator);
+        sb.append(this.message).append(separator);
+        sb.append(this.detail == null ? "" : this.detail).append(separator);
+        sb.append(this.code == null ? "" : this.code).append(separator);
+        sb.append(this.key == null ? " " : this.key);
+        return sb.toString();
+    }
+
+}

+ 360 - 0
src/main/java/com/uas/ps/product/model/User.java

@@ -0,0 +1,360 @@
+package com.uas.ps.product.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.hibernate.annotations.Cache;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.annotations.NotFound;
+import org.hibernate.annotations.NotFoundAction;
+import org.springframework.util.CollectionUtils;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:02
+ */
+@Entity
+@Table(name = "sec$users")
+public class User implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "user_uu")
+    private Long userUU;
+    @Column(name = "user_name", length = 50)
+    private String userName;
+    @Column(name = "user_pwd", length = 32)
+    private String userPwd;
+    @Column(name = "user_email", length = 50)
+    private String userEmail;
+    @Column(name = "user_tel", length = 30)
+    private String userTel;
+    @Column(name = "user_sex", length = 10)
+    private String userSex;
+    @Column(name = "user_idcode", length = 20)
+    private String userIdcode;
+    private Short enable;
+    private Short issys;
+    @Column(name = "user_imid")
+    private Long userIMId;
+    /**
+     * 用户类型
+     */
+    @Column(name = "user_type", length = 20)
+    private String userType;
+    /**
+     * 所属公司
+     */
+    @ManyToMany(cascade = {CascadeType.REFRESH, CascadeType.REMOVE}, fetch = FetchType.EAGER)
+    @JoinTable(name = "sec$userenterprise", joinColumns = @JoinColumn(name = "user_uu", referencedColumnName = "user_uu"), inverseJoinColumns = @JoinColumn(name = "en_uu", referencedColumnName = "en_uu"))
+    @OrderBy("uu")
+    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
+    private Set<Enterprise> enterprises;
+    /**
+     * 所属公司
+     */
+    @Transient
+    @NotFound(action = NotFoundAction.IGNORE)
+    private Enterprise enterprise;
+    /**
+     * 角色
+     */
+    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.EAGER)
+    @JoinTable(name = "sec$userrole", joinColumns = @JoinColumn(name = "user_uu", referencedColumnName = "user_uu"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "role_id"))
+    @OrderBy("id")
+    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
+    private Set<Role> roles;
+    /**
+     * 最近登录IP地址
+     */
+    @Transient
+    @NotFound(action = NotFoundAction.IGNORE)
+    private String ip;
+    /**
+     * 判断是否被分配
+     */
+    @Transient
+    private boolean distribute;
+    /**
+     * 判断是否被转移权限
+     */
+    @Transient
+    private boolean transfer;
+
+    public User() {
+    }
+
+    public User(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public Long getUserIMId() {
+        return userIMId;
+    }
+
+    public void setUserIMId(Long userIMId) {
+        this.userIMId = userIMId;
+    }
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public String getUserEmail() {
+        return userEmail;
+    }
+
+    public void setUserEmail(String userEmail) {
+        this.userEmail = userEmail;
+    }
+
+    public String getUserTel() {
+        return userTel;
+    }
+
+    public void setUserTel(String userTel) {
+        this.userTel = userTel;
+    }
+
+    public String getUserIdcode() {
+        return userIdcode;
+    }
+
+    public void setUserIdcode(String userIdcode) {
+        this.userIdcode = userIdcode;
+    }
+
+    public void setUserIccode(String userIdcode) {
+        this.userIdcode = userIdcode;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getUserPwd() {
+        return userPwd;
+    }
+
+    public void setUserPwd(String userPwd) {
+        this.userPwd = userPwd;
+    }
+
+    public Short getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Short enable) {
+        this.enable = enable;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Short getIssys() {
+        return issys;
+    }
+
+    public void setIssys(Short issys) {
+        this.issys = issys;
+    }
+
+    public String getUserSex() {
+        return userSex;
+    }
+
+    public void setUserSex(String userSex) {
+        this.userSex = userSex;
+    }
+
+    public Enterprise getEnterprise() {
+        return enterprise;
+    }
+
+    public void setEnterprise(Enterprise enterprise) {
+        this.enterprise = enterprise;
+    }
+
+    public String getUserType() {
+        return userType;
+    }
+
+    public void setUserType(String userType) {
+        this.userType = userType;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public Set<Enterprise> getEnterprises() {
+        return enterprises;
+    }
+
+    public void setEnterprises(Set<Enterprise> enterprises) {
+        this.enterprises = enterprises;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public boolean enable() {
+        return this.getEnable() != null && this.getEnable() == Constant.YES;
+    }
+
+    public void setCurrentEnterprise() {
+        if (this.enterprises != null && this.enterprises.size() > 0)
+            this.enterprise = this.enterprises.iterator().next();
+    }
+
+    public void setCurrentEnterprise(long enUU) {
+        if (this.enterprises != null && this.enterprises.size() > 0)
+            for (Enterprise enterprise : enterprises) {
+                if (enterprise.getUu() == enUU) {
+                    this.enterprise = enterprise;
+                    break;
+                }
+            }
+        if (this.enterprise == null)
+            setCurrentEnterprise();
+    }
+
+    public Set<Role> getRoles() {
+        return roles;
+    }
+
+    public void setRoles(Set<Role> roles) {
+        this.roles = roles;
+    }
+
+    public void addEnterprise(Enterprise enterprise) {
+        if (this.enterprises == null) {
+            Set<Enterprise> enterprises = new HashSet<Enterprise>();
+            enterprises.add(enterprise);
+            this.enterprises = enterprises;
+            return;
+        }
+        if (!this.enterprises.contains(enterprise)) {
+            this.enterprises.add(enterprise);
+        }
+    }
+
+    public void removeEnterprise(Enterprise enterprise) {
+        if (this.enterprises.contains(enterprise)) {
+            this.enterprises.remove(enterprise);
+        }
+    }
+
+    public boolean isSys() {
+        return getIssys() != null && getIssys() == Constant.YES;
+    }
+
+    @JsonIgnore
+    @JSONField(serialize = false)
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
+    public boolean getDistribute() {
+        return distribute;
+    }
+
+    public void setDistribute(boolean distribute) {
+        this.distribute = distribute;
+    }
+
+    public boolean getTransfer() {
+        return transfer;
+    }
+
+    public void setTransfer(boolean transfer) {
+        this.transfer = transfer;
+    }
+
+    /**
+     * 获取用户所属企业UU号
+     *
+     * @return
+     */
+    @JSONField(serialize = false)
+    @JsonIgnore
+    public Set<Long> getEnUUs() {
+        Set<Long> enUUs = new HashSet<Long>();
+        if (!CollectionUtils.isEmpty(enterprises)) {
+            for (Enterprise en : enterprises) {
+                enUUs.add(en.getUu());
+            }
+        }
+        return enUUs;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((userEmail == null) ? 0 : userEmail.hashCode());
+        result = prime * result + ((userTel == null) ? 0 : userTel.hashCode());
+        result = prime * result + ((userUU == null) ? 0 : userUU.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        User other = (User) obj;
+        if (userEmail == null) {
+            if (other.userEmail != null)
+                return false;
+        } else if (!userEmail.equals(other.userEmail))
+            return false;
+        if (userTel == null) {
+            if (other.userTel != null)
+                return false;
+        } else if (!userTel.equals(other.userTel))
+            return false;
+        if (userUU == null) {
+            if (other.userUU != null)
+                return false;
+        } else if (!userUU.equals(other.userUU))
+            return false;
+        return true;
+    }
+
+    /**
+     * 设置当前登录企业的角色
+     */
+    public void setCurrentEnterpriseRoles() {
+        if (!CollectionUtils.isEmpty(this.roles) && this.enterprise != null) {
+            Iterator<Role> iterator = this.roles.iterator();
+            Long enuu = this.enterprise.getUu();
+            while (iterator.hasNext()) {
+                Role role = iterator.next();
+                if (!role.getEnUU().equals(enuu)) {
+                    iterator.remove();
+                }
+            }
+        }
+    }
+
+}

+ 99 - 0
src/main/java/com/uas/ps/product/model/UserBaseInfo.java

@@ -0,0 +1,99 @@
+package com.uas.ps.product.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+/**
+ * 只包含最基本的信息,用与跟单据关联展现
+ *
+ * @author sunyj
+ * @since 2018/1/6 17:10
+ */
+@Entity
+@Table(name = "sec$users")
+public class UserBaseInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "user_uu")
+    private Long userUU;
+
+    @Column(name = "user_name")
+    private String userName;
+
+    @Column(name = "user_pwd")
+    private String userPwd;
+
+    @Column(name = "user_email")
+    private String userEmail;
+
+    @Column(name = "user_tel")
+    private String userTel;
+
+    @Column(name = "user_sex")
+    private String userSex;
+
+    @Column(name = "user_imid")
+    private Long userIMId;
+
+    public Long getUserUU() {
+        return userUU;
+    }
+
+    public void setUserUU(Long userUU) {
+        this.userUU = userUU;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getUserPwd() {
+        return userPwd;
+    }
+
+    public void setUserPwd(String userPwd) {
+        this.userPwd = userPwd;
+    }
+
+    public String getUserEmail() {
+        return userEmail;
+    }
+
+    public void setUserEmail(String userEmail) {
+        this.userEmail = userEmail;
+    }
+
+    public String getUserTel() {
+        return userTel;
+    }
+
+    public void setUserTel(String userTel) {
+        this.userTel = userTel;
+    }
+
+    public String getUserSex() {
+        return userSex;
+    }
+
+    public void setUserSex(String userSex) {
+        this.userSex = userSex;
+    }
+
+    public Long getUserIMId() {
+        return userIMId;
+    }
+
+    public void setUserIMId(Long userIMId) {
+        this.userIMId = userIMId;
+    }
+
+}

+ 48 - 0
src/main/java/com/uas/ps/product/service/ProductService.java

@@ -0,0 +1,48 @@
+package com.uas.ps.product.service;
+
+import com.uas.ps.product.model.Prod;
+import com.uas.ps.product.model.Product;
+import org.springframework.ui.ModelMap;
+
+import java.util.List;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:18
+ */
+public interface ProductService {
+
+    /**
+     * 批量保存产品
+     *
+     * @param products
+     * @return
+     */
+    public List<Product> save(List<Product> products);
+
+    /**
+     * 将ERP系统的产品,转为平台的产品
+     *
+     * @param prods
+     * @return
+     */
+    List<Product> convertProduct(List<Prod> prods);
+
+    /**
+     * 通过 enUU 查询非标准器件进行存储
+     *
+     * @param enUU
+     * @param userUU
+     * @return
+     */
+    ModelMap match(Long enUU, Long userUU);
+
+    /**
+     * 分配个人物料
+     *
+     * @param userUU
+     * @param productId
+     * @return
+     */
+    ModelMap assignPersonalProduct(Long userUU, Long productId);
+}

+ 11 - 0
src/main/java/com/uas/ps/product/service/UsageLogService.java

@@ -0,0 +1,11 @@
+package com.uas.ps.product.service;
+
+import com.uas.ps.product.logging.LogService;
+import com.uas.ps.product.model.UsageLog;
+
+/**
+ * @author sunyj
+ * @since 2018/1/9 16:07
+ */
+public interface UsageLogService extends LogService<UsageLog> {
+}

+ 122 - 0
src/main/java/com/uas/ps/product/service/impl/ProductServiceImpl.java

@@ -0,0 +1,122 @@
+package com.uas.ps.product.service.impl;
+
+import com.uas.ps.product.dao.*;
+import com.uas.ps.product.logging.BufferedLoggerManager;
+import com.uas.ps.product.logging.UsageBufferedLogger;
+import com.uas.ps.product.model.*;
+import com.uas.ps.product.service.ProductService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:19
+ */
+@Service
+public class ProductServiceImpl implements ProductService {
+
+    private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+    @Autowired
+    private ProductDao productDao;
+
+    @Autowired
+    private ProductMatchResultDao productMatchResultDao;
+
+    @Autowired
+    private ProductStoreStatusDao productStoreStatusDao;
+
+    @Autowired
+    private UserDao userDao;
+
+    @Autowired
+    private ProductUsersDao productUsersDao;
+
+    @Override
+    public List<Product> save(List<Product> products) {
+        return productDao.save(products);
+    }
+
+    @Override
+    public List<Product> convertProduct(List<Prod> prods) {
+        List<Product> products = new ArrayList<Product>();
+        for (Prod prod : prods) {
+            if (prod.getEnUU() == null) {
+                throw new IllegalArgumentException("enUU 为空");
+            }
+            prod.setKind(prod.getPr_detail());
+            if (prod.getPr_orispeccode() == null) {// 如果原厂型号不存在,将规格赋值给原厂型号
+                prod.setPr_orispeccode(prod.getPr_spec());
+            }
+            List<Product> prodResult = productDao.findByEnUUAndCode(prod.getEnUU(), prod.getPr_code());
+            if (CollectionUtils.isEmpty(prodResult)) {// 平台上不存在的新上传上来的物料,新增
+                products.add(prod.convert());
+            } else {// 平台上已经存在的物料,修改
+                Product product = prod.convert();
+                product.setId(prodResult.get(0).getId());
+                product.setCode(prodResult.get(0).getCode());
+                products.add(product);
+            }
+        }
+        return products;
+    }
+
+    @Override
+    public ModelMap match(Long enUU, Long userUU) {
+        ModelMap map = new ModelMap();
+        boolean flag = true;
+        ProductStoreStatus status = productStoreStatusDao.findByEnuu(enUU);
+        if (status != null) {
+            if (status.getStatus().equals(Status.RUNNING.value())) {// 有人正在操作这张单据,不能进行操作
+                map.put("error", "当前有人正在进行匹配操作,无法进行匹配");
+                flag = false;
+            } else {
+                status.setStatus(Status.RUNNING.value());
+                status = productStoreStatusDao.save(status);
+            }
+        } else {
+            ProductStoreStatus stroestatus = new ProductStoreStatus();
+            stroestatus.setDate(new Date());
+            stroestatus.setEnuu(enUU);
+            stroestatus.setUseruu(userUU);
+            stroestatus.setStatus(Status.RUNNING.value());
+            status = productStoreStatusDao.save(stroestatus);
+        }
+        int num = 0;
+        if (flag) {
+            // 清除掉原来匹配的数据
+            productMatchResultDao.deleteByEnuu(enUU);
+            User user = userDao.findOne(userUU);
+            logger.log(enUU, userUU, user.getIp(), "物料匹配", "一键匹配了产品(物料)信息", "大小" + num);
+            // TODO 匹配
+            map.put("size", num);
+            status.setStatus(Status.FINISH.value());
+            productStoreStatusDao.save(status);
+        }
+        return map;
+    }
+
+    @Override
+    public ModelMap assignPersonalProduct(Long userUU, Long productId) {
+        ModelMap map = new ModelMap();
+        // TODO 分配个人物料
+        ProductUsers productUsers = productUsersDao.findByUserUUAndProductId(userUU, productId);
+        if (productUsers != null) {
+            map.put("error", "物料已分配给个人");
+        } else {
+            productUsers = new ProductUsers();
+            productUsers.setUserUU(userUU);
+            productUsers.setProductId(productId);
+            productUsers.setDate(new Date());
+            productUsersDao.save(productUsers);
+            map.put("size", 1);
+        }
+        return map;
+    }
+
+}

+ 29 - 0
src/main/java/com/uas/ps/product/service/impl/UsageLogServiceImpl.java

@@ -0,0 +1,29 @@
+package com.uas.ps.product.service.impl;
+
+import com.uas.ps.product.dao.UsageLogDao;
+import com.uas.ps.product.model.UsageLog;
+import com.uas.ps.product.service.UsageLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author sunyj
+ * @since 2018/1/9 16:30
+ */
+@Service
+public class UsageLogServiceImpl implements UsageLogService {
+
+    @Autowired
+    private UsageLogDao usageLogDao;
+
+    @Override
+    public void save(UsageLog logable) {
+        usageLogDao.save(logable);
+    }
+
+    @Override
+    public void save(Iterable<UsageLog> logables) {
+        usageLogDao.save(logables);
+    }
+
+}

+ 72 - 0
src/main/java/com/uas/ps/product/util/ContextUtils.java

@@ -0,0 +1,72 @@
+package com.uas.ps.product.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * spring容器上下文对象
+ *
+ * @author yingp
+ */
+public class ContextUtils {
+    private static ApplicationContext applicationContext;
+
+    private static Logger logger = LoggerFactory.getLogger(ContextUtils.class);
+
+    public static ApplicationContext getApplicationContext() {
+        synchronized (ContextUtils.class) {
+            while (applicationContext == null) {
+                try {
+                    logger.debug("getApplicationContext, wait...");
+                    ContextUtils.class.wait(60000);
+                    if (applicationContext == null) {
+                        logger.warn("Have been waiting for ApplicationContext to be set for 1 minute", new Exception());
+                    }
+                } catch (InterruptedException ex) {
+                    logger.debug("getApplicationContext, wait interrupted");
+                }
+            }
+            return applicationContext;
+        }
+    }
+
+    public static void setApplicationContext(ApplicationContext applicationContext) {
+        synchronized (ContextUtils.class) {
+            logger.debug("setApplicationContext, notifyAll");
+            ContextUtils.applicationContext = applicationContext;
+            ContextUtils.class.notifyAll();
+        }
+    }
+
+    /**
+     * 获取bean
+     *
+     * @param name
+     * @return
+     */
+    public static Object getBean(String name) {
+        return getApplicationContext().getBean(name);
+    }
+
+    /**
+     * 获取bean
+     *
+     * @param cls
+     * @return
+     */
+    public static <T> T getBean(Class<T> cls) {
+        return getApplicationContext().getBean(cls);
+    }
+
+    /**
+     * 触发事件
+     *
+     * @param event
+     */
+    public static void publishEvent(ApplicationEvent event) {
+        getApplicationContext().publishEvent(event);
+    }
+
+}

+ 133 - 0
src/main/java/com/uas/ps/product/util/FileBuffer.java

@@ -0,0 +1,133 @@
+package com.uas.ps.product.util;
+
+import java.io.*;
+
+/**
+ * @author sunyj
+ * @since 2018/1/6 17:39
+ */
+public class FileBuffer {
+    private String filePath;
+    private BufferedWriter writer;
+    private BufferedReader reader;
+
+    public FileBuffer(String folderPath, String fileName) {
+        File file = new File(folderPath);
+        if (!file.isDirectory()) {
+            file.mkdirs();
+        }
+
+        this.filePath = folderPath + File.separator + fileName;
+    }
+
+    public synchronized boolean append(String content) {
+        if (this.writer == null) {
+            try {
+                File file = new File(this.filePath);
+                if (!file.exists()) {
+                    file.createNewFile();
+                }
+
+                this.writer = new BufferedWriter(new FileWriter(file, true));
+            } catch (IOException var5) {
+                return false;
+            }
+        } else {
+            try {
+                this.writer.write("\r\n");
+            } catch (IOException var4) {
+                return false;
+            }
+        }
+
+        try {
+            this.writer.write(content);
+            this.writer.flush();
+            return true;
+        } catch (IOException var3) {
+            return false;
+        }
+    }
+
+    public synchronized String readLine() {
+        if (this.writer != null) {
+            this.close();
+        }
+
+        if (this.reader == null) {
+            File file = new File(this.filePath);
+            if (file.exists()) {
+                try {
+                    InputStreamReader streamReader = new InputStreamReader(new FileInputStream(file));
+                    this.reader = new BufferedReader(streamReader);
+                } catch (FileNotFoundException var3) {
+                    return null;
+                }
+            }
+        }
+
+        if (this.reader != null) {
+            try {
+                return this.reader.readLine();
+            } catch (IOException var4) {
+                ;
+            }
+        }
+
+        return null;
+    }
+
+    public synchronized void close() {
+        if (this.writer != null) {
+            try {
+                this.writer.close();
+            } catch (IOException var5) {
+                ;
+            } finally {
+                this.writer = null;
+            }
+        }
+
+    }
+
+    public synchronized void delete() {
+        if (this.writer != null) {
+            try {
+                this.writer.close();
+            } catch (IOException var14) {
+                ;
+            } finally {
+                this.writer = null;
+            }
+        }
+
+        if (this.reader != null) {
+            try {
+                this.reader.close();
+            } catch (IOException var12) {
+                ;
+            } finally {
+                this.reader = null;
+            }
+        }
+
+        File file = new File(this.filePath);
+        if (file.exists()) {
+            file.delete();
+        }
+
+    }
+
+    public synchronized boolean isEmpty() {
+        boolean empty = this.writer == null;
+        if (!empty) {
+            File file = new File(this.filePath);
+            empty = !file.exists();
+            if (!empty) {
+                empty = file.length() == 0L;
+            }
+        }
+
+        return empty;
+    }
+}

+ 79 - 0
src/main/java/com/uas/ps/product/util/PathUtils.java

@@ -0,0 +1,79 @@
+package com.uas.ps.product.util;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+
+/**
+ * 路径
+ *
+ * @author sunyj
+ * @since 2018/1/6 17:30
+ */
+public class PathUtils {
+
+    private static String classPath;
+
+    private static String appPath;
+
+    private static String filePath;
+
+    /**
+     * classes文件目录
+     *
+     * @return
+     */
+    public static String getClassPath() {
+        if (classPath == null)
+            setClassPath();
+        return classPath;
+    }
+
+    /**
+     * 应用程序目录
+     *
+     * @return
+     */
+    public static String getAppPath() {
+        if (appPath == null)
+            setAppPath();
+        return appPath;
+    }
+
+    /**
+     * 日志、附件文件等存放目录,与程序同级
+     *
+     * @return
+     */
+    public static String getFilePath() {
+        if (filePath == null)
+            setFilePath();
+        return filePath;
+    }
+
+    private static void setClassPath() {
+        Class<?> objClass = ContextUtils.getApplicationContext().getClass();
+        String strRealPath = objClass.getClassLoader().getResource("").getFile();
+        try {
+            strRealPath = URLDecoder.decode(strRealPath, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        File objFile = new File(strRealPath);
+        classPath = objFile.getParent() + File.separator;
+        if (classPath.contains("/")) {
+            classPath = "/" + classPath;
+        }
+    }
+
+    private static void setAppPath() {
+        File file = new File(getClassPath());
+        appPath = file.getParent() + File.separator;
+    }
+
+    private static void setFilePath() {
+        File file = new File(getAppPath());
+        filePath = file.getParent() + File.separator;
+    }
+
+}

+ 32 - 0
src/main/resources/application.yml

@@ -0,0 +1,32 @@
+spring:
+ application:
+  name: product-server
+ jpa:
+  database: MYSQL
+  show-sql: false
+  properties:
+   hibernate:
+    dialect: org.hibernate.dialect.MySQL5Dialect
+    cache:
+     region:
+      factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
+    hbm2ddl:
+     auto: update
+
+ http:
+  encoding:
+   force: true
+  multipart:
+   enabled: true
+   max-file-size: 512MB
+   max-request-size: 512MB
+
+security:
+ basic:
+  enabled: true
+  path: /**
+ user:
+  name: admin
+  password: select111***
+  role: ADMIN
+ ignored: false

+ 19 - 0
src/main/resources/config/application-dev.properties

@@ -0,0 +1,19 @@
+datasource.url=jdbc:mysql://192.168.253.12:3306/public_resources?characterEncoding=utf-8&useSSL=false
+datasource.username=root
+datasource.password=select111***
+datasource.driverClassName=com.mysql.jdbc.Driver
+datasource.initialSize=1
+datasource.minIdle=1
+datasource.maxActive=20
+datasource.maxWait=60000
+datasource.timeBetweenEvictionRunsMillis=60000
+datasource.minEvictableIdleTimeMillis=300000
+datasource.validationQuery=SELECT 1 FROM DUAL
+datasource.testWhileIdle=true
+datasource.testOnBorrow=true
+datasource.testOnReturn=false
+datasource.poolPreparedStatements=true
+datasource.timeBetweenLogStatsMillis=60000
+datasource.maxPoolPreparedStatementPerConnectionSize=20
+datasource.filters=stat,slf4j
+datasource.connectionProperties=druid.stat.mergeSql=false;druid.stat.slowSqlMillis=5000

+ 44 - 0
src/main/resources/logback.xml

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+	<appender name="FILE"
+		class="ch.qos.logback.core.rolling.RollingFileAppender">
+		<File>logs/log.log</File>
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+			<!-- daily rollover -->
+			<FileNamePattern>logs/log.%d{yyyy-MM-dd}.log</FileNamePattern>
+			<!-- keep 10 days' worth of history -->
+			<maxHistory>10</maxHistory>
+		</rollingPolicy>
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Console output -->
+	<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+		<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
+		<encoder>
+			<pattern>
+				%date{yyyy-MM-dd HH:mm:ss:SSS} [%relative ms] %-5level [%50.50(%logger{36}.%method:%line)] ---- %msg%n
+			</pattern>
+			<charset>UTF-8</charset> <!-- 此处设置字符集 -->
+		</encoder>
+		<!-- Only log level WARN and above -->
+		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+			<level>INFO</level>
+		</filter>
+	</appender>
+
+	<!-- Enable FILE and STDOUT appenders for all log messages. By default, 
+		only log at level INFO and above. -->
+	<root level="INFO">
+		<appender-ref ref="FILE" />
+		<appender-ref ref="STDOUT" />
+	</root>
+</configuration>