hanfucheng пре 11 месеци
родитељ
комит
2694079f7d

+ 5 - 1
src/main/java/com/sooka/sponest/data/housingconstruction/controller/CenterdataTHousingconstructionSteelcylinderController.java

@@ -87,7 +87,11 @@ public class CenterdataTHousingconstructionSteelcylinderController extends BaseC
     @Log(title = "钢瓶基础数据", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable String[] ids) {
-        return toAjax(centerdataTHousingconstructionSteelcylinderService.deleteCenterdataTHousingconstructionSteelcylinderByIds(ids));
+        int num = centerdataTHousingconstructionSteelcylinderService.deleteCenterdataTHousingconstructionSteelcylinderByIds(ids);
+        if (num == -1) {
+            return AjaxResult.error("请先删除下级资源");
+        }
+        return toAjax(num);
     }
 
     /*

+ 10 - 0
src/main/java/com/sooka/sponest/data/housingconstruction/service/impl/CenterdataTHousingconstructionSteelcylinderServiceImpl.java

@@ -5,6 +5,7 @@ import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.datascope.annotation.DataScopeMutiDept;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.sooka.sponest.data.base.service.impl.BaseServiceImpl;
+import com.sooka.sponest.data.digitalwater.domain.CenterdataTHydraulicPatrolTask;
 import com.sooka.sponest.data.housingconstruction.domain.BO.SteelcylinderBO;
 import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSteelcylinder;
 import com.sooka.sponest.data.housingconstruction.domain.CenterdataTHousingconstructionSteelcylinderLog;
@@ -109,6 +110,15 @@ public class CenterdataTHousingconstructionSteelcylinderServiceImpl extends Base
      */
     @Override
     public int deleteCenterdataTHousingconstructionSteelcylinderByIds(String[] ids) {
+        for (String id : ids) {
+            CenterdataTHousingconstructionSteelcylinderLog steelcylinderLog = new CenterdataTHousingconstructionSteelcylinderLog();
+            steelcylinderLog.setSteelcylinderId(id);
+            setSookaDataBase(steelcylinderLog);
+            List<CenterdataTHousingconstructionSteelcylinderLog> list = centerdataTHousingconstructionSteelcylinderLogMapper.selectCenterdataTHousingconstructionSteelcylinderLogList(steelcylinderLog);
+            if (!list.isEmpty()) {
+                return -1;
+            }
+        }
         return centerdataTHousingconstructionSteelcylinderMapper.deleteCenterdataTHousingconstructionSteelcylinderByIds(ids);
     }
 

+ 25 - 15
src/main/resources/mapper/housingconstruction/CenterdataTHousingconstructionViewMapper.xml

@@ -40,9 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                   LEFT JOIN centerdata_t_housingconstruction_steelcylinder_log b ON a.id = b.steelcylinder_id
               WHERE
                   YEAR( b.sign_time ) = YEAR( CURRENT_DATE )
+            <if test="enterpriseId != null and enterpriseId != ''">
+                and a.enterprise_id = #{enterpriseId}
+            </if>
                   ${params.dataScope}
-              GROUP BY
-                  MONTH( b.sign_time )) b on a.`month` = b.`month`
+        GROUP BY MONTH( b.sign_time )) b on a.`month` = b.`month`
         ORDER BY a.`month`
     </select>
 
@@ -226,24 +228,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="getStoragetankList" parameterType="CenterdataTHousingconstructionStoragetank" resultType="map">
-        select
-            a.dept_id enterpriseId,
-            a.dept_name enterpriseName,
+        SELECT
+            a.enterprise_id enterpriseId,
+            a.enterprise_name enterpriseName,
             a.id storagetankId,
             a.name storagetankName,
-            IFNULL(b.LEVEL, '-') level,
-            IFNULL(b.heat,'-') heat,
-            IFNULL(b.pressure,'-') pressure,
-            IFNULL(b.gas_leak,'-') gasLeak,
-            IFNULL(b.security_state,'-') securityState,
-            IFNULL(b.run_state,'-') runState,
-            MAX(b.create_time)	as createTime
+            b.level,
+            b.heat,
+            b.pressure,
+            b.gas_leak gasLeak,
+            b.security_state securityState,
+            b.run_state runState
         from centerdata_t_housingconstruction_storagetank a
-        LEFT JOIN  centerdata_t_housingconstruction_storagetank_log b  ON b.storagetank_id = a.id
-        LEFT JOIN ${database_system}.sys_dept d on a.dept_id = d.dept_id
+        left join centerdata_t_housingconstruction_storagetank_log b on b.storagetank_id = a.id
+        left join onest_system.sys_dept d on a.dept_id = d.dept_id
+        <if test="state != null  and state != ''">
+            JOIN (
+                SELECT storagetank_id,MAX(create_time) AS max_time
+                FROM centerdata_t_housingconstruction_storagetank_log
+                where
+                DATE_FORMAT(create_time, '%Y_%m_%d') = CURDATE()
+                GROUP BY storagetank_id
+                ) c ON b.storagetank_id = c.storagetank_id AND b.create_time = c.max_time
+        </if>
         <where>
             <if test="enterpriseId != null  and enterpriseId != ''"> and a.enterprise_id = #{enterpriseId}</if>
-            <if test="state != null  and state != ''"> and a.security_state is not null</if>
+            <if test="state != null  and state != ''"> and a.security_state !=''</if>
             ${params.dataScope}
         </where>
         GROUP BY a.id