فهرست منبع

泗水数据对接

hym 4 سال پیش
والد
کامیت
c2a660e129

+ 97 - 0
meter-reading-sishui/read-sqlSever/pom.xml

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.zoniot</groupId>
+    <artifactId>read-sqlSever</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.1.RELEASE</version>
+        <relativePath/>
+    </parent>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <java.version>1.8</java.version>
+        <!-- 跳过打包检测 -->
+        <skipTests>true</skipTests>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jdbc</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.1.3</version>
+        </dependency>
+        <!-- MySQL -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.microsoft.sqlserver</groupId>
+            <artifactId>sqljdbc4</artifactId>
+            <version>4.0</version>
+        </dependency>
+        <!--Druid-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>0.2.9</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <!-- tomcatd的jsp支持 -->
+        <dependency>
+            <groupId>org.apache.tomcat.embed</groupId>
+            <artifactId>tomcat-embed-jasper</artifactId>
+        </dependency>
+        <!-- servlet容器 -->
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>jstl</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 17 - 0
meter-reading-sishui/read-sqlSever/src/main/java/com/zcxk/MainApplication.java

@@ -0,0 +1,17 @@
+package com.zcxk;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+
+@SpringBootApplication
+public class MainApplication {
+
+    public static void main(String[] args) {
+
+        SpringApplication.run(MainApplication.class, args);
+    }
+
+}

+ 45 - 0
meter-reading-sishui/read-sqlSever/src/main/java/com/zcxk/config/MysqlDataSourceConfig.java

@@ -0,0 +1,45 @@
+package com.zcxk.config;
+
+
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+
+import javax.sql.DataSource;
+
+@Configuration
+@MapperScan(basePackages = "com.zcxk.dao.mysql", sqlSessionTemplateRef  = "mysqlSqlSessionTemplate")
+public class MysqlDataSourceConfig {
+
+    @Bean(name = "mysqlDataSource")
+    @ConfigurationProperties(prefix = "spring.datasource.mysql")
+    public DataSource testDataSource() {
+        return DataSourceBuilder.create().build();
+    }
+
+    @Bean(name = "mysqlSqlSessionFactory")
+    public SqlSessionFactory testSqlSessionFactory(@Qualifier("mysqlDataSource") DataSource dataSource) throws Exception {
+        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
+        bean.setDataSource(dataSource);
+        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));
+        return bean.getObject();
+    }
+
+    @Bean(name = "mysqlTransactionManager")
+    public DataSourceTransactionManager testTransactionManager(@Qualifier("mysqlDataSource") DataSource dataSource) {
+        return new DataSourceTransactionManager(dataSource);
+    }
+
+    @Bean(name = "mysqlSqlSessionTemplate")
+    public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("mysqlSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+}

+ 51 - 0
meter-reading-sishui/read-sqlSever/src/main/java/com/zcxk/config/SqlServerDataSourceConfig.java

@@ -0,0 +1,51 @@
+package com.zcxk.config;
+
+
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.mybatis.spring.SqlSessionFactoryBean;
+import org.mybatis.spring.SqlSessionTemplate;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.jdbc.datasource.DataSourceTransactionManager;
+
+import javax.sql.DataSource;
+
+@Configuration
+@MapperScan(basePackages = "com.zcxk.dao.sqlserver", sqlSessionTemplateRef  = "sqlServerSqlSessionTemplate")
+public class SqlServerDataSourceConfig {
+
+    @Bean(name = "sqlServerDataSource")
+    @ConfigurationProperties(prefix = "spring.datasource.sqlsever")
+    @Primary
+    public DataSource testDataSource() {
+        return DataSourceBuilder.create().build();
+    }
+
+    @Bean(name = "sqlServerSqlSessionFactory")
+    @Primary
+    public SqlSessionFactory testSqlSessionFactory(@Qualifier("sqlServerDataSource") DataSource dataSource) throws Exception {
+        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
+        bean.setDataSource(dataSource);
+        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:sqlServer/*.xml"));
+        return bean.getObject();
+    }
+
+    @Bean(name = "sqlServerTransactionManager")
+    @Primary
+    public DataSourceTransactionManager testTransactionManager(@Qualifier("sqlServerDataSource") DataSource dataSource) {
+        return new DataSourceTransactionManager(dataSource);
+    }
+
+    @Bean(name = "sqlServerSqlSessionTemplate")
+    @Primary
+    public SqlSessionTemplate testSqlSessionTemplate(@Qualifier("sqlServerSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
+        return new SqlSessionTemplate(sqlSessionFactory);
+    }
+}
+

+ 9 - 0
meter-reading-sishui/read-sqlSever/src/main/java/com/zcxk/dao/mysql/SendDao.java

@@ -0,0 +1,9 @@
+package com.zcxk.dao.mysql;
+
+import org.apache.ibatis.annotations.Mapper;
+
+
+@Mapper
+public interface SendDao {
+    public void selectOne();
+}

+ 19 - 0
meter-reading-sishui/read-sqlSever/src/main/java/com/zcxk/dao/sqlserver/ReceiveDao.java

@@ -0,0 +1,19 @@
+package com.zcxk.dao.sqlserver;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.Map;
+
+@Mapper
+public interface ReceiveDao {
+
+   void getMeterInfor(Map<String,String> map);
+   void getMeterChangeRecord(Map<String,String> map);
+   void getUploadPlan(Map<String,String> map);
+   void creatUploadTask(Map<String,String> map);
+   void meterDataInsert(Map<String,String> map);
+   void dropMeterDataTable();
+   void createMeterDataTable();
+   void insertIntoMeterDataTemp(Map<String,Object>map);
+   void insertIntoMeterData();
+}

+ 16 - 0
meter-reading-sishui/read-sqlSever/src/main/resources/application-dev.properties

@@ -0,0 +1,16 @@
+spring.application.name=sishui-meter-reading
+logging.file.path=./logs/sishui-meter-reading
+logging.level.root=info
+spring.datasource.hikari.max-lifetime=30000
+spring.datasource.mysql.jdbc-url=jdbc:mysql://114.135.61.188:33306/sms?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
+spring.datasource.mysql.username=root
+spring.datasource.mysql.password=100Zone@123
+spring.datasource.mysql.driver-class-name=com.mysql.jdbc.Driver
+
+spring.datasource.sqlsever.jdbc-url=jdbc:sqlserver://218.58.156.234:14330;databaseName=copymetercollection_lz0320
+spring.datasource.sqlsever.username=LoginNo_MaiTuo
+spring.datasource.sqlsever.password=maituo@OKM123
+spring.datasource.sqlsever.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
+mybatis.configuration.map-underscore-to-camel-case=true
+mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+mybatis.configuration.use-column-label=true

+ 1 - 0
meter-reading-sishui/read-sqlSever/src/main/resources/application.properties

@@ -0,0 +1 @@
+spring.profiles.active=dev

+ 75 - 0
meter-reading-sishui/read-sqlSever/src/main/resources/mapper/ReceiveDao.xml

@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.zcxk.dao.sqlserver.ReceiveDao">
+
+
+
+
+
+    <update id="getMeterInfor" parameterType="map" statementType="CALLABLE">
+        { call DBi_GetMeterInfor_Batch(
+                #{regionId,mode=IN,jdbcType=VARCHAR},
+                #{returnCode,mode=OUT,jdbcType=INTEGER},
+                #{returnMsg,mode=OUT,jdbcType=VARCHAR}
+            )
+            }
+    </update>
+    <update id="getMeterChangeRecord" parameterType="map" statementType="CALLABLE">
+        { call DBi_GetMeterInfor_Batch(
+                #{regionId,mode=IN,jdbcType=VARCHAR},
+                #{changeField,mode=IN,jdbcType=VARCHAR},
+                #{id,mode=IN,jdbcType=INTEGER},
+                #{returnCode,mode=OUT,jdbcType=INTEGER},
+                #{returnMsg,mode=OUT,jdbcType=VARCHAR}
+            )
+            }
+    </update>
+    <update id="getUploadPlan" parameterType="map" statementType="CALLABLE">
+        { call DBi_GetMeterInfor_Batch(
+                #{returnCode,mode=OUT,jdbcType=INTEGER},
+                #{returnMsg,mode=OUT,jdbcType=VARCHAR}
+            )
+            }
+    </update>
+    <update id="creatUploadTask" parameterType="map" statementType="CALLABLE">
+        { call DBi_GetMeterInfor_Batch(
+                #{regionId,mode=IN,jdbcType=VARCHAR},
+                #{taskId,mode=OUT,jdbcType=VARCHAR},
+                #{returnCode,mode=OUT,jdbcType=INTEGER},
+                #{returnMsg,mode=OUT,jdbcType=VARCHAR}
+            )
+            }
+    </update>
+    <update id="meterDataInsert" parameterType="map" statementType="CALLABLE">
+        { call DBi_GetMeterInfor_Batch(
+                #{taskId,mode=IN,jdbcType=VARCHAR},
+                #{meterData,mode=IN,jdbcType=VARCHAR},
+                #{returnCode,mode=OUT,jdbcType=INTEGER},
+                #{returnMsg,mode=OUT,jdbcType=VARCHAR}
+            )
+            }
+    </update>
+    <update id="dropMeterDataTable">
+        drop table huaxu_meter_data
+    </update>
+    <update id="createMeterDataTable">
+        CREATE  table huaxu_meter_data (
+	releationId nvarchar(20) Not NULL,
+	currentReading decimal(18, 2)  NULL,
+	currentReadDate char (19) NOT NULL)
+    </update>
+    <insert id="insertIntoMeterDataTemp">
+        INSERT INTO huaxu_meter_data
+        (releationId, currentReading, currentReadDate)
+        VALUES
+        <foreach collection ="list" item="water" separator =",">
+            (#{water.releationId}, #{water.currentReading}, #{water.currentReadDate})
+        </foreach >
+    </insert>
+    <insert id="insertIntoMeterData">
+        insert into @meterData (releationId,currentReading,currentReadDate) select *from huaxu_meter_data
+    </insert>
+</mapper>

+ 11 - 0
meter-reading-sishui/read-sqlSever/src/main/resources/mapper/SendDao.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.zcxk.dao.mysql.SendDao">
+
+
+    <select id="selectOne"></select>
+
+</mapper>