소스 검색

改用jar包部署
pdf 添加-付款金额字段

wuweihao 1 년 전
부모
커밋
66c99998aa

+ 4 - 1
pom.xml

@@ -5,7 +5,8 @@
 	<groupId>net.sppan</groupId>
 	<artifactId>DingDingOA</artifactId>
 	<version>0.0.1-SNAPSHOT</version>
-	<packaging>war</packaging>
+	<!--<packaging>war</packaging>-->
+	<packaging>jar</packaging>
 	<repositories>
 		<repository>
 			<id>nexus-aliyun</id>
@@ -202,5 +203,7 @@
 				</configuration>
 			</plugin>
 		</plugins>
+		<!--<finalName>${parent.artifactId}</finalName>-->
+		<finalName>age_dingding_oa</finalName>
 	</build>
 </project>

+ 2 - 1
remark.md

@@ -1 +1,2 @@
-# 钉钉-财务使用 2022-2-24
+# 钉钉-财务使用 2022-2-24
+可以本地运行生产数据

+ 68 - 0
run.sh

@@ -0,0 +1,68 @@
+#!/bin/sh
+APP_NAME=age_dingding_oa.jar
+APP_PORT=8077
+APP_EVN=$2   #执行环境 sit|pro
+APP_ORDER=$1   #执行方法  start|stop|restart
+# 获取进程号
+APP_PID=`netstat -ntpl | grep $APP_PORT | grep LISTEN | awk '{print $7}' | awk -F "/" '{print $1}'`
+
+
+# 启动命令
+startApp(){
+    if [ ${APP_PID} ];
+    then
+    	echo "程序已经在运行了"
+    else
+    	echo "执行 start 方法"
+    	nohup java -jar -Xmx3072M -Xms512M ./$APP_NAME --spring.profiles.active=$APP_EVN --server.port=$APP_PORT > logs.log 2>error.log &  # 说明pid为空
+    	n=20
+    	echo "延迟 $n 秒后查询启动线程号"
+        sleep $n
+    	runPid=$(lsof -i :$APP_PORT | awk 'NR==2 {print $2}')
+    echo "进程号:" $runPid "端口号:" $APP_PORT
+	echo Start Success!
+fi
+}
+
+
+
+
+# 停止命令
+stopApp(){
+    echo "执行 stop 方法"
+    if [ ${APP_PID} ];
+	then
+		echo $APP_NAME "存在,执行 stop 方法"
+			kill -9 ${APP_PID} && echo 'Kill Process!'
+	else
+		echo $APP_NAME 没有运行
+    fi
+}
+
+# 重启命令
+restartApp(){
+    echo " 1 执行 restart 方法"
+	stopApp
+	APP_PID=''  #将进程号置空
+	sleep 2
+	echo "进程号:" ${APP_PID} "端口号:" ${APP_PORT}
+	echo " 2 执行 restart 方法"
+	startApp
+}
+
+# 判断执行命令 取第一个参数
+case $APP_ORDER in
+    "start")
+        startApp
+        ;;
+    "stop")
+        stopApp
+        ;;
+	"restart")
+		restartApp
+        ;;
+        *)
+     ;;
+esac
+
+

+ 7 - 0
src/main/java/com/fourdage/base/common/HttpHelper.java

@@ -17,6 +17,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import com.fourdage.dingding.util.HtmlPdfUtil;
 import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.HttpClient;
@@ -25,8 +26,12 @@ import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.message.BasicNameValuePair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class HttpHelper {
+
+
 	
 	/**
      * POST请求
@@ -219,6 +224,8 @@ public class HttpHelper {
             } else {
                 url = new URL(urlStr);
             }
+
+            System.out.println("url:" + url);
             URLConnection con = url.openConnection();
             // 设置请求属性
             con.setRequestProperty("accept", "*/*");

+ 1 - 0
src/main/java/com/fourdage/dingding/controller/ExaminationController.java

@@ -195,6 +195,7 @@ public class ExaminationController extends BaseController{
      */
     @RequestMapping(value = "/download", method = RequestMethod.GET)
     public void download(String processInstanceId, String processCodeId, String title, String businessId, HttpServletResponse res){
+    	logger.info("run download");
     	
         //首先查找文件是否已经存在
     	ProcessCode processCode = processCodeService.findById(Integer.valueOf(processCodeId));

+ 49 - 1
src/main/java/com/fourdage/dingding/util/HtmlPdfUtil.java

@@ -61,11 +61,13 @@ public class HtmlPdfUtil {
 	private String blankCode = "            &nbsp;&nbsp;";
 	
 	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");

+ 26 - 0
src/main/resources/application-dev.properties

@@ -0,0 +1,26 @@
+#springboot_config
+server.port=8077
+
+logging.config=classpath:logback.xml
+
+# jdbc_config
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa?characterEncoding=utf8
+#spring.datasource.username=root
+#spring.datasource.password=123456
+
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa_pro?characterEncoding=utf8
+spring.datasource.username=root
+spring.datasource.password=root
+
+#windows path
+#web.pdf.file.path=D:/4dseeshow/pdf/
+
+#linux path
+web.pdf.file.path=D:/dingding_oa_file/pdf/
+
+spring.mvc.static-path-pattern=/**
+spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.pdf.file.path}
+
+

+ 23 - 0
src/main/resources/application-pro.properties

@@ -0,0 +1,23 @@
+
+
+# jdbc_config
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa?characterEncoding=utf8
+#spring.datasource.username=root
+#spring.datasource.password=123456
+
+spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa_pro?characterEncoding=utf8&useSSL=false
+spring.datasource.username=root
+spring.datasource.password=4DAGE168
+
+
+
+#linux path
+#web.pdf.file.path=D:/dingding_oa_file/pdf/
+web.pdf.file.path=/opt/dingdingoa/pdf/
+
+spring.mvc.static-path-pattern=/**
+spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.pdf.file.path}
+
+

+ 27 - 0
src/main/resources/application-sit.properties

@@ -0,0 +1,27 @@
+
+
+# jdbc_config
+spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa?characterEncoding=utf8
+#spring.datasource.username=root
+#spring.datasource.password=123456
+
+#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa_pro?characterEncoding=utf8&useSSL=false
+#spring.datasource.username=root
+#spring.datasource.password=4DAGE168
+
+spring.datasource.url=jdbc:mysql://8.135.106.227:3306/dingdingoa_pro?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
+spring.datasource.password=4dkk2021testproject%
+spring.datasource.username=root
+
+
+
+#linux path
+#web.pdf.file.path=D:/dingding_oa_file/pdf/
+web.pdf.file.path=/home/data/age_dingding_oa_data/pdf/
+
+spring.mvc.static-path-pattern=/**
+spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.pdf.file.path}
+
+

+ 1 - 13
src/main/resources/application.properties

@@ -2,17 +2,12 @@
 server.port=8077
 
 logging.config=classpath:logback.xml
+spring.profiles.active=dev
 
 # jdbc_config
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
-#spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa?characterEncoding=utf8
-#spring.datasource.username=root
-#spring.datasource.password=123456
 
-spring.datasource.url=jdbc:mysql://127.0.0.1:3306/dingdingoa_pro?characterEncoding=utf8
-spring.datasource.username=root
-spring.datasource.password=root
 
 
 # jpa
@@ -41,13 +36,6 @@ spring.freemarker.settings.date_format=yyyy-MM-dd
 spring.freemarker.settings.time_format=HH:mm:ss
 spring.freemarker.settings.datetime_format=yyyy-MM-dd HH:mm:ss
 
-#windows path
-#web.pdf.file.path=D:/4dseeshow/pdf/
 
-#linux path
-web.pdf.file.path=D:/dingding_oa_file/pdf/
-
-spring.mvc.static-path-pattern=/**
-spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.pdf.file.path}