From afa3bc1e2f39f66f59ee9b15d6af16593acdc9a4 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期六, 02 十二月 2023 10:38:27 +0800 Subject: [PATCH] # --- src/main/java/com/zy/crm/common/web/DatavController.java | 79 +++++++++++++++++++++++++++++++++++---- 1 files changed, 71 insertions(+), 8 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 ee065f0..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,6 +1,9 @@ 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; @@ -8,26 +11,86 @@ 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 { - private String sql1; + 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"; - @PostConstruct - public void init() throws IOException { - this.sql1 = read(new ClassPathResource("datav/sql/1.sql").getInputStream()); +// { +// 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("/1test") - public R test1() { - return R.ok(this.sql1); + @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); } - public static String read(InputStream inputStream) { + private static String read(InputStream inputStream) { StringBuilder stringBuilder = new StringBuilder(); byte[] buffer = new byte[1024]; try { -- Gitblit v1.9.1