|
@@ -61,11 +61,13 @@ public class HtmlPdfUtil {
|
|
|
private String blankCode = " ";
|
|
|
|
|
|
public void generateHTMLFile(String accessToken, String processInstanceId, String fileName) {
|
|
|
+ logger.info("run generateHTMLFile");
|
|
|
// FileWriter out = null;
|
|
|
OutputStreamWriter out = null;
|
|
|
try {
|
|
|
String title = "";
|
|
|
String businessId = "";
|
|
|
+ logger.info("请求参数,processInstanceId:{}, accessToken:{}", processInstanceId, accessToken);
|
|
|
JSONObject jsonResult = dingdingUtil.getDingDingJSONResult(processInstanceId, accessToken);
|
|
|
logger.info("钉钉返回数据: {}", jsonResult);
|
|
|
if (jsonResult.getBoolean("success")){
|
|
@@ -140,10 +142,13 @@ public class HtmlPdfUtil {
|
|
|
}
|
|
|
|
|
|
public String generateHtmlAndPDF(String accessToken, String processInstanceId, String processCodeName) {
|
|
|
+ logger.info("run generateHtmlAndPDF");
|
|
|
String fileName = "";
|
|
|
try {
|
|
|
//从钉钉接口获取结果
|
|
|
+// logger.info("请求参数,processInstanceId:{}, accessToken:{}", processInstanceId, accessToken);
|
|
|
JSONObject jsonResult = dingdingUtil.getDingDingJSONResult(processInstanceId, accessToken);
|
|
|
+ logger.info("钉钉返回数据2: {}", jsonResult);
|
|
|
if (!jsonResult.getBoolean("success")) {
|
|
|
return "";
|
|
|
}
|
|
@@ -169,6 +174,7 @@ public class HtmlPdfUtil {
|
|
|
}
|
|
|
|
|
|
public void generatePdfFile(String filePathName) {
|
|
|
+ logger.info("run generatePdfFile 11111");
|
|
|
Document document = null;
|
|
|
FileInputStream fis = null;
|
|
|
BufferedReader br = null;
|
|
@@ -286,7 +292,18 @@ public class HtmlPdfUtil {
|
|
|
}
|
|
|
|
|
|
private StringBuffer generateForm(JSONObject result) {
|
|
|
+ logger.info("run generateForm");
|
|
|
+ logger.info("输入参数:{}", result);
|
|
|
+
|
|
|
JSONArray formArray = result.getJSONObject("form_component_values").getJSONArray("form_component_value_vo");
|
|
|
+ logger.info("formArray:{}", formArray);
|
|
|
+
|
|
|
+
|
|
|
+ // 2023-09-18 获取付款金额
|
|
|
+ JSONObject hasPay = getHasPay(formArray);
|
|
|
+// formArray.add(hasPay);
|
|
|
+ formArray.add(7, hasPay);
|
|
|
+
|
|
|
StringBuffer formSB = null;
|
|
|
if (formArray != null && formArray.size() > 0){
|
|
|
formSB = new StringBuffer();
|
|
@@ -393,7 +410,38 @@ public class HtmlPdfUtil {
|
|
|
}
|
|
|
return formSB;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private JSONObject getHasPay(JSONArray formArray) {
|
|
|
+ String subValue = "0";
|
|
|
+
|
|
|
+ for (Object o : formArray) {
|
|
|
+ JSONObject parentJson = JSONObject.parseObject(o.toString());
|
|
|
+ if ("DDBizSuite".equals(parentJson.getString("component_type"))){
|
|
|
+ String valueStr = parentJson.getString("value");
|
|
|
+ JSONArray subArray = JSONArray.parseArray(valueStr);
|
|
|
+ for (Object sub : subArray) {
|
|
|
+ JSONObject subJson = JSONObject.parseObject(sub.toString());
|
|
|
+ if ("MoneyField".equals(subJson.getString("componentType"))){
|
|
|
+ subValue = subJson.getString("value");
|
|
|
+ logger.info("付款金额:{}", subValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject res = new JSONObject();
|
|
|
+ res.put("component_type", "MoneyField");
|
|
|
+ res.put("id", null);
|
|
|
+ res.put("name", "付款金额");
|
|
|
+ res.put("value", subValue);
|
|
|
+ logger.info("返回结果:{}", res);
|
|
|
+
|
|
|
+ return res;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private String getDetailHtml(String accessToken, JSONObject jsonResult, String type) {
|
|
|
StringBuffer sb = new StringBuffer();
|
|
|
JSONObject result = jsonResult.getJSONObject("process_instance");
|