瀏覽代碼

身份认证同步更新粮信数据标识

ccjgmwz 3 年之前
父節點
當前提交
ce8069222f

+ 71 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/DriverViewInfoServiceImpl.java

@@ -18,9 +18,11 @@ import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
+import java.sql.*;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -40,7 +42,16 @@ public class DriverViewInfoServiceImpl extends ServiceImpl<DriverViewInfoMapper,
     private IDriverCarInfoService driverCarInfoService;
     @Autowired
     private IDriverPayeeInfoService driverPayeeInfoService;
+    @Value("com.mysql.jdbc.Driver")
+    private String driverClassName;
+    @Value("jdbc:mysql://47.100.3.209:3306/talk-portal?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true")
+    private String url;
+    @Value("root")
+    private String username;
+    @Value("Ccj841968545")
+    private String password;
 
+    Connection  coon=null;
     /**
      * 添加信息
      *
@@ -94,7 +105,15 @@ public class DriverViewInfoServiceImpl extends ServiceImpl<DriverViewInfoMapper,
         boolean one = this.insert(driverViewInfo);
         boolean two = driverCarInfoService.insertBatch(driverCarInfoList);
         boolean three = driverPayeeInfoService.insertBatch(driverPayeeInfoList);
-
+        //将粮信用户表的物流字段更新为1
+        if(driverViewInfo.getDriverPhone() != null){
+            DBConnection();
+            String sUserId = excSelect("select * from s_user s where s.user_name = '"+driverViewInfo.getDriverPhone()+"'",this.coon);
+            if( sUserId != null && !sUserId.isEmpty()){
+                excUpdate("update s_user s set s.driver_flag = 1 where s.user_name = '"+driverViewInfo.getDriverPhone()+"'",this.coon);
+            }
+            close();
+        }
         // 假如 都成功返回ok
         if (one && two && three) {
             return "OK";
@@ -273,5 +292,56 @@ public class DriverViewInfoServiceImpl extends ServiceImpl<DriverViewInfoMapper,
                 .eq(DriverCarInfo.QueryFiles.DRIVER_ID, id).eq(DriverViewInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0));
         return driverCarInfo;
     }
+    public void DBConnection(){
+        try{
+            //加载驱动程序
+            Class.forName(driverClassName);
+            coon=(Connection) DriverManager.getConnection(url,username,password);
+            if(!coon.isClosed()){
+                System.out.println("成功连接数据库!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+    public void close(){
+        try{
+            this.coon.close();
+            System.out.println("成功关闭数据库连接!");
+        }catch(Exception e){
+            e.printStackTrace();
+            System.out.println("关闭数据库连接异常!");
+        }
+    }
+    //    查询s_user表
+    public String excSelect(String sql,Connection  coon){
+        try{
+            Statement stmt=(Statement)coon.createStatement();
+            ResultSet rs=(ResultSet)stmt.executeQuery(sql);//得到的是结果的集合
 
+            while(rs.next()){
+                String id=rs.getString("id");
+                if(id != null && !id.isEmpty()){
+                    return id;
+                }
+            }
+            stmt.close();
+            return null;
+        }catch(Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
+    //    更改数据
+    public void excUpdate(String sql,Connection  coon){
+        try{
+            PreparedStatement prestmt=(PreparedStatement)coon.prepareStatement(sql);
+            prestmt.executeUpdate();
+            System.out.println("更改数据成功!");
+            prestmt.close();
+        }catch(Exception e){
+            System.out.println("粮信更改数据异常!");
+            e.printStackTrace();
+        }
+    }
 }

+ 75 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/IdentityAuthenticationInfoServiceImpl.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import cn.hutool.core.lang.UUID;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.plugins.Page;
@@ -14,10 +15,13 @@ import com.yh.saas.plugin.yiliangyiyun.exception.*;
 import com.yh.saas.plugin.yiliangyiyun.mapper.IdentityAuthenticationInfoMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.*;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.plugin.yiliangyiyun.util.MD5Util;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.sqlite.util.StringUtils;
 
+import java.sql.*;
 import java.util.List;
 
 /**
@@ -32,6 +36,16 @@ import java.util.List;
 public class IdentityAuthenticationInfoServiceImpl extends ServiceImpl<IdentityAuthenticationInfoMapper, IdentityAuthenticationInfo> implements IIdentityAuthenticationInfoService {
     @Autowired
     private ICommonBillOperateHisService billOperateHisService;
+    @Value("com.mysql.jdbc.Driver")
+    private String driverClassName;
+    @Value("jdbc:mysql://47.100.3.209:3306/talk-portal?createDatabaseIfNotExist=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true")
+    private String url;
+    @Value("root")
+    private String username;
+    @Value("Ccj841968545")
+    private String password;
+
+    Connection  coon=null;
     /**
      * 粮商认证列表
      * @param identityAuthenticationInfo
@@ -103,6 +117,15 @@ public class IdentityAuthenticationInfoServiceImpl extends ServiceImpl<IdentityA
         }
         // 操作主表数据
         this.insert(identityAuthenticationInfo);
+        //将粮信用户表的粮商字段更新为1
+        if(identityAuthenticationInfo.getCustomerPhone() != null){
+            DBConnection();
+            String sUserId = excSelect("select * from s_user s where s.user_name = '"+identityAuthenticationInfo.getCustomerPhone()+"'",this.coon);
+            if( sUserId != null && !sUserId.isEmpty()){
+                excUpdate("update s_user s set s.trader_flag = 1 where s.user_name = '"+identityAuthenticationInfo.getCustomerPhone()+"'",this.coon);
+            }
+            close();
+        }
         return identityAuthenticationInfo.getId();
     }
 
@@ -172,5 +195,57 @@ public class IdentityAuthenticationInfoServiceImpl extends ServiceImpl<IdentityA
         }
         return identityAuthenticationInfo;
     }
+    public void DBConnection(){
+        try{
+            //加载驱动程序
+            Class.forName(driverClassName);
+            coon=(Connection) DriverManager.getConnection(url,username,password);
+            if(!coon.isClosed()){
+                System.out.println("成功连接数据库!");
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+    public void close(){
+        try{
+            this.coon.close();
+            System.out.println("成功关闭数据库连接!");
+        }catch(Exception e){
+            e.printStackTrace();
+            System.out.println("关闭数据库连接异常!");
+        }
+    }
+    //    查询s_user表
+    public String excSelect(String sql,Connection  coon){
+        try{
+            Statement stmt=(Statement)coon.createStatement();
+            ResultSet rs=(ResultSet)stmt.executeQuery(sql);//得到的是结果的集合
+
+            while(rs.next()){
+                String id=rs.getString("id");
+                if(id != null && !id.isEmpty()){
+                    return id;
+                }
+            }
+            stmt.close();
+            return null;
+        }catch(Exception e){
+            e.printStackTrace();
+            return null;
+        }
+    }
+    //    更改数据
+    public void excUpdate(String sql,Connection  coon){
+        try{
+            PreparedStatement prestmt=(PreparedStatement)coon.prepareStatement(sql);
+            prestmt.executeUpdate();
+            System.out.println("更改数据成功!");
+            prestmt.close();
+        }catch(Exception e){
+            System.out.println("粮信更改数据异常!");
+            e.printStackTrace();
+        }
+    }
 }