Преглед на файлове

添加批次出库和调拨详情的sn参数

lmstack преди 3 години
родител
ревизия
630e09b433

+ 15 - 1
src/main/java/cn/fastfun/config/DataSourceConfig.java

@@ -1,13 +1,16 @@
 package cn.fastfun.config;
 
 import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
 import com.alibaba.druid.support.http.StatViewServlet;
 import com.alibaba.druid.support.http.WebStatFilter;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 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.jdbc.core.JdbcTemplate;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 import javax.sql.DataSource;
@@ -17,11 +20,17 @@ import javax.sql.DataSource;
 public class DataSourceConfig {
 
     @Bean
-    @ConfigurationProperties(prefix = "spring.datasource")
+    @ConfigurationProperties(prefix = "spring.datasource.oss")
     public DataSource druidDataSource() {
         return new DruidDataSource();
     }
 
+    @Bean
+    @ConfigurationProperties(prefix = "spring.datasource.runtime")
+    DataSource runtime() {
+        return DruidDataSourceBuilder.create().build();
+    }
+
     @Bean
     public ServletRegistrationBean druidServlet() {
         ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
@@ -36,4 +45,9 @@ public class DataSourceConfig {
         filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
         return filterRegistrationBean;
     }
+
+    @Bean
+    JdbcTemplate jdbcTemplateRuntime(@Qualifier("runtime") DataSource base) {
+        return new JdbcTemplate(base);
+    }
 }

+ 1 - 1
src/main/java/cn/fastfun/controller/api/ApiAppDeviceLogController.java

@@ -427,7 +427,7 @@ public class ApiAppDeviceLogController {
             for (Map<String, Object> p : list) {
                 p.put("add_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("add_time")), DateUtils.YMDHMS));
                 p.put("update_time", DateUtils.toString(ObjectUtil.obj2Date(p.get("update_time")), DateUtils.YMDHMS));
-                p.put("out_type", String.valueOf(p.get("out_type")));
+                p.put("out_type", p.get("out_type"));
             }
             page.setData(list);
         }

+ 8 - 1
src/main/java/cn/fastfun/controller/api/IndexController.java

@@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
 import jdk.nashorn.internal.runtime.PropertyMap;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.domain.Page;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -37,6 +38,9 @@ public class IndexController {
     @Resource(name = "appDeviceService")
     AppDeviceService appDeviceService;
 
+    @Resource(name = "jdbcTemplateRuntime")
+    JdbcTemplate jdbcTemplate;
+
     @Resource
     AppDeviceLogService appDeviceLogService;
 
@@ -156,9 +160,12 @@ public class IndexController {
             AppDeviceLog lastDeviceLogPage = new AppDeviceLog();
             if (!deviceLogPage.isEmpty()) {
                 lastDeviceLogPage =  deviceLogPage.getContent().get(0);
-                res.put("handleType", lastDeviceLogPage.getType());
+                res.put("handleType", lastDeviceLogPage.getHfEvent());
             }
         }
+
+        StringBuffer sql = new StringBuffer();
+        sql.append("select * from ");
         res.put("lastOnLineTime", 0);
         res.put("lat", 0);
         res.put("long", 0);

+ 6 - 0
src/main/java/cn/fastfun/controller/param/detialQueryParam.java

@@ -19,6 +19,12 @@ public class detialQueryParam extends QueryParam{
     @ApiModelProperty(value = "操作号", name = "operateID", required = true)
     Integer operateID;
 
+    @ApiModelProperty(value = "sn", name = "sn", required = true)
+    public void setSn(String sn) {
+        if (!StringUtils.isEmpty(sn))
+            addParam(QueryParamExp.like("sn", "%".concat(sn).concat("%")));
+    }
+
 }
 
 

+ 6 - 0
src/main/java/cn/fastfun/service/impl/AppDeviceServiceImp.java

@@ -9,6 +9,7 @@ import cn.fastfun.service.entity.AppDevice;
 import cn.fastfun.service.entity.Product;
 import cn.fastfun.service.repository.AppDeviceRepository;
 
+import cn.fastfun.util.VerifyUtil;
 import com.bridge.dto.ApiDTO;
 import com.bridge.dto.ApiPageDTO;
 import com.bridge.dto.QueryParam;
@@ -83,6 +84,11 @@ public class AppDeviceServiceImp extends JpaServiceImp<AppDevice, String> implem
                 throw new ApiRuntimeException("sn:" + device.getSn() + "已经被录入");
             }
             device.setOperateID(operateID.intValue());
+            String checkSnResult = VerifyUtil.checkImei(device.getImei());
+            if (!checkSnResult.equals("passed")) {
+                throw new ApiRuntimeException("imei:" + device.getImei() + "校验未通过:" + checkSnResult);
+            }
+
             // 批量导入时由于没有x-token, 无法确定操作者
 //            device.setOperator(utilService.getUserName());
             devices.add(device);

+ 9 - 3
src/main/resources/application-dev.yml

@@ -2,9 +2,15 @@ server:
   port: 8082
 spring:
   datasource:
-    url: jdbc:mysql://47.111.243.220:9306/pdms_oss?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
-    username: root
-    password: Qx123456
+    oss:
+      url: jdbc:mysql://47.111.243.220:9306/pdms_oss?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
+      username: root
+      password: Qx123456
+    runtime:
+      url: jdbc:mysql://172.16.121.236:3306/fastfun?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
+      username: readonly
+      password: Fast1234
+      driverClassName: com.mysql.cj.jdbc.Driver
   redis:
     host: 47.111.243.220
     port: 9379