Kaynağa Gözat

dify聊天窗部分功能代码提交

徐滕 2 gün önce
ebeveyn
işleme
9c783249b9

+ 0 - 152
src/main/java/com/jeeplus/modules/centerservice/config/GcServletListener.java

@@ -1,152 +0,0 @@
-package com.jeeplus.modules.centerservice.config;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.annotation.WebListener;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryPoolMXBean;
-import java.lang.management.MemoryUsage;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.temporal.ChronoUnit;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-@WebListener
-public class GcServletListener implements ServletContextListener {
-
-    private ScheduledExecutorService scheduler;
-
-    @Override
-    public void contextInitialized(ServletContextEvent sce) {
-        scheduler = Executors.newScheduledThreadPool(1);
-        System.out.println("✅ GC 任务已启动");
-
-        long initialDelay = getInitialDelay();
-        System.out.println("⏳ GC 第一次运行时间:" + LocalDateTime.now().plusSeconds(initialDelay));
-
-        scheduler.scheduleAtFixedRate(() -> {
-            LocalTime now = LocalTime.now();
-
-            // 仅在凌晨 2:00 - 5:00 之间执行 GC
-            if (now.isBefore(LocalTime.of(16, 45)) || now.isAfter(LocalTime.of(20, 0))) {
-                System.out.println("⏸️ 当前时间不在 02:00 - 05:00 之间,跳过 GC");
-                return;
-            }
-
-            System.out.println("🔄 GC 任务执行时间:" + LocalDateTime.now());
-            printMemoryUsage("GC 前内存状态");
-
-            // 1. 创建老年代对象(通过长期存活对象)
-            System.out.println("创建老年代对象...");
-            List<byte[]> oldGenObjects = new java.util.ArrayList<>();
-            for (int i = 0; i < 6; i++) {
-                byte[] data = new byte[500 * 1024 * 1024]; // 分配 500MB 对象
-                oldGenObjects.add(data);
-                System.gc(); // 触发 Minor GC,让对象进入老年代
-                try {
-                    Thread.sleep(100);
-                } catch (InterruptedException e) {
-                    System.out.println("创建老年代对象存在错误");
-                    throw new RuntimeException(e);
-                }
-            }
-            System.out.println("执行完了创建老年代对象");
-            oldGenObjects.clear(); // 清除引用
-            oldGenObjects = null;   // 释放列表引用
-
-
-            // 2. 手动触发 Full GC
-            triggerFullGcAndShrink();
-
-            // 3. 打印内存使用情况
-            printMemoryUsage("Full GC 后");
-
-            // 优化 GC 触发逻辑
-            for (int i = 1; i <= 3; i++) {  // 减少循环次数(原 8 次过多)
-                System.gc();
-                System.runFinalization();
-
-                // 分配并立即释放大内存块,尝试触发堆内存收缩
-                try {
-                    byte[] memoryHog = new byte[500 * 1024 * 1024]; // 分配 100MB
-                    memoryHog = null;  // 释放引用
-                } catch (OutOfMemoryError e) {
-                    System.out.println("⚠️ 内存不足,跳过分配测试块");
-                }
-
-                System.out.println("🚀 GC 执行第 " + i + " 次");
-                printMemoryUsage("本次 GC 后内存状态");
-
-                try {
-                    Thread.sleep(3000);  // 延长间隔(原 1 秒过短)
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-            }
-        }, initialDelay, 3 * 60, TimeUnit.SECONDS);  // 每 10 分钟运行一次
-    }
-
-    /**
-     * 强制触发 Full GC 并尝试释放内存给操作系统
-     */
-    private static void triggerFullGcAndShrink() {
-        System.out.println("触发 Full GC...");
-        System.gc(); // 建议 JVM 执行 GC(不保证立即执行)
-        System.runFinalization();
-
-        // 分配并释放大内存块,促使 JVM 释放内存
-        try {
-            byte[] memoryHog = new byte[1024 * 1024 * 500]; // 分配 500MB
-            memoryHog = null;
-        } catch (OutOfMemoryError e) {
-            System.out.println("内存不足,跳过分配测试块");
-        }
-
-        System.gc(); // 再次触发 GC
-    }
-
-    @Override
-    public void contextDestroyed(ServletContextEvent sce) {
-        if (scheduler != null) {
-            System.out.println("🛑 GC 任务已关闭");
-            scheduler.shutdown();
-        }
-    }
-
-    /**
-     * 计算当前时间到最近的 01:50 的秒数
-     */
-    private long getInitialDelay() {
-        LocalTime now = LocalTime.now();
-        LocalTime nextRunTime = LocalTime.of(1, 50);
-
-        if (now.isBefore(nextRunTime)) {
-            return ChronoUnit.SECONDS.between(now, nextRunTime);
-        } else {
-            // 如果已经过了 02:00,则计算到次日 02:00 的时间
-            return ChronoUnit.SECONDS.between(now, nextRunTime.plusHours(24));
-        }
-    }
-
-    /**
-     * 打印老年代内存使用情况
-     */
-    private void printMemoryUsage(String phase) {
-        for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
-            if (pool.getName().toLowerCase().contains("old") || pool.getName().toLowerCase().contains("tenured")) {
-                MemoryUsage usage = pool.getUsage();
-                System.out.printf("%s - %s: Used=%dMB, Committed=%dMB, Max=%dMB%n",
-                        phase, pool.getName(), usage.getUsed() / 1024 / 1024,
-                        usage.getCommitted() / 1024 / 1024, usage.getMax() / 1024 / 1024);
-            }
-        }
-    }
-}
-
-
-
-
-

+ 1 - 1
src/main/java/com/jeeplus/modules/knowledgeSharing/dify/DifyApiClient.java

@@ -40,7 +40,7 @@ public class DifyApiClient {
 
     //开发
     private static final String API_KEY = "dataset-TinelGDdnlrXJPyFe38iA0Zh";
-    private static final String API_URL = "http://3081089em4.wicp.vip:28499/v1/datasets";
+    private static final String API_URL = "http://3081089em4.wicp.vip:21548/v1/datasets";
 
 
 

+ 1 - 1
src/main/java/com/jeeplus/modules/knowledgeSharing/dify/KnowledgeDifyController.java

@@ -31,7 +31,7 @@ public class KnowledgeDifyController extends BaseController {
      */
     @RequestMapping(value = {"list", ""})
     public String list(KnowledgeSharingInfo knowledgeSharingInfo, HttpServletRequest request, Model model) {
-        String difySrc = "http://localhost/chatbot/";
+        String difySrc = "http://3081089em4.wicp.vip:21548/chatbot/";
         List<KnowledgeSharingTypeInfo> typeInfoList = typeService.findList(new KnowledgeSharingTypeInfo());
         if (StringUtils.isBlank(knowledgeSharingInfo.getColumnId())) {
 

+ 1 - 1
src/main/java/com/jeeplus/modules/knowledgeSharing/web/KnowledgeBaseController.java

@@ -81,7 +81,7 @@ public class KnowledgeBaseController {
     @RequestMapping(value = {"openChatPage"})
     public String openChatPage(KnowledgeSharingInfo knowledgeSharingInfo, HttpServletRequest request, HttpServletResponse response, Model model) throws Exception {
 
-        String difySrc = "http://3081089em4.wicp.vip:28499/chatbot/";
+        String difySrc = "http://3081089em4.wicp.vip:21548/chatbot/";
 
         model.addAttribute("columnId", knowledgeSharingInfo.getColumnId());
         model.addAttribute("difySrc", difySrc + "LlXD0YzBLGPKBlqb");

+ 14 - 4
src/main/webapp/webpage/modules/ruralprojectrecords/cost/projectcontentinfo/adminReportEditForm.jsp

@@ -823,6 +823,14 @@
 			obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
 		}
 
+		function num1(obj) {
+			obj.value = obj.value.replace(/[^\d.]/g,""); // 清除"数字"和"."以外的字符
+			obj.value = obj.value.replace(/^\./g,""); // 验证第一个字符是数字
+			obj.value = obj.value.replace(/\.{2,}/g,"."); // 只保留第一个点, 清除多余的
+			obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); // 只保留第一个小数点
+			obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d{1,4}).*$/, '$1$2.$3'); // 只保留4位小数
+		}
+
 	</script>
 	<script type="text/javascript">
 		var validateForm;
@@ -1410,7 +1418,9 @@
 					$("#JingHeJianLv").val("0");
 				}else{
 					var JingHeJianLv =(parseFloat(ShenDingJia) - parseFloat(SongShenJia)) * 100 / parseFloat(SongShenJia);
-					$("#JingHeJianLv").val(JingHeJianLv);
+					// 格式化结果,保留两位小数
+					var JingHeJianLvFormatted = JingHeJianLv.toFixed(2);
+					$("#JingHeJianLv").val(JingHeJianLvFormatted);
 				}
 			}else{
 				$("#JingHeJianE").val('');
@@ -2556,19 +2566,19 @@
 						<div class="layui-item layui-col-sm6 lw6" id="heTongJiaDiv">
 							<label class="layui-form-label double-line">合同价(万元):</label>
 							<div class="layui-input-block with-icon">
-								<form:input path="recordsReported.HeTongJia" id="HeTongJia" placeholder="请输入合同价" htmlEscape="false"  onkeyup="num(this)" class="form-control layui-input number"/>
+								<form:input path="recordsReported.HeTongJia" id="HeTongJia" placeholder="请输入合同价" htmlEscape="false"  onkeyup="num1(this)" class="form-control layui-input number"/>
 							</div>
 						</div>
 						<div class="layui-item layui-col-sm6 lw6" id="songShenJiaDiv">
 							<label class="layui-form-label double-line">送审价(万元):</label>
 							<div class="layui-input-block with-icon">
-								<form:input path="recordsReported.SongShenJia" id="SongShenJia" placeholder="请输入送审价" htmlEscape="false"  onkeyup="num(this)" class="form-control layui-input number" onchange="JingHeJianValue()"/>
+								<form:input path="recordsReported.SongShenJia" id="SongShenJia" placeholder="请输入送审价" htmlEscape="false"  onkeyup="num1(this)" class="form-control layui-input number" onchange="JingHeJianValue()"/>
 							</div>
 						</div>
 						<div class="layui-item layui-col-sm6 lw6" id="shenDingJiaDiv">
 							<label class="layui-form-label double-line">审定价(万元):</label>
 							<div class="layui-input-block with-icon">
-								<form:input path="recordsReported.ShenDingJia" id="ShenDingJia" placeholder="请输入审定价" htmlEscape="false"  onkeyup="num(this)" class="form-control layui-input number" onchange="JingHeJianValue()"/>
+								<form:input path="recordsReported.ShenDingJia" id="ShenDingJia" placeholder="请输入审定价" htmlEscape="false"  onkeyup="num1(this)" class="form-control layui-input number" onchange="JingHeJianValue()"/>
 							</div>
 						</div>
 						<div class="layui-item layui-col-sm6 lw6">

+ 2 - 2
src/main/webapp/webpage/modules/sys/sysIndex.jsp

@@ -23,11 +23,11 @@
     <script>
         window.difyChatbotConfig = {
             token: 'LlXD0YzBLGPKBlqb',
-            baseUrl: 'http://localhost'
+            baseUrl: 'http://3081089em4.wicp.vip:21548'
         }
     </script>
     <script
-            src="http://localhost/embed.min.js"
+            src="http://3081089em4.wicp.vip:21548/embed.min.js"
             id="LlXD0YzBLGPKBlqb"
             defer>
     </script>

+ 2 - 2
src/main/webapp/webpage/modules/workreimbursement/workReimbursementList.jsp

@@ -322,10 +322,10 @@
         {align:'center', title: '操作', width:150, templet:function(d){
                 var xml = "<div class=\"layui-btn-group\">";
                 if (d.notifyFlag != undefined && d.notifyFlag !=null && d.notifyFlag == 1) {
-                    xml += "<a href=\"#\" onclick=\"notifyDialogre('报销审批', '${ctx}/workprojectnotify/workProjectNotify/form?id=" + d.notifyId +"&home=reimbursement&pageFlag=all','95%', '95%')\" class=\"layui-btn layui-btn-xs layui-bg-green\" >审批</a>";
+                    xml += "<a href=\"#\" onclick=\"notifyDialogre('报销审批', '${ctx}/workprojectnotify/workProjectNotify/form?id=" + d.notifyId +"&home=reimbursement&pageFlag=workReimbursement','95%', '95%')\" class=\"layui-btn layui-btn-xs layui-bg-green\" >审批</a>";
                 }
                 if (d.notifyFlag != undefined && d.notifyFlag !=null && d.notifyFlag == 3) {
-                    xml += "<a href=\"#\" onclick=\"notifyDialogre('报销审批', '${ctx}/workprojectnotify/workProjectNotify/form?id=" + d.notifyId +"&home=reimbursement&pageFlag=all','95%', '95%')\" class=\"layui-btn layui-btn-xs layui-bg-green\" >审批</a>";
+                    xml += "<a href=\"#\" onclick=\"notifyDialogre('报销审批', '${ctx}/workprojectnotify/workProjectNotify/form?id=" + d.notifyId +"&home=reimbursement&pageFlag=workReimbursement','95%', '95%')\" class=\"layui-btn layui-btn-xs layui-bg-green\" >审批</a>";
                 }
                 if (d.paymentStatus != undefined && d.paymentStatus == 0 && d.paymentFlag != undefined && d.paymentFlag == 1) {
                     xml += "<a href=\"${ctx}/workreimbursement/workReimbursementAll/paymentSave?id=" + d.id + "&paymentStatus=1\" onclick=\"return confirmx('是否确认给报销编号为 " + d.number + " 的报销信息进行付款?', this.href)\" class=\"layui-btn layui-btn-xs layui-bg-blue\">付款</a>";