JRT代码结构调整和示例

之前一直没建表专门使用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时强制等待;-asirurl: 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时强制等待;-asirurl: 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 }]]});//查询JRTPrintImagefunction 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时强制等待;-asirurl: 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);//产品组存的业务IDdto.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"), "");//产品组存的业务IDString 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");//产品组存的业务IDp=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.mzph.cn/news/593299.shtml

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

相关文章

向日葵远程控制软件MySQL5.7的安装与配置

目录 一. 向日葵远程控制软件 1.1 简介 1.2 选择原因 1.3 安装及使用 1.4 使用场景 二. MySQL5.7 安装与配置 2.1 什么是MySQL 2.2 安装 MySQL5.7 2.2.1 安装步骤 2.2.2 内部连接 2.2.3 外部连接 三. 思维导图 一. 向日葵远程控制软件 1.1 简介 向日葵电脑版是一款拥有多年…

Java基础-----集合类(四)

文章目录 1. Iterator和ListIterator1.1 简介1.2 常用方法 2. remove方法2.1 比较foreach方式和迭代器方式删除元素2.2 找原因 -- 迭代器删除操作源码 1. Iterator和ListIterator 1.1 简介 1.Iterator 可以遍历List集合&#xff0c;也可以遍历Set集合&#xff1b; ListIterat…

05-SpringCloud-RabbitMQ-概述

RabbitMQ 1.初识MQ 1.1.同步和异步通讯 微服务间通讯有同步和异步两种方式&#xff1a; 同步通讯&#xff1a;就像打电话&#xff0c;需要实时响应。 异步通讯&#xff1a;就像发邮件&#xff0c;不需要马上回复。 两种方式各有优劣&#xff0c;打电话可以立即得到响应&am…

Linux安装rabbitMq RPM安装 以及带延迟插件

rabbitmq安装 文档中rabbitmq下载链接 以及延迟插件 网盘下载 目前下载文件中版本已经过多个服务器安装测试 完全成功 1.安装执行 rpm -ivh openssl-libs-1.0.2k-19.el7.x86_64.rpm --force --nodeps rpm -ivh libnsl-2.34-28.el9_0.x86_64.rpm --force --nodeps rpm -ivh e…

京东商品详情API:数据分析和挖掘以优化销售策略

京东商品详情API提供的数据分析和挖掘功能可以帮助商家优化销售策略&#xff0c;提高销售额和用户转化率。以下是一些可能的应用场景&#xff1a; 商品关联分析&#xff1a;通过分析商品之间的关联规则&#xff0c;商家可以发现哪些商品经常一起被购买&#xff0c;从而制定捆绑…

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…

跟cherno手搓游戏引擎【1】:配置与入口点

环境配置&#xff1a; 编译环境&#xff1a;VS2019 创建两个项目&#xff1a; 设置Sandbox为启动项&#xff1a; 设置sandbox的配置属性-常规-输出目录\中间目录为如下&#xff1a; 预处理定义&#xff1a;为了配置一些只有windows才能用的函数。 设置YOTOEngin&#xff08;我…

【大数据HA】keepalived结合haproxy实现高可用的HMS

背景 上一篇实现了haproxy代理后端HMS服务实现高可用。但是对于haproxy还是单点故障&#xff0c;所以需要对haproxy进一步做HA&#xff0c;实现真正的后端服务的HA。 要实现haproxy的HA&#xff0c;需要使用到keepalived&#xff0c;使用keepalived是VIP虚拟IP服务&#xff0…

【2023 CCF 大数据与计算智能大赛】基于TPU平台实现超分辨率重建模型部署 基于预训练ESPCN的轻量化图像超分辨率模型TPU部署方案

2023 CCF 大数据与计算智能大赛 《基于TPU平台实现超分辨率重建模型部署》 作品名&#xff1a;基于预训练ESPCN的轻量化图像超分辨率模型TPU部署方案 队伍名&#xff1a;Absofastlutely 蒋松儒 计算机科学与技术系 硕士 南京大学 中国-江苏 kahsoltqq.com 吕欢欢 计算…

经典卷积神经网络-VGGNet

经典卷积神经网络-VGGNet 一、背景介绍 VGG是Oxford的Visual Geometry Group的组提出的。该网络是在ILSVRC 2014上的相关工作&#xff0c;主要工作是证明了增加网络的深度能够在一定程度上影响网络最终的性能。VGG有两种结构&#xff0c;分别是VGG16和VGG19&#xff0c;两者并…

01-SpringCloud微服务入门

1.认识微服务 随着互联网行业的发展&#xff0c;对服务的要求也越来越高&#xff0c;服务架构也从单体架构逐渐演变为现在流行的微服务架构。这些架构之间有怎样的差别呢&#xff1f; 1.1.单体架构 单体架构&#xff1a;将业务的所有功能集中在一个项目中开发&#xff0c;打…

如何利用Oracle官方网站不登录账号下载和安装非最新版本的JDK(版本自由选择)

一、JDK概述 JDK(Java Development Kit)是Java开发工具集,是针对Java编程语言的软件开发环境。它包含了Java编译器、JRE(Java运行时环境)以及其他一些用于开发、调试和测试Java应用程序的工具,是Java开发人员的必备工具。 二、JDK下载 进入Oracle官方网站,我们很容易发…

桌面天气预报软件 Weather Widget free mac特点介绍

Weather Widget free for Mac多种吸引人的小部件设计可供选择&#xff0c;可以随时了解天气&#xff01;还可以在Dock和菜单栏中为您提供简短的天气预报或当前状况的概述。 Weather Widget free for Mac软件介绍 始终在桌面上使用时尚的天气小部件来随时了解天气&#xff01;多…

逻辑回归(LR)----机器学习

基本原理 逻辑回归&#xff08;Logistic Regression&#xff0c;LR&#xff09;也称为"对数几率回归"&#xff0c;又称为"逻辑斯谛"回归。 logistic回归又称logistic 回归分析 &#xff0c;是一种广义的线性回归分析模型&#xff0c;常用于数据挖掘&#…

FA发放云桌面并与FC对接

&#xff08;7&#xff09;分配桌面&#xff08;该组为刚刚创建的域名用户和组&#xff09;&#xff0c;确认无误&#xff0c;直接发放 &#xff08;8&#xff09;可在任务中心查看发放的进度 3、FA的登录流程 &#xff08;1&#xff09;登录WI&#xff1a;客户端访问VLB&…

springcloud alibaba整合sentinel并结合dashboard控制面板设置规则

目录 一、springcloud alibaba整合sentinel二、采用代码方式设置流控规则三、结合dashboard控制面板设置规则3.1、准备工作3.2、设置全局异常处理3.3、编写测试接口3.4、结合dashboard控制面板设置规则3.4.1、流控规则设置并测试——QPS3.4.2、流控规则设置并测试——线程数3.4…

【Unity嵌入Android原生工程】

Unity嵌入Android原生工程 本章学习,Unity模块嵌入Android## 标题Unity导出Android工程创建Android Studio工程Unity嵌入到Andorid StudioAndroid原生代码跳转到Unity场景工作需要嵌入原生工程,并实现热更,记录一下 工具,Unity2023.3.14,Android Studio 2022.3.1 patch3 Un…

《JVM由浅入深学习【四】 2023-12-24》JVM由简入深学习提升分享

JVM由简入深学习提升分享四 1.JVM中java堆的特点及作用2. JVM中对象如何在堆内存中分配3. JVM堆内存中的对象布局 1.JVM中java堆的特点及作用 是线程共享的一块区域虚拟机启动时就创建了是虚拟机中内存占用很大的一块存放所有的实例对象和数组GC主要的作用区域可分为新生代&am…

初学者快速入门学习日语,PDF文档音频教学资料合集

一、资料描述 本套学习资料是很全面的&#xff0c;共有734份文件&#xff0c;包括PDF&#xff0c;PPT&#xff0c;表格&#xff0c;图片&#xff0c;音频等多种格式&#xff0c;可以作为初级日语的学习教材&#xff0c;也是非常适合初学者入门的&#xff0c;可以帮助大家快速的…

Nginx(十三) 配置文件详解 - 反向代理(超详细)

本篇文章主要讲ngx_http_proxy_module和ngx_stream_proxy_module模块下各指令的使用方法。 1. 代理请求 proxy_pass 1.1 proxy_pass 代理请求 Syntax: proxy_pass URL; Default: — Context: location, if in location, limit_except 设置代理服务器的协议和地址以…