提交 200f1b52 编写于 作者: sq3536's avatar sq3536

aipvo

上级 f463a037
......@@ -140,11 +140,17 @@ public class AppEntityModel extends BaseModel{
return this;
}
private EntityModel entity;
public EntityModel getEntity()
{
if(getAppDataEntity().getPSDataEntity()==null)
return null;
return app.getSystem().getEntity(getAppDataEntity().getPSDataEntity().getCodeName());
if(entity==null)
{
if(getAppDataEntity().getPSDataEntity()==null)
entity = app.getSystem().getEntity(getAppDataEntity().getCodeName());
else
entity = app.getSystem().getEntity(getAppDataEntity().getPSDataEntity().getCodeName());
}
return entity;
}
private String serviceId;
......
package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.Inflector;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Charsets;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.IPSApplication;
import net.ibizsys.model.app.codelist.IPSAppCodeList;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
@Getter
......@@ -142,4 +149,64 @@ public class AppModel extends BaseModel{
}
private Map<String,Catalog> dictMaps;
public Map<String,Catalog> getDictMaps() {
return getDictMaps("");
}
public Collection<Catalog> getDicts() {
return getDictMaps().values();
}
public Map<String,Catalog> getDictMaps(String rootPath) {
if(dictMaps==null)
{
dictMaps=new LinkedHashMap<>();
Map<String,Catalog> catalogs= new LinkedHashMap<>();
if(!ObjectUtils.isEmpty(rootPath))
{
java.nio.file.Path path = Paths.get(rootPath,getApplication().getDynaModelFilePath().replace("/PSSYSAPP.json","/ALLCODELIST.json"));
if(Files.exists(path))
{
try {
JSON.parseArray(new String(Files.readAllBytes(path), Charsets.UTF_8),Catalog.class).forEach(catalog -> {
if(StringUtils.isEmpty(catalog.getName()))
{
IPSAppCodeList codeList=getApplication().getPSAppCodeList(catalog.getCode(),true);
if(codeList!=null)
catalog.setName(codeList.getLogicName());
catalogs.put(catalog.getCode(),catalog);
}
});
} catch (IOException e) {
//e.printStackTrace();
}
}
}
if(this.getApplication().getAllPSAppCodeLists()!=null)
{
this.getApplication().getAllPSAppCodeLists().forEach(codeList->{
Catalog catalog=catalogs.get(codeList.getCodeName());
if(catalog!=null)
{
catalog.setName(codeList.getName());
catalog.setCodeName(codeList.getCodeName());
}
else
{
catalog=new Catalog().setCode(codeList.getCodeName()).setName(codeList.getName());
catalog.setCodeName(codeList.getCodeName());
if(!ObjectUtils.isEmpty(codeList.getPSCodeItems()))
{
catalog.setCodeItem(codeList.getPSCodeItems());
}
}
dictMaps.put(catalog.getCodeName(),catalog);
});
}
}
return dictMaps;
}
}
package cn.ibizlab.codegen.model;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.codelist.IPSCodeItem;
import org.springframework.util.ObjectUtils;
import java.util.*;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Catalog extends BaseModel
{
private String code;
private String name;
@JSONField(name = "items")
@JsonProperty("items")
private List<Option> options = new ArrayList<>();
@JsonIgnore
@JSONField(serialize = false)
public String getValueType()
{
return ObjectUtils.isEmpty(options)?"String":options.get(0).getValueType();
}
public Option findCodeItem(Object value)
{
return findCodeItem(value,this.options);
}
public Option findCodeItem(Object value, List<Option> options){
for(Option codeItem : options){
if(value != null && codeItem.getValue() != null && value.equals(codeItem.getValue()))
return codeItem;
else if (!ObjectUtils.isEmpty(codeItem.getChildren()))
{
Option rt=findCodeItem(value,codeItem.getChildren());
if(rt!=null)
return rt;
}
}
return null;
}
public List<Option> loop(Map<String, List<Option>> listCodeItem, Object parentValue) {
List<Option> trees = new ArrayList<Option>();
if(listCodeItem.containsKey(parentValue)) {
for (Option codeItem : listCodeItem.get(parentValue)) {
List<Option> childCodeItem = loop(listCodeItem, codeItem.getValue());
if (childCodeItem.size() > 0)
codeItem.setChildren(childCodeItem);
trees.add(codeItem);
}
}
return trees;
}
public Catalog setCodeItem(List<IPSCodeItem> items) {
items.forEach(item->{
options.add(new Option().setItem(item));
});
return this;
}
}
......@@ -13,6 +13,7 @@ import net.ibizsys.model.control.IPSControlContainer;
import net.ibizsys.model.control.dashboard.IPSDBContainerPortletPart;
import net.ibizsys.model.control.dashboard.IPSDBPortletPart;
import net.ibizsys.model.control.dataview.IPSDEDataView;
import net.ibizsys.model.control.form.*;
import net.ibizsys.model.control.grid.IPSDEGrid;
import net.ibizsys.model.control.grid.IPSDEGridColumn;
import net.ibizsys.model.control.list.IPSList;
......@@ -20,6 +21,7 @@ import net.ibizsys.model.control.panel.IPSLayoutPanel;
import net.ibizsys.model.control.toolbar.IPSDETBUIActionItem;
import net.ibizsys.model.control.toolbar.IPSDEToolbar;
import net.ibizsys.model.view.IPSUIAction;
import org.springframework.util.ObjectUtils;
import java.util.*;
......@@ -301,4 +303,47 @@ public class CtrlModel extends BaseModel{
return false;
}
private List<VoFieldModel> voItems;
public List<VoFieldModel> getVoItems()
{
if(voItems==null && this.getControl() instanceof IPSDEEditForm)
{
IPSDEEditForm editForm=(IPSDEEditForm)this.getControl();
if(editForm.getPSDEFormItems()!=null)
{
voItems = new ArrayList<>();
editForm.getPSDEFormPages().forEach(page->{
loopItem(page.getPSDEFormDetails()).forEach(item->{
VoFieldModel field=new VoFieldModel(this,item);
voItems.add(field);
});
});
}
}
return voItems;
}
public List<IPSDEFormItem> loopItem(List<IPSDEFormDetail> items)
{
List<IPSDEFormItem> list=new ArrayList<>();
if(!ObjectUtils.isEmpty(items))
{
for(IPSDEFormDetail item:items)
{
if(item instanceof IPSDEFormItem) {
list.add((IPSDEFormItem)item);
}
else if(item instanceof IPSDEFormGroupBase)
{
list.addAll(loopItem(((IPSDEFormGroupBase)item).getPSDEFormDetails()));
}
}
}
return list;
}
}
......@@ -39,10 +39,12 @@ public class ModelStorage {
private SystemModel systemModel = null;
private String strPSModelFolderPath = null;
public SystemModel getSystemModel() {
if (systemModel == null) {
String modelPath = config.getInputSpec();
String strPSModelFolderPath = null;
if (Files.exists(Paths.get(modelPath, "PSSYSTEM.json"))) {
strPSModelFolderPath = Paths.get(modelPath).toString();
} else if (Files.exists(Paths.get(modelPath, "model", "PSSYSTEM.json"))) {
......@@ -135,6 +137,15 @@ public class ModelStorage {
});
});
}
else if(type.equals(TemplateFileType.dict))
{
getSystemModel().getApps().forEach(app->{
app.getDictMaps(strPSModelFolderPath).values().forEach(item->{
CliOption opt=newCliOption(TemplateFileType.dict).baseData(item, StringAdvUtils.pascalcase(item.getCodeName())).set("apps",app.getCodeName().toLowerCase());
rt.addOption(opt);
});
});
}
else if (type.equals(TemplateFileType.entity)) {
getSystemModel().getEntities().forEach(item -> {
CliOption opt = newCliOption(TemplateFileType.entity).setCliSubType(item.getStorage()).setModule(item.getModule())
......
package cn.ibizlab.codegen.model;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.codelist.IPSCodeItem;
import org.springframework.util.ObjectUtils;
import java.util.*;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class Option
{
private String id;
private Object value;
private String label;
private List<Option> children;
private String iconClass;
private String filter;
private Boolean disabled;
private String parent;
private Map<String, Object> extension;
@JsonIgnore
@JSONField(serialize = false)
public Set<String> getFilterSet()
{
Set<String> set=new HashSet<>();
if(!ObjectUtils.isEmpty(filter))
for(String str:filter.split(";|,"))
set.add(str);
return set;
}
@JsonIgnore
@JSONField(serialize = false)
public String getValueType()
{
if(value==null || value instanceof CharSequence)
return "String";
else
return "Integer";
}
public Option addChildren(Option item) {
if(children==null)
children=new ArrayList<Option>();
children.add(item);
item.setParent(this.getValue().toString());
return this;
}
public Option setItem(IPSCodeItem item)
{
this.setId(item.getValue()).setValue(item.getValue()).setLabel(item.getText()).setIconClass(item.getIconCls());
if(!ObjectUtils.isEmpty(item.getPSCodeItems()))
{
item.getPSCodeItems().forEach(child->{
this.addChildren(new Option().setItem(child));
});
}
return this;
}
}
package cn.ibizlab.codegen.model;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import net.ibizsys.model.app.dataentity.IPSAppDEField;
import net.ibizsys.model.control.IPSEditor;
import net.ibizsys.model.control.form.IPSDEForm;
import net.ibizsys.model.control.form.IPSDEFormItem;
import net.ibizsys.model.dataentity.service.IPSDEMethodDTOField;
import org.springframework.util.StringUtils;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class VoFieldModel extends BaseModel {
private CtrlModel voModel;
private PropType type ;
public VoFieldModel(CtrlModel voModel, IPSDEFormItem formItem) {
this.opt = formItem;
this.voModel = voModel;
this.setCodeName(StringUtils.isEmpty(formItem.getCodeName())?formItem.getName():formItem.getCodeName());
this.setName(formItem.getName());
}
public IPSDEFormItem getPSDEFormItem() {
return (IPSDEFormItem) opt;
}
public IPSEditor getPSEditor() {
return getPSDEFormItem().getPSEditor();
}
public IPSDEForm getPSDEForm()
{
return (IPSDEForm)getVoModel().getControl();
}
private FieldModel appDEField;
public FieldModel getAppDEField() {
if(appDEField==null) {
appDEField=getVoModel().getAppEntity().getEntity().getFieldMap().get(this.getName().toUpperCase());
}
return appDEField;
}
public PropType getType() {
type=PropType.findType(this.getPSDEFormItem().getDataType());
return type;
}
public String getLogicName() {
String logicName=this.getPSDEFormItem().getCaption();
if (StringUtils.isEmpty(logicName)&&this.getPSEditor()!=null) {
logicName=this.getPSEditor().getLogicName();
}
if (StringUtils.isEmpty(logicName)&&this.getAppDEField()!=null) {
logicName=this.getAppDEField().getLogicName();
}
return logicName;
}
public String javaType()
{
return getType().getJava();
}
private String format;
private String timeType;
public String getTimeType()
{
getFormat();
return timeType;
}
public String getFormat(){
if("Timestamp".equals(getType().getJava()))
{
if(this.getPSDEFormItem().getDataType()==PropType.DATE.getCode()||"%1$tY-%1$tm-%1$td".equalsIgnoreCase(this.getPSDEFormItem().getValueFormat())){
timeType="DATE";
format = "yyyy-MM-dd";
}
else if(this.getPSDEFormItem().getDataType()==PropType.TIME.getCode()||"%1$tH:%1$tM:%1$tS".equalsIgnoreCase(this.getPSDEFormItem().getValueFormat())){
timeType="TIME";
format = "HH:mm:ss";
}
else{
timeType="DATETIME";
format = "yyyy-MM-dd HH:mm:ss";
}
}
return format;
}
public String getJsonName() {
return getCodeName().toLowerCase();
}
}
......@@ -68,8 +68,8 @@ public class TemplateDefinition {
String[] pairs=m.group(1).split("@");
if(type.name().equalsIgnoreCase(pairs[0])
||type.value().equalsIgnoreCase(pairs[0])
||type.name().endsWith(" "+pairs[0])
||type.value().endsWith(" "+pairs[0])
||pairs[0].endsWith(" "+type.name())
||pairs[0].endsWith(" "+type.value())
||type.name().startsWith(pairs[0]+".")
||type.value().startsWith(pairs[0]+".")
) {
......
......@@ -15,6 +15,7 @@ public enum TemplateFileType {
subEntity(Constants.SUB_ENTITIES),
api(Constants.APIS),
app(Constants.APPS),
dict(Constants.DICTS),
supportingFiles(Constants.SUPPORTING_FILES);
private final String templateType;
......@@ -51,6 +52,7 @@ public enum TemplateFileType {
public static class Constants {
public static final String APIS = "apis";
public static final String APPS = "apps";
public static final String DICTS = "dicts";
public static final String ENTITIES = "entities";
public static final String WORKFLOWS = "workflows";
public static final String SYSUTILS = "syUtils";
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ibizlab-template</artifactId>
<groupId>cn.ibizlab</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ibizlab-template-apivo</artifactId>
<groupId>cn.ibizlab</groupId>
<version>1.0-SNAPSHOT</version>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>{{projectName}}</artifactId>
<groupId>{{packageName}}</groupId>
<version>{{system.pub.versionString}}</version>
</parent>
<artifactId>{{projectName}}-api</artifactId>
<name>{{projectDesc}} Api</name>
<description>{{projectDesc}} Api</description>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-generator-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<output>
../
</output>
<inputSpec>
</inputSpec>
<templateDirs>
${basedir}/src/main/resources/templ
</templateDirs>
<packageName>
${project.groupId}
</packageName>
<name>
${parent.artifactId}
</name>
</configuration>
<dependencies>
<dependency>
<groupId>cn.ibizlab</groupId>
<artifactId>ibizlab-template-apivo</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
package {{packageName}}.api.{{apps}}.dict.{{pascalCase dict.codeName}};
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* {{dict.name}}
*/
public class {{pascalCase dict.codeName}} {
{{#each dict.options}}
{{#eq dict.valueType "String"}}
V_{{value}}_N_{{label}} ("{{value}}","{{label}}",{{#if parent}}"{{parent}}"{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{#eq dict.valueType "Integer"}}
V_{{value}}_N_{{label}} ({{value}},"{{label}}",{{#if parent}}{{parent}}{{else}}null{{/if}}){{#if @last}};{{else}},{{/if}}
{{/eq}}
{{/each}}
private {{dict.valueType}} value;
@JsonValue
@JSONField
public {{dict.valueType}} getValue() {
return value;
}
private String label;
public String getLabel() {
return label;
}
private {{dict.valueType}} parent;
public {{dict.valueType}} getParent() {
return parent;
}
{{pascalCase dict.codeName}}({{dict.valueType}} value, String label, {{dict.valueType}} parent) {
this.value = value;
this.label = label;
this.parent = parent;
}
@JsonCreator
@JSONCreator
public static {{pascalCase dict.codeName}} valueOf(Object tag) {
if(tag==null)
return null;
for ({{pascalCase dict.codeName}} item : values())
if (item.getValue().equals(tag){{#eq dict.valueType "Integer"}}||item.getValue().toString().equals(tag){{/eq}})
return item;
Sjjcy ret =null;
for ({{pascalCase dict.codeName}} item : values())
if (item.getLabel().equals(tag))
ret = item;
return ret;
}
}
\ No newline at end of file
package {{packageName}}.api.{{apps}}.dto.{{pascalCase appEntity.codeName}};
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.math.BigInteger;
import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* {{ctrl.appEntity.entity.logicName}}DTO对象[{{ctrl.codeName}}]{{replace ctrl.logicName "编辑" ""}}
*/
@Getter
@Setter
@NoArgsConstructor
@ApiModel("{{ctrl.appEntity.entity.logicName}}DTO对象[{{ctrl.codeName}}]")
public class {{ctrl.codeName}}Dto implements Serializable {
private static final long serialVersionUID = 1L;
{{#each ctrl.voItems }}
/**
* {{logicName}}
*/
@JsonProperty("{{camelCase codeName}}")
{{#timeType}}
@JsonFormat(pattern = "{{format}}", locale = "zh", timezone = "GMT+8")
{{/timeType}}
@JSONField(name = "{{jsonName}}"{{#timeType}} , format = "{{format}}"{{/timeType}})
{{#eq javaType "Long"}}
@JsonSerialize(using = ToStringSerializer.class)
{{/eq}}
@ApiModelProperty("{{logicName}}")
private {{javaType}} {{camelCase codeName}};
{{/each}}
}
\ No newline at end of file
......@@ -18,6 +18,7 @@
<module>ibizlab-template-doc</module>
<module>ibizlab-template-r7</module>
<module>ibizlab-template-r8</module>
<module>ibizlab-template-apivo</module>
</modules>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册