之前已经实现了JRT实体编译的菜单,用Linux指令编译放在网站下的实体代码。那么就有个问题,有人就是直接换实体jar文件不修改网站的实体代码。或者就只修改实体代码不编译搁置在那里,那么后面更新实体的人就得给别人背锅,后面人新编译实体导致使用的实体丢代码或者把别人放着一半的代码编译进去了,为了避免这种背锅的情况产生,提供实体比对功能。编译实体之前先比对当前网站的实体代码和实体jar包是否一致。
实现比对,实体编译的时候把源码也放进了jar包
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
* 编译JRT架构下的实体jar包,编译的实体工程文件和代码放在Web的CompileModel下面,驱动java -cp D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel BuildModel JRT.Model来编译,
* JRT.Model为实体的文件名称,将借助此工具实现JRT的业务脚本化目标部分的实体代码脚本化部分,在Web下的CompileModel放实体代码,需要改实体时候修改代码后运行jrt命令选8编译实体即可,
* 实体的业务脚本化不采用自动编译的模式,和普通业务脚本的差别就是让人命令执行
*/
public class BuildModel {
/**
* 实体名称
*/
private static String ModeDirName = "JRT.Model";
/**
* 实体编译入口
*
* @param args
*/
public static void main(String[] args) {
try {
//检查参数
if (args == null || args.length == 0) {
System.out.println("请传入实体文件夹名字");
return;
} else {
ModeDirName = args[0];
}
//创建编译对象
BuildModel bl = new BuildModel();
if (args.length > 1) {
//比对实体
if (args[1].equals("compare")) {
List<String> javaList = bl.CompareAllJavas();
return;
}
}
System.out.println("开始编译实体...");
//开始编译
bl.BuildJava();
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
}
/**
* 得到再用的实体里面所有的java类路径
*
* @return
* @throws Exception
*/
public List<String> CompareAllJavas() throws Exception {
List<String> javas = new ArrayList<>();
//得到.class所在的路径CompileModel
String srcpath = this.getClass().getResource("").getPath();
String curPath = new File(srcpath).toString();
//上一级是Web的路径
String webPath = new File(curPath).getParent();
File fiBase = new File(webPath);
String parentPath = fiBase.getParent();
//到webapps一级
File fiParent = new File(parentPath);
//到WebSrc一级
File fiParent1 = new File(fiParent.getParent());
//jar包存放路径
String bashePath = Paths.get(fiParent1.toString(), "lib").toString() + File.separator;
System.out.println("jar包路径:" + bashePath);
//组装成jar包路径
String jarPath = bashePath + ModeDirName + ".jar";
File file = new File(jarPath);
if (!file.exists()) {
throw new Exception("未能找到" + jarPath + "的文件");
}
//实体根路径
String modeldir = Paths.get(curPath, ModeDirName).toString();
//遍历文件
List<String> newCodes = SeeFile(new File(modeldir), ".java");
//不一致数量
int notEquealNum = 0;
try (JarFile jarFile = new JarFile(jarPath)) {
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.getName().endsWith(".java")) {
InputStream inputStream = jarFile.getInputStream(entry);
Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader bufferedReader = new BufferedReader(reader);
StringBuilder contentBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
contentBuilder.append(line + System.lineSeparator());
}
String oldCode = contentBuilder.toString();
//新实体路径
String newCodePath = GetNewCodePath(entry.getName(), curPath);
String newCode = "";
File fi = new File(newCodePath);
//新实体代码
if (fi.exists()) {
newCode = ReadTextStr(newCodePath);
}
//移除都有的文件名称,最后剩余的就是新代码多加的类
if (newCodes.contains(newCodePath)) {
newCodes.remove(newCodePath);
}
if (!oldCode.equals(newCode)) {
System.out.println("-------------------------------------------------------------------------------------------------------");
System.out.println(entry.getName() + "代码不一致");
System.out.println("老代码:");
System.out.println(oldCode);
System.out.println("新代码:");
System.out.println(newCode);
System.out.println("-------------------------------------------------------------------------------------------------------");
System.out.println("");
notEquealNum++;
}
bufferedReader.close();
reader.close();
}
}
}
//新代码比老代码多的部分
if (newCodes.size() > 0) {
System.out.println("******************************************************************************************");
System.out.println("以下实体是老代码没有的,新代码有的实体");
for (String s : newCodes) {
System.out.println("-------------------------------------------------------------------------------------------------------");
System.out.println("新代码:");
String newCode = ReadTextStr(s);
System.out.println(newCode);
System.out.println("-------------------------------------------------------------------------------------------------------");
System.out.println("");
notEquealNum++;
}
}
if (notEquealNum == 0) {
System.out.println("当前使用的实体和代码没差异");
} else {
System.out.println("当前使用的实体和代码有" + notEquealNum + "个差异,请比对后再编译");
}
return javas;
}
/**
* 得到新的实体代码路径
*
* @param path jar包类的相对路径
* @param modelPath 实体根路径
* @return
* @throws Exception
*/
private String GetNewCodePath(String path, String modelPath) throws Exception {
String[] arr = path.split("/");
String codePath = Paths.get(modelPath, ModeDirName).toString();
if (arr.length > 2) {
for (int i = 2; i < arr.length; i++) {
codePath = Paths.get(codePath, arr[i]).toString();
}
}
return codePath;
}
/**
* 读取文本
*
* @param path 路径
* @return
*/
public String ReadTextStr(String path) throws Exception {
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(path)), "UTF-8"));
String str = null;
while ((str = br.readLine()) != null) {
sb.append(str + System.lineSeparator());
}
} catch (IOException e) {
throw e;
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
/**
* 编译java代码
*
* @throws Exception
*/
public void BuildJava() throws Exception {
//得到.class所在的路径CompileModel
String srcpath = this.getClass().getResource("").getPath();
String curPath = new File(srcpath).toString();
//上一级是Web的路径
String webPath = new File(curPath).getParent();
//编译成功了就生成这样的文件表示成功
String successFilePath = Paths.get(curPath, "buildsuccess.jrt").toString();
File successFile = new File(successFilePath);
//删删除成功标志
if (successFile.exists()) {
successFile.delete();
}
//编译执行
int retcode = BuildJavaDo(webPath, curPath);
//编译成功
if (retcode == 0) {
successFile.createNewFile();
}
System.out.println("编译结束返回:" + retcode);
}
/**
* 编译java执行
*
* @param webPath 网站路径
* @param curPath 编译程序class所在路径
* @return 返回0编译成功
* @throws Exception
*/
private int BuildJavaDo(String webPath, String curPath) throws Exception {
File fiBase = new File(webPath);
String parentPath = fiBase.getParent();
//到webapps一级
File fiParent = new File(parentPath);
//到WebSrc一级
File fiParent1 = new File(fiParent.getParent());
//jar包存放路径
String libPath = Paths.get(fiParent1.toString(), "lib").toString() + File.separator;
System.out.println("jar包路径:" + libPath);
String cmd = "javac -encoding UTF-8 -classpath ";
//实体代码文件夹
String modelPath = Paths.get(curPath, ModeDirName).toString();
//实体代码工程文件
String imlFile = Paths.get(modelPath, ModeDirName + ".iml").toString();
//判断配置是否存在
File iml = new File(imlFile);
if (!iml.exists()) {
System.out.println(imlFile + "文件不存在,请确认!");
return -1;
}
//解析xml
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(iml);
//获得根节点
Element rootElement = document.getDocumentElement();
//获得根节点下的所有子节点
NodeList students = rootElement.getElementsByTagName("component");
String classPath = "";
String sp = ";";
if (IsOSLinux()) {
sp = ":";
}
//解析配置,得到依赖jar包
for (int i = 0; i < students.getLength(); i++) {
//由于节点多种类型,而一般我们需要处理的是元素节点
Node childNode = students.item(i);
//元素节点就是非空的子节点,也就是还有孩子的子节点
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element childElement = (Element) childNode;
NodeList children = childElement.getChildNodes();
for (int k = 0; k < children.getLength(); k++) {
Node child = children.item(k);
if (child.getNodeType() == Node.ELEMENT_NODE) {
childElement = (Element) child;
//不是对象配置元素就忽略
if (childElement.getNodeName() != "orderEntry") {
continue;
}
//解析得到包名
String name = childElement.getAttribute("name");
String type = childElement.getAttribute("type");
if (!type.equals("library")) {
continue;
}
String oneJarPath = Paths.get(libPath, name + ".jar").toString();
if (classPath == "") {
classPath = oneJarPath;
} else {
classPath += sp + oneJarPath;
}
}
}
}
}
//遍历目录下所有java文件,组装成路径串,英文,分割路径
File modeldir = new File(modelPath);
System.out.println("查找:" + modeldir + "下的.java文件");
//遍历文件
List<String> files = SeeFile(modeldir, ".java");
int execode = -1;
Runtime exe = Runtime.getRuntime();
//循环遍历路径编译文件
if (files.size() > 0) {
System.out.println("找到:" + files.size() + "个.java文件");
String pathstr = "";
int count = 0;
for (int i = 0; i < files.size(); i++) {
String path = files.get(i);
//空路径退出
if (path.isEmpty()) {
continue;
}
if (pathstr.isEmpty()) {
pathstr = path;
} else {
pathstr = pathstr + " " + path;
}
count++;
//一次编译100个文件,太多文件导致串太长,编译报错
if (((count) % 100 == 0) || ((i + 1) == files.size())) {
System.out.println("执行编译:" + i + 1);
String execcmd = cmd + classPath + " " + pathstr;
//执行编译命令
execode = Exec(exe, execcmd, webPath);
pathstr = "";
if (execode != 0) {
break;
}
}
}
System.out.println("编译结束!");
} else {
execode = 0;
System.out.println("找到:" + files.size() + "个.java文件");
System.out.println("没有需要编译的.java文件");
}
//编译成功,打包编译的class文件为jar包
if (execode == 0) {
System.out.println("编译成功!");
String modelpath = Paths.get(curPath, ModeDirName).toString();
String jarFileStr = ModeDirName + ".jar";
//临时目录
Path tmppath = Paths.get(curPath, "ModelTmp");
if (!tmppath.toFile().exists()) {
Files.createDirectory(tmppath);
}
String[] modelArr = ModeDirName.split("\\.");
Path tmpmodel = Paths.get(tmppath.toString(), modelArr[0], modelArr[1]);
//没有的路径就创建
if (!tmpmodel.toFile().exists()) {
Files.createDirectories(tmpmodel);
}
//拷贝class文件到临时目录
Files.walk(Paths.get(modelpath)).filter(Files::isRegularFile).forEach((Path var) -> {
try {
File file = var.toFile();
String fileabpath = file.getAbsolutePath().replace(modelpath, tmpmodel.toString());
//不是.class和.java的退出
if (!fileabpath.endsWith(".class") && !fileabpath.endsWith(".java")) {
return;
}
Path par = Paths.get(fileabpath).getParent();
//没路径的创建
if (!par.toFile().exists()) {
Files.createDirectories(par);
}
//把class文件复制到新的目录,方便打包
Files.copy(var, Paths.get(fileabpath), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
});
System.out.println("打包:" + tmppath + "到:" + jarFileStr);
cmd = "jar cf " + jarFileStr + " -C " + tmppath + " .";
execode = Exec(exe, cmd, curPath);
if (execode == 0) {
System.out.println("打包完成!");
//打包完成清除class文件,减少网站目录的文件数
Files.walk(tmppath).filter(Files::isRegularFile).map(Path::toFile).forEach(File::deleteOnExit);
}
}
return execode;
}
/**
* 执行cmd命令
*
* @param exe
* @param cmd
* @param workdir
* @return
* @throws Exception
*/
private int Exec(Runtime exe, String cmd, String workdir) throws Exception {
if (workdir == null || workdir.isEmpty()) {
workdir = ".";
}
System.out.println("执行:" + cmd);
Process ps = exe.exec(cmd, null, Paths.get(workdir).toFile());
// 获取命令行程序的输出结果
StringBuilder retsb = new StringBuilder();
//windows默认gb18030编码读取错误信息
String charset = "gb18030";
if (IsOSLinux()) {
//linux用fut-8编码
charset = "utf-8";
}
BufferedReader reader = new BufferedReader(new InputStreamReader(ps.getErrorStream(), charset));
String line;
while ((line = reader.readLine()) != null) {
retsb.append(line);
}
int execode = ps.waitFor();
ps.destroy();
if (execode == 0) {
System.out.println("执行成功!");
} else {
System.out.println("执行失败!");
System.out.println(retsb);
}
return execode;
}
/**
* 判断OS
*
* @return 得到是否是Linux
*/
public static boolean IsOSLinux() {
Properties prop = System.getProperties();
String os = prop.getProperty("os.name");
if (os != null && os.toLowerCase().indexOf("linux") > -1) {
return true;
} else {
return false;
}
}
/**
* 扫描文件
*
* @param dir
* @param fileext
* @return
* @throws Exception
*/
public static List<String> SeeFile(File dir, String fileext) throws Exception {
ArrayList<String> list = new ArrayList<>();
if (!dir.exists()) return list;
if (dir.isFile()) {
list.add(dir.getPath());
return list;
}
Files.walk(dir.toPath()).filter(Files::isRegularFile).map(Path::toFile).forEach((File f) -> {
String file = f.getPath();
if (fileext != null && !fileext.isEmpty() && !file.toLowerCase().endsWith(fileext.toLowerCase())) {
return;
}
if (fileext.equals(".java")) {
String clspath = file.replace(".java", ".class");
File clsfile = new File(clspath);
if (clsfile.exists()) {
//java文件与之相应的class文件修改时间对比,class文件修改时间新就不编译
long clsmodtime = clsfile.lastModified();
long javamodtime = new File(file).lastModified();
if (clsmodtime > javamodtime) {
return;
}
}
}
list.add(f.getPath());
});
return list;
}
}
测试
D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel>
D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel>
D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel>
D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel>
D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel>java -cp D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel BuildModel JRT.Model compare
jar包路径:D:\JRTPlan\WebLoader\WebSrc\lib\
-------------------------------------------------------------------------------------------------------
JRT/Model/Entity/JRTPrintTemplate.java代码不一致
老代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/**
*[功能描述:本代码由LIS内部代码生成工具生成,请不要手动修改,如要修改,请写修改变更记录]
*[创建者:JRT.Entity生成器]
*/
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_PrintTemplate")
public class JRTPrintTemplate
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 模板代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 100)
public String Code;
/**
* 模板名称
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 100)
public String CName;
/**
* 产品组唯一标识
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 30)
public String ProductGroup;
/**
* 产品组存的业务ID
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 30)
public String ProductBllID;
/**
* 模板纸张
*/
@FrekeyAttribute(Name = "JRTPrintPaper", RefColumnName = "RowID", AssociaField = "CName")
@LengthAttribute(MaxLen = 10)
public Integer JRTPrintPaperDR;
/**
* 边距
*/
@LengthAttribute(MaxLen = 10)
public Double ResultLineSpacing;
/**
* 结果行数
*/
@LengthAttribute(MaxLen = 10)
public Integer ResultRows;
/**
* 结果列
*/
@LengthAttribute(MaxLen = 10)
public Integer ResultCols;
/**
* 纸张方向
*/
@LengthAttribute(MaxLen = 10)
public String PaperLayout;
/**
* 下边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperBottom;
/**
* 左边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperLeft;
/**
* 右边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperRight;
/**
* 上边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperTop;
/**
* 微生物边距
*/
@LengthAttribute(MaxLen = 10)
public Double MicResultLineSpacing;
/**
* 微生物行数
*/
@LengthAttribute(MaxLen = 10)
public Integer MicResultRows;
/**
* 微生物列数
*/
@LengthAttribute(MaxLen = 10)
public Integer MicResultCols;
/**
* 边距
*/
@LengthAttribute(MaxLen = 10)
public Double ArchivesMargin;
/**
* 双列填充类型
*/
@LengthAttribute(MaxLen = 10)
public String DoubleColFillType;
/**
* 序号
*/
@LengthAttribute(MaxLen = 10)
public Integer Sequence;
/**
* 父模板
*/
@FrekeyAttribute(Name = "JRTPrintTemplate", RefColumnName = "RowID", AssociaField = "CName")
@LengthAttribute(MaxLen = 10)
public Integer ParentTemplateDR;
/**
* 截止日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@DateAttribute
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 截止时间
*/
@JsonSerialize(using = JRTTimeSerializer.class)
@JsonDeserialize(using = JRTTimeDeserializer.class)
@TimeAttribute
@LengthAttribute(MaxLen = 10)
public Integer EndTime;
/**
* 截止说明
*/
@LengthAttribute(MaxLen = 50)
public String EndRemark;
}
新代码:
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
JRT/Model/Entity/JRTTask.java代码不一致
老代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_Task")
public class JRTTask
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 20)
public String Code;
/**
* 名称
*/
@LengthAttribute(MaxLen = 50)
public String CName;
/**
* 说明
*/
@LengthAttribute(MaxLen = 100)
public String Description;
/**
* 类型:SYS,USR
*/
@LengthAttribute(MaxLen = 5)
public String Type;
/**
* 执行脚本类
*/
@LengthAttribute(MaxLen = 100)
public String ScriptClass;
/**
* 执行脚本方法
*/
@LengthAttribute(MaxLen = 30)
public String ScriptMethod;
/**
* 优先级别:0:Normal, 1:Low, 2:High
*/
@LengthAttribute(MaxLen = 1)
public String Priority;
/**
* 是否有效
*/
@LengthAttribute(MaxLen = 10)
public Boolean Active;
/**
* 启用日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer StartDate;
/**
* 结束日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 任务周期类型:D(按天),W(按周),M(按月)
*/
@LengthAttribute(MaxLen = 1)
public String ScheduleType;
/**
* 任务周期间隔
*/
@LengthAttribute(MaxLen = 10)
public Integer ScheduleStep;
/**
* 任务周期内执行天数列表
*/
@LengthAttribute(MaxLen = 100)
public String ScheduleList;
/**
* 任务运行频率:0:一次,1:重复
*/
@LengthAttribute(MaxLen = 1)
public Integer ScheduleFrequency;
/**
* 任务运行频率时间
*/
@LengthAttribute(MaxLen = 10)
public Integer FrequencyTime;
/**
* 任务启动地址
*/
@LengthAttribute(MaxLen = 200)
public String RunAdddress;
}
新代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_Task")
public class JRTTask
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 20)
public String Code;
/**
* 名称
*/
@LengthAttribute(MaxLen = 50)
public String CName;
/**
* 说明
*/
@LengthAttribute(MaxLen = 100)
public String Description;
/**
* 类型:SYS,USR
*/
@LengthAttribute(MaxLen = 5)
public String Type;
/**
* 执行脚本类
*/
@LengthAttribute(MaxLen = 100)
public String ScriptClass;
/**
* 执行脚本方法
*/
@LengthAttribute(MaxLen = 30)
public String ScriptMethod;
/**
* 优先级别:0:Normal, 1:Low, 2:High
*/
@LengthAttribute(MaxLen = 1)
public String Priority;
/**
* 是否有效
*/
@LengthAttribute(MaxLen = 10)
public Boolean Active;
/**
* 启用日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer StartDate;
/**
* 结束日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 任务周期类型:D(按天),W(按周),M(按月)
*/
@LengthAttribute(MaxLen = 1)
public String ScheduleType;
/**
* 任务周期间隔
*/
@LengthAttribute(MaxLen = 10)
public Integer ScheduleStep;
/**
* 任务周期内执行天数列表
*/
@LengthAttribute(MaxLen = 100)
public String ScheduleList;
/**
* 任务运行频率:0:一次,1:重复
*/
@LengthAttribute(MaxLen = 1)
public Integer ScheduleFrequency;
/**
* 任务运行频率时间
*/
@LengthAttribute(MaxLen = 10)
public Integer FrequencyTime;
/**
* 任务启动地址
*/
@LengthAttribute(MaxLen = 200)
public String RunAdddress1;
}
-------------------------------------------------------------------------------------------------------
******************************************************************************************
以下实体是老代码没有的,新代码有的实体
-------------------------------------------------------------------------------------------------------
新代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_Task")
public class JRTTask1
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 20)
public String Code;
/**
* 名称
*/
@LengthAttribute(MaxLen = 50)
public String CName;
/**
* 说明
*/
@LengthAttribute(MaxLen = 100)
public String Description;
/**
* 类型:SYS,USR
*/
@LengthAttribute(MaxLen = 5)
public String Type;
/**
* 执行脚本类
*/
@LengthAttribute(MaxLen = 100)
public String ScriptClass;
/**
* 执行脚本方法
*/
@LengthAttribute(MaxLen = 30)
public String ScriptMethod;
/**
* 优先级别:0:Normal, 1:Low, 2:High
*/
@LengthAttribute(MaxLen = 1)
public String Priority;
/**
* 是否有效
*/
@LengthAttribute(MaxLen = 10)
public Boolean Active;
/**
* 启用日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer StartDate;
/**
* 结束日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 任务周期类型:D(按天),W(按周),M(按月)
*/
@LengthAttribute(MaxLen = 1)
public String ScheduleType;
/**
* 任务周期间隔
*/
@LengthAttribute(MaxLen = 10)
public Integer ScheduleStep;
/**
* 任务周期内执行天数列表
*/
@LengthAttribute(MaxLen = 100)
public String ScheduleList;
/**
* 任务运行频率:0:一次,1:重复
*/
@LengthAttribute(MaxLen = 1)
public Integer ScheduleFrequency;
/**
* 任务运行频率时间
*/
@LengthAttribute(MaxLen = 10)
public Integer FrequencyTime;
/**
* 任务启动地址
*/
@LengthAttribute(MaxLen = 200)
public String RunAdddress;
}
-------------------------------------------------------------------------------------------------------
当前使用的实体和代码有3个差异,请比对后再编译
D:\JRTPlan\WebLoader\WebSrc\webapps\JRTWeb\CompileModel>
整合进入jrt命令
[root@localhost ~]# jrt
欢迎使用jrt的linux命令呼出入口,通过jrt命令引导bash脚本
执行命令:bash /jrtbase/jrt.sh
+欢迎您使用jrt网站运维脚本
+该脚本致力于简化基于jrt框架的web在linux上运维
+常用菜单选项有1、2
+检验约定发布在8080端口
+在没有jrt命令的检验服务器运行bash /jrtbase/jrt.sh来第一次初始化jrt命令
+*************************************************JRTWeb网站配置工具************************************************************+
+ +
+ 1:重启Tomcat网站 +
+ +
+ 2:端口查看和开放,查看端口占用(lsof -i:8080) +
+ +
+ 3:查看网站进程信息 +
+ +
+ 8:编译实体 +
+ +
+ 9:常用命令帮助 +
+ +
+ 10:启动rsync服务 +
+ +
+ 11:停止Tomcat网站 +
+ +
+ 18:实体编译测试和代码比对 +
+ +
+ 发布后系统访问地址http://127.0.0.1:8080/JRTWeb/login/form/Login.aspx +
+ 小乌鱼 20231228 +
+*******************************************************************************************************************************+
请按菜单输入选择功能Ctrl+C退出:18
开始编译/jrtbase/webapps/JRTWeb/CompileModel的实体代码
执行命令:java -cp /jrtbase/webapps/JRTWeb/CompileModel BuildModel JRT.Model
开始编译实体...
jar包路径:/jrtbase/lib/
查找:/jrtbase/webapps/JRTWeb/CompileModel/JRT.Model下的.java文件
找到:8个.java文件
执行编译:71
编译结束返回:1
开始比对/jrtbase/webapps/JRTWeb/CompileModel的实体代码
执行命令:java -cp /jrtbase/webapps/JRTWeb/CompileModel BuildModel JRT.Model compare
jar包路径:/jrtbase/lib/
-------------------------------------------------------------------------------------------------------
JRT/Model/Entity/JRTPrintTemplate.java代码不一致
老代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/**
*[功能描述:本代码由LIS内部代码生成工具生成,请不要手动修改,如要修改,请写修改变更记录]
*[创建者:JRT.Entity生成器]
*/
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_PrintTemplate")
public class JRTPrintTemplate
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 模板代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 100)
public String Code;
/**
* 模板名称
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 100)
public String CName;
/**
* 产品组唯一标识
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 30)
public String ProductGroup;
/**
* 产品组存的业务ID
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 30)
public String ProductBllID;
/**
* 模板纸张
*/
@FrekeyAttribute(Name = "JRTPrintPaper", RefColumnName = "RowID", AssociaField = "CName")
@LengthAttribute(MaxLen = 10)
public Integer JRTPrintPaperDR;
/**
* 边距
*/
@LengthAttribute(MaxLen = 10)
public Double ResultLineSpacing;
/**
* 结果行数
*/
@LengthAttribute(MaxLen = 10)
public Integer ResultRows;
/**
* 结果列
*/
@LengthAttribute(MaxLen = 10)
public Integer ResultCols;
/**
* 纸张方向
*/
@LengthAttribute(MaxLen = 10)
public String PaperLayout;
/**
* 下边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperBottom;
/**
* 左边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperLeft;
/**
* 右边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperRight;
/**
* 上边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperTop;
/**
* 微生物边距
*/
@LengthAttribute(MaxLen = 10)
public Double MicResultLineSpacing;
/**
* 微生物行数
*/
@LengthAttribute(MaxLen = 10)
public Integer MicResultRows;
/**
* 微生物列数
*/
@LengthAttribute(MaxLen = 10)
public Integer MicResultCols;
/**
* 边距
*/
@LengthAttribute(MaxLen = 10)
public Double ArchivesMargin;
/**
* 双列填充类型
*/
@LengthAttribute(MaxLen = 10)
public String DoubleColFillType;
/**
* 序号
*/
@LengthAttribute(MaxLen = 10)
public Integer Sequence;
/**
* 父模板
*/
@FrekeyAttribute(Name = "JRTPrintTemplate", RefColumnName = "RowID", AssociaField = "CName")
@LengthAttribute(MaxLen = 10)
public Integer ParentTemplateDR;
/**
* 截止日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@DateAttribute
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 截止时间
*/
@JsonSerialize(using = JRTTimeSerializer.class)
@JsonDeserialize(using = JRTTimeDeserializer.class)
@TimeAttribute
@LengthAttribute(MaxLen = 10)
public Integer EndTime;
/**
* 截止说明
*/
@LengthAttribute(MaxLen = 50)
public String EndRemark;
}
新代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
/**
*[功能描述:本代码由LIS内部代码生成工具生成,请不要手动修改,如要修改,请写修改变更记录]
*[创建者:JRT.Entity生成器]
*/
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_PrintTemplate")
public class JRTPrintTemplate
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 模板代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 100)
public String Code;
/**
* 模板名称
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 100)
public String CName;
/**
* 产品组唯一标识
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 30)
public String ProductGroup;
/**
* 产品组存的业务ID
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 30)
public String ProductBllID;
/**
* 模板纸张
*/
@FrekeyAttribute(Name = "JRTPrintPaper", RefColumnName = "RowID", AssociaField = "CName")
@LengthAttribute(MaxLen = 10)
public Integer JRTPrintPaperDR;
/**
* 边距
*/
@LengthAttribute(MaxLen = 10)
public Double ResultLineSpacing;
/**
* 结果行数
*/
@LengthAttribute(MaxLen = 10)
public Integer ResultRows;
/**
* 结果列
*/
@LengthAttribute(MaxLen = 10)
public Integer ResultCols;
/**
* 纸张方向
*/
@LengthAttribute(MaxLen = 10)
public String PaperLayout;
/**
* 下边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperBottom;
/**
* 左边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperLeft;
/**
* 右边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperRight;
/**
* 上边距
*/
@LengthAttribute(MaxLen = 10)
public Double PaperTop;
/**
* 微生物边距
*/
@LengthAttribute(MaxLen = 10)
public Double MicResultLineSpacing;
/**
* 微生物行数
*/
@LengthAttribute(MaxLen = 10)
public Integer MicResultRows;
/**
* 微生物列数
*/
@LengthAttribute(MaxLen = 10)
public Integer MicResultCols;
/**
* 边距
*/
@LengthAttribute(MaxLen = 10)
public Double ArchivesMargin;
/**
* 双列填充类型
*/
@LengthAttribute(MaxLen = 10)
public String DoubleColFillType;
/**
* 序号
*/
@LengthAttribute(MaxLen = 10)
public Integer Sequence;
/**
* 父模板
*/
@FrekeyAttribute(Name = "JRTPrintTemplate", RefColumnName = "RowID", AssociaField = "CName")
@LengthAttribute(MaxLen = 10)
public Integer ParentTemplateDR;
/**
* 截止日期
*/
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 截止时间
*/
@LengthAttribute(MaxLen = 10)
public Integer EndTime;
/**
* 截止说明
*/
@LengthAttribute(MaxLen = 50)
public String EndRemark;
}
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
JRT/Model/Entity/JRTTask.java代码不一致
老代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_Task")
public class JRTTask
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 20)
public String Code;
/**
* 名称
*/
@LengthAttribute(MaxLen = 50)
public String CName;
/**
* 说明
*/
@LengthAttribute(MaxLen = 100)
public String Description;
/**
* 类型:SYS,USR
*/
@LengthAttribute(MaxLen = 5)
public String Type;
/**
* 执行脚本类
*/
@LengthAttribute(MaxLen = 100)
public String ScriptClass;
/**
* 执行脚本方法
*/
@LengthAttribute(MaxLen = 30)
public String ScriptMethod;
/**
* 优先级别:0:Normal, 1:Low, 2:High
*/
@LengthAttribute(MaxLen = 1)
public String Priority;
/**
* 是否有效
*/
@LengthAttribute(MaxLen = 10)
public Boolean Active;
/**
* 启用日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer StartDate;
/**
* 结束日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 任务周期类型:D(按天),W(按周),M(按月)
*/
@LengthAttribute(MaxLen = 1)
public String ScheduleType;
/**
* 任务周期间隔
*/
@LengthAttribute(MaxLen = 10)
public Integer ScheduleStep;
/**
* 任务周期内执行天数列表
*/
@LengthAttribute(MaxLen = 100)
public String ScheduleList;
/**
* 任务运行频率:0:一次,1:重复
*/
@LengthAttribute(MaxLen = 1)
public Integer ScheduleFrequency;
/**
* 任务运行频率时间
*/
@LengthAttribute(MaxLen = 10)
public Integer FrequencyTime;
/**
* 任务启动地址
*/
@LengthAttribute(MaxLen = 200)
public String RunAdddress;
}
新代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_Task")
public class JRTTask
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 20)
public String Code;
/**
* 名称
*/
@LengthAttribute(MaxLen = 50)
public String CName;
/**
* 说明
*/
@LengthAttribute(MaxLen = 100)
public String Description;
/**
* 类型:SYS,USR
*/
@LengthAttribute(MaxLen = 5)
public String Type;
/**
* 执行脚本类
*/
@LengthAttribute(MaxLen = 100)
public String ScriptClass;
/**
* 执行脚本方法
*/
@LengthAttribute(MaxLen = 30)
public String ScriptMethod;
/**
* 优先级别:0:Normal, 1:Low, 2:High
*/
@LengthAttribute(MaxLen = 1)
public String Priority;
/**
* 是否有效
*/
@LengthAttribute(MaxLen = 10)
public Boolean Active;
/**
* 启用日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer StartDate;
/**
* 结束日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 任务周期类型:D(按天),W(按周),M(按月)
*/
@LengthAttribute(MaxLen = 1)
public String ScheduleType;
/**
* 任务周期间隔
*/
@LengthAttribute(MaxLen = 10)
public Integer ScheduleStep;
/**
* 任务周期内执行天数列表
*/
@LengthAttribute(MaxLen = 100)
public String ScheduleList;
/**
* 任务运行频率:0:一次,1:重复
*/
@LengthAttribute(MaxLen = 1)
public Integer ScheduleFrequency;
/**
* 任务运行频率时间
*/
@LengthAttribute(MaxLen = 10)
public Integer FrequencyTime;
/**
* 任务启动地址
*/
@LengthAttribute(MaxLen = 200)
public String RunAdddress1;
}
-------------------------------------------------------------------------------------------------------
******************************************************************************************
以下实体是老代码没有的,新代码有的实体
-------------------------------------------------------------------------------------------------------
新代码:
package JRT.Model.Entity;
import JRT.Core.CustomAttributes.*;
import JRT.Core.JsonAttributes.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@UniqueAttribute(ColNames = "RowID")
@TableAttribute(Name="dbo.JRT_Task")
public class JRTTask1
{
/**
* 主键
*/
@NotNullAttribute
@IdAttribute(Name = "RowID")
@LengthAttribute(MaxLen = 10)
public int RowID;
/**
* 代码
*/
@NotNullAttribute
@LengthAttribute(MaxLen = 20)
public String Code;
/**
* 名称
*/
@LengthAttribute(MaxLen = 50)
public String CName;
/**
* 说明
*/
@LengthAttribute(MaxLen = 100)
public String Description;
/**
* 类型:SYS,USR
*/
@LengthAttribute(MaxLen = 5)
public String Type;
/**
* 执行脚本类
*/
@LengthAttribute(MaxLen = 100)
public String ScriptClass;
/**
* 执行脚本方法
*/
@LengthAttribute(MaxLen = 30)
public String ScriptMethod;
/**
* 优先级别:0:Normal, 1:Low, 2:High
*/
@LengthAttribute(MaxLen = 1)
public String Priority;
/**
* 是否有效
*/
@LengthAttribute(MaxLen = 10)
public Boolean Active;
/**
* 启用日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer StartDate;
/**
* 结束日期
*/
@JsonSerialize(using = JRTDateSerializer.class)
@JsonDeserialize(using = JRTDateDeserializer.class)
@LengthAttribute(MaxLen = 10)
public Integer EndDate;
/**
* 任务周期类型:D(按天),W(按周),M(按月)
*/
@LengthAttribute(MaxLen = 1)
public String ScheduleType;
/**
* 任务周期间隔
*/
@LengthAttribute(MaxLen = 10)
public Integer ScheduleStep;
/**
* 任务周期内执行天数列表
*/
@LengthAttribute(MaxLen = 100)
public String ScheduleList;
/**
* 任务运行频率:0:一次,1:重复
*/
@LengthAttribute(MaxLen = 1)
public Integer ScheduleFrequency;
/**
* 任务运行频率时间
*/
@LengthAttribute(MaxLen = 10)
public Integer FrequencyTime;
/**
* 任务启动地址
*/
@LengthAttribute(MaxLen = 200)
public String RunAdddress;
}
-------------------------------------------------------------------------------------------------------
当前使用的实体和代码有3个差异,请比对后再编译
+*************************************************JRTWeb网站配置工具************************************************************+
+ +
+ 1:重启Tomcat网站 +
+ +
+ 2:端口查看和开放,查看端口占用(lsof -i:8080) +
+ +
+ 3:查看网站进程信息 +
+ +
+ 8:编译实体 +
+ +
+ 9:常用命令帮助 +
+ +
+ 10:启动rsync服务 +
+ +
+ 11:停止Tomcat网站 +
+ +
+ 18:实体编译测试和代码比对 +
+ +
+ 发布后系统访问地址http://127.0.0.1:8080/JRTWeb/login/form/Login.aspx +
+ 小乌鱼 20231228 +
+*******************************************************************************************************************************+
请按菜单输入选择功能Ctrl+C退出:
实体编译的问题就完全解决了