Browse Source

今日订单sql优化

Memory_LG 9 months ago
parent
commit
781f40a70b

+ 8 - 2
src/main/java/com/sooka/sponest/data/housingconstruction/controller/CenterdataTHousingconstructionViewController.java

@@ -3,6 +3,7 @@ package com.sooka.sponest.data.housingconstruction.controller;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.web.controller.BaseController;
 import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.TableDataInfo;
 import com.sooka.sponest.data.housingconstruction.domain.*;
 import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionViewService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,6 +11,9 @@ 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;
+import java.util.Map;
+
 /*
 * 住建-可视化
 *
@@ -162,8 +166,10 @@ public class CenterdataTHousingconstructionViewController extends BaseController
     * @date 2024/8/2 下午3:46
     */
     @GetMapping("/getJoinHouseUserList")
-    public R getJoinHouseUserList(CenterdataTHousingconstructionSteelcylinder steelcylinder) {
-        return R.ok(housingconstructionViewService.getJoinHouseUserList(steelcylinder));
+    public TableDataInfo getJoinHouseUserList(CenterdataTHousingconstructionSteelcylinder steelcylinder) {
+        startPage();
+        List<Map<String,Object>> list = housingconstructionViewService.getJoinHouseUserList(steelcylinder);
+        return getDataTable(list);
     }
 
     /*

+ 47 - 5
src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionViewMapper.xml

@@ -325,8 +325,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="enterpriseId != null  and enterpriseId != ''"> and a.dept_id = #{enterpriseId}</if>
     </select>
 
-    <select id="getJoinHouseUserList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">
-        SELECT
+
+        <!--SELECT
             a.id,
             a.`name`,
             b.join_house_id joinHouseId,
@@ -345,7 +345,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="enterpriseId != null  and enterpriseId != ''"> and a.enterprise_id = #{enterpriseId}</if>
         <if test="steelcylinderNumber != null  and steelcylinderNumber != ''"> and a.steelcylinder_number like concat('%', #{steelcylinderNumber}, '%')</if>
         <if test="state != null  and state != ''"> and DATE( b.delivery_time ) = DATE( NOW( ) )</if>
+            ${params.dataScope}-->
+    <select id="getJoinHouseUserList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">
+        SELECT b.gas_address as gasAddress,
+               a.steelcylinder_name as steelcylinderName,
+               a.join_house_id as joinHouseId,
+               a.join_house_name as joinHouseName,
+               b.dept_id as id,
+               b.dept_name as name,
+               a.delivery_time deliveryTime,
+               a.delivery_name deliveryName
+        FROM (
+            SELECT steelcylinder_name, join_house_id, join_house_name, delivery_time, delivery_name FROM centerdata_t_housingconstruction_steelcylinder_log
+            <where>
+                steelcylinder_id in (
+                select id FROM centerdata_t_housingconstruction_steelcylinder
+                <where>
+                    AND state = 'state_4'
+                    <if test="enterpriseId != null  and enterpriseId != ''">
+                        and enterprise_id = #{enterpriseId}
+                    </if>
+                </where>
+                )
+                <if test="state != null  and state != ''">
+                    and DATE(sign_time) = CURDATE()
+                </if>
+                <if test="steelcylinderName != null  and steelcylinderName != ''">
+                    and steelcylinder_name like concat('%', #{steelcylinderName}, '%')
+                </if>
+            </where>
+        ) a
+        LEFT JOIN (
+            SELECT gas_address, id, dept_id, dept_name  FROM centerdata_t_housingconstruction_realnameuser
+            <where>
+                <if test="enterpriseId != null  and enterpriseId != ''">
+                    and enterprise_id = #{enterpriseId}
+                </if>
+            </where>
+        ) b on a.join_house_id = b.id
+        LEFT JOIN ${database_system}.sys_dept d ON b.dept_id = d.dept_id
+        <where>
             ${params.dataScope}
+        </where>
     </select>
 
     <select id="getGassourceList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">
@@ -357,9 +398,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
             centerdata_t_housingconstruction_gassource a
             left join ${database_system}.sys_dept d on a.dept_id = d.dept_id
-        where
-        <if test="enterpriseId != null  and enterpriseId != ''"> and a.enterprise_id = #{enterpriseId}</if>
-        ${params.dataScope}
+        <where>
+            <if test="enterpriseId != null  and enterpriseId != ''"> and a.enterprise_id = #{enterpriseId}</if>
+            ${params.dataScope}
+        </where>
     </select>
 
     <select id="getSteelcylinderPointList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">