之前一直没建表专门使用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;}}
哈哈哈