JRT代码结构调整和示例

news2024/11/23 20:39:22

之前一直没建表专门使用ORM的api,做模板设计器需要建表,就一边开发设计器一般测试和调整ORM的api,只有做业务才能知道哪些api使用别扭,写了设计器之后改进了ORM的api以方便业务操作数据库。新写法差不多是ORM操作数据库的稳定api了,基于JRT开发基本只要关心页面和示例代码的业务脚本代码了到头了,没有maven、rowmapper、controller、路由那些,非常简单。

调整方面:
1.查询方法都从原来传实体对象改为传实体类型,减少不必要的实体创建
2.提供GetCoutNum方法满足判断子表是否有数据,解决FindAll查询列表来判断子数据有没有的不便捷性
3.提供FindAllSimple满足大部分查询不需要传详细参数的情况
4.其他调整

判断是否有子数据老写法
在这里插入图片描述

判断是否有子数据新写法
在这里插入图片描述

在这里插入图片描述

新查询
在这里插入图片描述

其他优化比较新老代码

老查询
在这里插入图片描述

老写法

import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.OutParam;
import JRT.Core.Dto.OutValue;
import JRT.Core.Dto.ParamDto;
import JRT.Core.MultiPlatform.FileCollection;
import JRT.Core.MultiPlatform.JRTContext;
import JRT.Core.Util.Convert;
import JRT.Model.Entity.JRTPrintImage;
import JRT.Model.Entity.JRTPrintPaper;
import JRT.Model.Entity.JRTPrintTemplate;
import JRT.Model.Entity.JRTPrintTemplateEle;
import JRTBLLBase.BaseHttpHandlerNoSession;
import JRTBLLBase.Helper;

import java.io.*;
import java.nio.file.Paths;
import java.util.*;
import java.util.regex.Pattern;

/**
 * JRT模板设计器的后台代码
 */
public class ashJRTPrintDesigner extends BaseHttpHandlerNoSession {

    /**
     * 查询图标信息
	  
     * @return
     */
    public String QryPrintImage() throws Exception
    {
        //产品组代码
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        //产品组业务代码
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        //查询类型
        String ImgType = Helper.ValidParam(JRTContext.GetRequest(Request, "ImgType"), "");
        HashParam para = new HashParam();
        para.Add("ProductGroup", ProductGroup);
        para.Add("ProductBllID", ProductBllID);
        para.Add("ImgType", ImgType);
        List<JRTPrintImage> retList=EntityManager().FindAll(new JRTPrintImage(),para,"",-1,-1,"",null,null);
        return Helper.Object2Json(retList);
    }

    /**
     * 得到图片的Base64串
	  
     * @return
     */
    public String GetImgStr() throws Exception
    {
        //得到文件
        List<FileCollection> fileList = JRT.Core.MultiPlatform.JRTWebFile.GetFiles(Request);
        if (fileList != null && fileList.size() > 0) {
            //得到输入流
            InputStream input = fileList.get(0).GetInputStream();
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            byte[] buffer = new byte[4096];
            int bytesRead;
            while ((bytesRead = input.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }
            byte[] dataBytes = outputStream.toByteArray();

            String base64Data = Base64.getEncoder().encodeToString(dataBytes);
            return base64Data;
        }
        return "";
    }

    /**
     * 删除图标
	  
     * @return
     * @throws Exception
     */
    public String DeletePrintImage() throws Exception
    {
        int RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), 0);
        JRTPrintImage dto=new JRTPrintImage();
        dto.RowID=RowID;
        Err=new OutParam();
        int ret=EntityManager().Remove(dto,Err);
        if(ret==-1)
        {
            return Helper.Error();
        }
        return Helper.Success();
    }

    /**
     * 保存图标
	  
     * @return
     */
    public String SavePrintImage() throws Exception
    {
        //产品组代码
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        //产品组业务代码
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        String RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), "");
        String Code = Helper.ValidParam(JRTContext.GetRequest(Request, "Code"), "");
        String CName = Helper.ValidParam(JRTContext.GetRequest(Request, "CName"), "");
        String StartDate = Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), "");
        StartDate=StartDate.replace("-","");
        String EndDate = Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), "");
        EndDate=EndDate.replace("-","");
        String GraphBase64String = Helper.ValidParam(JRTContext.GetRequest(Request, "GraphBase64String"), "");
        String ImgType = Helper.ValidParam(JRTContext.GetRequest(Request, "ImgType"), "");
        JRTPrintImage dto=null;
        //添加图标
        if(RowID.equals("-1"))
        {
            dto=new JRTPrintImage();
            dto.CName=CName;
            dto.Code=Code;
            dto.EndDate=Helper.ValidParam(StartDate, dto.EndDate);
            dto.ImgBase64String=GraphBase64String;
            dto.ImgType=ImgType;
            dto.ProductBllID=ProductBllID;
            dto.ProductGroup=ProductGroup;
            dto.StartDate=Helper.ValidParam(StartDate, dto.StartDate);
            Err=new OutParam();
            int ret=EntityManager().Save(dto,Err);
            if(ret!=1)
            {
                return Helper.Error(Err);
            }
        }
        else
        {
            dto=EntityManager().GetById(new JRTPrintImage(),Convert.ToInt32(RowID));
            dto.CName=CName;
            dto.Code=Code;
            dto.EndDate=Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), dto.EndDate);
            dto.ImgBase64String=GraphBase64String;
            dto.ImgType=ImgType;
            dto.ProductBllID=ProductBllID;
            dto.ProductGroup=ProductGroup;
            dto.StartDate=Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), dto.StartDate);
            Err=new OutParam();
            int ret=EntityManager().Update(dto,Err,null);
            if(ret!=1)
            {
                return Helper.Error(Err);
            }
        }
        return Helper.Success();
    }


    /**
     * 删除一个模板
     */
    public String DeleteOneTemplate() throws Exception {
        //主键
        int RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), 0);
        HashParam para = new HashParam();
        para.Add("RowID", RowID);
        HashParam paraEle = new HashParam();
        paraEle.Add("PrintTemplateDR", RowID);
        Err = new OutParam();
        //先删子元素
        int ret = EntityManager().Remove(new JRTPrintTemplateEle(), paraEle, Err, null, null);
        if (ret != -1) {
													 
            //先删子元素
            ret = EntityManager().Remove(new JRTPrintTemplate(), para, Err, null, null);
        } else {
            throw new Exception(Err.GetString());
				 
			 
        }
						 
																		   
						
													  
		 
        return Helper.Success();
    }

    /**
     * 查询一个模板的json串
     *
     * @return
     * @throws Exception
     */
    public String QueryOneTemplateJson() throws Exception {
        //主键
        String RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), "");
        HashParam para = new HashParam();
        para.Add("RowID", RowID);
        //查询数据
        List<JRTPrintTemplateRetDto> list = EntityManager().FindAll(new JRTPrintTemplateRetDto(), para, "", -1, -1, "", null, null);
        if (list != null && list.size() > 0) {
            //转换数据库对象为Json对象
            JRTPrintTemplateRetDto dto = list.get(0);
            daReport daObj = new daReport();
            daObj.line = new ArrayList<>();
            daObj.pictureBox = new ArrayList<>();
            daObj.textField = new ArrayList<>();
            //取纸张代码
            if (dto.JRTPrintPaperDR != null) {
                JRTPrintPaper paper = EntityManager().DolerGet(new JRTPrintPaper(), dto.JRTPrintPaperDR);
                dto.PaperCode = paper.Code;
            }
            daObj.papersize = dto.PaperCode;
            daObj.archivesMargin = String.valueOf(dto.ArchivesMargin);
            daObj.documentCode = dto.Code;
            daObj.documentName = dto.CName;
            daObj.doubleColFillType = dto.DoubleColFillType;
            daObj.layout = dto.PaperLayout;
            daObj.micresultCols = String.valueOf(dto.MicResultCols);
            daObj.micresultLineSpacing = String.valueOf(dto.MicResultLineSpacing);
            daObj.micresultRows = String.valueOf(dto.MicResultRows);
            daObj.resultCols = String.valueOf(dto.ResultCols);
            daObj.resultLineSpacing = String.valueOf(dto.ResultLineSpacing);
            daObj.resultRows = String.valueOf(dto.ResultRows);
            daObj.fixedReport = "";
            daObj.margins = new PaperMargins();
            daObj.content = new PrintTmpXmlElements();
            daObj.content.staticContent = new ArrayList<>();
            HashParam paraEle = new HashParam();
            paraEle.Add("PrintTemplateDR", dto.RowID);
            //查询子元素
            List<JRTPrintTemplateEle> eleList = EntityManager().FindAll(new JRTPrintTemplateEle(), paraEle, "", -1, -1, "", null, null);
            if (eleList != null && eleList.size() > 0) {
                //遍历转换元素
                for (JRTPrintTemplateEle ele : eleList) {
                    //线
                    if (ele.PrintType.equals("ILineN")) {
                        LineElement line = new LineElement();
                        line.height = String.valueOf(ele.PrintHeight);
                        line.lineColor = ele.Color;
                        line.PrintFlag = ele.PrintFlag;
                        line.width = String.valueOf(ele.PrintWidth);
                        line.x = String.valueOf(ele.PrintX);
                        line.y = String.valueOf(ele.PrintY);
                        line.FixedReport = ele.FixedReport;
                        daObj.content.staticContent.add(line);
                        daObj.line.add(line);
                    }
                    //图
                    else if (ele.PrintType.equals("Graph")) {
                        PictureBoxElement pic = new PictureBoxElement();
                        pic.height = String.valueOf(ele.PrintHeight);
                        pic.DataField = ele.DataField;
                        if (pic.DataField == null) {
                            pic.DataField = "";
                        }
                        pic.PrintFlag = ele.PrintFlag;
                        if (pic.PrintFlag == null) {
                            pic.PrintFlag = "";
                        }
                        pic.width = String.valueOf(ele.PrintWidth);
                        pic.x = String.valueOf(ele.PrintX);
                        pic.y = String.valueOf(ele.PrintY);
                        pic.border = new Border();
                        pic.FixedReport = ele.FixedReport;
                        daObj.content.staticContent.add(pic);
                        daObj.pictureBox.add(pic);
                    }
                    //文本
                    else {
                        TextFieldElement txt = new TextFieldElement();
                        txt.height = String.valueOf(ele.PrintHeight);
                        txt.DataField = ele.DataField;
                        txt.PrintFlag = ele.PrintFlag;
                        txt.width = String.valueOf(ele.PrintWidth);
                        txt.x = String.valueOf(ele.PrintX);
                        txt.y = String.valueOf(ele.PrintY);
                        txt.border = new Border();
                        txt.FixedReport = ele.FixedReport;
                        String color = ele.Color;
                        String colorBK = "";
                        if (ele.Color.contains("^")) {
                            String[] colorArr = ele.Color.split("\\^");
                            color = colorArr[0];
                            if (colorArr.length > 1) {
                                colorBK = colorArr[1];
                            }
                        }
                        txt.backgroundColor = new BackgroundColor();
                        txt.backgroundColor.color = color;
                        txt.font = new Font();
                        txt.font.family = ele.PrintFont;
                        txt.font.size = ele.PrintFontSize;
                        txt.font.style = ele.PrintFontStyle;
                        txt.foregroundColor = new ForegroundColor();
                        txt.foregroundColor.color = colorBK;
                        txt.text = new Text();
                        txt.text.text = ele.PrintText;
                        txt.text.verAlignment = ele.PrintAlignment;
                        txt.TextDataType = ele.PrintType;
                        txt.TextLength = String.valueOf(ele.PrintLength);
                        daObj.content.staticContent.add(txt);
                        daObj.textField.add(txt);
                    }
                }
            }
            return "{\"daReport\":" + Helper.Object2Json(daObj) + "}";
        }
        return "{}";
    }

    /**
     * 查询数据库有的模板列表
     *
     * @return
     */
    public String QueryTemplate() throws Exception {
        //产品组代码
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        //产品组业务代码
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        HashParam para = new HashParam();
        para.Add("ProductGroup", ProductGroup);
        para.Add("ProductBllID", ProductBllID);
        //查询数据
        List<JRTPrintTemplateRetDto> list = EntityManager().FindAll(new JRTPrintTemplateRetDto(), para, "", -1, -1, "", null, null);
        if (list != null && list.size() > 0) {
            JRTPrintPaper paperType = new JRTPrintPaper();
            //遍历组装数据
            for (JRTPrintTemplateRetDto dto : list) {
                //取纸张代码
                if (dto.JRTPrintPaperDR != null) {
                    JRTPrintPaper paper = EntityManager().DolerGet(paperType, dto.JRTPrintPaperDR);
                    dto.PaperCode = paper.Code;
                }
                //判断历史
                List<ParamDto> paraChild = new ArrayList<>();
                ParamDto p = new ParamDto();
                p.Key = "ParentTemplateDR";
                p.Value = dto.RowID;
                List<JRTPrintTemplate> childList = EntityManager().FindAll(new JRTPrintTemplate(), paraChild, "", -1, -1, "", null, null);
                if (childList != null && childList.size() > 0) {
                    dto.HasHistory = "1";
                }
                //从名称第二位分割出类型
                if (dto.CName.contains("^")) {
                    String[] arr = dto.CName.split("\\^");
                    dto.CName = arr[0];
                    if (arr.length > 1) {
                        dto.GrpType = arr[1];
                    }
                }
            }
        }
        return Helper.Object2Json(list);
    }

    /**
     * 保存模板
     *
     * @return
     */
    public String SaveTempLate() throws Exception {
        //参数对象
        String TmpDR = Helper.ValidParam(JRTContext.GetRequest(Request, "TmpDR"), "");
        String SaveStr = Helper.ValidParam(JRTContext.GetRequest(Request, "SaveStr"), "");
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        String EndDate = Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), "");
        String EndTime = Helper.ValidParam(JRTContext.GetRequest(Request, "EndTime"), "");
        String ParentDR = Helper.ValidParam(JRTContext.GetRequest(Request, "ParentDR"), "");
        String EndRemark = Helper.ValidParam(JRTContext.GetRequest(Request, "EndRemark"), "");
        int Sequence = Helper.ValidParam(JRTContext.GetRequest(Request, "Sequence"), 1);
        Err = new OutParam();
        //转换成对象
        daReport daObj = (daReport) Helper.Json2Object(SaveStr, daReport.class);
        JRTPrintTemplate temp = null;
        //新增模板
        if (TmpDR.isEmpty()) {
            temp = new JRTPrintTemplate();
        }
        //保存模板
        else {
            temp = EntityManager().GetById(new JRTPrintTemplate(), Convert.ToInt32(TmpDR));
        }
        temp.ArchivesMargin = Helper.ValidParam(daObj.archivesMargin, temp.ArchivesMargin);
        temp.CName = Helper.ValidParam(daObj.documentName, temp.CName);
        temp.Code = Helper.ValidParam(daObj.documentCode, temp.Code);
        temp.DoubleColFillType = Helper.ValidParam(daObj.doubleColFillType, temp.DoubleColFillType);
        temp.EndDate = Helper.ValidParam(EndDate, temp.EndDate);
        temp.EndTime = Helper.ValidParam(EndTime, temp.EndTime);
        if (daObj.papersize!=null&&!daObj.papersize.isEmpty()) {
            List<ParamDto> para = new ArrayList<>();
            ParamDto p = new ParamDto();
            p.Key = "Code";
            p.Value = daObj.papersize;
            para.add(p);
            List<JRTPrintPaper> paperList = EntityManager().FindAll(new JRTPrintPaper(), para, "", -1, -1, "", null, null);
            if (paperList != null && paperList.size() > 0) {
                temp.JRTPrintPaperDR = paperList.get(0).RowID;
            }
        } else {
            temp.JRTPrintPaperDR = null;
        }
        temp.EndRemark = Helper.ValidParam(EndRemark, temp.EndRemark);
        temp.MicResultCols = Helper.ValidParam(daObj.micresultCols, temp.MicResultCols);
        temp.MicResultLineSpacing = Helper.ValidParam(daObj.micresultLineSpacing, temp.MicResultLineSpacing);
        temp.MicResultRows = Helper.ValidParam(daObj.micresultRows, temp.MicResultRows);
        temp.PaperBottom = 0.0;
        temp.PaperLayout = Helper.ValidParam(daObj.layout, temp.PaperLayout);
        temp.PaperLeft = 0.0;
        temp.PaperRight = 0.0;
        temp.PaperTop = 0.0;
        temp.ParentTemplateDR = Helper.ValidParam(ParentDR, temp.ParentTemplateDR);
        temp.ProductBllID = Helper.ValidParam(ProductBllID, temp.ProductBllID);
        temp.ProductGroup = Helper.ValidParam(ProductGroup, temp.ProductGroup);
        temp.ResultCols = Helper.ValidParam(daObj.resultCols, temp.ResultCols);
        temp.ResultLineSpacing = Helper.ValidParam(daObj.resultLineSpacing, temp.ResultLineSpacing);
        temp.ResultRows = Helper.ValidParam(daObj.resultRows, temp.ResultRows);
        temp.Sequence = Sequence;
        int saveTempRet;
        if (TmpDR.isEmpty()) {
            OutValue key = new OutValue();
            saveTempRet = EntityManager().Save(temp, key, Err);
            if (saveTempRet == 1) {
                temp.RowID = key.GetInerger();
            } else {
                throw new Exception(Err.GetString());
            }
        } else {
            saveTempRet = EntityManager().Update(temp, null);
            if (saveTempRet == 1) {
                HashParam para = new HashParam();
                para.Add("PrintTemplateDR", temp.RowID);
                //删除老元素
                int ret = EntityManager().Remove(new JRTPrintTemplateEle(), para, Err, null, null);
															
															 
										 
																		
                if (ret != 1) {
                    throw new Exception(Err.GetString());
						 
					 
                }
            }
        }
        //保存元素
        if (saveTempRet == 1) {
            //存线
            if (daObj.line != null && daObj.line.size() > 0) {
                for (LineElement line : daObj.line) {
                    JRTPrintTemplateEle ele = new JRTPrintTemplateEle();
                    ele.Angle = "";
                    ele.Color = line.lineColor;
                    ele.DataField = "";
                    ele.IsVShow = "";
                    ele.LayOut = "";
                    ele.PrintAlignment = "";
                    ele.PrintFlag = line.PrintFlag;
                    ele.PrintFont = "";
                    ele.PrintFontSize = "";
                    ele.PrintFontStyle = "";
                    ele.PrintHeight = Helper.ValidParam(line.height, ele.PrintHeight);
                    ele.PrintLength = 10.0;
                    ele.PrintTemplateDR = temp.RowID;
                    ele.PrintText = "";
                    ele.PrintType = "ILineN";
                    ele.PrintWidth = Helper.ValidParam(line.width, ele.PrintWidth);
                    ele.PrintX = Helper.ValidParam(line.x, ele.PrintX);
                    ele.PrintY = Helper.ValidParam(line.y, ele.PrintY);
                    OutValue key = new OutValue();
                    int eleRet = EntityManager().Save(ele, key, Err);
                    if (eleRet != 1) {
                        throw new Exception(Err.GetString());
                    }
                }
            }
            //存图
            if (daObj.pictureBox != null && daObj.pictureBox.size() > 0) {
                for (PictureBoxElement pic : daObj.pictureBox) {
                    JRTPrintTemplateEle ele = new JRTPrintTemplateEle();
                    ele.Angle = "";
                    ele.Color = "";
                    ele.DataField = pic.DataField;
                    ele.IsVShow = "";
                    ele.LayOut = "";
                    ele.PrintAlignment = "";
                    ele.PrintFlag = pic.PrintFlag;
                    ele.PrintFont = "";
                    ele.PrintFontSize = "";
                    ele.PrintFontStyle = "";
                    ele.PrintHeight = Helper.ValidParam(pic.height, ele.PrintHeight);
                    ele.PrintLength = 10.0;
                    ele.PrintTemplateDR = temp.RowID;
                    ele.PrintText = "";
                    ele.PrintType = "Graph";
                    ele.PrintWidth = Helper.ValidParam(pic.width, ele.PrintWidth);
                    ele.PrintX = Helper.ValidParam(pic.x, ele.PrintX);
                    ele.PrintY = Helper.ValidParam(pic.y, ele.PrintY);
                    OutValue key = new OutValue();
                    int eleRet = EntityManager().Save(ele, key, Err);
                    if (eleRet != 1) {
                        throw new Exception(Err.GetString());
                    }
                }
            }
            //存文本
            if (daObj.textField != null && daObj.textField.size() > 0) {
                for (TextFieldElement txt : daObj.textField) {
                    JRTPrintTemplateEle ele = new JRTPrintTemplateEle();
                    ele.Angle = "";
                    ele.Color = txt.foregroundColor.color;
                    if (txt.backgroundColor != null && !txt.backgroundColor.color.isEmpty()) {
                        ele.Color += "^" + txt.backgroundColor.color;
                    }
                    ele.DataField = txt.DataField;
                    ele.IsVShow = "";
                    ele.LayOut = "";
                    ele.PrintAlignment = txt.verAlignment;
                    ele.PrintFlag = txt.PrintFlag;
                    ele.PrintFont = txt.font.family;
                    ele.PrintFontSize = txt.font.size;
                    ele.PrintFontStyle = txt.font.style;
                    ele.PrintHeight = Helper.ValidParam(txt.height, ele.PrintHeight);
                    ele.PrintLength = Helper.ValidParam(txt.TextLength, ele.PrintLength);
                    ele.PrintTemplateDR = temp.RowID;
                    ele.PrintText = txt.text.text;
                    ele.PrintType = txt.TextDataType;
                    ele.PrintWidth = Helper.ValidParam(txt.width, ele.PrintWidth);
                    ele.PrintX = Helper.ValidParam(txt.x, ele.PrintX);
                    ele.PrintY = Helper.ValidParam(txt.y, ele.PrintY);
                    OutValue key = new OutValue();
                    int eleRet = EntityManager().Save(ele, key, Err);
                    if (eleRet != 1) {
                        throw new Exception(Err.GetString());
                    }
                }
            }
        }
        return Helper.Success(String.valueOf(temp.RowID));
    }

							 
	   
	/**
     * 返回模板列表数据实体
     */
    public static class JRTPrintTemplateRetDto extends JRTPrintTemplate {
        /**
         * 页面代码
         */
        public String PaperCode;

        /**
         * 是否有历史
         */
        public String HasHistory;

        /**
         * 分组类型
         */
        public String GrpType;
    }																		 
		    
}

新写法

import JRT.Core.Dto.HashParam;
import JRT.Core.Dto.OutParam;
import JRT.Core.Dto.OutValue;
import JRT.Core.Dto.ParamDto;
import JRT.Core.MultiPlatform.FileCollection;
import JRT.Core.MultiPlatform.JRTContext;
import JRT.Core.Util.Convert;
import JRT.Model.Entity.JRTPrintImage;
import JRT.Model.Entity.JRTPrintPaper;
import JRT.Model.Entity.JRTPrintTemplate;
import JRT.Model.Entity.JRTPrintTemplateEle;
import JRTBLLBase.BaseHttpHandlerNoSession;
import JRTBLLBase.Helper;

import java.io.*;
import java.nio.file.Paths;
import java.util.*;
import java.util.regex.Pattern;

/**
 * JRT模板设计器的后台代码
 */
public class ashJRTPrintDesigner extends BaseHttpHandlerNoSession {

    /**
     * 查询图标信息
     *
     * @return
     */
    public String QryPrintImage() throws Exception {
	 
        //产品组代码
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        //产品组业务代码
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        //查询类型
        String ImgType = Helper.ValidParam(JRTContext.GetRequest(Request, "ImgType"), "");
        HashParam para = new HashParam();
        para.Add("ProductGroup", ProductGroup);
        para.Add("ProductBllID", ProductBllID);
        para.Add("ImgType", ImgType);
        List<JRTPrintImage> retList = EntityManager().FindAllSimple(JRTPrintImage.class, para);
        return Helper.Object2Json(retList);
    }

    /**
     * 得到图片的Base64串
     *
     * @return
     */
    public String GetImgStr() throws Exception {
	 
        //得到文件
        List<FileCollection> fileList = JRT.Core.MultiPlatform.JRTWebFile.GetFiles(Request);
        if (fileList != null && fileList.size() > 0) {
            //得到输入流
            InputStream input = fileList.get(0).GetInputStream();
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            byte[] buffer = new byte[4096];
            int bytesRead;
            while ((bytesRead = input.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }
            byte[] dataBytes = outputStream.toByteArray();

            String base64Data = Base64.getEncoder().encodeToString(dataBytes);
            return base64Data;
        }
        return "";
    }

    /**
     * 删除图标
     *
     * @return
     * @throws Exception
     */
    public String DeletePrintImage() throws Exception {
	 
        int RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), 0);
        int ret = EntityManager().RemoveById(JRTPrintImage.class, RowID, ErrRet());
						
						   
												
        if (ret == -1) {
		 
            return Helper.Error();
        }
        return Helper.Success();
    }

    /**
     * 保存图标
     *
     * @return
     */
    public String SavePrintImage() throws Exception {
	 
        //产品组代码
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        //产品组业务代码
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        String RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), "");
        String Code = Helper.ValidParam(JRTContext.GetRequest(Request, "Code"), "");
        String CName = Helper.ValidParam(JRTContext.GetRequest(Request, "CName"), "");
        String StartDate = Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), "");
        StartDate = StartDate.replace("-", "");
        String EndDate = Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), "");
        EndDate = EndDate.replace("-", "");
        String GraphBase64String = Helper.ValidParam(JRTContext.GetRequest(Request, "GraphBase64String"), "");
        String ImgType = Helper.ValidParam(JRTContext.GetRequest(Request, "ImgType"), "");
        JRTPrintImage dto = null;
        //添加图标
        if (RowID.equals("-1")) {
		 
            dto = new JRTPrintImage();
            dto.CName = CName;
            dto.Code = Code;
            dto.EndDate = Helper.ValidParam(StartDate, dto.EndDate);
            dto.ImgBase64String = GraphBase64String;
            dto.ImgType = ImgType;
            dto.ProductBllID = ProductBllID;
            dto.ProductGroup = ProductGroup;
            dto.StartDate = Helper.ValidParam(StartDate, dto.StartDate);
							   
            int ret = EntityManager().Save(dto, ErrRet());
            if (ret != 1) {
			 
                return Helper.Error(ErrRet());
            }
        } else {
			
		 
            dto = EntityManager().GetById(JRTPrintImage.class, Convert.ToInt32(RowID));
            dto.CName = CName;
            dto.Code = Code;
            dto.EndDate = Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), dto.EndDate);
            dto.ImgBase64String = GraphBase64String;
            dto.ImgType = ImgType;
            dto.ProductBllID = ProductBllID;
            dto.ProductGroup = ProductGroup;
            dto.StartDate = Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), dto.StartDate);
							   
            int ret = EntityManager().Update(dto, ErrRet(), null);
            if (ret != 1) {
			 
                return Helper.Error(ErrRet());
            }
        }
        return Helper.Success();
    }


    /**
     * 删除一个模板
     */
    public String DeleteOneTemplate() throws Exception {
        //主键
        int RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), 0);
        HashParam para = new HashParam();
        para.Add("RowID", RowID);
        HashParam paraEle = new HashParam();
        paraEle.Add("PrintTemplateDR", RowID);
							 
						 
        List<JRTPrintTemplateEle> eleList = EntityManager().FindAllSimple(JRTPrintTemplateEle.class, paraEle);
        if (eleList != null && eleList.size() > 0) {
            for (JRTPrintTemplateEle ele : eleList) {
                //先删子元素
                int ret = EntityManager().Remove(ele, ErrRet());
                if (ret == -1) {
                    throw new Exception(ErrRet().GetString());
                }
            }
        }
        //再删主元素
        int ret = EntityManager().Remove(JRTPrintTemplate.class, ErrRet());
        if (ret == -1) {
            throw new Exception(ErrRet().GetString());
        }
        return Helper.Success();
    }

    /**
     * 查询一个模板的json串
     *
     * @return
     * @throws Exception
     */
    public String QueryOneTemplateJson() throws Exception {
        //主键
        String RowID = Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), "");
        HashParam para = new HashParam();
        para.Add("RowID", RowID);
        //查询数据
        List<JRTPrintTemplateRetDto> list = EntityManager().FindAllSimple(JRTPrintTemplateRetDto.class, para);
        if (list != null && list.size() > 0) {
            //转换数据库对象为Json对象
            JRTPrintTemplateRetDto dto = list.get(0);
            daReport daObj = new daReport();
            daObj.line = new ArrayList<>();
            daObj.pictureBox = new ArrayList<>();
            daObj.textField = new ArrayList<>();
            //取纸张代码
            if (dto.JRTPrintPaperDR != null) {
                JRTPrintPaper paper = EntityManager().DolerGet(JRTPrintPaper.class, dto.JRTPrintPaperDR);
                dto.PaperCode = paper.Code;
            }
            daObj.papersize = dto.PaperCode;
            daObj.archivesMargin = String.valueOf(dto.ArchivesMargin);
            daObj.documentCode = dto.Code;
            daObj.documentName = dto.CName;
            daObj.doubleColFillType = dto.DoubleColFillType;
            daObj.layout = dto.PaperLayout;
            daObj.micresultCols = String.valueOf(dto.MicResultCols);
            daObj.micresultLineSpacing = String.valueOf(dto.MicResultLineSpacing);
            daObj.micresultRows = String.valueOf(dto.MicResultRows);
            daObj.resultCols = String.valueOf(dto.ResultCols);
            daObj.resultLineSpacing = String.valueOf(dto.ResultLineSpacing);
            daObj.resultRows = String.valueOf(dto.ResultRows);
            daObj.fixedReport = "";
            daObj.margins = new PaperMargins();
            daObj.content = new PrintTmpXmlElements();
            daObj.content.staticContent = new ArrayList<>();
            HashParam paraEle = new HashParam();
            paraEle.Add("PrintTemplateDR", dto.RowID);
            //查询子元素
            List<JRTPrintTemplateEle> eleList = EntityManager().FindAllSimple(JRTPrintTemplateEle.class, paraEle);
            if (eleList != null && eleList.size() > 0) {
                //遍历转换元素
                for (JRTPrintTemplateEle ele : eleList) {
                    //线
                    if (ele.PrintType.equals("ILineN")) {
                        LineElement line = new LineElement();
                        line.height = String.valueOf(ele.PrintHeight);
                        line.lineColor = ele.Color;
                        line.PrintFlag = ele.PrintFlag;
                        line.width = String.valueOf(ele.PrintWidth);
                        line.x = String.valueOf(ele.PrintX);
                        line.y = String.valueOf(ele.PrintY);
                        line.FixedReport = ele.FixedReport;
                        daObj.content.staticContent.add(line);
                        daObj.line.add(line);
                    }
                    //图
                    else if (ele.PrintType.equals("Graph")) {
                        PictureBoxElement pic = new PictureBoxElement();
                        pic.height = String.valueOf(ele.PrintHeight);
                        pic.DataField = ele.DataField;
                        if (pic.DataField == null) {
                            pic.DataField = "";
                        }
                        pic.PrintFlag = ele.PrintFlag;
                        if (pic.PrintFlag == null) {
                            pic.PrintFlag = "";
                        }
                        pic.width = String.valueOf(ele.PrintWidth);
                        pic.x = String.valueOf(ele.PrintX);
                        pic.y = String.valueOf(ele.PrintY);
                        pic.border = new Border();
                        pic.FixedReport = ele.FixedReport;
                        daObj.content.staticContent.add(pic);
                        daObj.pictureBox.add(pic);
                    }
                    //文本
                    else {
                        TextFieldElement txt = new TextFieldElement();
                        txt.height = String.valueOf(ele.PrintHeight);
                        txt.DataField = ele.DataField;
                        txt.PrintFlag = ele.PrintFlag;
                        txt.width = String.valueOf(ele.PrintWidth);
                        txt.x = String.valueOf(ele.PrintX);
                        txt.y = String.valueOf(ele.PrintY);
                        txt.border = new Border();
                        txt.FixedReport = ele.FixedReport;
                        String color = ele.Color;
                        String colorBK = "";
                        if (ele.Color.contains("^")) {
                            String[] colorArr = ele.Color.split("\\^");
                            color = colorArr[0];
                            if (colorArr.length > 1) {
                                colorBK = colorArr[1];
                            }
                        }
                        txt.backgroundColor = new BackgroundColor();
                        txt.backgroundColor.color = color;
                        txt.font = new Font();
                        txt.font.family = ele.PrintFont;
                        txt.font.size = ele.PrintFontSize;
                        txt.font.style = ele.PrintFontStyle;
                        txt.foregroundColor = new ForegroundColor();
                        txt.foregroundColor.color = colorBK;
                        txt.text = new Text();
                        txt.text.text = ele.PrintText;
                        txt.text.verAlignment = ele.PrintAlignment;
                        txt.TextDataType = ele.PrintType;
                        txt.TextLength = String.valueOf(ele.PrintLength);
                        daObj.content.staticContent.add(txt);
                        daObj.textField.add(txt);
                    }
                }
            }
            return "{\"daReport\":" + Helper.Object2Json(daObj) + "}";
        }
        return "{}";
    }

    /**
     * 查询数据库有的模板列表
     *
     * @return
     */
    public String QueryTemplate() throws Exception {
        //产品组代码
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        //产品组业务代码
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        HashParam para = new HashParam();
        para.Add("ProductGroup", ProductGroup);
        para.Add("ProductBllID", ProductBllID);
        //查询数据
        List<JRTPrintTemplateRetDto> list = EntityManager().FindAllSimple(JRTPrintTemplateRetDto.class, para);
        if (list != null && list.size() > 0) {
														  
            //遍历组装数据
            for (JRTPrintTemplateRetDto dto : list) {
                //取纸张代码
                if (dto.JRTPrintPaperDR != null) {
                    JRTPrintPaper paper = EntityManager().DolerGet(JRTPrintPaper.class, dto.JRTPrintPaperDR);
                    dto.PaperCode = paper.Code;
                }
                //判断历史
                int childNum = EntityManager().GetCoutNum(JRTPrintTemplate.class, "ParentTemplateDR", dto.RowID);
											
										   
									
																																		  
                if (childNum > 0) {
                    dto.HasHistory = "1";
                }
                //从名称第二位分割出类型
                if (dto.CName.contains("^")) {
                    String[] arr = dto.CName.split("\\^");
                    dto.CName = arr[0];
                    if (arr.length > 1) {
                        dto.GrpType = arr[1];
                    }
                }
            }
        }
        return Helper.Object2Json(list);
    }

    /**
     * 保存模板
     *
     * @return
     */
    public String SaveTempLate() throws Exception {
        //参数对象
        String TmpDR = Helper.ValidParam(JRTContext.GetRequest(Request, "TmpDR"), "");
        String SaveStr = Helper.ValidParam(JRTContext.GetRequest(Request, "SaveStr"), "");
        String ProductGroup = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
        String ProductBllID = Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
        String EndDate = Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), "");
        String EndTime = Helper.ValidParam(JRTContext.GetRequest(Request, "EndTime"), "");
        String ParentDR = Helper.ValidParam(JRTContext.GetRequest(Request, "ParentDR"), "");
        String EndRemark = Helper.ValidParam(JRTContext.GetRequest(Request, "EndRemark"), "");
        int Sequence = Helper.ValidParam(JRTContext.GetRequest(Request, "Sequence"), 1);
							 
        //转换成对象
        daReport daObj = (daReport) Helper.Json2Object(SaveStr, daReport.class);
        JRTPrintTemplate temp = null;
        //新增模板
        if (TmpDR.isEmpty()) {
            temp = new JRTPrintTemplate();
        }
        //保存模板
        else {
            temp = EntityManager().GetById(JRTPrintTemplate.class, Convert.ToInt32(TmpDR));
        }
        temp.ArchivesMargin = Helper.ValidParam(daObj.archivesMargin, temp.ArchivesMargin);
        temp.CName = Helper.ValidParam(daObj.documentName, temp.CName);
        temp.Code = Helper.ValidParam(daObj.documentCode, temp.Code);
        temp.DoubleColFillType = Helper.ValidParam(daObj.doubleColFillType, temp.DoubleColFillType);
        temp.EndDate = Helper.ValidParam(EndDate, temp.EndDate);
        temp.EndTime = Helper.ValidParam(EndTime, temp.EndTime);
        if (daObj.papersize != null && !daObj.papersize.isEmpty()) {
            HashParam para=new HashParam();
										
						   
            para.Add("Code",daObj.papersize);
						
            List<JRTPrintPaper> paperList = EntityManager().FindAllSimple(JRTPrintPaper.class, para);
            if (paperList != null && paperList.size() > 0) {
                temp.JRTPrintPaperDR = paperList.get(0).RowID;
            }
        } else {
            temp.JRTPrintPaperDR = null;
        }
        temp.EndRemark = Helper.ValidParam(EndRemark, temp.EndRemark);
        temp.MicResultCols = Helper.ValidParam(daObj.micresultCols, temp.MicResultCols);
        temp.MicResultLineSpacing = Helper.ValidParam(daObj.micresultLineSpacing, temp.MicResultLineSpacing);
        temp.MicResultRows = Helper.ValidParam(daObj.micresultRows, temp.MicResultRows);
        temp.PaperBottom = 0.0;
        temp.PaperLayout = Helper.ValidParam(daObj.layout, temp.PaperLayout);
        temp.PaperLeft = 0.0;
        temp.PaperRight = 0.0;
        temp.PaperTop = 0.0;
        temp.ParentTemplateDR = Helper.ValidParam(ParentDR, temp.ParentTemplateDR);
        temp.ProductBllID = Helper.ValidParam(ProductBllID, temp.ProductBllID);
        temp.ProductGroup = Helper.ValidParam(ProductGroup, temp.ProductGroup);
        temp.ResultCols = Helper.ValidParam(daObj.resultCols, temp.ResultCols);
        temp.ResultLineSpacing = Helper.ValidParam(daObj.resultLineSpacing, temp.ResultLineSpacing);
        temp.ResultRows = Helper.ValidParam(daObj.resultRows, temp.ResultRows);
        temp.Sequence = Sequence;
        int saveTempRet;
        if (TmpDR.isEmpty()) {
            OutValue key = new OutValue();
            saveTempRet = EntityManager().Save(temp, key, ErrRet());
            if (saveTempRet == 1) {
                temp.RowID = key.GetInerger();
            } else {
                throw new Exception(ErrRet().GetString());
            }
        } else {
            saveTempRet = EntityManager().Update(temp, null);
            if (saveTempRet == 1) {
                HashParam para = new HashParam();
                para.Add("PrintTemplateDR", temp.RowID);
                //删除老元素
                List<JRTPrintTemplateEle> eleList = EntityManager().FindAllSimple(JRTPrintTemplateEle.class, para);
                if (eleList != null && eleList.size() > 0) {
                    for (JRTPrintTemplateEle ele : eleList) {
                        //先删子元素
                        int ret = EntityManager().Remove(ele, ErrRet());
                        if (ret == -1) {
                            throw new Exception(ErrRet().GetString());
                        }
                    }
                }
            }
        }
        //保存元素
        if (saveTempRet == 1) {
            //存线
            if (daObj.line != null && daObj.line.size() > 0) {
                for (LineElement line : daObj.line) {
                    JRTPrintTemplateEle ele = new JRTPrintTemplateEle();
                    ele.Angle = "";
                    ele.Color = line.lineColor;
                    ele.DataField = "";
                    ele.IsVShow = "";
                    ele.LayOut = "";
                    ele.PrintAlignment = "";
                    ele.PrintFlag = line.PrintFlag;
                    ele.PrintFont = "";
                    ele.PrintFontSize = "";
                    ele.PrintFontStyle = "";
                    ele.PrintHeight = Helper.ValidParam(line.height, ele.PrintHeight);
                    ele.PrintLength = 10.0;
                    ele.PrintTemplateDR = temp.RowID;
                    ele.PrintText = "";
                    ele.PrintType = "ILineN";
                    ele.PrintWidth = Helper.ValidParam(line.width, ele.PrintWidth);
                    ele.PrintX = Helper.ValidParam(line.x, ele.PrintX);
                    ele.PrintY = Helper.ValidParam(line.y, ele.PrintY);
                    OutValue key = new OutValue();
                    int eleRet = EntityManager().Save(ele, key, ErrRet());
                    if (eleRet != 1) {
                        throw new Exception(ErrRet().GetString());
                    }
                }
            }
            //存图
            if (daObj.pictureBox != null && daObj.pictureBox.size() > 0) {
                for (PictureBoxElement pic : daObj.pictureBox) {
                    JRTPrintTemplateEle ele = new JRTPrintTemplateEle();
                    ele.Angle = "";
                    ele.Color = "";
                    ele.DataField = pic.DataField;
                    ele.IsVShow = "";
                    ele.LayOut = "";
                    ele.PrintAlignment = "";
                    ele.PrintFlag = pic.PrintFlag;
                    ele.PrintFont = "";
                    ele.PrintFontSize = "";
                    ele.PrintFontStyle = "";
                    ele.PrintHeight = Helper.ValidParam(pic.height, ele.PrintHeight);
                    ele.PrintLength = 10.0;
                    ele.PrintTemplateDR = temp.RowID;
                    ele.PrintText = "";
                    ele.PrintType = "Graph";
                    ele.PrintWidth = Helper.ValidParam(pic.width, ele.PrintWidth);
                    ele.PrintX = Helper.ValidParam(pic.x, ele.PrintX);
                    ele.PrintY = Helper.ValidParam(pic.y, ele.PrintY);
                    OutValue key = new OutValue();
                    int eleRet = EntityManager().Save(ele, key, ErrRet());
                    if (eleRet != 1) {
                        throw new Exception(ErrRet().GetString());
                    }
                }
            }
            //存文本
            if (daObj.textField != null && daObj.textField.size() > 0) {
                for (TextFieldElement txt : daObj.textField) {
                    JRTPrintTemplateEle ele = new JRTPrintTemplateEle();
                    ele.Angle = "";
                    ele.Color = txt.foregroundColor.color;
                    if (txt.backgroundColor != null && !txt.backgroundColor.color.isEmpty()) {
                        ele.Color += "^" + txt.backgroundColor.color;
                    }
                    ele.DataField = txt.DataField;
                    ele.IsVShow = "";
                    ele.LayOut = "";
                    ele.PrintAlignment = txt.verAlignment;
                    ele.PrintFlag = txt.PrintFlag;
                    ele.PrintFont = txt.font.family;
                    ele.PrintFontSize = txt.font.size;
                    ele.PrintFontStyle = txt.font.style;
                    ele.PrintHeight = Helper.ValidParam(txt.height, ele.PrintHeight);
                    ele.PrintLength = Helper.ValidParam(txt.TextLength, ele.PrintLength);
                    ele.PrintTemplateDR = temp.RowID;
                    ele.PrintText = txt.text.text;
                    ele.PrintType = txt.TextDataType;
                    ele.PrintWidth = Helper.ValidParam(txt.width, ele.PrintWidth);
                    ele.PrintX = Helper.ValidParam(txt.x, ele.PrintX);
                    ele.PrintY = Helper.ValidParam(txt.y, ele.PrintY);
                    OutValue key = new OutValue();
                    int eleRet = EntityManager().Save(ele, key, ErrRet());
                    if (eleRet != 1) {
                        throw new Exception(ErrRet().GetString());
                    }
                }
            }
        }
        return Helper.Success(String.valueOf(temp.RowID));
    }



    /**
     * 返回模板列表数据实体
     */
    public static class JRTPrintTemplateRetDto extends JRTPrintTemplate {
        /**
         * 页面代码
         */
        public String PaperCode;

        /**
         * 是否有历史
         */
        public String HasHistory;

        /**
         * 分组类型
         */
        public String GrpType;
    }
}


生成的示例代码,写业务已经压缩成只要会下面两个语法就都能马上上手

页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>JRTPrintImage供拷贝代码使用</title>
    <link rel="shortcut icon" href="../../resource/common/images/favicon.ico" />
    <script src="../../resource/common/js/JRTBSBase.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        SYSPageCommonInfo.Init();
        var BasePath = '';
        var ResourcePath = '';
        var WebServicAddress = SYSPageCommonInfo.Data.WebServicAddress;
        var UserDR = SYSPageCommonInfo.Data.Sesssion.UserDR;
        var WorkGroupDR = SYSPageCommonInfo.Data.Sesssion.WorkGroupDR;
        var sysTheme = SYSPageCommonInfo.Data.Sesssion.Theme;
        var SessionStr = SYSPageCommonInfo.Data.SessionStr;
    </script>
    <script type="text/javascript">
        //全局变量
        var me = {
            actionUrl: '../ashx/ashJRTPrintImage.ashx'
        };

        //jquery入口
        $(function () {

            //新增数据点击
            $("#btnAddJRTPrintImage").click(function () {
                $("#txtJRTPrintImageRowID").val(""); 
				$('#winEditJRTPrintImage').window({
                    title: TranslateDataMTHD('Add Data', '新增数据', ''),
                    modal: true
                });
            });


            //修改数据点击
            $("#btnUpdateJRTPrintImage").click(function () {
				UpdateJRTPrintImage();
            });

			//修改数据
			function UpdateJRTPrintImage(row)
			{
                var selectRow = $('#dgJRTPrintImage').datagrid("getSelected");
                if(row!=null)
                {
                	selectRow=row;
                }
                if (selectRow == null) {
                    $.messager.alert(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Please select the data to modify', '请选择要修改的数据!', ''), 'info');
                    return;
                }
				$("#formJRTPrintImage").form('load', selectRow);
				$('#winEditJRTPrintImage').window({
                    title: TranslateDataMTHD('Update Data', '修改数据', ''),
                    modal: true
                });
			}



            //删除数据点击
            $("#btnDeleteJRTPrintImage").click(function () {
                var checkRow = $('#dgJRTPrintImage').datagrid("getChecked");
                var selectRow = $('#dgJRTPrintImage').datagrid("getSelected");
                if ((checkRow == null || checkRow.length == 0)&&selectRow==null) {
                    $.messager.alert(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Please select the data to delete', '请勾选要删除的数据!', ''), 'info');
                    return;
                }
                if ((checkRow == null || checkRow.length == 0)) {
                    checkRow=[selectRow];
                }
                var RowIDS = "";
                for (var i = 0; i < checkRow.length; i++) {
                    if (i == 0) {
                        RowIDS = checkRow[i].RowID;
                    }
                    else {
                        RowIDS += "^" + checkRow[i].RowID;
                    }
                }
                $.messager.confirm(TranslateDataMTHD('Info', '提示', ''), TranslateDataMTHD('Do you want to delete the selected data', '是否要删除选择的数据?', '') , function (r) {
                    if (r) {
                		//开启等待
                		$.messager.progress({ text: TranslateDataMTHD("Deleting data","正在删除数据", ""), interval: 500 });
                		setTimeout(function () {
                    		$.messager.progress('close');
                		}, 8000);
                		//往后台提交数据
                		$.ajax({
                    		type: "post",
                    		dataType: "json",
                    		cache: false, //
                    		async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
                    		url: me.actionUrl + '?Method=DeleteJRTPrintImage',
                    		data: { RowIDS: RowIDS },
                    		success: function (data, status) {
                        		$.messager.progress('close');
                        		if (!FilterBackData(data)) {
                            		return;
                        		}
                        		if (!data.IsOk) {
                            		$.messager.alert(TranslateDataMTHD("Error message", "错误提示", ""), TranslateDataMTHD("failed to dalete data, error message:", "删除失败,错误信息:", "") + data.Message);
                        		}
                        		else {
                            		QryJRTPrintImage();
                            		$.messager.show({
                                		title: TranslateDataMTHD("Info", "提示", ""),
                               		 	msg: TranslateDataMTHD("Successfully deleted!", "删除成功!", ""),
                                		timeout: 500,
                                		showType: 'slide'
                            		});
                        		}
                    		}
                		});
                    }
                });
            });


            //保存数据
            $("#btnSaveJRTPrintImage").click(function () {
                var saveData = jQuery.parseJSON($("#formJRTPrintImage").serializeObject());
                //开启等待
                $.messager.progress({ text: TranslateDataMTHD("Saving data","正在保存数据", ""), interval: 500 });
                setTimeout(function () {
                    $.messager.progress('close');
                }, 8000);
                //往后台提交数据
                $.ajax({
                    type: "post",
                    dataType: "json",
                    cache: false, //
                    async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
                    url: me.actionUrl + '?Method=SaveJRTPrintImage',
                    data: saveData,
                    success: function (data, status) {
                        $.messager.progress('close');
                        if (!FilterBackData(data)) {
                            return;
                        }
                        if (!data.IsOk) {
                            $.messager.alert(TranslateDataMTHD("Error message", "错误提示", ""), TranslateDataMTHD("failed to dalete data, error message:", "删除失败,错误信息:", "") + data.Message);
                        }
                        else {
                            QryJRTPrintImage();
                            $.messager.show({
                                title: TranslateDataMTHD("Info", "提示", ""),
                                msg: TranslateDataMTHD("Successfully saveed!", "保存成功!", ""),
                                timeout: 500,
                                showType: 'slide'
                            });
                            $('#winEditJRTPrintImage').window("close");
                        }
                    }
                });
            });


            //关闭窗口
            $("#btnCloseJRTPrintImage").click(function () {
				$('#winEditJRTPrintImage').window("close");
            });


            //构造查询事件
            $("#txtFilterJRTPrintImage").searchbox({
                searcher: function (value, name) {
                    QryJRTPrintImage();
                },
                prompt: TranslateDataMTHD('Enter query', '回车查询', '')
            });



            //开始日期日期渲染
            $('#txtJRTPrintImageStartDate').datebox({
                required:false,
                editable: true,
                width: 205,
                formatter: DateFormatter,
                parser: DateParser
            });
            //设置默认日期
            $('#txtJRTPrintImageStartDate').datebox("setValue",GetCurentDate())

            //结束日期日期渲染
            $('#txtJRTPrintImageEndDate').datebox({
                required:false,
                editable: true,
                width: 205,
                formatter: DateFormatter,
                parser: DateParser
            });
            //设置默认日期
            $('#txtJRTPrintImageEndDate').datebox("setValue",GetCurentDate())

            //JRTPrintImage表格
            $('#dgJRTPrintImage').datagrid({
                remoteSort:false,
                singleSelect: true,
                toolbar: "#dgJRTPrintImageToolBar",
                fit: true,
                onSelect: function (index, row) {
                    //方便拷贝到子表查询用
                	var selectJRTPrintImage=$('#dgJRTPrintImage').datagrid("getSelected");
                },
                onDblClickRow: function (index, row) {
                    UpdateJRTPrintImage(row);
                },

                columns: [[
                    { field: 'ChkFlag', title: TranslateDataMTHD('Check', '选择', ''), width: 20, sortable: true, align: 'center', checkbox: true },
                    { field: 'RowID', title: TranslateDataMTHD('RowID', '主键', '') , width: 150, sortable: true },
                    { field: 'Code', title: TranslateDataMTHD('Code', '代码', '') , width: 150, sortable: true },
                    { field: 'CName', title: TranslateDataMTHD('CName', '名称', '') , width: 150, sortable: true },
                    { field: 'ProductGroup', title: TranslateDataMTHD('ProductGroup', '产品组唯一标识', '') , width: 150, sortable: true },
                    { field: 'ProductBllID', title: TranslateDataMTHD('ProductBllID', '产品组存的业务ID', '') , width: 150, sortable: true },
                    { field: 'StartDate', title: TranslateDataMTHD('StartDate', '开始日期', '') , width: 150, sortable: true },
                    { field: 'EndDate', title: TranslateDataMTHD('EndDate', '结束日期', '') , width: 150, sortable: true },
                    { field: 'ImgBase64String', title: TranslateDataMTHD('ImgBase64String', '图片Base64串', '') , width: 150, sortable: true },
                    { field: 'ImgType', title: TranslateDataMTHD('ImgType', '图片类别', '') , width: 150, sortable: true }
                ]]
            });


            //查询JRTPrintImage
            function QryJRTPrintImage() {
                var Filter = $("#txtFilterJRTPrintImage").searchbox("getValue");
                //开启等待,默认注释,在单击事件调用的逻辑启用等待会冲掉双击事件,按需要开启
                //$.messager.progress({ text: TranslateDataMTHD("Querying data","正在查询数据", ""), interval: 500 });
                //setTimeout(function () {
                    //$.messager.progress('close');
                //}, 8000);
                $.ajax({
                    type: "post",
                    dataType: "json",
                    cache: false, //
                    async: true, //为true时,异步,不等待后台返回值,为false时强制等待;-asir
                    url: me.actionUrl + '?Method=QryJRTPrintImage',
                    data: { Filter: Filter },
                    success: function (data, status) {
                        //结束等待
                        //$.messager.progress('close');
                        if (!FilterBackData(data)) {
                           return;
                        }
                        $('#dgJRTPrintImage').datagrid("loadData", data);
                    }
                });
            };


            //执行查询数据
            QryJRTPrintImage();


		});
    </script>
</head>
<body>
    <div class="easyui-layout" fit="true" style="border: none;">
        <div data-options="region:'center',title:''" style="border: none;">
            <div id="dgJRTPrintImageToolBar" style="padding: 3px 0px 3px 10px;">
                <a id="btnAddJRTPrintImage" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" plain="true" listranslate="html~Add">新增</a>
                <a id="btnUpdateJRTPrintImage" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-write-order'" plain="true" listranslate="html~Mod">修改</a>
                <a id="btnDeleteJRTPrintImage" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" plain="true" listranslate="html~Del">删除</a>
                <input id="txtFilterJRTPrintImage" style="margin-left: 14px; width: 240px;"></input>
            </div>
            <table id="dgJRTPrintImage" title="" iconcls="icon-paper" listranslate="title~JRTPrintImage"></table>
        </div>
        <div id="winEditJRTPrintImage" style="padding: 10px 0px 0px 10px;width:770px;height:286.5px;display: none;">
            <form id="formJRTPrintImage" name="edit_form" method="post">
                <input type="hidden" id="txtJRTPrintImageRowID" name="RowID" value="0" />
                <table>
                    <tr>
                        <td class="lisar" jrttranslate="html~Code">代码</td>
                        <td class="lisal"><input id="txtJRTPrintImageCode" type="text" name="Code" style="width:200px;" class="easyui-validatebox"  maxlength="20"/></td>
                        <td class="lisar" jrttranslate="html~CName">名称</td>
                        <td class="lisal"><input id="txtJRTPrintImageCName" type="text" name="CName" style="width:200px;" class="easyui-validatebox"  maxlength="40"/></td>
                    </tr>
                    <tr>
                        <td class="lisar" jrttranslate="html~ProductGroup">产品组唯一标识</td>
                        <td class="lisal"><input id="txtJRTPrintImageProductGroup" type="text" name="ProductGroup" style="width:200px;" class="easyui-validatebox"  maxlength="30"/></td>
                        <td class="lisar" jrttranslate="html~ProductBllID">产品组存的业务ID</td>
                        <td class="lisal"><input id="txtJRTPrintImageProductBllID" type="text" name="ProductBllID" style="width:200px;" class="easyui-validatebox"  maxlength="30"/></td>
                    </tr>
                    <tr>
                        <td class="lisar" jrttranslate="html~StartDate">开始日期</td>
                        <td class="lisal"><input id="txtJRTPrintImageStartDate" type="text" name="StartDate" style="width:200px;" class="easyui-validatebox"  maxlength="10"/></td>
                        <td class="lisar" jrttranslate="html~EndDate">结束日期</td>
                        <td class="lisal"><input id="txtJRTPrintImageEndDate" type="text" name="EndDate" style="width:200px;" class="easyui-validatebox"  maxlength="10"/></td>
                    </tr>
                    <tr>
                        <td class="lisar" jrttranslate="html~ImgBase64String">图片Base64串</td>
                        <td class="lisal"><input id="txtJRTPrintImageImgBase64String" type="text" name="ImgBase64String" style="width:200px;" class="easyui-validatebox"  maxlength="827670"/></td>
                        <td class="lisar" jrttranslate="html~ImgType">图片类别</td>
                        <td class="lisal"><input id="txtJRTPrintImageImgType" type="text" name="ImgType" style="width:200px;" class="easyui-validatebox"  maxlength="10"/></td>
                    </tr>
                </table>
                <div region="south" border="fale" style="text-align: center; padding: 5px 0 0;">
                    <a id="btnSaveJRTPrintImage" href="#" class="easyui-linkbutton" plain="false" listranslate="html~Save">保存</a>
                    <span class="sp6"></span>
                    <a id="btnCloseJRTPrintImage" href="#" class="easyui-linkbutton" plain="false" listranslate="html~Cancel">取消</a>
                </div>
            </form>
        </div>
</body>
</html>


后台

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;

/**
*由代码生成器生成的后台代码
*/
public class ashJRTPrintImage extends BaseHttpHandlerNoSession {

	/**
	 * 保存数据,前台按表的属性名提交
	 * @return 字符串
	 */
	public String SaveJRTPrintImage() throws Exception
    {
		JRTPrintImage dto=new JRTPrintImage();
		//主键
		dto.RowID=Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), dto.RowID);
		//代码
		dto.Code=Helper.ValidParam(JRTContext.GetRequest(Request, "Code"), dto.Code);
		//名称
		dto.CName=Helper.ValidParam(JRTContext.GetRequest(Request, "CName"), dto.CName);
		//产品组唯一标识
		dto.ProductGroup=Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), dto.ProductGroup);
		//产品组存的业务ID
		dto.ProductBllID=Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), dto.ProductBllID);
		//开始日期
		dto.StartDate=Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), dto.StartDate);
		//结束日期
		dto.EndDate=Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), dto.EndDate);
		//图片Base64串
		dto.ImgBase64String=Helper.ValidParam(JRTContext.GetRequest(Request, "ImgBase64String"), dto.ImgBase64String);
		//图片类别
		dto.ImgType=Helper.ValidParam(JRTContext.GetRequest(Request, "ImgType"), dto.ImgType);
		OutParam out=new OutParam();
		int ret=0;
		//更新
		if(dto.RowID>0)
		{
			ret=EntityManager().Update(dto,null, out, null, null, null);
		}
		//插入数据
		else
		{
			ret=EntityManager().Save(dto,out);
		}
		if(ret==1)
		{
			return Helper.Success();
		}
		else
		{
			return Helper.Error(out);
		}
    }



	/**
	 * 删除数据,多个RowID以上尖号分割
	 * @return 字符串
	 */
	public String DeleteJRTPrintImage() throws Exception
    {
		String RowIDS=Helper.ValidParam(JRTContext.GetRequest(Request, "RowIDS"), "");
		if(RowIDS.isEmpty())
		{
			return Helper.Error("请传入要删除数据的RowID,多个以^分割!");
		}
		//分割主键
		String [] arr=RowIDS.split("^");
		//out参数
		OutParam out=new OutParam();
		//循环删除数据
		for(int i=0;i<arr.length;i++)
		{
			int ret=EntityManager().RemoveById(JRTPrintImage.class,Convert.ToInt32(arr[i]),out);
			if(ret!=1)
			{
				return Helper.Error(out);
			}
		}
		return Helper.Success();
	}



	/**
	 * 查询数据,前台按表的属性名提交
	 * @return 字符串
	 */
	public String QryJRTPrintImage() throws Exception
    {
		//预留的取前台参数代码
		//参数
		List<ParamDto> para=new ArrayList<>();
		//sql连接符号
		List<String> joiner=new ArrayList<>();
		//sql比较符号
		List<String> operators=new ArrayList<>();
		//模糊查询
		String Filter=Helper.ValidParam(JRTContext.GetRequest(Request, "Filter"), "");
		//预留参数
		//主键
		String RowID=Helper.ValidParam(JRTContext.GetRequest(Request, "RowID"), "");
		//代码
		String Code=Helper.ValidParam(JRTContext.GetRequest(Request, "Code"), "");
		//名称
		String CName=Helper.ValidParam(JRTContext.GetRequest(Request, "CName"), "");
		//产品组唯一标识
		String ProductGroup=Helper.ValidParam(JRTContext.GetRequest(Request, "ProductGroup"), "");
		//产品组存的业务ID
		String ProductBllID=Helper.ValidParam(JRTContext.GetRequest(Request, "ProductBllID"), "");
		//开始日期
		String StartDate=Helper.ValidParam(JRTContext.GetRequest(Request, "StartDate"), "");
		//结束日期
		String EndDate=Helper.ValidParam(JRTContext.GetRequest(Request, "EndDate"), "");
		//图片Base64串
		String ImgBase64String=Helper.ValidParam(JRTContext.GetRequest(Request, "ImgBase64String"), "");
		//图片类别
		String ImgType=Helper.ValidParam(JRTContext.GetRequest(Request, "ImgType"), "");
		//模糊查询
		if(!Filter.isEmpty())
		{
			ParamDto p=null;
			//代码
			p=new ParamDto();
			p.Key="Code";
			p.Value="%"+Filter+"%";
			para.add(p);
			joiner.add("or");
			operators.add("like");
			//名称
			p=new ParamDto();
			p.Key="CName";
			p.Value="%"+Filter+"%";
			para.add(p);
			joiner.add("or");
			operators.add("like");
			//产品组唯一标识
			p=new ParamDto();
			p.Key="ProductGroup";
			p.Value="%"+Filter+"%";
			para.add(p);
			joiner.add("or");
			operators.add("like");
			//产品组存的业务ID
			p=new ParamDto();
			p.Key="ProductBllID";
			p.Value="%"+Filter+"%";
			para.add(p);
			joiner.add("or");
			operators.add("like");
			//图片Base64串
			p=new ParamDto();
			p.Key="ImgBase64String";
			p.Value="%"+Filter+"%";
			para.add(p);
			joiner.add("or");
			operators.add("like");
			//图片类别
			p=new ParamDto();
			p.Key="ImgType";
			p.Value="%"+Filter+"%";
			para.add(p);
			joiner.add("or");
			operators.add("like");
		}
		//调用查询
		String json=EntityManager().QueryAllWithFK(JRTPrintImage.class,para,"",true,-1,-1,"",joiner,operators);
		return json;
	}


}

哈哈哈

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1350688.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【jmeter】将上一个请求的结果作为下一个请求的参数

1、简介 ApacheJMeter是Apache组织开发的基于Java的压力测试工具。用于对软件做压力测试&#xff0c;它最初被设计用于Web应用测试但后来扩展到其他测试领域。它可以用于测试静态和动态资源例如静态文件、Java小服务程序、CGI脚本、Java对象、数据库&#xff0c;FTP服务器&…

Think-on-Graph—基于知识图谱的LLM推理

文章目录 背景动机LLM模型存在的问题LLM ⊕ \oplus ⊕KG范式的局限性 LLM ⊗ \otimes ⊗KG范式&#xff08;Think on Graph&#xff0c;ToG&#xff09;LLM ⊗ \otimes ⊗KG范式的过程ToG的三个阶段初始化实体提取关系及实体探索推理 例子及效果相关结论搜索深度和波束宽度对To…

Centos安装Kafka(KRaft模式)

1. KRaft引入 Kafka是一种高吞吐量的分布式发布订阅消息系统&#xff0c;它可以处理消费者在网站中的所有动作流数据。其核心组件包含Producer、Broker、Consumer&#xff0c;以及依赖的Zookeeper集群。其中Zookeeper集群是Kafka用来负责集群元数据的管理、控制器的选举等。 由…

大模型通向AGI,腾讯云携手业界专家探索创新应用新风向

引言 一年过去&#xff0c;ChatGPT 引发的 AGI 热潮丝毫未减。只是相对于最初推出时掀起的全民大模型热&#xff0c;如今关于该如何落地的讨论更多了起来。 随着算力、数据库、大数据等底层技术的发展&#xff0c;大模型的建设与在各个领域的应用正在加速推进&#xff0c;那么…

SaleSmartly获得了Meta Business Partners认证徽章

近日&#xff0c;SaleSmartly通过了社交网络服务巨头Meta在消息领域的Business Partners认证&#xff0c;这项权威且重要的认证进一步证实了SaleSmartly在消息管理领域的卓越实力和卓越成果。 Meta是一家美国互联网公司&#xff0c;旗下拥有Facebook、Instagram、WhatsApp等社交…

YOLOv8改进 | 注意力篇 | ACmix自注意力与卷积混合模型(提高FPS+检测效率)

一、本文介绍 本文给大家带来的改进机制是ACmix自注意力机制的改进版本&#xff0c;它的核心思想是&#xff0c;传统卷积操作和自注意力模块的大部分计算都可以通过1x1的卷积来实现。ACmix首先使用1x1卷积对输入特征图进行投影&#xff0c;生成一组中间特征&#xff0c;然后根…

项目引入Jar包的几种方式

目录 背景 方式一 前提 创建一个jar包 使用 方式二 背景 通常情况下&#xff0c;使用SpringBoot框架开发项目的过程中&#xff0c;需要引入一系列依赖&#xff0c;首选的就是在项目的 pom.xml 文件里面通过Maven坐标进行引入&#xff08;可以通过Maven的坐标引入jar包的前…

设计模式之工厂设计模式【创造者模式】

学习的最大理由是想摆脱平庸&#xff0c;早一天就多一份人生的精彩&#xff1b;迟一天就多一天平庸的困扰。各位小伙伴&#xff0c;如果您&#xff1a; 想系统/深入学习某技术知识点… 一个人摸索学习很难坚持&#xff0c;想组团高效学习… 想写博客但无从下手&#xff0c;急需…

今天用vite新建的vue3的项目 启动遇到报错

UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token ??at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18) (Use node --trace-warnings ... to show where the warning was created) (node:30304) UnhandledPromiseRejectionWarning: U…

数据库索引、三范式、事务

索引 索引&#xff08;Index&#xff09;是帮助 MySQL 高效获取数据的数据结构。常见的查询算法,顺序查找,二分查找,二叉排序树查找,哈希散列法,分块查找,平衡多路搜索树 B 树&#xff08;B-tree&#xff09;。 常见索引原则有 选择唯一性索引&#xff1a;唯一性索引的值是唯…

听GPT 讲Rust源代码--library/panic_unwind

File: rust/library/panic_unwind/src/seh.rs 在Rust源代码中&#xff0c;rust/library/panic_unwind/src/seh.rs这个文件的作用是实现Windows操作系统上的SEH&#xff08;Structured Exception Handling&#xff09;异常处理机制。 SEH是Windows上的一种异常处理机制&#xff…

c++ / day04

1. 整理思维导图 2. 全局变量&#xff0c;int monster 10000;定义英雄类hero&#xff0c;受保护的属性string name&#xff0c;int hp,int attck&#xff1b;公有的无参构造&#xff0c;有参构造&#xff0c;虚成员函数 void Atk(){blood-0;}&#xff0c;法师类继承自英雄类&a…

七功能遥控编解码芯片

一、基本概述 TT6/TR6 是一对为遥控玩具车设计的 CMOS LSI 芯片。TT6 为发射编码芯片&#xff0c;TR6 为接收解码芯片。TT6/TR6 提供七个功能按键控制前进、后退、左转、右转、加速、独立功能 F1,独立功能 F2 的动作。除此以外&#xff0c;还有这五种常规小车功能&#xff08;…

valgrind跨平台调试及其问题分析

背景 同事在项目中遇到了内存泄漏问题&#xff0c;长时间没有解决&#xff0c;领导临时让我支援一下。心想&#xff0c;应该不难&#xff0c;毕竟我之间做过valgrind的使用总结。并输出内存泄漏问题分析思路&#xff08;案例篇&#xff09;和快速定位内存泄漏的套路两篇文章&a…

关于Github部分下载的方法

一、问题 在Github中&#xff0c;我需要下载部分文件&#xff0c;而github只有下载最原始文件夹和单独文件的功能。 比如我想下载头四个文件&#xff0c;难以操作。 二、方法 推荐使用谷歌浏览器&#xff0c;进入扩展程序界面&#xff1a; 在应用商店获取GitZip for github…

理解SQL中not in 与null值的真实含义

A not in B的原理是拿A表值与B表值做是否不等的比较, 也就是a ! b. 在sql中, null是缺失未知值而不是空值。 当你判断任意值a ! null时, 官方说, “You cannot use arithmetic comparison operators such as , <, or <> to test for NULL”, 任何与null值的对比都将返…

Java基础综合练习(飞机票,打印素数,验证码,复制数组,评委打分,数字加密,数字解密,抽奖,双色球)

练习一&#xff1a;飞机票 需求: ​ 机票价格按照淡季旺季、头等舱和经济舱收费、输入机票原价、月份和头等舱或经济舱。 ​ 按照如下规则计算机票价格&#xff1a;旺季&#xff08;5-10月&#xff09;头等舱9折&#xff0c;经济舱8.5折&#xff0c;淡季&#xff08;11月到来…

菜鸟之MATLAB学习——QPSK OQPSK信号生成及频谱分析

本人MATLAB学习小白&#xff0c;仅做笔记记录和分享~~ % qpsk && oqpsk clc; close all;Ts1; fc10;N_sample16; N_sum100; dt1/fc/N_sample; t0:dt:N_sum*Ts-dt; Tdt*length(t);d1sign(randn(1,N_sum)); d2sign(randn(1,N_sum));gtones(1,fc*N_sample); …

反转链表、链表的中间结点、合并两个有序链表【LeetCode刷题日志】

一、反转链表 给你单链表的头节点 head &#xff0c;请你反转链表&#xff0c;并返回反转后的链表。 力扣&#xff08;LeetCode&#xff09;官网 - 全球极客挚爱的技术成长平台 思路一&#xff1a;翻转单链表指针方向 这里解释一下三个指针的作用&#xff1a; n1&#xff1…

【Linux驱动】设备树模型的LED驱动 | 查询方式的按键驱动

&#x1f431;作者&#xff1a;一只大喵咪1201 &#x1f431;专栏&#xff1a;《Linux驱动》 &#x1f525;格言&#xff1a;你只管努力&#xff0c;剩下的交给时间&#xff01; 目录 &#x1f36e;设备树模型的LED驱动&#x1f369;设备树文件&#x1f369;驱动程序 &#x1…