Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void doCalculator(SqlSegment segment,Map<String,Object> inputRecord,Map<S
Assert.isTrue(sqlNodes.size()==3,"substr function must have three parameters");
Assert.isTrue(SqlKind.IDENTIFIER.equals(sqlNodes.get(0).getKind())," first parameter must be column");
String column=sqlNodes.get(0).toString();
if(!Const.META_TYPE_STRING.equals(segment.getOriginSchemaMap().get(column).getColumnType())){
if(!Const.CLASSTYPE.STRING.equals(segment.getOriginSchemaMap().get(column).getColumnType())){
throw new OperationNotSupportException("only string column can substr");
}
Integer fromPos=((Number)((SqlLiteral)sqlNodes.get(1)).getValue()).intValue();
Expand Down Expand Up @@ -349,9 +349,9 @@ private static boolean walkTree(SqlNode node, Map<String, Object> inputMap, SqlS
return runValue;
}
protected static void checkColumnNumeric(SqlSegment segment,String columnName){
Assert.isTrue(Const.META_TYPE_INTEGER.equals(segment.getOriginSchemaMap().get(columnName).getColumnType())
|| Const.META_TYPE_BIGINT.equals(segment.getOriginSchemaMap().get(columnName).getColumnType())
|| Const.META_TYPE_DOUBLE.equals(segment.getOriginSchemaMap().get(columnName).getColumnType()),"require numeric column");
Assert.isTrue(Const.CLASSTYPE.INTEGER.equals(segment.getOriginSchemaMap().get(columnName).getColumnType())
|| Const.CLASSTYPE.LONG.equals(segment.getOriginSchemaMap().get(columnName).getColumnType())
|| Const.CLASSTYPE.DOUBLE.equals(segment.getOriginSchemaMap().get(columnName).getColumnType()),"require numeric column");
}

private static Object getValueWithCalculate(Map<String, Object> inputMap, SqlSegment segment, SqlNode nodes) {
Expand Down
34 changes: 17 additions & 17 deletions common/src/main/java/com/robin/comm/sql/CommSqlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static List<DataSetColumnMeta> getCalculateSchema(SqlSegment segment, Dat
}
columns.add(meta1);
} else {
columns.add(new DataSetColumnMeta(columnName, Const.META_TYPE_FORMULA));
columns.add(new DataSetColumnMeta(columnName, Const.CLASSTYPE.FORMULA));
}
}
}
Expand Down Expand Up @@ -405,7 +405,7 @@ public static class ValueParts {
private List<SqlNode> functionParams;
private String aliasName;
private SqlLiteral constantValue;
private String columnType;
private Const.CLASSTYPE columnType;
private SqlNode node;
private SqlKind sqlKind = SqlKind.IDENTIFIER;
private String nodeString;
Expand All @@ -429,10 +429,10 @@ public void setCalculator(SqlNode node) {
this.calculator = node.toString().replace(Quoting.BACK_TICK.string, "").replaceAll("\\s+", "");
this.sqlKind = SqlKind.LISTAGG;
if (FilterSqlParser.fourZeOper.matcher(calculator).find()) {
columnType = Const.META_TYPE_DOUBLE;
columnType = Const.CLASSTYPE.DOUBLE;
polandQueue = PolandNotationUtil.parsePre(calculator);
} else {
columnType = Const.META_TYPE_BOOLEAN;
columnType = Const.CLASSTYPE.BOOLEAN;
}
}

Expand All @@ -442,17 +442,17 @@ public void decideType(SqlLiteral literal) {
SqlNumericLiteral literal1 = (SqlNumericLiteral) literal;
if (literal1.getScale() == 0) {
if (literal1.getPrec() < 12) {
columnType = Const.META_TYPE_INTEGER;
columnType = Const.CLASSTYPE.INTEGER;
} else {
columnType = Const.META_TYPE_BIGINT;
columnType = Const.CLASSTYPE.LONG;
}
} else {
columnType = Const.META_TYPE_DOUBLE;
columnType = Const.CLASSTYPE.DOUBLE;
}
} else if (SqlTimeLiteral.class.isAssignableFrom(literal.getClass())) {
columnType = Const.META_TYPE_TIMESTAMP;
columnType = Const.CLASSTYPE.TIMESTAMP;
} else if (SqlCharStringLiteral.class.isAssignableFrom(literal.getClass())) {
columnType = Const.META_TYPE_STRING;
columnType = Const.CLASSTYPE.STRING;
}
}
}
Expand All @@ -464,14 +464,14 @@ public static void main(String[] args) {
String groupSql = "select max(a1),min(a2),sum(c1),c3 from test where ((a1+a2)*a9)/10>a3 group by c3 having sum(c1)>100 order by c3 desc,sum(c1) asc";

DataCollectionMeta.Builder builder = new DataCollectionMeta.Builder();
DataCollectionMeta meta = builder.addColumn("a1", Const.META_TYPE_DOUBLE).addColumn("a2", Const.META_TYPE_DOUBLE)
.addColumn("a3", Const.META_TYPE_DOUBLE).addColumn("a4", Const.META_TYPE_DOUBLE)
.addColumn("a5", Const.META_TYPE_DOUBLE).addColumn("a6", Const.META_TYPE_DOUBLE)
.addColumn("a7", Const.META_TYPE_INTEGER).addColumn("a8", Const.META_TYPE_DOUBLE)
.addColumn("a9", Const.META_TYPE_DOUBLE).addColumn("b1", Const.META_TYPE_DOUBLE)
.addColumn("b2", Const.META_TYPE_DOUBLE).addColumn("b3", Const.META_TYPE_DOUBLE)
.addColumn("c1", Const.META_TYPE_DOUBLE).addColumn("c2", Const.META_TYPE_DOUBLE)
.addColumn("c3", Const.META_TYPE_INTEGER).addColumn("c4", Const.META_TYPE_STRING).tableName("test").build();
DataCollectionMeta meta = builder.addColumn("a1", Const.CLASSTYPE.DOUBLE).addColumn("a2", Const.CLASSTYPE.DOUBLE)
.addColumn("a3", Const.CLASSTYPE.DOUBLE).addColumn("a4", Const.CLASSTYPE.DOUBLE)
.addColumn("a5", Const.CLASSTYPE.DOUBLE).addColumn("a6", Const.CLASSTYPE.DOUBLE)
.addColumn("a7", Const.CLASSTYPE.INTEGER).addColumn("a8", Const.CLASSTYPE.DOUBLE)
.addColumn("a9", Const.CLASSTYPE.DOUBLE).addColumn("b1", Const.CLASSTYPE.DOUBLE)
.addColumn("b2", Const.CLASSTYPE.DOUBLE).addColumn("b3", Const.CLASSTYPE.DOUBLE)
.addColumn("c1", Const.CLASSTYPE.DOUBLE).addColumn("c2", Const.CLASSTYPE.DOUBLE)
.addColumn("c3", Const.CLASSTYPE.INTEGER).addColumn("c4", Const.CLASSTYPE.STRING).tableName("test").build();
SqlSegment segment = CommSqlParser.parseSingleTableQuerySql(sql, Lex.MYSQL, meta, "N_COLUMN");
Map<String, Object> map = new HashMap<>();
map.put("a1", 1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ public RelDataType getRowType(RelDataTypeFactory typeFactory) {
Assert.isTrue(!ObjectUtils.isEmpty(colmeta) && !CollectionUtils.isEmpty(colmeta.getColumnList()),"meta define is missing!");
RelDataTypeFactory.Builder builder = typeFactory.builder();
for(DataSetColumnMeta columnMeta:colmeta.getColumnList()){
if(Const.META_TYPE_INTEGER.equals(columnMeta.getColumnType())){
if(Const.CLASSTYPE.INTEGER.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.INTEGER);
}else if(Const.META_TYPE_BIGINT.equals(columnMeta.getColumnType())){
}else if(Const.CLASSTYPE.LONG.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.BIGINT);
}
else if(Const.META_TYPE_DOUBLE.equals(columnMeta.getColumnType())){
else if(Const.CLASSTYPE.DOUBLE.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.DOUBLE);
}
else if(Const.META_TYPE_DECIMAL.equals(columnMeta.getColumnType())){
else if(Const.CLASSTYPE.DECIMAL.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.DECIMAL);
}
else if(Const.META_TYPE_TIMESTAMP.equals(columnMeta.getColumnType())){
else if(Const.CLASSTYPE.TIMESTAMP.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.TIMESTAMP);
}
else if(Const.META_TYPE_DATE.equals(columnMeta.getColumnType())){
else if(Const.CLASSTYPE.DATE.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.DATE);
}
else if(Const.META_TYPE_CLOB.equals(columnMeta.getColumnType()) || Const.META_TYPE_BLOB.equals(columnMeta.getColumnType())){
else if(Const.CLASSTYPE.CLOB.equals(columnMeta.getColumnType()) || Const.CLASSTYPE.BLOB.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.BINARY);
}else if(Const.META_TYPE_STRING.equals(columnMeta.getColumnType())){
}else if(Const.CLASSTYPE.STRING.equals(columnMeta.getColumnType())){
builder.add(columnMeta.getColumnName(), SqlTypeName.VARCHAR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ protected static boolean cmpObject(Map<String, Set<String>> inPartMap,Map<String
retVal = !cmpObject(inPartMap,columnMap,node, leftValue, rightValue, node.getNotCompareOper());
break;
case "like":
Assert.isTrue(Const.META_TYPE_STRING.equals(columnMap.get(node.getLeftNode().getValue()).getColumnType()),"only string column can use like");
Assert.isTrue(Const.CLASSTYPE.STRING.equals(columnMap.get(node.getLeftNode().getValue()).getColumnType()),"only string column can use like");
String fitStr=node.getRightNode().getValue();
if(fitStr.startsWith("%")){
if(fitStr.endsWith("%")){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,21 @@ public static Map<String,Object> getIndex(String httpUrl,String indexName,String
}
return indexCfgMap;
}
public static String translateEsType(String columnType) {
public static Const.CLASSTYPE translateEsType(String columnType) {
Assert.notNull(columnType,"type is null");
String retType;
Const.CLASSTYPE retType;
if ("auto".equalsIgnoreCase(columnType) || "keyword".equalsIgnoreCase(columnType) || "text".equalsIgnoreCase(columnType)) {
retType=Const.META_TYPE_STRING;
retType= Const.CLASSTYPE.STRING;
}else if("double".equalsIgnoreCase(columnType)){
retType=Const.META_TYPE_DOUBLE;
retType= Const.CLASSTYPE.DOUBLE;
}else if("integer".equalsIgnoreCase(columnType)){
retType=Const.META_TYPE_INTEGER;
retType= Const.CLASSTYPE.INTEGER;
}else if("float".equalsIgnoreCase(columnType)){
retType=Const.META_TYPE_NUMERIC;
retType= Const.CLASSTYPE.NUMERIC;
}else if("short".equalsIgnoreCase(columnType)){
retType=Const.META_TYPE_SHORT;
retType= Const.CLASSTYPE.SHORT;
}else {
retType=Const.META_TYPE_STRING;
retType= Const.CLASSTYPE.STRING;
}
return retType;
}
Expand Down
73 changes: 48 additions & 25 deletions common/src/main/java/com/robin/comm/util/ppt/PptBaseUtil.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
package com.robin.comm.util.ppt;


import com.robin.comm.util.xls.TableConfigProp;
import com.robin.comm.util.xls.TableHeaderColumn;
import org.apache.poi.hslf.model.HeadersFooters;
import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hslf.usermodel.HSLFTable;
import org.apache.poi.hwpf.usermodel.Picture;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
import org.apache.poi.sl.usermodel.*;
import org.apache.poi.xslf.usermodel.SlideLayout;
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
import org.apache.poi.xslf.usermodel.XSLFSlideMaster;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;


public class PptBaseUtil {
/*public static void adjustHeaderFooter(HSLFSlideShow show,PptHeaderFooterSection section){
public static void adjustHeaderFooter(HSLFSlideShow show, PptHeaderFooterSection section){
HeadersFooters slideHeaders = show.getSlideHeadersFooters();
if(section.getHeaderStr()!=null && !"".equals(section.getHeaderStr()))
slideHeaders.setHeaderText(section.getHeaderStr());
Expand All @@ -17,17 +40,17 @@ public class PptBaseUtil {
if(section.getNodeHeaderStr()!=null && !"".equals(section.getNodeHeaderStr()))
notesHeaders.setHeaderText(section.getNodeHeaderStr());
}
public static void insertTable(HSLFSlide slide,PptTableDef def,List<Map<String, String>> resultList){
TableHeaderProp prop=def.getHeaderProp();
public static void insertTable(HSLFSlide slide, PptTableDef def, List<Map<String, String>> resultList){
TableConfigProp prop=def.getHeaderProp();
int width=prop.getContainrow();
int rows=prop.getTotalCol();
HSLFTable celltab=new HSLFTable(width,rows,null);
/*HSLFTable celltab=new HSLFTable(width,rows,null);

List<TableHeaderColumn> list=prop.getHeaderColumnList().get(0);
for(int i=0;i<list.size();i++){
TableHeaderColumn col=list.get(i);
TableCell cell=celltab.getCell(0, i);
cell.setText(col.getColumnName());
TextRun run= cell.setText(col.getColumnName());
RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
rt.setFontSize(10);
rt.setFontName("STSong-Light");
Expand Down Expand Up @@ -61,24 +84,24 @@ public static void insertTable(HSLFSlide slide,PptTableDef def,List<Map<String,
celltab.setColumnWidth(0, 60);
celltab.moveTo(200, 200);
slide.addShape(celltab);
celltab.setAnchor(new Rectangle(200,200,300,200));
celltab.setAnchor(new Rectangle(200,200,300,200));*/
}
public static void insertImage(SlideShow show,Slide slide,PptImageDef def) throws IOException, URISyntaxException{
BufferedImage image=ImageIO.read(new File(def.getPicUrl()));
public static void insertImage(SlideShow show, Slide slide, PptImageDef def) throws IOException, URISyntaxException {
BufferedImage image= ImageIO.read(new File(def.getPicUrl()));
String path=def.getPicUrl();
int pic_type=-1;
PictureType pic_type;
if(path.indexOf(".png") != -1){
pic_type = Picture.PNG;
pic_type = PictureType.PNG;
}else{
pic_type = Picture.JPEG;
pic_type = PictureType.JPEG;
}
int newindex=show.addPicture(new File(def.getPicUrl()), pic_type);
Picture pic=new Picture(newindex);
PictureData data =show.addPicture(new File(def.getPicUrl()), pic_type);
/*Picture pic=new Picture(newindex);
pic.setAnchor(new Rectangle(def.getPosx(),def.getPosy(),image.getWidth(),image.getHeight()));
slide.addShape(pic);
slide.addShape(pic);*/
}
public static void insertText(Slide slide,PptPragraph pragraph){
AutoShape _autoShape = new AutoShape(ShapeTypes.Rectangle);
/*AutoShape _autoShape = new AutoShape(ShapeTypes.Rectangle);
TextRun _autoText = _autoShape.createTextRun();
_autoText.setRawText(pragraph.getContext());
_autoShape.setAnchor(new Rectangle(pragraph.getPosx(),pragraph.getPosy(),pragraph.getPosx()+pragraph.getWidth(),pragraph.getPosy()+pragraph.getHeight()));
Expand All @@ -88,22 +111,22 @@ public static void insertText(Slide slide,PptPragraph pragraph){
_autoShape.setFillColor(new Color(255,255,255));
_autoShape.setLineWidth(5.0);
_autoShape.setLineStyle(Line.LINE_DOUBLE);
slide.addShape(_autoShape);
slide.addShape(_autoShape);*/
}
public static void setBackground(SlideShow show,PptConfig config) throws IOException{
SlideMaster master = show.getSlidesMasters()[0];
List<MasterSheet> master = show.getSlideMasters();
XSLFSlideMaster slideMaster=(XSLFSlideMaster) master.get(0);

Fill fill = master.getBackground().getFill();
XSLFSlideLayout layout=slideMaster.getLayout(SlideLayout.BLANK);
String path=config.getBackgroundPic();
int pic_type=-1;
PictureType pic_type;
if(path.indexOf(".png") != -1){
pic_type = Picture.PNG;
pic_type = PictureType.PNG;
}else{
pic_type = Picture.JPEG;
pic_type = PictureType.JPEG;
}
int idx = show.addPicture(new File(path), pic_type);
fill.setFillType(Fill.FILL_PICTURE);
fill.setPictureData(idx);
}*/
PictureData data = show.addPicture(new File(path), pic_type);

}

}
23 changes: 14 additions & 9 deletions common/src/main/java/com/robin/comm/util/ppt/PptGenerater.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.robin.comm.util.ppt;

import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.sl.usermodel.Slide;
import org.apache.poi.sl.usermodel.SlideShow;

import java.io.IOException;
import java.util.List;

public class PptGenerater {
/*public static void GeneratePpt(SlideShow show,PptConfig config){
public static void GeneratePpt(HSLFSlideShow show, PptConfig config) throws IOException{
List<List<PptSection>> sectionList=config.getSectionList();
PptHeaderFooterSection headerFooter=config.getHeaderFooter();
if(config.getBackgroundPic()!=null)
try {
PptBaseUtil.setBackground(show, config);
} catch (IOException e) {
e.printStackTrace();
}
if(config.getBackgroundPic()!=null){
PptBaseUtil.setBackground(show, config);
}
if(headerFooter!=null)
PptBaseUtil.adjustHeaderFooter(show, headerFooter);
for (int i=0;i<sectionList.size();i++) {
Expand All @@ -28,13 +33,13 @@ private static void GenerateSlide(SlideShow show,Slide slide,List<PptSection> se
}
}else if(sec.getType().equalsIgnoreCase(PptSection.TYPE_TABLE))
{
PptBaseUtil.insertTable(slide, sec.getTableDef(),sec.getResultList());
PptBaseUtil.insertTable((HSLFSlide)slide, sec.getTableDef(),sec.getResultList());
}else if(sec.getType().equalsIgnoreCase(PptSection.TYPE_IMAGE))
PptBaseUtil.insertImage(show, slide, sec.getImageDef());
}
}catch (Exception e) {
e.printStackTrace();
}
}*/
}

}
Loading
Loading