hanfucheng vor 9 Monaten
Ursprung
Commit
ca8c7ffaf0

+ 8 - 24
src/main/java/com/sooka/sponest/data/housingconstruction/service/impl/CenterdataTHousingconstructionViewServiceImpl.java

@@ -11,14 +11,15 @@ import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconst
 import com.sooka.sponest.data.housingconstruction.mapper.CenterdataTHousingconstructionViewMapper;
 import com.sooka.sponest.data.housingconstruction.service.ICenterdataTHousingconstructionViewService;
 import org.apache.commons.collections4.MapUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static com.ruoyi.common.core.utils.DateUtils.getLastMonths;
 
 /**
  * 车辆数据Service业务层处理
@@ -359,7 +360,8 @@ public class CenterdataTHousingconstructionViewServiceImpl extends BaseServiceIm
         for (Map<String, Object> resultDatum : getData) {
             data.put(MapUtils.getString(resultDatum,"month"), resultDatum);
         }
-        List<String> twelveMonths = getTwelveMonths();
+        List<String> twelveMonths = getLastMonths(12);
+
 
         List<Map<String, Object>> resultData = new ArrayList<>();
         twelveMonths.forEach(month->{
@@ -375,22 +377,4 @@ public class CenterdataTHousingconstructionViewServiceImpl extends BaseServiceIm
         return resultData;
     }
 
-    private List<String> getTwelveMonths(){
-        // 获取当前日期
-        LocalDate currentDate = LocalDate.now();
-
-        // 存储过去12个月的月份
-        List<String> lastTwelveMonths = new ArrayList<>();
-
-        // 设置日期格式
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
-
-        for (int i = 0; i < 12; i++) {
-            // 计算月份
-            LocalDate date = currentDate.minusMonths(i);
-            // 格式化并添加到列表
-            lastTwelveMonths.add(date.format(formatter));
-        }
-        return lastTwelveMonths;
-    }
 }

+ 1 - 1
src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionRealnameuserMapper.xml

@@ -140,7 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             gas_address gasAddress,
             license_code licenseCode,
             contact_number contactNumber,
-            account_open_time accountOpenTime,
+            IFNULL(account_open_time,'') accountOpenTime,
             longitude,
             latitude,
             a.merchant_name merchantName,

+ 31 - 43
src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionViewMapper.xml

@@ -124,7 +124,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
             centerdata_t_housingconstruction_realnameuser a
                 LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-        where 1=1 ${params.dataScope}
+        where 1=1
+        <if test="enterpriseId != null  and enterpriseId != ''"> and enterprise_id = #{enterpriseId}</if>
+            ${params.dataScope}
         UNION ALL
         SELECT
             'add' type,
@@ -132,7 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM
             centerdata_t_housingconstruction_realnameuser a
                 LEFT JOIN ${database_system}.sys_dept d ON a.dept_id = d.dept_id
-        WHERE a.create_time >= DATE_SUB( CURRENT_DATE, INTERVAL 30 DAY )
+        WHERE 1=1
+        <if test="enterpriseId != null  and enterpriseId != ''"> and enterprise_id = #{enterpriseId}</if>
+          and DATE_FORMAT(a.account_open_time, '%Y-%m-%d') >= DATE_SUB( CURRENT_DATE, INTERVAL 30 DAY )
             ${params.dataScope}
     </select>
 
@@ -363,11 +367,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             count( a.id ) num
         FROM
             centerdata_t_housingconstruction_inspect a
-            JOIN ( SELECT steelcylinder_id, MAX( create_time ) max_time
+            JOIN ( SELECT steelcylinder_id, MAX( next_inspect_time ) max_time
                    FROM centerdata_t_housingconstruction_inspect GROUP BY steelcylinder_id ) b
-            ON a.steelcylinder_id = b.steelcylinder_id AND a.create_time = b.max_time
+            ON a.steelcylinder_id = b.steelcylinder_id AND a.next_inspect_time = b.max_time
         WHERE
-            a.next_inspect_time &lt; DATE( NOW( ) )
+            a.next_inspect_time &lt;= DATE_FORMAT(NOW(),'%Y-%m-%d %h:%m:%s')
         <if test="enterpriseId != null  and enterpriseId != ''"> and a.dept_id = #{enterpriseId}</if>
     </select>
 
@@ -393,46 +397,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <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="name != null  and name != ''">
-                    and steelcylinder_name like concat('%', #{name}, '%')
-                </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
+        SELECT
+            SUBSTRING_INDEX( GROUP_CONCAT( l.steelcylinder_name ORDER BY sign_time DESC ), ',', 1 ) steelcylinderName,
+            u.longitude,
+            u.latitude,
+            u.gas_address gasAddress,
+            l.join_house_id as joinHouseId,
+            l.join_house_name as joinHouseName,
+            u.dept_id as id,
+            u.dept_name as name,
+            l.sign_time deliveryTime,
+            l.delivery_name deliveryName
+        FROM
+        centerdata_t_housingconstruction_steelcylinder_log l
+        LEFT JOIN centerdata_t_housingconstruction_realnameuser u ON u.id = l.join_house_id
+        LEFT JOIN ${database_system}.sys_dept d ON d.dept_id = u.dept_id
         <where>
-            ${params.dataScope}
+            <if test="state != null  and state != ''">
+                and DATE(l.sign_time) = CURDATE()
+            </if>
+            <if test="enterpriseId != null  and enterpriseId != ''"> and u.enterprise_id = #{enterpriseId}</if>
+            <if test="name != null  and name != ''"> and l.steelcylinder_name like concat('%', #{name}, '%')</if>
         </where>
+        GROUP BY join_house_id
     </select>
 
     <select id="getGassourceList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">
@@ -448,6 +435,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="enterpriseId != null  and enterpriseId != ''"> and a.enterprise_id = #{enterpriseId}</if>
             ${params.dataScope}
         </where>
+        ORDER BY a.join_instation_time desc
     </select>
 
     <select id="getSteelcylinderPointList" parameterType="CenterdataTHousingconstructionSteelcylinder" resultType="map">