Compare commits
18 Commits
eac83a3efe
...
fe577e254b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fe577e254b | ||
![]() |
38da4269be | ||
c6f606c769 | |||
12ba81e92a | |||
![]() |
728a223675 | ||
25b7dd7643 | |||
![]() |
4c8ff75bf1 | ||
![]() |
286e959c4f | ||
fab8a9cd9f | |||
![]() |
e861a3c62f | ||
![]() |
c3f14bdc9f | ||
![]() |
713cc279a8 | ||
![]() |
cf4598c101 | ||
8966670dec | |||
12c316893e | |||
![]() |
95195bb712 | ||
![]() |
c30a97c291 | ||
6c55309096 |
12
YXZG.iml
Normal file
12
YXZG.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="newWizard_KINGDEE_COSMIC_MODULE_TYPE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="cosmic-lib" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -5,6 +5,7 @@ import com.yem.wm.utils.DynamicObjectUtil;
|
||||
import com.yem.wm.utils.YEM;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.BillEntityType;
|
||||
import kd.bos.entity.ExtendedDataEntity;
|
||||
import kd.bos.entity.botp.plugin.AbstractConvertPlugIn;
|
||||
import kd.bos.entity.botp.plugin.args.AfterConvertEventArgs;
|
||||
@ -28,9 +29,9 @@ public class DeclareDocxToExportinvoiceConvert extends AbstractConvertPlugIn {
|
||||
public void afterConvert(AfterConvertEventArgs e) {
|
||||
super.afterConvert(e);
|
||||
String targetName = this.getTgtMainType().getName();
|
||||
//上游
|
||||
String name = this.getSrcMainType().getName();
|
||||
ExtendedDataEntity[] findByEntityKeys = e.getTargetExtDataEntitySet().FindByEntityKey(targetName);
|
||||
|
||||
for (ExtendedDataEntity findByEntityKey : findByEntityKeys) {
|
||||
//携带合同中的佣金率
|
||||
setRate(findByEntityKey);
|
||||
@ -90,8 +91,66 @@ public class DeclareDocxToExportinvoiceConvert extends AbstractConvertPlugIn {
|
||||
// }
|
||||
|
||||
calculatePremium(dataEntity);
|
||||
|
||||
}
|
||||
|
||||
ExtendedDataEntity[] findByname = e.getTargetExtDataEntitySet().FindByEntityKey(targetName);
|
||||
yemCushscode(findByname);
|
||||
}
|
||||
|
||||
private void yemCushscode(ExtendedDataEntity[] findByname) {
|
||||
for (ExtendedDataEntity extendedDataEntity : findByname) {
|
||||
DynamicObject dataEntity = extendedDataEntity.getDataEntity();
|
||||
long aLong2 = dataEntity.getLong("yem_sourcebillid");
|
||||
String yem_es_declare = DynamicObjectUtil.getSelectfields("yem_es_declaredocx", false);
|
||||
String yem_es_declare_ec = DynamicObjectUtil.getEntrySelectfields(yem_es_declare, "yem_es_declaredocx", "yem_es_declare_ec", false);
|
||||
DynamicObject dynamicObject2 = BusinessDataServiceHelper.loadSingle("yem_es_declaredocx", yem_es_declare_ec, new QFilter[]{new QFilter("id", QCP.equals, aLong2)});
|
||||
DynamicObjectCollection dynamicObjectCollection = dynamicObject2.getDynamicObjectCollection("yem_es_declare_ec");
|
||||
//出口发票
|
||||
for (DynamicObject dynamicObject : dynamicObjectCollection) {
|
||||
DynamicObject yemCushscode = dynamicObject.getDynamicObject("yem_cushscode");
|
||||
long aLong1 = dynamicObject.getLong("id");
|
||||
if (yemCushscode != null) {
|
||||
String yemCushscodeString = yemCushscode.getString("number");
|
||||
String yemDecmatericalname = dynamicObject.getString("yem_decmatericalname");
|
||||
BigDecimal yemCusconsalesprice = dynamicObject.getBigDecimal("yem_cusconsalesprice");
|
||||
QFilter qFilter = new QFilter("yem_ca_cddetailedentry.yem_codets.number", QCP.equals, yemCushscodeString);
|
||||
qFilter.and(new QFilter("yem_ca_cddetailedentry.yem_codetsname", QCP.equals, yemDecmatericalname));
|
||||
qFilter.and(new QFilter("yem_ca_cddetailedentry.yem_declprice", QCP.equals, yemCusconsalesprice));
|
||||
String selectfield = DynamicObjectUtil.getSelectfields("yem_ca_cusdec", false);
|
||||
String selectfields = DynamicObjectUtil.getEntrySelectfields(selectfield, "yem_ca_cusdec", "yem_ca_cddetailedentry", false);
|
||||
//单一窗口报关单
|
||||
DynamicObject load = BusinessDataServiceHelper.loadSingle("yem_ca_cusdec", selectfields, new QFilter[]{qFilter});
|
||||
if (load != null) {
|
||||
DynamicObjectCollection dynamicObjectCollection1 = load.getDynamicObjectCollection("yem_ca_cddetailedentry");
|
||||
for (DynamicObject object : dynamicObjectCollection1) {
|
||||
DynamicObject yemCodets = object.getDynamicObject("yem_codets");
|
||||
BigDecimal bigDecimal = object.getBigDecimal("yem_declprice");
|
||||
String string = object.getString("yem_codetsname");
|
||||
DynamicObject yemGunit = object.getDynamicObject("yem_gunit");
|
||||
DynamicObject yemunit = object.getDynamicObject("yem_unit1");
|
||||
DynamicObject yemUnit = object.getDynamicObject("yem_unit2");
|
||||
if (yemCodets != null) {
|
||||
String yemCodetsString = yemCodets.getString("number");
|
||||
if (yemCodetsString.equals(yemCushscodeString) && bigDecimal.compareTo(yemCusconsalesprice) == 0 && yemDecmatericalname.equals(string)) {
|
||||
DynamicObjectCollection dynamicObjectCollection2 = dataEntity.getDynamicObjectCollection("yem_exportinvoice_c");
|
||||
for (DynamicObject dynamicObject1 : dynamicObjectCollection2) {
|
||||
long aLong = dynamicObject1.getLong("yem_sourcebillentryid");
|
||||
if (aLong1 == aLong) {
|
||||
dynamicObject1.set("yem_customsdeclaration", yemGunit);
|
||||
dynamicObject1.set("yem_unitmeasurement", yemunit);
|
||||
dynamicObject1.set("yem_measurement", yemUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取出口日期的海运费汇率 保费汇率
|
||||
|
@ -375,7 +375,11 @@ public class SalesOrderPJEdit extends AbstractBillPlugIn implements Plugin, Befo
|
||||
// calculateCostSharing(model);
|
||||
ClientUtils.addSaAmountTk(model, rowIndex);//销售金额(价格条款)结算币别
|
||||
break;
|
||||
case "yem_sharethecost":
|
||||
case "yem_sumedamount":
|
||||
// String dataNewValue =(String) this.getModel().getValue("yem_sharethecost");
|
||||
// if ("A".equals(dataNewValue)){
|
||||
// }
|
||||
calculateCostSharing(model);
|
||||
break;
|
||||
}
|
||||
|
@ -123,6 +123,11 @@ public class SalesOrderAutoSignOp extends AbstractOperationServicePlugIn {
|
||||
// 书签位置替换为图片(书签不会删除)
|
||||
file = ContactSignUtils.replaceBookmarkWithImage(in, stream, filename, BOOKMARK);
|
||||
AttachmentUtil.uploadAttachment(appId, formId, String.valueOf(pkId), UPLOAD_ATTACHMENT_KEY, file.getName(), file.getPath());
|
||||
List<Map<String, Object>> uploaded = AttachmentServiceHelper.getAttachments(formId, pkId, UPLOAD_ATTACHMENT_KEY);
|
||||
File pdf = ContactSignUtils.convertToPDF(uploaded);
|
||||
if (pdf != null) {
|
||||
AttachmentUtil.uploadAttachment(appId, formId, String.valueOf(pkId), UPLOAD_ATTACHMENT_KEY, pdf.getName(), pdf.getPath());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
@ -1,17 +1,22 @@
|
||||
package com.yem.wm.utils;
|
||||
|
||||
import com.yem.wm.es.encasement.util.FileUtil;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.exception.KDBizException;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 合同盖章
|
||||
@ -21,6 +26,8 @@ import java.util.List;
|
||||
|
||||
public class ContactSignUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContactSignUtils.class);
|
||||
|
||||
public static List<CTBookmark> getFileBookMarks(InputStream in) {
|
||||
List<CTBookmark> list = new ArrayList<>();
|
||||
try (XWPFDocument doc = new XWPFDocument(in)) {
|
||||
@ -86,4 +93,142 @@ public class ContactSignUtils {
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static File convertToPDF(List<Map<String, Object>> files) {
|
||||
for (Map<String, Object> file : files) {
|
||||
InputStream in = word2PdfByYunpan(file);
|
||||
if (in == null) {
|
||||
logger.error("word2PdfByYunpan response null");
|
||||
return null;
|
||||
}
|
||||
FileUtil fileUtil = new FileUtil("sales-order-sign-file-pdf");
|
||||
try {
|
||||
File outFile = fileUtil.createNewFile(changeFileExtension((String) file.get("name"), "pdf"));
|
||||
writeToFile(in, outFile);
|
||||
return outFile;
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void writeToFile(InputStream in, File file) {
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(file);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while ((bytesRead = in.read(buffer)) != -1) {
|
||||
fos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
logger.info("PDF文件写入成功");
|
||||
} catch (IOException e) {
|
||||
logger.error("PDF文件写入本地失败");
|
||||
logger.error(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
if (fos != null) {
|
||||
fos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过预览服务器生成pdf文件
|
||||
*
|
||||
* @param urlWord 附件面板数据
|
||||
* @return 文件流
|
||||
*/
|
||||
public static InputStream word2PdfByYunpan(Map<String, Object> urlWord) {
|
||||
//需要添加到附件的文件
|
||||
String yunPanUrl = System.getProperty("yunpan.previewUrl");
|
||||
String getPdfUrl = yunPanUrl + "/api/officeToPdf";
|
||||
// 请求参数
|
||||
Map<String, Object> param = new HashMap<>(8);
|
||||
//文件id
|
||||
param.put("id", urlWord.get("uid"));
|
||||
//文件名
|
||||
String wordName = urlWord.get("name").toString();
|
||||
String[] wordNameStr = wordName.split("\\.");
|
||||
//获取文件类型 doc/docx
|
||||
param.put("ext", wordNameStr[wordNameStr.length - 1]);
|
||||
//构造原始word文件获取的url,需要携带token
|
||||
String url = urlWord.get("url").toString();
|
||||
logger.info("download_url {}", url);
|
||||
param.put("download_url", url
|
||||
+ "&access_token=" + RequestContext.get().getGlobalSessionId());
|
||||
String paramUrl = getGetParamUrl(param);
|
||||
String officeToPdfUrl = getPdfUrl + "?" + paramUrl;
|
||||
logger.info("officeToPdfUrl {}", officeToPdfUrl);
|
||||
//word 转pdf之后的文件流
|
||||
return getInputStreamByUrl(officeToPdfUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过浏览器下载获取文件流
|
||||
* 传入一个url 地址,获取文件二进制流
|
||||
*
|
||||
* @param pdfUrl 地址
|
||||
*/
|
||||
public static InputStream getInputStreamByUrl(String pdfUrl) {
|
||||
//输入流
|
||||
try {
|
||||
// 当作一个URL来装载文件
|
||||
URL url = new URL(pdfUrl);
|
||||
URLConnection con = url.openConnection();
|
||||
con.setConnectTimeout(3 * 1000);
|
||||
return con.getInputStream();
|
||||
} catch (Exception e) {
|
||||
logger.error("word转pdf失败", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把key-value参数序列化成 url get参数
|
||||
*
|
||||
* @param body key-value
|
||||
* @return a=1&b=2
|
||||
*/
|
||||
public static String getGetParamUrl(Map<String, Object> body) {
|
||||
String client;
|
||||
String strBody = "";
|
||||
if (body != null && !body.isEmpty()) {
|
||||
Iterator<String> iterator = body.keySet().iterator();
|
||||
List<BasicNameValuePair> params = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
client = iterator.next();
|
||||
String value = body.get(client).toString();
|
||||
params.add(new BasicNameValuePair(client, value));
|
||||
}
|
||||
try {
|
||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
|
||||
strBody = EntityUtils.toString(entity);
|
||||
} catch (IOException var28) {
|
||||
logger.error("Http get error", var28);
|
||||
}
|
||||
}
|
||||
return strBody;
|
||||
}
|
||||
|
||||
public static String changeFileExtension(String fileName, String newExtension) {
|
||||
String fileNameWithoutExtension = removeFileExtension(fileName);
|
||||
return fileNameWithoutExtension + "." + newExtension;
|
||||
}
|
||||
|
||||
private static String removeFileExtension(String fileName) {
|
||||
int dotIndex = fileName.lastIndexOf(".");
|
||||
if (dotIndex > 0 && dotIndex < fileName.length() - 1) {
|
||||
return fileName.substring(0, dotIndex);
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
|
@ -3,38 +3,56 @@ package kd.cosmic;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.cosmic.server.Launcher;
|
||||
import kd.cosmic.server.Launcher;
|
||||
|
||||
/**
|
||||
* 启动本地应用程序(微服务节点)
|
||||
*/
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Launcher cosmic = new Launcher();
|
||||
//
|
||||
// cosmic.setClusterNumber("cosmic");
|
||||
// cosmic.setTenantNumber("sample");
|
||||
// cosmic.setServerIP("10.64.112.152");
|
||||
//// cosmic.set("fileserver", "http://10.64.112.152:30003/fileserver/");
|
||||
//// cosmic.set("imageServer.url", "http://10.64.112.152:30003/fileserver/");
|
||||
//// cosmic.set("attachmentServer.url", "http://10.64.112.152:30003/fileserver/");
|
||||
//
|
||||
//
|
||||
cosmic.setAppName("cosmic-25655-N0OqzfBY");
|
||||
cosmic.setWebPath("D:/Cosine/Comics_Debug/Comics_YXZG/YXZG-server/webapp");
|
||||
// cosmic.setConfigUrl("10.64.112.152:2181","zookeeper","Cosmic@5092");
|
||||
//
|
||||
// cosmic.setStartWithQing(false);
|
||||
//
|
||||
// cosmic.start();
|
||||
|
||||
// cosmic.setClusterNumber("cosmic");
|
||||
// cosmic.setTenantNumber("sample");
|
||||
// cosmic.setServerIP("10.64.112.152");
|
||||
//
|
||||
// cosmic.setAppName("cosmic-ZZSLL-6a9PvQR2");
|
||||
// cosmic.setWebPath("D:/Code/ensign-server/webapp");
|
||||
//
|
||||
// cosmic.setConfigUrl("10.64.112.152:2181","zookeeper","Cosmic@5092");
|
||||
|
||||
cosmic.setAppName("cosmic-violet-GNfGyyH1");
|
||||
cosmic.setWebPath("E:/Code/ensign_back/ensign-server/webapp");
|
||||
|
||||
//152
|
||||
////152
|
||||
cosmic.setClusterNumber("yxzg-topview-dev");
|
||||
cosmic.setTenantNumber("yxzg-topview-dev");
|
||||
cosmic.setServerIP("10.64.112.152");
|
||||
cosmic.setFileServerPathIPAndPort("", "");
|
||||
cosmic.setConfigUrl("10.64.112.152:2181", "zookeeper", "Cosmic@5092");
|
||||
cosmic.set("login.type","STANDALONE");
|
||||
|
||||
// 134
|
||||
System.setProperty("mq.debug.queue.tag", "wrxtest");
|
||||
////134
|
||||
// cosmic.setClusterNumber("yxzg-prod");
|
||||
// cosmic.setTenantNumber("yxzg-prod");
|
||||
// cosmic.setServerIP("10.64.111.134");
|
||||
// cosmic.setConfigUrl("10.64.111.134:2181","zookeeper","d@f*g:SGVsbG8==U4HRwjlqTOp0p9b60T+T8D2fQ8ThQgJLu/qgfLyLgknPa2RwYXNzd29yZA==");
|
||||
|
||||
|
||||
cosmic.setStartWithQing(false);
|
||||
|
||||
cosmic.start();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user