Quellcode durchsuchen

lrl -2021-12-09

lirl vor 3 Jahren
Ursprung
Commit
69bd2ae0c7

+ 29 - 0
src/main/java/com/steerinfo/config/druidConfig/DruidConfig.java

@@ -30,6 +30,7 @@ public class DruidConfig {
     private String jdbcUrl2;//ds2数据源
     private String jdbcUrl3;
     private String jdbcUrl4;
+    private String jdbcUrl5;
     private String username1;
     private String password1;
     private String username2;
@@ -38,6 +39,8 @@ public class DruidConfig {
     private String password3;
     private String username4;
     private String password4;
+    private String username5;
+    private String password5;
     private int maxActive;
     private int minIdle;
     private int initialSize;
@@ -150,6 +153,29 @@ public class DruidConfig {
         return druidDataSource;
     }
 
+    public DataSource getDs5() {
+        DruidDataSource druidDataSource = new DruidDataSource();
+        druidDataSource.setDriverClassName(driverClassNameOracle);
+        druidDataSource.setUrl(jdbcUrl5);
+        druidDataSource.setUsername(username5);
+        druidDataSource.setPassword(password5);
+        druidDataSource.setMaxActive(maxActive);
+        druidDataSource.setInitialSize(initialSize);
+        druidDataSource.setTimeBetweenConnectErrorMillis(timeBetweenEvictionRunsMillis);
+        druidDataSource.setValidationQuery(validationQuery);
+        druidDataSource.setTestWhileIdle(testWhileIdle);
+        druidDataSource.setTestOnBorrow(testOnBorrow);
+        druidDataSource.setTestOnReturn(testOnReturn);
+        druidDataSource.setPoolPreparedStatements(poolPreparedStatements);
+        druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
+        try {
+            druidDataSource.setFilters(filters);
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return druidDataSource;
+    }
+
     @Bean
     public DataSource dynamicDataSource() {
         Map<Object, Object> targetDataSources = new HashMap<>();
@@ -157,10 +183,12 @@ public class DruidConfig {
         DataSource ds2 = getDs2();
         DataSource ds3 = getDs3();
         DataSource ds4 = getDs4();
+        DataSource ds5 = getDs5();
         targetDataSources.put("ds1", ds1);
         targetDataSources.put("ds2", ds2);
         targetDataSources.put("ds3", ds3);
         targetDataSources.put("ds4", ds4);
+        targetDataSources.put("ds5", ds5);
         DynamicDataSource dynamicDataSource = new DynamicDataSource();
         dynamicDataSource.setTargetDataSources(targetDataSources);
         dynamicDataSource.setDefaultTargetDataSource(ds1);
@@ -168,6 +196,7 @@ public class DruidConfig {
         DynamicDataSourceContextHolder.dataSourceIds.add("ds2");
         DynamicDataSourceContextHolder.dataSourceIds.add("ds3");
         DynamicDataSourceContextHolder.dataSourceIds.add("ds4");
+        DynamicDataSourceContextHolder.dataSourceIds.add("ds5");
         return dynamicDataSource;
     }
 

+ 28 - 0
src/main/java/com/steerinfo/weight/gxmes/controller/GxWeightController.java

@@ -0,0 +1,28 @@
+package com.steerinfo.weight.gxmes.controller;
+
+import com.steerinfo.weight.gxmes.model.GxWeight;
+import com.steerinfo.weight.gxmes.service.IGxWeightService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/${api.version}/gxweight")
+public class GxWeightController {
+      @Autowired
+      private IGxWeightService gxWeightService;
+    @GetMapping("/QueryWeightforRound")
+    public List<GxWeight> QueryWeightforRound(String startTime,String endTime){
+        List<GxWeight> gxWeights = gxWeightService.QueryWeightforRound(startTime,endTime);
+        List<GxWeight> gxWeights2 = gxWeightService.QueryWeightforRound2(startTime,endTime);
+        gxWeights2.forEach((GxWeight gxWeight) ->{
+            gxWeights.add(gxWeight);
+        });
+        System.out.println(gxWeights.size());
+        return  gxWeights;
+    }
+
+}

+ 13 - 0
src/main/java/com/steerinfo/weight/gxmes/mapper/GxWeightMapper.java

@@ -0,0 +1,13 @@
+package com.steerinfo.weight.gxmes.mapper;
+
+import com.steerinfo.weight.gxmes.model.GxWeight;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface GxWeightMapper {
+    public List<GxWeight> QueryWeightforRound(@Param("startTime")String startTime, @Param("endTime") String endTime);
+    public List<GxWeight> QueryWeightforRound2(@Param("startTime")String startTime, @Param("endTime") String endTime);
+
+
+}

+ 20 - 0
src/main/java/com/steerinfo/weight/gxmes/mapper/GxWeightMapper.xml

@@ -0,0 +1,20 @@
+<?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.steerinfo.weight.gxmes.mapper.GxWeightMapper">
+    <resultMap id="BaseResultMap" type="com.steerinfo.weight.gxmes.model.GxWeight">
+        <id column="TYPES" jdbcType="VARCHAR" property="type"/>
+        <id column="QTY" jdbcType="DECIMAL" property="weight"/>
+        <id column="PRODATE"  jdbcType="VARCHAR" property="prodate"/>
+        <id column="MATERIALCODE" jdbcType="VARCHAR" property="materialcode"/>
+        <id column="MATERIALNAME" jdbcType="VARCHAR" property="materialname"/>
+        <id column="UNIT" jdbcType="VARCHAR" property="unit"/>
+        <id column="FID" jdbcType="VARCHAR" property="fid"/>
+        <id column="LC_ID" jdbcType="VARCHAR" property="roundid"/>
+    </resultMap>
+     <select id="QueryWeightforRound" parameterType="java.lang.String" resultMap="BaseResultMap">
+        select * from table(gxmes.EMS_GX_ROLLDESIGN(#{startTime},#{endTime}))
+     </select>
+    <select id="QueryWeightforRound2" parameterType="java.lang.String" resultMap="BaseResultMap">
+        select * from table(gxmes.EMS_GX_ROLLDESIGN2(#{startTime},#{endTime}))
+     </select>
+</mapper>

+ 25 - 0
src/main/java/com/steerinfo/weight/gxmes/model/GxWeight.java

@@ -0,0 +1,25 @@
+package com.steerinfo.weight.gxmes.model;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class GxWeight {
+    private String id;
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id == null ? null : id.trim();
+    }
+    private String type;
+    private BigDecimal weight;
+    private String prodate;
+    private String materialcode;
+    private String unit;
+    private String materialname;
+    private String fid;
+    private String roundid;
+
+}

+ 12 - 0
src/main/java/com/steerinfo/weight/gxmes/service/IGxWeightService.java

@@ -0,0 +1,12 @@
+package com.steerinfo.weight.gxmes.service;
+
+import com.steerinfo.weight.gxmes.model.GxWeight;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface IGxWeightService {
+    public List<GxWeight> QueryWeightforRound(@Param("startTime")String startTime, @Param("endTime") String endTime);
+    public List<GxWeight> QueryWeightforRound2(@Param("startTime")String startTime, @Param("endTime") String endTime);
+
+}

+ 30 - 0
src/main/java/com/steerinfo/weight/gxmes/service/impl/GxWeightImpl.java

@@ -0,0 +1,30 @@
+package com.steerinfo.weight.gxmes.service.impl;
+import com.steerinfo.config.dynamicDataSource.TargetDataSource;
+import com.steerinfo.weight.gxmes.mapper.GxWeightMapper;
+import com.steerinfo.weight.gxmes.model.GxWeight;
+import com.steerinfo.weight.gxmes.service.IGxWeightService;
+import com.steerinfo.weight.lgmes.model.LgWeight;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service("gxWeightService")
+public class GxWeightImpl implements IGxWeightService {
+
+    @Autowired
+    private GxWeightMapper gxWeightMapper;
+
+    @Override
+    @TargetDataSource(name = "ds5")
+    public List<GxWeight> QueryWeightforRound(String startTime, String endTime) {
+        return gxWeightMapper.QueryWeightforRound(startTime,endTime);
+    }
+
+    @Override
+    @TargetDataSource(name = "ds5")
+    public List<GxWeight> QueryWeightforRound2(String startTime, String endTime) {
+        return gxWeightMapper.QueryWeightforRound2(startTime,endTime);
+    }
+
+}

+ 1 - 1
src/main/java/com/steerinfo/weight/lgmes/mapper/LgWeightMapper.xml

@@ -4,7 +4,7 @@
     <resultMap id="BaseResultMap" type="com.steerinfo.weight.lgmes.model.LgWeight">
         <id column="TYPES" jdbcType="VARCHAR" property="type"/>
         <id column="QTY" jdbcType="DECIMAL" property="weight"/>
-        <id column="PRODATE"  jdbcType="VARCHAR" property="date"/>
+        <id column="PRODATE"  jdbcType="VARCHAR" property="prodate"/>
         <id column="MATERIALCODE" jdbcType="VARCHAR" property="materialcode"/>
         <id column="MATERIALNAME" jdbcType="VARCHAR" property="materialname"/>
         <id column="UNIT" jdbcType="VARCHAR" property="unit"/>

+ 1 - 1
src/main/java/com/steerinfo/weight/lgmes/model/LgWeight.java

@@ -15,7 +15,7 @@ public class LgWeight  {
     }
     private String type;
     private BigDecimal weight;
-    private String date;
+    private String prodate;
     private String materialcode;
     private String unit;
     private String materialname;

+ 6 - 2
src/main/resources/bootstrap.properties

@@ -7,9 +7,13 @@ spring.druid.jdbcUrl2=jdbc:oracle:thin:@172.16.90.252:1521:jymes
 spring.druid.username2=xtmes
 spring.druid.password2=xtmes
 
+spring.druid.jdbcUrl5=jdbc:oracle:thin:@172.16.90.240:1521:gxmes
+spring.druid.username5=gxems
+spring.druid.password5=gxems
+
 spring.druid.jdbcUrl3=jdbc:sqlserver://192.168.0.224:1433;DatabaseName=bfgl_001_2018
-spring.druid.username3=meiqihyd
-spring.druid.password3=atjt@123
+spring.druid.username3=nengyuanjiankong
+spring.druid.password3=nyjk_123
 
 spring.druid.jdbcUrl4=jdbc:sqlserver://192.168.0.224:1433;DatabaseName=bfgl_001_2018
 spring.druid.username4=nengyuanjiankong