From dd534649e57dc09635c09a2e112fffd33b4425d0 Mon Sep 17 00:00:00 2001 From: water_xu Date: Wed, 29 May 2024 16:20:33 +0800 Subject: [PATCH] =?UTF-8?q?AI=E6=8A=A5=E8=AD=A6-=E6=8B=86=E5=88=86HIDDEN?= =?UTF-8?q?=5FIDS=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/AppAIWarningController.java | 24 +++++++- .../keyProjects/AIWarningHiddensMapper.java | 51 ++++++++++++++++ .../keyProjects/AIWarningHiddensService.java | 48 +++++++++++++++ .../impl/AIWarningHiddensServiceImpl.java | 59 ++++++++++++++++++ .../impl/KeyprojectHiddenServiceImpl.java | 8 +++ .../keyProjects/KeyprojectHiddenMapper.xml | 14 +++-- .../keyProjects/AIWarningHiddensMapper.xml | 61 +++++++++++++++++++ .../dsno2/keyProjects/AIWarningMapper.xml | 4 -- 8 files changed, 256 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/zcloud/mapper/dsno2/keyProjects/AIWarningHiddensMapper.java create mode 100644 src/main/java/com/zcloud/service/keyProjects/AIWarningHiddensService.java create mode 100644 src/main/java/com/zcloud/service/keyProjects/impl/AIWarningHiddensServiceImpl.java create mode 100644 src/main/resources/mybatis/dsno2/keyProjects/AIWarningHiddensMapper.xml diff --git a/src/main/java/com/zcloud/controller/keyProjects/app/AppAIWarningController.java b/src/main/java/com/zcloud/controller/keyProjects/app/AppAIWarningController.java index d17877f0..7b8c6db9 100644 --- a/src/main/java/com/zcloud/controller/keyProjects/app/AppAIWarningController.java +++ b/src/main/java/com/zcloud/controller/keyProjects/app/AppAIWarningController.java @@ -1,11 +1,14 @@ package com.zcloud.controller.keyProjects.app; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import com.zcloud.service.bus.ImgFilesService; +import com.zcloud.service.keyProjects.AIWarningHiddensService; import com.zcloud.service.keyProjects.AIWarningService; import com.zcloud.service.keyProjects.KeyprojectHiddenService; import com.zcloud.util.*; @@ -20,6 +23,7 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.*; +import java.util.stream.Collectors; /** * 说明:AI报警 @@ -37,6 +41,8 @@ public class AppAIWarningController extends BaseController { private KeyprojectHiddenService keyprojectHiddenService; @Autowired private ImgFilesService imgFilesService; + @Autowired + private AIWarningHiddensService aiwarningHiddensService; /**新增 * @param * @throws Exception @@ -171,7 +177,17 @@ public class AppAIWarningController extends BaseController { } } if (!hiddenIdList.isEmpty()) { - pd.put("HIDDEN_IDS", hiddenIdList.toString().replace("[","").replace("]","").replace(" ","")); + PageData finalPd = pd; + hiddenIdList.forEach(e -> { + PageData pageData = new PageData(); + pageData.put("AIWARNING_HIDDEN_ID", this.get32UUID()); + + pageData.put("AIWARNING_ID", finalPd.getString("AIWARNING_ID")); + pageData.put("HIDDEN_ID", e); + + aiwarningHiddensService.save(pageData); + }); + } aiwarningService.edit(pd); map.put("result", errInfo); @@ -216,10 +232,12 @@ public class AppAIWarningController extends BaseController { pd.put("NAME",user.getString("name")); } pd.put("FOREIGN_ID", pd.getString("OUTSOURCED_ID")); - if (Tools.notEmpty(pd.getString("HIDDEN_IDS"))){ + List hiddens = aiwarningHiddensService.findByAiId(pd); + if (CollUtil.isNotEmpty(hiddens)){ PageData pageData = new PageData(); pageData.put("AI_WARNING","Y"); - pageData.put("array",pd.getString("HIDDEN_IDS").split(",")); + pageData.put("AIWARNING_ID", Assert.notBlank(pd.getString("AIWARNING_ID"))); + pageData.put("array",hiddens.stream().map(e -> e.getString("HIDDEN_ID")).collect(Collectors.toList())); pd.put("hiddenList", keyprojectHiddenService.listAllInspection(pageData)); } map.put("pd", pd); diff --git a/src/main/java/com/zcloud/mapper/dsno2/keyProjects/AIWarningHiddensMapper.java b/src/main/java/com/zcloud/mapper/dsno2/keyProjects/AIWarningHiddensMapper.java new file mode 100644 index 00000000..f7ed726c --- /dev/null +++ b/src/main/java/com/zcloud/mapper/dsno2/keyProjects/AIWarningHiddensMapper.java @@ -0,0 +1,51 @@ +package com.zcloud.mapper.dsno2.keyProjects; + + + +import com.zcloud.entity.PageData; + +import java.util.List; + + +/** + * 说明:AI报警表的Hidden_ids中间表 + * 官网:www.zcloudchina.com + * @Autor:water_xu + * @Date:2024-05-29 + */ +public interface AIWarningHiddensMapper { + + /**新增 + * @param pd + * @throws Exception + */ + void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + PageData findById(PageData pd); + + + /**通过AiId获取数据 + * @param pd + * @throws Exception + */ + List findByAiId(PageData pd); + + /**通过HiddenId获取数据 + * @param pd + * @throws Exception + */ + PageData findByHiddenId(PageData pd); + + +} + diff --git a/src/main/java/com/zcloud/service/keyProjects/AIWarningHiddensService.java b/src/main/java/com/zcloud/service/keyProjects/AIWarningHiddensService.java new file mode 100644 index 00000000..7e1b5482 --- /dev/null +++ b/src/main/java/com/zcloud/service/keyProjects/AIWarningHiddensService.java @@ -0,0 +1,48 @@ +package com.zcloud.service.keyProjects; + +import com.zcloud.entity.PageData; + +import java.util.List; + +/** + * 说明:AI报警表的Hidden_ids中间表 + * 官网:www.zcloudchina.com + * @Autor water_xu + * @Date 2024.05.29 + */ +public interface AIWarningHiddensService { + + /**新增 + * @param pd + * @throws Exception + */ + public void save(PageData pd); + + /**修改 + * @param pd + * @throws Exception + */ + public void edit(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + public PageData findById(PageData pd); + + /** + * 通过id获取数据 + * + * @param pd + * @throws Exception + */ + public List findByAiId(PageData pd); + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + public PageData findByHiddenId(PageData pd); + +} + diff --git a/src/main/java/com/zcloud/service/keyProjects/impl/AIWarningHiddensServiceImpl.java b/src/main/java/com/zcloud/service/keyProjects/impl/AIWarningHiddensServiceImpl.java new file mode 100644 index 00000000..a2b12cc8 --- /dev/null +++ b/src/main/java/com/zcloud/service/keyProjects/impl/AIWarningHiddensServiceImpl.java @@ -0,0 +1,59 @@ + +package com.zcloud.service.keyProjects.impl; + +import com.zcloud.entity.PageData; +import com.zcloud.mapper.dsno2.keyProjects.AIWarningHiddensMapper; +import com.zcloud.service.keyProjects.AIWarningHiddensService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 说明:AI报警表的Hidden_ids中间表 + * 官网:www.zcloudchina.com + * @Autor water_xu + * @Date 2024.05.29 + */ +@Service +public class AIWarningHiddensServiceImpl implements AIWarningHiddensService { + + @Autowired + private AIWarningHiddensMapper aiWarningHiddensMapper; + + /**新增 + * @param pd + * @throws Exception + */ + public void save(PageData pd){ + aiWarningHiddensMapper.save(pd); + } + + /**修改 + * @param pd + * @throws Exception + */ + public void edit(PageData pd){ + aiWarningHiddensMapper.edit(pd); + } + + /**通过id获取数据 + * @param pd + * @throws Exception + */ + public PageData findById(PageData pd){ + return aiWarningHiddensMapper.findById(pd); + } + + @Override + public List findByAiId(PageData pd){ + return aiWarningHiddensMapper.findByAiId(pd); + } + + @Override + public PageData findByHiddenId(PageData pd){ + return aiWarningHiddensMapper.findByHiddenId(pd); + } + +} + diff --git a/src/main/java/com/zcloud/service/keyProjects/impl/KeyprojectHiddenServiceImpl.java b/src/main/java/com/zcloud/service/keyProjects/impl/KeyprojectHiddenServiceImpl.java index beb7b93e..17af2bfe 100644 --- a/src/main/java/com/zcloud/service/keyProjects/impl/KeyprojectHiddenServiceImpl.java +++ b/src/main/java/com/zcloud/service/keyProjects/impl/KeyprojectHiddenServiceImpl.java @@ -184,6 +184,14 @@ public class KeyprojectHiddenServiceImpl implements KeyprojectHiddenService { @Override public List listAllInspection(PageData pd) throws Exception { List hiddenList = hiddenMapper.listAllInspection(pd); + /** + * 这里如果不传对应的参数会出现全表查询的现象,为了避免这种情况,默认如果记录数超过100条,抛出异常 + * @Autor water_xu + * @Date 2024/05/29 + */ + if (hiddenList.size() >= 100){ + throw new RuntimeException("参数异常-listAllInspection查询结果记录数为:" + hiddenList.size()); + } for (PageData hd : hiddenList) { PageData pd2 = new PageData(); pd2.put("FOREIGN_KEY",hd.getString("HIDDEN_ID")); diff --git a/src/main/resources/mybatis/datasource/keyProjects/KeyprojectHiddenMapper.xml b/src/main/resources/mybatis/datasource/keyProjects/KeyprojectHiddenMapper.xml index d94d66e8..83793a1d 100644 --- a/src/main/resources/mybatis/datasource/keyProjects/KeyprojectHiddenMapper.xml +++ b/src/main/resources/mybatis/datasource/keyProjects/KeyprojectHiddenMapper.xml @@ -1136,6 +1136,10 @@ from f left join `qa-gwj-prevention`.bus_hiddenregion hr on hr.HIDDENREGION_ID = f.HIDDENPART + + left join `qa-gwj-regulatory`.bus_aiwarning_hiddens aih on aih.HIDDEN_ID = f.HIDDEN_ID + left join `qa-gwj-regulatory`.bus_aiwarning ai on ai.AIWARNING_ID = aih.AIWARNING_ID + left join lv on f.HIDDENLEVEL = lv.BIANMA left join ht on f.HIDDENTYPE = ht.BIANMA left join ht2 on f.HIDDENTYPE2 = ht2.BIANMA and ht2.PARENT_ID = '18c0a9aea6e54feab9f4ab3f46e0bc86' @@ -1148,13 +1152,11 @@ and f.FOREIGN_ID = #{FOREIGN_ID} - - - and f.HIDDEN_ID in - - #{item} - + + + and ai.AIWARNING_ID = #{AIWARNING_ID} + and ( diff --git a/src/main/resources/mybatis/dsno2/keyProjects/AIWarningHiddensMapper.xml b/src/main/resources/mybatis/dsno2/keyProjects/AIWarningHiddensMapper.xml new file mode 100644 index 00000000..3805e40f --- /dev/null +++ b/src/main/resources/mybatis/dsno2/keyProjects/AIWarningHiddensMapper.xml @@ -0,0 +1,61 @@ + + + + + + + BUS_AIWARNING_HIDDENS + + + + + insert into + + ( + AIWARNING_HIDDEN_ID,AIWARNING_ID,HIDDEN_ID + ) values ( + #{AIWARNING_HIDDEN_ID},#{AIWARNING_ID},#{HIDDEN_ID} + ) + + + + + + update + + set + AIWARNING_ID = #{AIWARNING_ID},HIDDEN_ID = #{HIDDEN_ID} + where + AIWARNING_HIDDEN_ID = #{AIWARNING_HIDDEN_ID} + + + + + + + + + + + diff --git a/src/main/resources/mybatis/dsno2/keyProjects/AIWarningMapper.xml b/src/main/resources/mybatis/dsno2/keyProjects/AIWarningMapper.xml index b34f1a62..a6d4266c 100644 --- a/src/main/resources/mybatis/dsno2/keyProjects/AIWarningMapper.xml +++ b/src/main/resources/mybatis/dsno2/keyProjects/AIWarningMapper.xml @@ -28,7 +28,6 @@ f.ISTRUE, f.HASHIDDEN, f.AIWARNING_ID, - f.HIDDEN_IDS, f.REMARKS @@ -126,9 +125,6 @@ ,OPERATTIME = #{OPERATTIME} - - ,HIDDEN_IDS = #{HIDDEN_IDS} - where AIWARNING_ID = #{AIWARNING_ID}