Browse Source

项目列表逻辑优化

ljy121 1 year ago
parent
commit
3665e99cc0

+ 0 - 2
zjugis-business/src/main/java/com/zjugis/business/ZjugisBusinessApplication.java

@@ -6,12 +6,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.cloud.openfeign.EnableFeignClients;
-import org.springframework.context.annotation.ComponentScan;
 
 @SpringBootApplication
 @EnableDiscoveryClient
 @EnableFeignClients
-@ComponentScan(value = {"com.zjugis.*"})
 @MapperScan({"com.zjugis.business.flow.demo.dao","com.zjugis.business.mapper"})
 @RefreshScope
 public class ZjugisBusinessApplication{

+ 3 - 0
zjugis-business/src/main/java/com/zjugis/business/mapper/ProjectMapper.java

@@ -1,5 +1,6 @@
 package com.zjugis.business.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.business.bean.dto.ProjectDto;
 import com.zjugis.business.bean.entity.Project;
 import com.zjugis.business.bean.response.ProjectCalculateResponse;
@@ -22,5 +23,7 @@ public interface ProjectMapper extends BaseMapperX<Project> {
     ProjectCalculateResponse calculate(ProjectDto projectDto);
 
     List<ProjectResponse> selectWithChildren(@Param("id") String id);
+
+    Page<Project> page(Page<Project> page, @Param("params") ProjectDto projectDto);
 }
 

+ 0 - 21
zjugis-business/src/main/java/com/zjugis/business/mybatis/config/MybatisConfig.java

@@ -1,21 +0,0 @@
-package com.zjugis.business.mybatis.config;
-
-
-//@AutoConfiguration
-//public class MybatisConfig {
-//
-//    @Bean
-//    public MybatisPlusInterceptor mybatisPlusInterceptor() {
-//        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
-//        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor()); // 分页插件
-//        return mybatisPlusInterceptor;
-//    }
-//
-//    @Primary
-//    @Bean
-//    public MetaObjectHandler defaultMetaObjectHandler(){
-//        return new MybatisFieldHandler(); // 自动填充参数类
-//    }
-//
-//
-//}

+ 1 - 12
zjugis-business/src/main/java/com/zjugis/business/service/impl/ProjectServiceImpl.java

@@ -9,8 +9,6 @@ import com.zjugis.business.bean.response.ProjectCalculateResponse;
 import com.zjugis.business.bean.response.ProjectResponse;
 import com.zjugis.business.mapper.ProjectMapper;
 import com.zjugis.business.service.ProjectService;
-import com.zjugis.framework.mybatis.core.query.QueryWrapperX;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -37,16 +35,7 @@ public class ProjectServiceImpl implements ProjectService {
 
     @Override
     public Page<Project> page(Page<Project> page, ProjectDto projectDto) {
-        QueryWrapperX<Project> queryWrapper = new QueryWrapperX<>();
-        queryWrapper.likeIfPresent("XMMC",projectDto.getXmmc());
-        queryWrapper.likeIfPresent("XMBH",projectDto.getXmbh());
-        queryWrapper.eq(StringUtils.isNotBlank(projectDto.getProjectTypeId()),"PROJECT_TYPE_ID",projectDto.getProjectTypeId());
-        queryWrapper.eq(StringUtils.isNotBlank(projectDto.getXzqdm()),"XZQDM",projectDto.getXzqdm());
-        queryWrapper.eqIfPresent("HY_ID",projectDto.getHyId());
-        queryWrapper.eqIfPresent("XMZT",projectDto.getXmzt());
-        queryWrapper.eqIfPresent("IS_SIGN",projectDto.getIsSign());
-        queryWrapper.betweenIfPresent("LXSJ",projectDto.getLxsjOn(),projectDto.getLxsjOff());
-        return  projectMapper.selectPage(page, queryWrapper);
+        return  projectMapper.page(page,projectDto);
     }
 
     @Override

+ 3 - 0
zjugis-business/src/main/resources/application.yaml

@@ -12,6 +12,9 @@ spring:
           url: jdbc:oracle:thin:@10.10.10.8:1521:ORCL
           username: ZJUGIS_BUSINESS
           password: Zjugis1402
+          type: com.zaxxer.hikari.HikariDataSource
+
+
   #freemarker
   freemarker:
     settings:

+ 36 - 0
zjugis-business/src/main/resources/mapper/oracle/ProjectMapper.xml

@@ -18,4 +18,40 @@
         )
         CONNECT BY PRIOR ID = PID
     </select>
+
+    <select id="page" resultType="com.zjugis.business.bean.entity.Project">
+        SELECT * FROM PROJECT
+        <where>
+            ISVALID = 1
+            <if test="params != null and params.hyId != null">
+                AND HY_ID = #{params.hyId}
+            </if>
+            <if test="params != null and params.xzqdm != null and params.xzqdm != ''">
+                AND XZQDM = #{params.xzqdm}
+            </if>
+            <if test="params != null and params.xmzt != null">
+                AND XMZT = #{params.xmzt}
+            </if>
+            <if test="params != null and params.lxsjOn != null">
+                AND LXSJ &gt;= #{params.lxsjOn}
+            </if>
+            <if test="params != null and params.lxsjOff != null">
+                AND LXSJ &lt;= #{params.lxsjOff}
+            </if>
+            <if test="params != null and params.isSign != null">
+                AND IS_SIGN = #{params.isSign}
+            </if>
+            <if test="params != null and params.xmmc != null and params.xmmc != ''">
+                <bind name="xmmc" value="'%'+params.xmmc+'%'"/>
+                AND XMMC LIKE #{xmmc}
+            </if>
+            <if test="params != null and params.xmbh != null and params.xmbh != ''">
+                <bind name="xmbh" value="'%'+params.xmbh+'%'"/>
+                AND XMBH LIKE #{xmbh}
+            </if>
+        </where>
+        ORDER BY LXSJ DESC
+
+
+    </select>
 </mapper>