From 26031a77da12200e22b589fa108f86885d8f6865 Mon Sep 17 00:00:00 2001 From: dashixiong Date: Thu, 5 Mar 2026 10:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=80=E5=B1=9E=E6=B3=B5?= =?UTF-8?q?=E7=AB=99=E5=92=8C=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sparepart/SewageController.java | 42 +++++++++++++++- .../service/sparepart/SewageService.java | 28 ++++++++--- src/main/webapp/jsp/sparepart/sewageAdd.jsp | 48 +++++++------------ src/main/webapp/jsp/sparepart/sewageEdit.jsp | 48 ++++++++----------- src/main/webapp/jsp/sparepart/sewageList.jsp | 44 +++++++++-------- src/main/webapp/jsp/user/roleMenu.jsp | 19 ++------ 6 files changed, 127 insertions(+), 102 deletions(-) diff --git a/src/main/java/com/sipai/controller/sparepart/SewageController.java b/src/main/java/com/sipai/controller/sparepart/SewageController.java index 0b993844..69c3ef0f 100644 --- a/src/main/java/com/sipai/controller/sparepart/SewageController.java +++ b/src/main/java/com/sipai/controller/sparepart/SewageController.java @@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.sipai.entity.base.Result; import com.sipai.entity.sparepart.Sewage; +import com.sipai.entity.user.ProcessSection; import com.sipai.entity.user.Unit; import com.sipai.entity.user.User; import com.sipai.service.sparepart.SewageService; @@ -85,7 +86,13 @@ public class SewageController { wherestr += " and (contract_number like '%"+request.getParameter("search_name")+"%' or name like '%"+request.getParameter("search_name")+"%' ) "; } if (request.getParameter("processSectionId")!= null && !request.getParameter("processSectionId").isEmpty()) { - wherestr += " and process_section_id = '"+request.getParameter("processSectionId")+"'"; + String processSectionId = request.getParameter("processSectionId"); + ProcessSection processSection = this.processSectionService.selectById(processSectionId); + if (processSection != null) { + wherestr += " and (process_section_id = '" + processSectionId + "' or process_section_id = '" + processSection.getCode() + "')"; + } else { + wherestr += " and process_section_id = '"+processSectionId+"'"; + } } if (request.getParameter("city")!= null && !request.getParameter("city").isEmpty()) { wherestr += " and city like '%"+request.getParameter("city")+"%'"; @@ -192,6 +199,31 @@ public class SewageController { return "result"; } + /** + * 排污源页面专用泵站下拉,value 使用 process_section.id,避免前端提交 code 导致无法正确保存/查询 + */ + @RequestMapping("/getProcessSectionId4Select.do") + public ModelAndView getProcessSectionId4Select(HttpServletRequest request, Model model) { + String companyId = request.getParameter("companyId"); + String wherestr = "where 1=1 and active='1' "; + if (companyId != null && !companyId.isEmpty()) { + wherestr += " and unit_id = '" + companyId + "' "; + } + wherestr += " order by code asc"; + List processSections = this.processSectionService.selectListByWhere(wherestr); + JSONArray jsonArray = new JSONArray(); + if (processSections != null && processSections.size() > 0) { + for (ProcessSection processSection : processSections) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id", processSection.getId()); + jsonObject.put("text", processSection.getSname() == null ? processSection.getName() : processSection.getSname()); + jsonArray.add(jsonObject); + } + } + model.addAttribute("result", jsonArray.toString()); + return new ModelAndView("result"); + } + @RequestMapping("/view.do") public String doview(HttpServletRequest request,Model model, @@ -222,7 +254,13 @@ public class SewageController { wherestr += " and city like '%"+request.getParameter("search_name1")+"%'"; } if (request.getParameter("processSectionId")!= null && !request.getParameter("processSectionId").isEmpty()) { - wherestr += " and process_section_id = '"+request.getParameter("processSectionId")+"'"; + String processSectionId = request.getParameter("processSectionId"); + ProcessSection processSection = this.processSectionService.selectById(processSectionId); + if (processSection != null) { + wherestr += " and (process_section_id = '" + processSectionId + "' or process_section_id = '" + processSection.getCode() + "')"; + } else { + wherestr += " and process_section_id = '"+processSectionId+"'"; + } } List list = this.sewageService.selectListByWhere(wherestr+orderstr); diff --git a/src/main/java/com/sipai/service/sparepart/SewageService.java b/src/main/java/com/sipai/service/sparepart/SewageService.java index d8d97c25..ad2d486f 100644 --- a/src/main/java/com/sipai/service/sparepart/SewageService.java +++ b/src/main/java/com/sipai/service/sparepart/SewageService.java @@ -46,14 +46,30 @@ public class SewageService implements CommService{ @Resource private JsywPointService jsywPointService; + + private ProcessSection getProcessSectionByStoredValue(String processSectionValue) { + if (processSectionValue == null || processSectionValue.isEmpty()) { + return null; + } + ProcessSection processSection = this.processSectionService.selectById(processSectionValue); + if (processSection != null) { + return processSection; + } + List processSectionList = this.processSectionService.selectListByWhere( + "where code = '" + processSectionValue + "' and unit_id = 'JSBZ'"); + if (processSectionList != null && processSectionList.size() > 0) { + return processSectionList.get(0); + } + return null; + } @Override public Sewage selectById(String id) { Sewage sewage = SewageDao.selectByPrimaryKey(id); sewage.setCompany(this.unitService.getCompById(sewage.getUnitId())); - List processSectionList = this.processSectionService.selectListByWhere("where code = '"+sewage.getProcessSectionId()+"' and unit_id = 'JSBZ'"); - if (processSectionList.size()>0) { - sewage.setProcessSection(processSectionList.get(0)); + ProcessSection processSection = this.getProcessSectionByStoredValue(sewage.getProcessSectionId()); + if (processSection != null) { + sewage.setProcessSection(processSection); } List sewageInputList = this.sewageInputService.selectListByWhere("where sewage_id='"+sewage.getContractNumber()+"' order by insdt"); if(sewageInputList!=null && sewageInputList.size()>0){ @@ -92,9 +108,9 @@ public class SewageService implements CommService{ List list = SewageDao.selectListByWhere(sewage); for (Sewage item : list) { item.setCompany(this.unitService.getCompById(item.getUnitId())); - List processSectionList = this.processSectionService.selectListByWhere("where code = '"+item.getProcessSectionId()+"' and unit_id = 'JSBZ'"); - if (processSectionList.size()>0) { - item.setProcessSection(processSectionList.get(0)); + ProcessSection processSection = this.getProcessSectionByStoredValue(item.getProcessSectionId()); + if (processSection != null) { + item.setProcessSection(processSection); } List sewageInputList = this.sewageInputService.selectListByWhere4Pure("where sewage_id='"+item.getContractNumber()+"' order by insdt"); if(sewageInputList!=null && sewageInputList.size()>0){ diff --git a/src/main/webapp/jsp/sparepart/sewageAdd.jsp b/src/main/webapp/jsp/sparepart/sewageAdd.jsp index fefd6f83..affe3d06 100644 --- a/src/main/webapp/jsp/sparepart/sewageAdd.jsp +++ b/src/main/webapp/jsp/sparepart/sewageAdd.jsp @@ -23,35 +23,25 @@ } },'json'); } - } + } function getProcessSectionFun() { - var selectType = $("#processsectionCode").select2({minimumResultsForSearch: 10}) - $.post(ext.contextPath + "/user/processSection/getProcessSection4Select.do", {companyId: "JSBZ"}, function (data) { - $("#processsectionCode").empty(); - var selelct_ = $("#processsectionCode").select2({ - data: data, - placeholder: '请选择',//默认文字提示 - allowClear: false,//允许清空 - escapeMarkup: function (markup) { - return markup; - }, // 自定义格式化防止xss注入 - language: "zh-CN", - minimumInputLength: 0, - minimumResultsForSearch: 10,//数据超过10个启用搜索框 - formatResult: function formatRepo(repo) { - return repo.text; - }, // 函数用来渲染结果 - formatSelection: function formatRepoSelection(repo) { - return repo.text; - } // 函数用于呈现当前的选择 + var $processSection = $("#processsectionCode"); + // 弹窗内该字段使用原生select,规避select2在部分环境下无法点选的问题 + if ($processSection.hasClass("select2-hidden-accessible")) { + $processSection.select2("destroy"); + } + $processSection.removeClass("select2-hidden-accessible").removeAttr("data-select2-id").show(); + $processSection.next(".select2").remove(); + $.post(ext.contextPath + "/sparepart/sewage/getProcessSectionId4Select.do", {companyId: "JSBZ"}, function (data) { + $processSection.empty(); + if (typeof data === "string") { + try { data = JSON.parse(data); } catch (e) { data = []; } + } + $processSection.append(''); + $.each(data || [], function (idx, item) { + $processSection.append(''); }); - selelct_.val('').trigger("change"); - selelct_.on('change', function (e) { - $('#processSectionId').val(e.target.value); - //给设备编码(工艺段部分)赋值 - // var name = $("#processsectionCode").find("option:selected").text(); - // $('#processsectionCodeAuto').val(getParenthesesStr(name)); - }) + $processSection.val(''); }, 'json'); } //输入框验证 @@ -165,10 +155,8 @@
- -
diff --git a/src/main/webapp/jsp/sparepart/sewageEdit.jsp b/src/main/webapp/jsp/sparepart/sewageEdit.jsp index c97a8c66..cb9b1189 100644 --- a/src/main/webapp/jsp/sparepart/sewageEdit.jsp +++ b/src/main/webapp/jsp/sparepart/sewageEdit.jsp @@ -33,35 +33,26 @@ } },'json'); } - } + } function getProcessSectionFun() { - var selectType = $("#processsectionCode").select2({minimumResultsForSearch: 10}) - $.post(ext.contextPath + "/user/processSection/getProcessSection4Select.do", {companyId: "JSBZ"}, function (data) { - $("#processsectionCode").empty(); - var selelct_ = $("#processsectionCode").select2({ - data: data, - placeholder: '请选择',//默认文字提示 - allowClear: false,//允许清空 - escapeMarkup: function (markup) { - return markup; - }, // 自定义格式化防止xss注入 - language: "zh-CN", - minimumInputLength: 0, - minimumResultsForSearch: 10,//数据超过10个启用搜索框 - formatResult: function formatRepo(repo) { - return repo.text; - }, // 函数用来渲染结果 - formatSelection: function formatRepoSelection(repo) { - return repo.text; - } // 函数用于呈现当前的选择 + var $processSection = $("#processsectionCode"); + var selectedProcessSectionId = "${not empty sewage.processSection ? sewage.processSection.id : sewage.processSectionId}"; + // 弹窗内该字段使用原生select,规避select2在部分环境下无法点选的问题 + if ($processSection.hasClass("select2-hidden-accessible")) { + $processSection.select2("destroy"); + } + $processSection.removeClass("select2-hidden-accessible").removeAttr("data-select2-id").show(); + $processSection.next(".select2").remove(); + $.post(ext.contextPath + "/sparepart/sewage/getProcessSectionId4Select.do", {companyId: "JSBZ"}, function (data) { + $processSection.empty(); + if (typeof data === "string") { + try { data = JSON.parse(data); } catch (e) { data = []; } + } + $processSection.append(''); + $.each(data || [], function (idx, item) { + $processSection.append(''); }); - selelct_.val("${sewage.processSectionId}").trigger("change"); - selelct_.on('change', function (e) { - $('#processSectionId').val(e.target.value); - //给设备编码(工艺段部分)赋值 - // var name = $("#processsectionCode").find("option:selected").text(); - // $('#processsectionCodeAuto').val(getParenthesesStr(name)); - }) + $processSection.val(selectedProcessSectionId); }, 'json'); } //输入框验证 @@ -171,9 +162,8 @@
- -
diff --git a/src/main/webapp/jsp/sparepart/sewageList.jsp b/src/main/webapp/jsp/sparepart/sewageList.jsp index dc84591a..a8cc0839 100644 --- a/src/main/webapp/jsp/sparepart/sewageList.jsp +++ b/src/main/webapp/jsp/sparepart/sewageList.jsp @@ -174,24 +174,26 @@ // dosearch(); // }); - //选择工艺段 - $.post(ext.contextPath + "/user/processSection/getProcessSection4Select.do", {companyId:"JSBZ"}, function(data) { - $("#processSection").empty(); - var selelct_ =$("#processSection").select2({ - data: data, - placeholder:'请选择',//默认文字提示 - allowClear: true,//允许清空 - escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入 - language: "zh-CN", - minimumInputLength: 0, - minimumResultsForSearch: 10,//数据超过十个启用搜索框 - formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果 - formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择 - }); - selelct_.val("").trigger("change"); - selelct_.on("change",function(e){ + //选择工艺段,使用原生select并直接返回process_section.id,避免select2/编码值导致无法选择或查询失效 + $.post(ext.contextPath + "/sparepart/sewage/getProcessSectionId4Select.do", {companyId:"JSBZ"}, function(data) { + var $processSection = $("#processSection"); + if ($processSection.hasClass("select2-hidden-accessible")) { + $processSection.select2("destroy"); + } + $processSection.removeClass("select2-hidden-accessible").removeAttr("data-select2-id").show(); + $processSection.next(".select2").remove(); + $processSection.empty(); + if (typeof data === "string") { + try { data = JSON.parse(data); } catch (e) { data = []; } + } + $processSection.append(''); + $.each(data || [], function (idx, item) { + $processSection.append(''); + }); + $processSection.val(""); + $processSection.off("change.sewageSearch").on("change.sewageSearch", function(){ dosearch(); - }); + }); },'json'); //选择工艺段 $.post(ext.contextPath + "/sparepart/sewage/getSewageCity4Select.do", {unitId: unitId}, function(data) { @@ -432,9 +434,9 @@ --> -
- -