From baa98c7a04e13ac1630696b532add9c3e7f0d907 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 10 十一月 2023 15:30:56 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/crm/common/web/DatavController.java | 124 ++++++++++++++++++++++++++++++++--------
1 files changed, 98 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/zy/crm/common/web/DatavController.java b/src/main/java/com/zy/crm/common/web/DatavController.java
index 4994858..d42e254 100644
--- a/src/main/java/com/zy/crm/common/web/DatavController.java
+++ b/src/main/java/com/zy/crm/common/web/DatavController.java
@@ -1,41 +1,113 @@
package com.zy.crm.common.web;
+import com.core.common.Cools;
import com.core.common.R;
+import com.zy.crm.common.service.DbSqlServer;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.PostConstruct;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
/**
* Created by vincent on 2023/7/25
*/
@RestController
+@SuppressWarnings("all")
public class DatavController {
- @GetMapping("/1test")
- public R test1() {
- /**
- * select
- * (case when A.org='1002208180000267' then '鍢夊杽'
- * when A.org='1002208180000506' then '骞垮痉'
- * else '' end) as 缁勭粐,
- * A.DocNo as 鍗曞彿,A3.Code as 椤圭洰鍙�,
- * (case when A.DocState='0' then '寮�绔�'
- * when A.DocState='1' then '宸插鏍�'
- * when A.DocState='2' then '寮�宸�'
- * when A.DocState='3' then '瀹屽伐'
- * when A.DocState='4' then '鏍稿噯涓�'
- * ELSE'' end) as 鐘舵��,
- * A.StartDate as 璁″垝寮�宸ユ棩,
- * A.CompleteDate as 璁″垝瀹屽伐鏃�,A2.Code as 鏂欏彿,A2.name as 鍝佸悕,A2.SPECS as 瑙勬牸 , a.ProductQty as 鐢熶骇鏁伴噺,TotalCompleteQty as 瀹屽伐鏁伴噺
- * from MO_MO as A
- * left join CBO_ItemMaster as A2 on (A.ItemMaster = A2.ID)
- * left join CBO_Project as A3 on (A.Project = A3.ID)
- * where
- * A.MODocType != '1002306121624435' --杩囨护鍐呴儴鐮斿彂椤圭洰
- * and A.IsWBSTask!=1 --杩囨护鐜板満鏂藉伐浠诲姟
- * and A.DocState != '3' --杩囨护瀹屽伐鐘舵�佺殑璁㈠崟
- * ORDER BY A.CompleteDate
- */
- return R.ok();
+ private String product = "select\n" +
+ "A5.NAME AS 鎵�灞炵粍缁�,\n" +
+ "A.DocNo as 鍗曞彿,A3.Code as 椤圭洰鍙�,a7.Name as 鍗曟嵁绫诲瀷,\n" +
+ "A.StartDate as 璁″垝寮�宸ユ棩,\n" +
+ "A.CompleteDate as 璁″垝瀹屽伐鏃�,A2.Code as 鏂欏彿,A2.name as 鍝佸悕,A2.SPECS as 瑙勬牸 , a.ProductQty as 鐢熶骇鏁伴噺,TotalCompleteQty as 瀹屽伐鏁伴噺\n" +
+ "from MO_MO as A\n" +
+ "left join CBO_ItemMaster as A2 on (A.ItemMaster = A2.ID)\n" +
+ "left join CBO_Project as A3 on (A.Project = A3.ID)\n" +
+ "left join Base_Organization as A4 on (A.Org = A4.ID)\n" +
+ "left join Base_Organization_Trl as a5 on (a4.ID = a5.ID)\n" +
+ "left join MO_MODocType as a6 on (a.MODocType=a6.ID)\n" +
+ "left join MO_MODocType_Trl as a7 on (a6.id=a7.ID)\n" +
+ "where A7.NAME != '鐮斿彂椤圭洰' --杩囨护鍐呴儴鐮斿彂椤圭洰\n" +
+ "and A.IsWBSTask!=1 --杩囨护鐜板満鏂藉伐浠诲姟\n" +
+ "and A.DocState != '3' --杩囨护瀹屽伐鐘舵�佺殑璁㈠崟\n" +
+ "and (A7.NAME IS NOT NULL AND A7.NAME !='')\n" +
+ "ORDER BY A.CompleteDate";
+ private String sale = "select sum(total) as sum, month\n" +
+ "from\n" +
+ "(\n" +
+ "\tselect A.DOCNO as 椤圭洰鍙�,a.TotalMoneyTC as total,a.CreatedOn as 鍒涘缓鏃ユ湡,a3.PersonName_DisplayName as 涓氬姟鍛�,\n" +
+ "\ta7.Name as 椤圭洰绫诲瀷,A6.Name as 瀹㈡埛鍚嶇О,A9.name AS 鎵�灞炵粍缁�,Month(a.CreatedOn) as month\n" +
+ "\tfrom SM_SO as A\n" +
+ "\tleft join CBO_Operators as A2 on(A.Seller = A2.ID)\n" +
+ "\tleft join Base_Contact as A3 on (a2.Contact=a3.ID)\n" +
+ "\tleft join SM_SODocType as A4 on (A.DocumentType = a4.ID)\n" +
+ "\tleft join SM_SODocType_Trl as A7 ON (A4.ID=A7.ID)\n" +
+ "\tleft join CBO_Customer as A5 on(A.OrderBy_Customer = A5.ID)\n" +
+ "\tleft join CBO_Customer_Trl as A6 on (A5.ID=A6.ID) AND (A6.SysMLFlag = 'zh-CN')\n" +
+ "\tleft join Base_Organization as A8 on (A.Org = A8.ID)\n" +
+ "\tleft join Base_Organization_Trl as a9 on (a8.ID = a9.ID)\n" +
+ "\twhere A5.CODE not in ('S-00002','S-00003') --杩囨护鍐呴儴浜ゆ槗鐨勮鍗昞n" +
+ ") a\n" +
+ "group by month\n" +
+ "order by month asc\n";
+
+// {
+// try {
+// this.product = read(new ClassPathResource("datav/sql/product.sql").getInputStream());
+// this.閿�鍞鍗� = read(new ClassPathResource("datav/sql/閿�鍞鍗�.sql").getInputStream());
+// } catch (IOException ignore) {}
+// }
+//
+
+ @Autowired
+ private DbSqlServer dbSqlServer;
+
+ @GetMapping("/data1")
+ public R data1() {
+ List<Map<String, Object>> res = dbSqlServer.select(this.product);
+ if (Cools.isEmpty(res)) {
+ return R.ok();
+ }
+ int limit = 30;
+ if (res.size() > limit) {
+ res = res.subList(0, limit);
+ }
+ return R.ok().add(res);
+ }
+
+ @GetMapping("/data3")
+ public R data3() {
+ List<Map<String, Object>> res = dbSqlServer.select(this.sale);
+ if (Cools.isEmpty(res)) {
+ return R.ok();
+ }
+ return R.ok().add(res);
+ }
+
+ private static String read(InputStream inputStream) {
+ StringBuilder stringBuilder = new StringBuilder();
+ byte[] buffer = new byte[1024];
+ try {
+ int bytesRead;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ stringBuilder.append(new String(buffer, 0, bytesRead));
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return stringBuilder.toString();
}
}
--
Gitblit v1.9.1