ecology_maven/customization/test/DocCopyTest.java

173 lines
118 KiB
Java
Raw Normal View History

2021-11-14 15:29:16 +08:00
package customization.test;
import aiyh.utils.Util;
import aiyh.utils.sqlUtil.sqlResult.impl.BatchSqlResultImpl;
import aiyh.utils.sqlUtil.sqlResult.impl.PrepSqlResultImpl;
import aiyh.utils.sqlUtil.whereUtil.Where;
import aiyh.utils.sqlUtil.whereUtil.impl.PrepWhereImpl;
import com.api.aiyh_kafang.service.UploadByBase64Service;
import org.apache.axiom.util.base64.Base64Utils;
import org.junit.Test;
import weaver.conn.RecordSet;
import weaver.docs.docs.DocManager;
import weaver.file.ImageFileManager;
import weaver.workflow.workflow.WorkflowVersion;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author EBU7-dev1-ayh
* @create 2021/8/26 0026 13:19
* wen dang fu zhi
*/
public class DocCopyTest extends BaseTest {
@Test
public void testCopyFile() throws Exception {
DocManager doc = new DocManager();
doc.setId(16);
doc.copyDocNew();
}
@Test
public void testUploadBase64() throws IOException {
ImageFileManager fileManager = new ImageFileManager();
byte[] data = null;
2021-11-25 21:46:05 +08:00
// String base64 = new String("/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCANABOwDASIAAhEBAxE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0AJS0oFFACClopaAGmmnrTjSGgBKOlGKO1AhveiiigApBS0UAOb7oNJTj9xaZQMkUYRR7UU7FGKSGNxRinYopiG0U6igBtLS0UAFGKKWmAlFLSUAFFLRQAUUtGKACloooAKXtRRQAUUUtABRRRQAtFFFACYopaKADtRRRQAlLRRQAUUUUAFJS0lABRRRQAUUUUAFFFFABRSUUALRSUUAFLSUUAFFFFAB3ooooAKKKKACkpaSgBaSlpKACiiigApKWkoAWiiigAopKWgQlFFFAwooooEFJS0lABSUtJQMKKKKBBSUtFACUUppKACiiikAUUUlACUUtFADTRRR3pgJRRRQAtJRS0AGKUUUtABRRRQAUUtJQAtJRRQAtFFJQAtFJS0AFJRS0AFFJS0AFFFFABS0lLQAlGaWjvQAZooooAKKKKACkPSlooATtRRSUAKaSiigAoopKACiijtQAUd6KO9ABRRiigAoxRRQAlFLRSASlopaYCUtFKBSAKWkp1AwoxS0lACUmaU02gBaKSjNAB2pKWigQYpMUtFADaTtTj1pKAEpO9LSUASN9xaZSseBTaBk9FOpMUkAlHalopgJ2pKWjtQAlFLRigAopcUUAJRS44opgFFFLQAYopaKAEpaMUUgCiiigBaO1FHamAtFFFIAooooAKKKKYBRRRQAUUUUAFFFJQAUUUUAFFFJQAUUUUALmkoooAKKKKACikooAWiiigAopKKAClpKKACiiigAooooAKKKKACiiigBKKKKACiiigQUUUUAFFFJQMWkpaSgQUUUUAFJRRQAUUtJmgAooooAKSlooASiiigA7UlLSUAFFFFACUlOpKAGmkpzUgGaAAUoFLilxQAUUUUALRRRQAUlLSUALSUUUAFFFFAC0UUUAFFFFABRRRQAUUUUAFLRRQAUUUlAC0UUUAFFJRQAUmaWkoAKKSjigBaSiigApKWk5oAXtRRRQAtJ3opaAEooooAKKO9FIBKWk7UUwFFLSClpDDFLiilFABSiiigBaSlpKAE7U2nGm0AFFLSUAJ3pRSUtAgoNJmkzQAtJRmigBKO9FFACt9wU2nv/qxUeaBlukpe1FJAJSUtFMBKKWigBKKXFFABS4pKKAFoopaYCUUtJQAuKKSloAWkoopAFFFGaACijNFABRS0lABRRRQAUUUUwCiiigApaKKAEooooAKKKSgAooooAKKSigAooooAKKKKACiiigAooooAKKKSgBaKKKACiikoAWikooAKXtSUUCCiiigAoopKAClpKO1ABS0lFABRRRQAUUlFAC0lFFABRRRQAUUUUAFJS0UAJRS0YoAbS0lFABRS9qSgAopaSgAoopKAFxS0lFAC0dqSigBaKTNFAC0UCigBKKWkoAO1FFFABRRS0AFFFFACUtFFABRRSZoAWijrSUALRSUooAKKU0lABRRSUAFLSUUAFFJR2oAKSiloAKKKKACilooASlooFABR0opKAFFJR3pKACijNHekAUtJS0wCloopDF70tJRQA6ikzRQAtJRRQAUlLSUAIaKKSgAopKKACiim0CFopM0UAL1pQKQU8UAI/3BUdSv/q/xqKgC3RRRSQwpKWimAlFLRQAUUUHpQBFLPDBt86ZI933dxxmo/t9l/wA/kH/fYrmvGVvHealoFtKu6KW4IYZ6jisLVdS8G6Rq1xp8+jzM8DYZkJxQB6Kl5aScJdQse2HFTf0615pq+n6O2n6Hqmk28lt9quVXBY8jNdnJr1nJql9onzLdRW+4buA2R2pgaokR1DI4ZT0IORQ0sSHbJNGjejMAa878KXGqaJpu6dzPaPKyNABmSFieD9K1YrCDUNWaz8QW8st6FLRzxEhHTqPxoA64TwNwLiI/8DFO3Dfs3rvxkLnkivPl/wCENm0S51JEuo44JfKdRJ84b1xWUniea5sxdW8NzLqFm/l2k6oSrxej+9AHqomh6edHkf7Qp24bgu4bjyBnk15n9p8OXKCa80/VIrmT5pdgbCt3xWtNb3UegSaq90HawXfZSq3JT+64oA7bOPvEAe9J5kf/AD1j/wC+hXn2neJ77xH4R12a8EaNDEApj461E0HhzR/D+l3WrS3vm3cecpITk96APRg6f89U/wC+hTu2c/lXmos/Det6VqE2k3d8s1pEZNzORj0rsfCTvJ4U095HZ2MfLMck0AbVFJS0gCikopgLRSUUAFLSUUALRRSUALRSUUAFFFFABRSUUAFFFJQAtJR2ooAWikooAWikooAWikooAWkoooAKKKKACiiigAooooAKKKSgQtFJS0AFJRSUALRRSUAFFLSUAFFJRQAtFJSigAooNJmgB1JSZppNAD80ZqPNHPpQA/PFGaYA3pRyOv8AOgB+aTNJ+X50mG7CgB1LUfzDsaUGgB9FNzS5oAWiko7UAFJjmlJpM0AFFFFABRmkzSZoAWne9Mpc0AOo70lGaAFopKWgAopKM0ALS03NGaAHUCkooAWkoooAKKKKACiikoAO9Lmq8t1FAjs7cIQGx2z0pyzxmcwhv3gGdp7igCbNJ3qNpUQ4c4qFdRtHZQkud33eOuKALeaTNMjcSjcucH1qE38AiklLfJG+xj70AWu9FRrIjkqrAleo7iojeQb9nmZYHBAHSgCxSHjmoTdwAA+Z95to9zU3tQAitkZpe1JwPYDvTY5Y5cmKRXx1welAD+9LTQy+Z5e4b8Z255xTFnhkk8tJVZ/
// data = Base64Utils.decode(base64);
// System.out.println(data.length);
// fileManager.setImagFileName("buzhidap.jpg");
// fileManager.setData(data);
//// int i = fileManager.saveImageFile();
//// System.out.println(i);
// InputStream inputStreamById1 = ImageFileManager.getInputStreamById(2364);
// Image image1 = ImageIO.read(inputStreamById1);
// int width1 = image1.getWidth(null);
// int height1 = image1.getHeight(null);
// BufferedImage bufferedImage1 = new BufferedImage(width1, height1, BufferedImage.TYPE_INT_RGB);
// Graphics graphics1 = bufferedImage1.createGraphics();
// graphics1.drawImage(image1, 0, 0, width1, height1, null);
// graphics1.dispose();
// FileOutputStream fileOutputStream = new FileOutputStream(URLDecoder.decode("C:\\Users\\77449\\Desktop\\测试base64.jpg", "utf-8"));
// ImageIO.write(bufferedImage1, "jpg", fileOutputStream);
// fileOutputStream.close();
2021-11-14 15:29:16 +08:00
}
@Test
public void test(){
System.out.println("[" + WorkflowVersion.getVersionStringByWfid("45") + "]");
}
@Test
public void testuplosd() throws IOException {
UploadByBase64Service uploadByBase64Service = new UploadByBase64Service();
int i = uploadByBase64Service.uploadImage(null);
System.out.println(i);
InputStream inputStreamById1 = ImageFileManager.getInputStreamById(i);
Image image1 = ImageIO.read(inputStreamById1);
int width1 = image1.getWidth(null);
int height1 = image1.getHeight(null);
BufferedImage bufferedImage1 = new BufferedImage(width1, height1, BufferedImage.TYPE_INT_RGB);
Graphics graphics1 = bufferedImage1.createGraphics();
graphics1.drawImage(image1, 0, 0, width1, height1, null);
graphics1.dispose();
FileOutputStream fileOutputStream = new FileOutputStream(URLDecoder.decode("C:\\Users\\77449\\Desktop\\测试base64.jpg", "utf-8"));
ImageIO.write(bufferedImage1, "jpg", fileOutputStream);
fileOutputStream.close();
}
@Test
public void testBatchUpdate(){
ArrayList<LinkedHashMap<String,Object>> objects = new ArrayList<LinkedHashMap<String,Object>>(){{
add(new LinkedHashMap<String,Object>(){{
put("email","1@qq.com");
}});
add(new LinkedHashMap<String,Object>(){{
put("email","2@qq.com");
}});
add(new LinkedHashMap<String,Object>(){{
put("email","3@qq.com");
}});
add(new LinkedHashMap<String,Object>(){{
put("email","4@qq.com");
}});
add(new LinkedHashMap<String,Object>(){{
put("email","5@qq.com");
}});
}};
ArrayList<Where> prepWheres = new ArrayList<Where>(){{
add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(22));
add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(23));
add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(24));
add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(25));
add(Util.createPrepWhereImpl().whereAnd("id").whereEqual(26));
}};
BatchSqlResultImpl batchSqlResult = Util.createSqlBuilder().updateBatchSql("hrmresource",objects, prepWheres);
RecordSet rs = new RecordSet();
rs.executeBatchSql(batchSqlResult.getSqlStr(),batchSqlResult.getBatchList());
}
@Test
public void testEntity() throws IntrospectionException, InvocationTargetException, IllegalAccessException {
TestVoItem testVoItem = new TestVoItem();
testVoItem.setCurrency("currency");
testVoItem.setLocalCurrency("localCurrency");
testVoItem.setRate("1.22");
BeanInfo beanInfo = Introspector.getBeanInfo(testVoItem.getClass(), Object.class);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor proper : propertyDescriptors) {
String name = proper.getName();
Method readMethod = proper.getReadMethod();
Object invoke = readMethod.invoke(testVoItem);
System.out.println(name);
System.out.println(invoke);
}
// List<Field> entityFields = Util.getEntityFields(testVoItem.getClass());
// System.out.println(entityFields);
// for (Field entityField : entityFields) {
// entityField.setAccessible(true);
// String name = entityField.getName();
// System.out.println(name);
// System.out.println(String.valueOf(entityField.get(name)));
// }
}
@Test
public void testByentity(){
TestVoItem testVoItem = new TestVoItem();
testVoItem.setCurrency("currency");
testVoItem.setLocalCurrency("localCurrency");
testVoItem.setRate("1.22");
PrepSqlResultImpl testTable = Util.createSqlBuilder().insertSqlByEntity("testTable", testVoItem);
System.out.println(testTable.getSqlStr());
System.out.println(testTable.getArgs());
}
}