JRT导出协议实现

之前实现了JRT的打印客户端实现,这次实现JRT的导出Excel的客户端实现,这样这套框架就成为完全体了。还是一样的设计,不面向具体业务编程,我喜欢面向协议编程,导出一样定义了一套协议。

协议约定:
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

然后就是对约定的实现

导出数据输出的示例

import JRT.Core.Dto.OutParam;
import JRT.Model.Entity.BTTestCode;
import JRTBLLBase.BaseHttpHandlerNoSession;
import JRTBLLBase.Helper;

import java.util.List;

/**
 * 输出符合Query约定的数据供导出Excel用,所有的虚拟M方法参数约定就是这个样子
 */
public class ExportExcelTest extends BaseHttpHandlerNoSession {
    /**
     * 查询所有项目数据导出到Excel
     * @param P0
     * @param P1
     * @param P2
     * @param P3
     * @param P4
     * @param P5
     * @param P6
     * @param P7
     * @param P8
     * @param P9
     * @param P10
     * @param P11
     * @param P12
     * @param P13
     * @param Session
     * @param Output
     * @return
     */
    public String QryTestCode(String P0, String P1, String P2, String P3, String P4, String P5, String P6, String P7, String P8, String P9, String P10, String P11, String P12, String P13, OutParam Session, OutParam Output) throws Exception{
        BTTestCode dto=new BTTestCode();
        //返回的参数,供Excel模板使用
        Session.Message="项目数据导出^"+JRT.Core.Util.TimeParser.GetNowDate()+"^zhanglianzhu";
        //查询项目数据
        List<BTTestCode> retList=EntityManager().FindAll(dto,null,"",-1,-1);
        //数组转json就是等价Query的
        return Helper.Object2Json(retList);
    }
}





打印消息处理类对接导出命令

package Monitor.Msg;

import JRTPrintDraw.DrawConvert;
import JRTPrintDraw.JsonDealUtil;
import JRTPrintDraw.WebService.OutValue;
import JRTPrintDraw.WebService.Parameters;
import JRTPrintDraw.WebService.WebGetData;
import Monitor.Util.LogUtils;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import org.apache.poi.ss.usermodel.Workbook;
import org.java_websocket.WebSocket;

/**
 * 处理打印消息
 */
public class MessagePrintDeal implements Monitor.Msg.IMessageDeal {
    /**
     * 处理消息
     *
     * @param socket  套接字,可以获得id,发送消息给socket
     * @param message 约定#分割的第一位描述消息类型,收到的消息内容
     * @return 是否继续往后传递消息,true是,false否
     */
    public boolean DealMessage(WebSocket socket, String message) throws Exception {
        LogUtils.WriteDebugLog("识别以print#开头的消息");
        //识别打印消息
        if (message.split("#")[0].equals("print")) {
            LogUtils.WriteDebugLog("确定为打印消息,准备处理");
            int index = message.indexOf('#');
            String msg = message.substring(index + 1);
            String[] arrMsg = msg.split("@");

            //报告打印消息直接处理,不驱动exe,提高速度
            if (arrMsg.length > 5 && (!arrMsg[4].contains("PDF#")) && (arrMsg[0].equals("iMedicalLIS://0") || arrMsg[0].equals("iMedicalLIS://1") || arrMsg[0].equals("iMedicalLIS://Export")) && (!arrMsg[4].equals("ReportView"))) {
                String cmdLine = msg.substring(14);
                String[] tmpStrings = cmdLine.split("@");
                String printFlag = tmpStrings[0];
                String connectString = tmpStrings[1].replace("&", "&amp;");
                String rowids = tmpStrings[2];
                String userCode = tmpStrings[3];
                //PrintOut:打印  PrintPreview打印预览
                String printType = tmpStrings[4];
                //参数模块名称(LIS工作站,DOC医生,SELF自助,OTH其它)
                String paramList = tmpStrings[5];

                String clsName = "";
                String funName = "";
                if (tmpStrings.length >= 8) {
                    clsName = tmpStrings[6];
                    funName = tmpStrings[7];
                }
                //导出Excel
                if (printFlag.equals("Export") || (printFlag.equals("ExportFast") && tmpStrings.length > 2)) {
                    String tempExcelPath = tmpStrings[6];
                    //快速导出Excel标识
                    if (tmpStrings[0] == "ExportFast") {
                        //ExportUtil.IsExportFast = true;
                    }
                    //选模板的模式
                    if (tempExcelPath.contains("|")) {
                        Platform.runLater(() -> {
                            //选择模板
                            Monitor.Dialog.SelectExcelDialog frmSelect = new Monitor.Dialog.SelectExcelDialog(tempExcelPath);
                            frmSelect.Show();
                            if (frmSelect.IsOK == true) {
                                tmpStrings[6] = frmSelect.SelectPath;
                                try {
                                    Monitor.Excel.ExportUtil.RealExport(tmpStrings);
                                } catch (Exception ee) {
                                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                                    alert.setTitle("提示");
                                    alert.setContentText(ee.getMessage());
                                    alert.showAndWait();
                                }
                            }
                        });
                    } else {
                        Platform.runLater(() -> {
                            try {
                                Monitor.Excel.ExportUtil.RealExport(tmpStrings);
                            } catch (Exception ee) {
                                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                                alert.setTitle("提示");
                                alert.setContentText(ee.getMessage());
                                alert.showAndWait();
                            }
                        });
                    }
                    return false;
                }
                //没传报告主键退出
                else if (rowids == "" && printType != "ReportView") {
                    javafx.application.Platform.runLater(() -> {
                        Alert alert = new Alert(Alert.AlertType.INFORMATION);
                        alert.setTitle("提示");
                        alert.setHeaderText("打印参数异常");
                        alert.setContentText("未传入报告主键");
                        alert.showAndWait();
                    });
                    return true;
                }
                ;
                String ip = "";
                String hostName = "";
                String mac = "";
                paramList = paramList + "^HN" + hostName + "^IP" + ip + "^MAC" + mac;
                //printFlag  0:打印所有报告 1:循环打印每一份报告
                if (printFlag.substring(0, 1).equals("0")) {
                    Monitor.Print.PrintProtocol reportPrint = new Monitor.Print.PrintProtocol(rowids, userCode, paramList, connectString, printType, clsName, funName);
                } else {
                    String[] tmpRowids = rowids.split((char) 94 + "");
                    for (int i = 0; i < tmpRowids.length; i++) {
                        rowids = tmpRowids[i];
                        if (rowids != "") {
                            Monitor.Print.PrintProtocol reportPrint = new Monitor.Print.PrintProtocol(rowids, userCode, paramList, connectString, printType, clsName, funName);
                        }
                    }
                }
            }
            return false;
        }
        LogUtils.WriteDebugLog("不是打印消息,传递消息链");
        return true;
    }


}

导出主控制类实现

package Monitor.Excel;

import JRTPrintDraw.DrawConvert;
import JRTPrintDraw.JsonDealUtil;
import JRTPrintDraw.WebService.OutValue;
import JRTPrintDraw.WebService.Parameters;
import JRTPrintDraw.WebService.WebGetData;
import javafx.scene.control.Alert;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import javax.net.ssl.*;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.List;

public class ExportUtil {
    /**
     * 文件序号
     */
    private static int fileIndex = 0;

    /**
     * 是否是快速导出模式
     */
    private static boolean IsExportFast = false;

    /**
     * url编码
     *
     * @param url
     * @return
     * @throws Exception
     */
    private static String UrlEnCode(String url) throws Exception {
        String[] arr = url.split("/");
        String head = "";
        String left = "";
        for (int i = 0; i < arr.length; i++) {
            if (i < 3) {
                if (head.isEmpty()) {
                    head = arr[i];
                } else {
                    head = head + "/" + arr[i];
                }
            } else {
                left = left + "/" + URLEncoder.encode(arr[i], "UTF-8");
            }
        }
        return head + left;

    }

    /**
     * 执行导出Excel
     *
     * @param inputStrArr
     * @throws Exception
     */
    public static void RealExport(String[] inputStrArr) throws Exception {
        String webServicAddress = inputStrArr[1].replace("&", "&amp;");
        //获得配置的连接信息
        //String connectStringOne = System.Configuration.ConfigurationSettings.AppSettings["WebServiceAddressOne"];
        //没有强制地址,使用单独地址
        //if (connectStringOne != "")
        //{
        //webServicAddress = connectStringOne;
        //}
        String className = inputStrArr[2];
        String functionName = inputStrArr[3];
        String paraJson = inputStrArr[4];
        String session = inputStrArr[5];
        String tempExcelPath = inputStrArr[6];
        //导出路径-1桌面  0用户选择  -2直接打印其他路径信息不带最后的\\
        String exportPath = inputStrArr[7];
        //用户选择
        if (exportPath.equals("0")) {
            String fileName = "";
            if (tempExcelPath != "") {
                String[] tmpNameArr = tempExcelPath.split("/");
                fileName = tmpNameArr[tmpNameArr.length - 1];
            }
            Monitor.Dialog.SaveExcelFileDialog sfMy = new Monitor.Dialog.SaveExcelFileDialog(fileName);
            sfMy.Show();
            if (sfMy.IsOK == true) {
                String fullName = sfMy.SavePath;
                if (fullName != "") {
                    exportPath = "F#" + fullName;
                    //ExportUtil.ExportStart = DateTime.Now;
                } else {
                    exportPath = "-2";
                }
            } else {
                return;
            }
        }
        //取图片串
        String imgStr = "";
        if (inputStrArr.length > 8) {
            imgStr = inputStrArr[8];
        }
        String printerPara = "";
        if (inputStrArr.length > 9) {
            printerPara = inputStrArr[9];
        }
        //得到参数
        Parameters para = null;
        try {
            para = (Parameters) JsonDealUtil.Json2Object(paraJson, Parameters.class);
        } catch (Exception ex) {
            if (paraJson.contains("\\\"")) {
                try {
                    para = (Parameters) JsonDealUtil.Json2Object(paraJson.replace("\\\"", "\""), Parameters.class);
                } catch (Exception ee) {
                    // 弹出一个信息对话框
                    Alert alert = new Alert(Alert.AlertType.INFORMATION);
                    alert.setTitle("提示");
                    alert.setHeaderText(null);
                    alert.setContentText(ee.getMessage());
                    alert.showAndWait();
                }
            } else {
                // 弹出一个信息对话框
                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("提示");
                alert.setHeaderText(null);
                alert.setContentText(ex.getMessage());
                alert.showAndWait();
            }
        }
        String err;
        OutValue sessionObj = new OutValue();
        sessionObj.Value = session;
        //执行查询
        String jsonStr = WebGetData.GetData(webServicAddress, className, functionName, para, sessionObj);
        //Monitor.Util.LogUtils.WriteDebugLog("地址:" + webServicAddress + "类名:" + className + "方法:" + functionName + "参数:" + paraJson + "会话:" + session + "数据:" + jsonStr);
        int changePageNum = -1;
        if (exportPath.contains("-2")) {
            String[] cpArr = exportPath.split("^");
            exportPath = cpArr[0];
            if (cpArr.length > 1) {
                changePageNum = DrawConvert.ToInt32(cpArr[1]);
            }
        }
        //直接打印
        if (exportPath.equals("-2") && changePageNum > 0) {
            return;
        }

        Workbook workbook = null;
        String fileName = "";
        String tmpFileName = "";
        if (!tempExcelPath.isEmpty()) {
            try {
                //忽略证书
                if (tempExcelPath.contains("https://")) {
                    TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
                        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                            return null;
                        }

                        public void checkClientTrusted(X509Certificate[] certs, String authType) {
                        }

                        public void checkServerTrusted(X509Certificate[] certs, String authType) {
                        }
                    }
                    };

                    // Install the all-trusting trust manager
                    SSLContext sc = SSLContext.getInstance("SSL");
                    sc.init(null, trustAllCerts, new java.security.SecureRandom());
                    HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

                    // Create all-trusting host name verifier
                    HostnameVerifier allHostsValid = new HostnameVerifier() {
                        public boolean verify(String hostname, SSLSession session) {
                            return true;
                        }
                    };
                }
                URL u = new URL(UrlEnCode(tempExcelPath));
                HttpURLConnection http = (HttpURLConnection) u.openConnection();
                http.setDoOutput(Boolean.TRUE);
                http.setRequestMethod("GET");
                int responseCode = http.getResponseCode();
                InputStream responseStream = http.getInputStream();
                String[] tmpNameArr = tempExcelPath.split("/");
                String tmpPath = Paths.get(Monitor.Util.Path.BasePath, "tmp").toString();
                File dirTMP = new File(tmpPath);
                //检查创建目录
                if (!dirTMP.exists()) {
                    dirTMP.mkdirs();
                }

                fileName = tmpNameArr[tmpNameArr.length - 1];
                //临时文件名
                tmpFileName = Paths.get(tmpPath, fileIndex + "-" + fileName).toString();
                FileOutputStream fileOutputStream = new FileOutputStream(tmpFileName);
                // 创建一个byte数组来缓存读取的数据
                byte[] buffer = new byte[1024];
                int bytesRead;
                // 读取InputStream中的数据,并将其写入到文件中
                while ((bytesRead = responseStream.read(buffer)) != -1) {
                    fileOutputStream.write(buffer, 0, bytesRead);
                }
                if (responseStream != null) {
                    responseStream.close();
                }
                if (fileOutputStream != null) {
                    fileOutputStream.close();
                }
                // 2007版本
                if (tmpFileName.indexOf(".xlsx") > 0) {
                    File file = new File(tmpFileName);
                    FileInputStream st = new FileInputStream(file);
                    if (ExportUtil.IsExportFast == true) {
                        workbook = new SXSSFWorkbook(new XSSFWorkbook(st));
                    } else {
                        workbook = new XSSFWorkbook(st);
                    }
                }
                // 2003版本
                else if (tmpFileName.indexOf(".xls") > 0) {
                    File file = new File(tmpFileName);
                    FileInputStream st = new FileInputStream(file);
                    workbook = new HSSFWorkbook(st);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                Alert alert = new Alert(Alert.AlertType.INFORMATION);
                alert.setTitle("提示");
                alert.setContentText(ex.getMessage());
                alert.showAndWait();
            }
        }
        try {
            List<HashMap> dataList = JsonDealUtil.Json2List(jsonStr, Object.class);
            Monitor.Excel.ExcelProtocol.DealListToExcel(dataList, workbook, fileName, exportPath, imgStr, printerPara, sessionObj.GetString());
            if (!tmpFileName.isEmpty()) {
                File fileTmp = new File(tmpFileName);
                if (fileTmp.exists()) {
                    fileTmp.delete();
                }
            }
        } catch (Exception ex) {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("提示");
            alert.setContentText(ex.getMessage());
            alert.showAndWait();
        }
    }

    /**
     * 保存Excel文件
     *
     * @param name
     * @param workbook
     * @param path
     * @param printerPara
     * @return
     * @throws Exception
     */
    public static String SaveFile(String name, Workbook workbook, String path, String printerPara) throws Exception {
        //替换回车换行符
        path = path.replace("\r\n", "");
        //保存到桌面
        if (path.equals("-1")) {
            path = Paths.get(System.getProperty("user.home"), "Desktop").toString();
            String fullName = Paths.get(path, name).toString();
            Save(fullName, workbook);
            workbook.close();
            return fullName;
        }
        //直接打印
        if (path.equals("-2")) {

        }
        //用户自己选择模式
        else if (path.equals("0")) {
            Monitor.Dialog.SaveExcelFileDialog sfMy = new Monitor.Dialog.SaveExcelFileDialog(name);
            sfMy.Show();
            if (sfMy.IsOK == true) {
                String fullName = sfMy.SavePath;
                if (!fullName.isEmpty()) {
                    Save(fullName, workbook);
                } else {

                }
            }
        }
        //保存到固定路径
        else if (path.length() > 2 && path.substring(0, 2).equals("F#")) {
            String fullName = path.substring(2);
            Save(fullName, workbook);
            workbook.close();
            return fullName;
        }
        //否则就把路径和名称组装
        else {
            String fullName = Paths.get(path, name).toString();
            Save(fullName, workbook);
            workbook.close();
            return fullName;
        }
        return "";
    }

    /**
     * 保存文件
     *
     * @param fullName 全面
     * @param workbook 工作簿
     * @throws Exception
     */
    private static void Save(String fullName, Workbook workbook) throws Exception {
        File fi = new File(fullName);
        Path path = Paths.get(fullName).getParent();
        //没有父路径就创建
        if (!Files.exists(path)) {
            // 如果路径不存在,则创建路径
            Files.createDirectories(path);
        }
        FileOutputStream file = null;
        try {
            file = new FileOutputStream(fullName);
            // 把相应的Excel工作蒲存盘
            workbook.write(file);
        } finally {
            if (file != null) {
                file.close();
            }
        }
    }

}

导出协议实现
$s

$b
在这里插入图片描述

$col
在这里插入图片描述

选择多个Excel模板弹窗实现

package Monitor.Dialog;

import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;

import java.io.File;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 选择Excel模板弹创
 */
public class SelectExcelDialog {
    /**
     * 舞台
     */
    Stage curStage = null;

    /**
     * 控件坐标
     */
    private int left = 40;

    /**
     * 控件坐标
     */
    private int top = 0;

    /**
     * 添加按钮数量
     */
    private int num = 0;

    /**
     * 用户选择的模板
     */
    public String SelectPath;

    /**
     * 是否成功
     */
    public boolean IsOK = false;

    /**
     * 构造函数
     */
    public SelectExcelDialog(String paths) {
        // 创建新的Stage对象,设置标题和尺寸
        curStage = new Stage();
        curStage.setTitle("导出Excel多模板选择");
        int Width = 500;
        int Height = 200;
        if (num > 0 && num % 3 == 0) {
            left = 40;
            top += 122;
            Height += 80;
        }
        // 创建一个水平排列的容器,将按钮添加到容器中
        // 设置按钮之间的间距为10
        VBox hbox = new VBox(10);
        String[] pathArr = paths.split("\\|");
        for (String path : pathArr) {
            int index = path.lastIndexOf('/');
            String fileName = path.substring(index + 1);
            // 创建按钮
            Button btnOne = new Button(fileName.split("\\.")[0]);
            btnOne.setPrefWidth(450);
            btnOne.setPrefHeight(40);
            btnOne.setUserData(path);
            btnOne.setOnMouseClicked(e -> {
                Button clickedButton = (Button) e.getSource();
                SelectPath = clickedButton.getUserData().toString();
                IsOK = true;
                Hide();
            });
            hbox.getChildren().add(btnOne);
            left += 173;
            num++;
        }


        // 设置容器的内边距为10
        hbox.setPadding(new Insets(10));
        // 设置容器的对齐方式为居中
        hbox.setAlignment(Pos.CENTER);

        // 创建一个容器,将水平排列的容器添加到主窗口中
        StackPane root = new StackPane();
        root.getChildren().add(hbox);
        curStage.setWidth(Width);
        curStage.setHeight(Height);
        // 创建Scene对象,并将容器作为根节点添加到Scene中
        Scene scene = new Scene(root, Width, Height);
        curStage.setScene(scene);
        curStage.initModality(Modality.APPLICATION_MODAL);
    }

    /**
     * 隐藏
     */
    private void Hide() {
        Platform.runLater(() -> {
            curStage.hide();
        });
    }

    /**
     * 展示
     */
    public void Show() {
        curStage.showAndWait();
    }
}

选择保存路径实现

package Monitor.Dialog;

import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Pair;

import java.io.File;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 保存Excel的文件对话框
 */
public class SaveExcelFileDialog {
    /**
     * 舞台
     */
    Stage curStage = null;

    /**
     * 供外部获取选择的路径
     */
    public String SavePath = "";

    /**
     * 是否成功
     */
    public boolean IsOK = false;

    /**
     * 保存的文件名字
     */
    private String Name = "";

    /**
     * 构造函数
     */
    public SaveExcelFileDialog(String name) {
        Name = name;
        // 创建新的Stage对象,设置标题和尺寸
        curStage = new Stage();
        curStage.setTitle("导出Excel保存-导出大量数据时候肯需要比较久的时间");
        curStage.setWidth(600);
        curStage.setHeight(220);
        // 创建3个按钮
        Button btnDeskTop = new Button("保存桌面");
        btnDeskTop.setPrefWidth(150);
        btnDeskTop.setPrefHeight(110);
        btnDeskTop.setOnMouseClicked(e -> {
            String desktopPath = Paths.get(System.getProperty("user.home"), "Desktop").toString();
            if (!Name.contains(".")) {
                Name += ".xlsx";
            }
            LocalDateTime currentTime = LocalDateTime.now();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddhhmmss");
            String formattedTime = currentTime.format(formatter);
            SavePath = Paths.get(desktopPath, formattedTime + "-" + Name).toString();
            IsOK = true;
            Hide();
        });

        Button btnUserSave = new Button("选择保存");
        btnUserSave.setPrefWidth(150);
        btnUserSave.setPrefHeight(110);
        btnUserSave.setOnMouseClicked(e -> {
            // 创建一个保存文件的对话框
            FileChooser fileChooser = new FileChooser();
            fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Excel Files", "*.xls"));
            fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Excel Files", "*.xlsx"));
            fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("All Files", "*.*"));
            if (!Name.contains(".")) {
                Name += ".xlsx";
            }
            fileChooser.setInitialFileName(Name);
            // 弹出保存文件对话框并获取用户选择的文件
            File result = fileChooser.showSaveDialog(curStage);
            if (result != null) {
                SavePath = result.getAbsolutePath();
                IsOK = true;
            } else {
                IsOK = false;
            }
            Hide();
        });

        Button btnPrint = new Button("打印");
        btnPrint.setPrefWidth(150);
        btnPrint.setPrefHeight(110);
        btnPrint.setOnMouseClicked(e -> {
            // 弹出一个信息对话框
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("提示");
            alert.setHeaderText(null);
            alert.setContentText("还没实现打印Excel支持!");
            IsOK = true;
            alert.showAndWait();
            Hide();
        });
        //创建一个水平排列的容器,将按钮添加到容器中
        //设置按钮之间的间距为10
        HBox hbox = new HBox(10, btnDeskTop, btnUserSave, btnPrint);
        // 设置容器的内边距为10
        hbox.setPadding(new Insets(10));
        // 设置容器的对齐方式为居中
        hbox.setAlignment(Pos.CENTER);

        //创建一个容器,将水平排列的容器添加到主窗口中
        StackPane root = new StackPane();
        root.getChildren().add(hbox);

        //创建Scene对象,并将容器作为根节点添加到Scene中
        Scene scene = new Scene(root, 600, 220);
        curStage.setScene(scene);
        curStage.initModality(Modality.APPLICATION_MODAL);
    }

    /**
     * 隐藏
     */
    private void Hide() {
        Platform.runLater(() -> {
            curStage.hide();
        });
    }

    /**
     * 展示
     */
    public void Show() {
        curStage.showAndWait();
    }
}

多模板让用户选的模板存放方式
在这里插入图片描述
页面调用
在这里插入图片描述

测试
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

DolerGet测试

import JRTBLLBase.BaseHttpHandlerNoSession;
import JRTBLLBase.Helper;
import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.ParamDto;
import JRT.Core.Dto.OutParam;
import JRT.Model.Entity.*;
import JRT.Core.Util.Convert;
import JRT.Core.MultiPlatform.JRTContext;

import java.util.ArrayList;
import java.util.List;

/**
 * 测试DolerGet和不用DolerGet的性能差别
 *
 */
public class ashDolerGetTest extends BaseHttpHandlerNoSession {
    /**
     * 不用DolerGet查询数据
     * @return
     */
    public String NoDolerGet() throws Exception
    {
        long start=JRT.Core.Util.TimeParser.GetTimeInMillis();
        StringBuilder retSb=new StringBuilder();
        List<ParamDto> para=new ArrayList<>();
        List<RPVisitNumber> visList=EntityManager().FindAll(new RPVisitNumber(),para,"",-1,-1,"",null,null);
        retSb.append(Helper.Object2Json(visList));
        int getNum=0;
        for(RPVisitNumber vis:visList)
        {
            for(int i=0;i<200;i++) {
                if (vis.LocationDR != null) {
                    BTLocation loc = EntityManager().GetById(new BTLocation(), vis.LocationDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(loc));
                }
                if (vis.HospitalDR != null) {
                    BTHospital hos = EntityManager().GetById(new BTHospital(), vis.HospitalDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(hos));
                }
                if (vis.AdmissionTypeDR != null) {
                    BTAdmissionType adm = EntityManager().GetById(new BTAdmissionType(), vis.AdmissionTypeDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(adm));
                }
                if (vis.SpecimenDR != null) {
                    BTSpecimen sp = EntityManager().GetById(new BTSpecimen(), vis.SpecimenDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(sp));
                }
            }
        }
        long end=JRT.Core.Util.TimeParser.GetTimeInMillis();
        return "消耗时间:"+(end-start)+"    获取次数:"+getNum+"  "+retSb.toString();
    }

    /**
     * 用DolerGet查询数据
     * @return
     */
    public String DolerGet() throws Exception
    {
        long start=JRT.Core.Util.TimeParser.GetTimeInMillis();
        StringBuilder retSb=new StringBuilder();
        List<ParamDto> para=new ArrayList<>();
        List<RPVisitNumber> visList=EntityManager().FindAll(new RPVisitNumber(),para,"",-1,-1,"",null,null);
        retSb.append(Helper.Object2Json(visList));
        int getNum=0;
        for(RPVisitNumber vis:visList)
        {
            for(int i=0;i<200;i++) {
                if (vis.LocationDR != null) {
                    BTLocation loc = EntityManager().DolerGet(new BTLocation(), vis.LocationDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(loc));
                }
                if (vis.HospitalDR != null) {
                    BTHospital hos = EntityManager().DolerGet(new BTHospital(), vis.HospitalDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(hos));
                }
                if (vis.AdmissionTypeDR != null) {
                    BTAdmissionType adm = EntityManager().DolerGet(new BTAdmissionType(), vis.AdmissionTypeDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(adm));
                }
                if (vis.SpecimenDR != null) {
                    BTSpecimen sp = EntityManager().DolerGet(new BTSpecimen(), vis.SpecimenDR);
                    getNum++;
                    //retSb.append(Helper.Object2Json(sp));
                }
            }
        }
        long end=JRT.Core.Util.TimeParser.GetTimeInMillis();
        return "消耗时间:"+(end-start)+"    获取次数:"+getNum+"  "+retSb.toString();
    }

    /**
     * 查看缓存数据
     * @return
     * @throws Exception
     */
    public String View() throws Exception
    {
        return JRT.DAL.ORM.Global.GlobalManager.ViewGlobalJson();
    }

    /**
     * 查看缓存队列数据
     * @return
     * @throws Exception
     */
    public String ViewQuen() throws Exception
    {
        return JRT.DAL.ORM.Global.GlobalManager.ViewGlobalTaskQuenDate();
    }
}

不用DolerGet
在这里插入图片描述

使用DolerGet
在这里插入图片描述
缓存观测
在这里插入图片描述

这是第一版的DolerGet实现,已经有了起码一倍的性能提升,后面在细致优化,这样多维查询就不是难事了

  • 7
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
2020年是“jrt0166”的发展之年。在这一年,jrt0166迎来了许多重要的事件和转折点。 首先,jrt0166在2020年取得了巨大的发展和成就。他们成功推出了多个创新产品,并在市场上获得了广泛认可和赞誉。jrt0166团队经过不懈努力,不断改进和创新,使其产品在质量和性能方面不断提高,赢得了许多忠实的用户。 其次,2020年也是jrt0166公司扩大市场份额的一年。他们积极参加各种国内外展览和行业会议,与客户和合作伙伴广泛交流,拓展了合作关系。通过不断增强市场竞争力,他们成功进入了新的市场领域,为公司的长远发展打下了坚实基础。 此外,2020年也是jrt0166注重企业文化建设和员工培养的一年。他们积极组织各种培训和活动,提升员工的技能和动力。公司注重员工的职业发展和个人成长,并提供了广阔发展空间,使员工感受到公司的关心和支持。 最后,2020年也带来了一些挑战和困难。例如,全球爆发的COVID-19疫情对全球经济造成了巨大冲击,jrt0166也不例外。然而,面对挑战,jrt0166团队坚定信心,灵活应对,并采取了一系列应对措施,保持了公司的正常运营,并取得了不俗的业绩。 综上所述,2020年对于jrt0166来说是一个充满挑战和机遇的年份。通过不懈努力,创新实践和灵活应对,jrt0166成功地应对了各种挑战,并取得了长足发展,为公司的未来发展奠定了坚实基础。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小乌鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值