Преглед изворни кода

修改sql

Signed-off-by: tangsong <86121657@qq.com>
tangsong пре 1 година
родитељ
комит
363cd35eb0

+ 1 - 1
base-server/src/main/resources/bootstrap-devmysql.yml

@@ -14,7 +14,7 @@ spring:
14
     restart:
14
     restart:
15
       enabled: false
15
       enabled: false
16
   datasource:
16
   datasource:
17
-#    type: com.alibaba.druid.pool.DruidDataSource
17
+    type: com.alibaba.druid.pool.DruidDataSource
18
     url: jdbc:mysql://172.16.0.46:3306/base?useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT%2b8
18
     url: jdbc:mysql://172.16.0.46:3306/base?useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT%2b8
19
 #    url: jdbc:mysql://101.36.160.140:10311/base?useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT%2b8
19
 #    url: jdbc:mysql://101.36.160.140:10311/base?useUnicode=true&characterEncoding=UTF-8&useSSL=true&serverTimezone=GMT%2b8
20
     username: root
20
     username: root

+ 24 - 23
base-server/src/main/resources/mybatis/mapper/TzSlqyMapper.xml

@@ -161,12 +161,12 @@
161
             (select first 1 pj.pjjg
161
             (select first 1 pj.pjjg
162
                 from qyxypjdc pj
162
                 from qyxypjdc pj
163
                 where pj.ztmc = tz.qymc
163
                 where pj.ztmc = tz.qymc
164
-                and to_date(pj.pjyxq
165
-                , 'yyyy-MM-dd') &gt;= to_date((select sysdate from dual)
166
-                , 'yyyy-MM-dd')
167
-                and to_date(pj.pjrq
168
-                , 'yyyy-MM-dd') &lt;= to_date((select sysdate from dual)
169
-                , 'yyyy-MM-dd')
164
+                and DATE_FORMAT(pj.pjyxq
165
+                , '%Y-%m-%d') &gt;= DATE_FORMAT(now()
166
+                , '%Y-%m-%d')
167
+                and DATE_FORMAT(pj.pjrq
168
+                , '%Y-%m-%d') &lt;= DATE_FORMAT(now()
169
+                , '%Y-%m-%d')
170
                 and zt = '已提交'
170
                 and zt = '已提交'
171
                 order by pj.pjnd desc) x) as pjjg
171
                 order by pj.pjnd desc) x) as pjjg
172
         from
172
         from
@@ -289,10 +289,10 @@
289
 
289
 
290
     <!--	根据统一社会信用代码获取企业相关信息-->
290
     <!--	根据统一社会信用代码获取企业相关信息-->
291
     <select id="getqyxxBytyshxydm" parameterType="java.lang.String" resultMap="BaseResultMap">
291
     <select id="getqyxxBytyshxydm" parameterType="java.lang.String" resultMap="BaseResultMap">
292
-		SELECT qymc, fddbr, create_date,refresh_time,zcr,
293
-        (select distinct p.provin_name from usercenter.BAS_AREA p where p.provin_code= txprovince) ||
294
-	    (select distinct p.county_name from usercenter.BAS_AREA p where p.county_code= txcity) ||
295
-         (select distinct p.city_name from usercenter.BAS_AREA p where p.city_code= txcity) || qytxdz as qytxdz
292
+    SELECT qymc, fddbr, create_date,refresh_time,zcr,
293
+        concat((select distinct p.provin_name from usercenter.BAS_AREA p where p.provin_code= txprovince),
294
+	    (select distinct p.county_name from usercenter.BAS_AREA p where p.county_code= txcity) ,
295
+         (select distinct p.city_name from usercenter.BAS_AREA p where p.city_code= txcity) , qytxdz) as qytxdz
296
         FROM TZ_SLQY
296
         FROM TZ_SLQY
297
 		WHERE tyshxydm = #{kddm}
297
 		WHERE tyshxydm = #{kddm}
298
 	</select>
298
 	</select>
@@ -1393,9 +1393,9 @@
1393
     <select id="getCompanyBytyshxydm" parameterType="java.lang.String" resultMap="BaseResultMap">
1393
     <select id="getCompanyBytyshxydm" parameterType="java.lang.String" resultMap="BaseResultMap">
1394
         SELECT
1394
         SELECT
1395
         <include refid="Base_Column_List_common"></include>
1395
         <include refid="Base_Column_List_common"></include>
1396
-        ,(select nvl(count(0),0) from base.d_kdxxsjy where tyshxydm=tz.tyshxydm and status=1) as kqsl
1397
-        ,(select nvl(count(distinct(gfcfdm)),0) from base.d_cfxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5) as cfsl
1398
-        ,(select nvl(count(0),0) from base.d_ygxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5 ) as ygsl
1396
+        ,(select ifnull(count(0),0) from base.d_kdxxsjy where tyshxydm=tz.tyshxydm and status=1) as kqsl
1397
+        ,(select ifnull(count(distinct(gfcfdm)),0) from base.d_cfxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5) as cfsl
1398
+        ,(select ifnull(count(0),0) from base.d_ygxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5 ) as ygsl
1399
         from
1399
         from
1400
         TZ_SLQY tz
1400
         TZ_SLQY tz
1401
         <where>
1401
         <where>
@@ -1405,7 +1405,8 @@
1405
     </select>
1405
     </select>
1406
 
1406
 
1407
     <select id="selectMaxId" resultType="java.lang.Integer">
1407
     <select id="selectMaxId" resultType="java.lang.Integer">
1408
-  	    SELECT MAX(CAST(ID AS INT)) AS ID FROM TZ_SLQY
1408
+  	    SELECT MAX(ID) AS ID FROM TZ_SLQY
1409
+--   	    SELECT MAX(CAST(ID AS INT)) AS ID FROM TZ_SLQY
1409
   </select>
1410
   </select>
1410
 
1411
 
1411
     <select id="selectByEntity" resultMap="BaseResultMap">
1412
     <select id="selectByEntity" resultMap="BaseResultMap">
@@ -1482,7 +1483,7 @@
1482
   </select>
1483
   </select>
1483
 
1484
 
1484
     <select id="selectQyjg" resultType="com.unis.base.common.vo.TzQyjgVO">
1485
     <select id="selectQyjg" resultType="com.unis.base.common.vo.TzQyjgVO">
1485
-        SELECT * FROM TZ_QYJG  WHERE status=1
1486
+        SELECT * FROM TZ_QYJG  WHERE status =1
1486
     </select>
1487
     </select>
1487
 
1488
 
1488
     <select id="selectKdxx" resultType="com.unis.base.common.vo.DKdxxsjyVO">
1489
     <select id="selectKdxx" resultType="com.unis.base.common.vo.DKdxxsjyVO">
@@ -1685,7 +1686,7 @@
1685
             SELECT DISTINCT(tz.id)
1686
             SELECT DISTINCT(tz.id)
1686
             from TZ_SLQY tz
1687
             from TZ_SLQY tz
1687
             left join TZ_QYLX q on tz.id = q.qyid
1688
             left join TZ_QYLX q on tz.id = q.qyid
1688
-            WHERE tz.status = 1 AND decode(tz.qyjd, null, 0, 1)  =1 and decode(tz.qywd, null, 0, 1) = 1
1689
+            WHERE tz.status = 1 AND if(tz.qyjd = null, 0, 1)  =1 and if(tz.qywd =null, 0, 1) = 1
1689
             <!-- 企业类型 -->
1690
             <!-- 企业类型 -->
1690
             <if test="qylxbh != null and qylxbh != ''">
1691
             <if test="qylxbh != null and qylxbh != ''">
1691
                 and q.qylxbh LIKE concat(CONCAT('%',#{qylxbh,jdbcType=VARCHAR}) ,'%')
1692
                 and q.qylxbh LIKE concat(CONCAT('%',#{qylxbh,jdbcType=VARCHAR}) ,'%')
@@ -2063,7 +2064,7 @@
2063
     <!--根据实体的唯一属性查询数量-->
2064
     <!--根据实体的唯一属性查询数量-->
2064
     <select id='selectCountById' resultType='java.lang.Integer'>
2065
     <select id='selectCountById' resultType='java.lang.Integer'>
2065
         SELECT
2066
         SELECT
2066
-        COUNT(*)
2067
+        COUNT(1)
2067
         FROM TZ_SLQY
2068
         FROM TZ_SLQY
2068
         <where>
2069
         <where>
2069
             <if test='id !=null and id != ""'>
2070
             <if test='id !=null and id != ""'>
@@ -2077,9 +2078,9 @@
2077
     <select id="getCompanyByqymc" resultType="com.unis.base.server.entity.TzSlqyDO">
2078
     <select id="getCompanyByqymc" resultType="com.unis.base.server.entity.TzSlqyDO">
2078
         SELECT
2079
         SELECT
2079
         <include refid="Base_Column_List_common"></include>
2080
         <include refid="Base_Column_List_common"></include>
2080
-        ,(select nvl(count(0),0) from base.d_kdxxsjy where tyshxydm=tz.tyshxydm and status=1) as kqsl
2081
-        ,(select nvl(count(distinct(gfcfdm)),0) from base.d_cfxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5) as cfsl
2082
-        ,(select nvl(count(0),0) from base.d_ygxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5 ) as ygsl
2081
+        ,(select ifnull(count(0),0) from base.d_kdxxsjy where tyshxydm=tz.tyshxydm and status=1) as kqsl
2082
+        ,(select ifnull(count(distinct(gfcfdm)),0) from base.d_cfxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5) as cfsl
2083
+        ,(select ifnull(count(0),0) from base.d_ygxxsjy where tyshxydm=tz.tyshxydm and status=1 and sfba=5 ) as ygsl
2083
         from
2084
         from
2084
         TZ_SLQY tz
2085
         TZ_SLQY tz
2085
         <where>
2086
         <where>
@@ -2531,7 +2532,7 @@
2531
         update TZ_SLQY
2532
         update TZ_SLQY
2532
         set
2533
         set
2533
             <if test="sjcr != null">
2534
             <if test="sjcr != null">
2534
-                sjcr = (select nvl(sum(sjcr),0)
2535
+                sjcr = (select ifnull(sum(sjcr),0)
2535
                         from (select a.sjcr,
2536
                         from (select a.sjcr,
2536
                                 row_number() over(partition by a.gfcfdm order by a.refresh_time desc) as rn
2537
                                 row_number() over(partition by a.gfcfdm order by a.refresh_time desc) as rn
2537
                               from  base.D_CFXXSJY a
2538
                               from  base.D_CFXXSJY a
@@ -2539,7 +2540,7 @@
2539
                               and a.sfba = '5'
2540
                               and a.sfba = '5'
2540
                               and tyshxydm = #{tyshxydm,jdbcType=VARCHAR})
2541
                               and tyshxydm = #{tyshxydm,jdbcType=VARCHAR})
2541
                         where rn=1),
2542
                         where rn=1),
2542
-                zcr = (select nvl(sum(dczlrj),0)
2543
+                zcr = (select ifnull(sum(dczlrj),0)
2543
                         from (select a.dczlrj,
2544
                         from (select a.dczlrj,
2544
                                  row_number() over(partition by a.gfcfdm order by a.refresh_time desc) as rn
2545
                                  row_number() over(partition by a.gfcfdm order by a.refresh_time desc) as rn
2545
                               from  base.D_CFXXSJY a
2546
                               from  base.D_CFXXSJY a
@@ -2549,7 +2550,7 @@
2549
                         where rn=1),
2550
                         where rn=1),
2550
             </if>
2551
             </if>
2551
             <if test="gr != null">
2552
             <if test="gr != null">
2552
-                gr = (select nvl(sum(sjgr),0)
2553
+                gr = (select ifnull(sum(sjgr),0)
2553
                      from d_ygxxsjy
2554
                      from d_ygxxsjy
2554
                      where sfba = '5'
2555
                      where sfba = '5'
2555
                      and tyshxydm = #{tyshxydm,jdbcType=VARCHAR}),
2556
                      and tyshxydm = #{tyshxydm,jdbcType=VARCHAR}),

+ 3 - 3
base-server/src/main/resources/mybatis/mapper/XzqhMapper.xml

@@ -202,7 +202,7 @@
202
   <!--根据实体的某些属性查询数量-->
202
   <!--根据实体的某些属性查询数量-->
203
   <select id='selectCountByEntity' resultType='java.lang.Integer'>
203
   <select id='selectCountByEntity' resultType='java.lang.Integer'>
204
     SELECT 
204
     SELECT 
205
-    COUNT(*) 
205
+    COUNT(1)
206
     FROM TY_XZQHB
206
     FROM TY_XZQHB
207
     <where>
207
     <where>
208
       <!--自定义配置的检索条件-->
208
       <!--自定义配置的检索条件-->
@@ -234,7 +234,7 @@
234
   <!--根据实体的唯一属性查询数量-->
234
   <!--根据实体的唯一属性查询数量-->
235
   <select id='selectCountById' resultType='java.lang.Integer'>
235
   <select id='selectCountById' resultType='java.lang.Integer'>
236
     SELECT 
236
     SELECT 
237
-    COUNT(*) 
237
+    COUNT(1)
238
     FROM TY_XZQHB
238
     FROM TY_XZQHB
239
     <where>
239
     <where>
240
       <if test='qhid !=null and qhid != ""'>
240
       <if test='qhid !=null and qhid != ""'>
@@ -246,7 +246,7 @@
246
   <!--根据实体的业务唯一属性(且非指定主键数据)判断是否存在-->
246
   <!--根据实体的业务唯一属性(且非指定主键数据)判断是否存在-->
247
   <select id='selectExistsByEntity' resultType='java.lang.Integer'>
247
   <select id='selectExistsByEntity' resultType='java.lang.Integer'>
248
     SELECT
248
     SELECT
249
-    COUNT(*) 
249
+    COUNT(1)
250
     FROM TY_XZQHB
250
     FROM TY_XZQHB
251
     <where>
251
     <where>
252
       <if test='qhid !=null and qhid != ""'>
252
       <if test='qhid !=null and qhid != ""'>