当前位置:   article > 正文

基于springboot广场舞团管理系统源码和论文

基于springboot广场舞团管理系统源码和论文

随着信息技术和网络技术的飞速发展,人类已进入全新信息化时代,传统管理技术已无法高效,便捷地管理信息。为了迎合时代需求,优化管理效率,各种各样的管理系统应运而生,各行各业相继进入信息管理时代,广场舞团就是信息时代变革中的产物之一。

任何系统都要遵循系统设计的基本流程,本系统也不例外,同样需要经过市场调研,需求分析,概要设计,详细设计,编码,测试这些步骤,基于java语言设计并实现了广场舞团。该系统基于B/S即所谓浏览器/服务器模式,应用java技术,选择MySQL作为后台数据库。系统主要包括系统首页,社团,社团活动,交流中心,公告资讯,个人中心,后台管理等功能模块。

本文首先介绍了广场舞团管理的技术发展背景与发展现状,然后遵循软件常规开发流程,首先针对系统选取适用的语言和开发平台,根据需求分析制定模块并设计数据库结构,再根据系统总体功能模块的设计绘制系统的功能模块图,流程图以及E-R图。然后,设计框架并根据设计的框架编写代码以实现系统的各个功能模块。最后,对初步完成的系统进行测试,主要是功能测试、单元测试和性能测试。测试结果表明,该系统能够实现所需的功能,运行状况尚可并无明显缺点

关键词:广场舞团;java;MySQL数据库

基于springboot广场舞团管理系统源码和论文368

基于springboot广场舞团管理系统源码和论文


Abstract

With the rapid development of information technology and network technology, mankind has entered a new era of information technology, and traditional management technology has been unable to manage information efficiently and conveniently. In order to meet the needs of the times and optimize management efficiency, a variety of management systems came into being, and all walks of life have entered the era of information management, and square dance troupes are one of the products of the change in the information age.

Any system must follow the basic process of system design, this system is no exception, the same need to go through market research, requirements analysis, outline design, detailed design, coding, testing these steps, based on the Java language design and the realization of square dance troupe. The system is based on B/S, the so-called browser/server model, which applies Java technology and selects MySQL as the background database. The system mainly includes functional modules such as system homepage, community, community activities, communication center, announcement information, personal center, background management and so on.

This article first introduces the technical development background and development status of square dance troupe management, and then follows the conventional development process of the software, first selects the applicable language and development platform for the system, formulates the module and designs the database structure according to the requirements analysis, and then draws the functional module diagram, flow chart and E-R diagram of the system according to the design of the overall functional module of the system. Then, design the framework and write code based on the designed framework to implement the various functional modules of the system. Finally, the initially completed system is tested, mainly functional, unit, and performance tests. The test results show that the system can achieve the required functions, and the operating conditions are not obvious.

Keywords: square dance troupe; java; MySQL database

  1. package com.controller;
  2. import java.io.*;
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.*;
  8. import javax.servlet.http.HttpServletRequest;
  9. import com.alibaba.fastjson.JSON;
  10. import com.utils.StringUtil;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.json.JSONObject;
  13. import org.slf4j.Logger;
  14. import org.slf4j.LoggerFactory;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.beans.factory.annotation.Value;
  17. import org.springframework.util.ResourceUtils;
  18. import org.springframework.web.bind.annotation.PathVariable;
  19. import org.springframework.web.bind.annotation.RequestBody;
  20. import org.springframework.web.bind.annotation.RequestMapping;
  21. import org.springframework.web.bind.annotation.RequestParam;
  22. import org.springframework.web.bind.annotation.RestController;
  23. import com.annotation.IgnoreAuth;
  24. import com.baidu.aip.face.AipFace;
  25. import com.baidu.aip.face.MatchRequest;
  26. import com.baidu.aip.util.Base64Util;
  27. import com.baomidou.mybatisplus.mapper.EntityWrapper;
  28. import com.baomidou.mybatisplus.mapper.Wrapper;
  29. import com.entity.ConfigEntity;
  30. import com.service.CommonService;
  31. import com.service.ConfigService;
  32. import com.utils.BaiduUtil;
  33. import com.utils.FileUtil;
  34. import com.utils.R;
  35. /**
  36. * 通用接口
  37. */
  38. @RestController
  39. public class CommonController {
  40. private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
  41. @Autowired
  42. private CommonService commonService;
  43. /**
  44. * Java代码实现MySQL数据库导出
  45. *
  46. * @param mysqlUrl MySQL安装路径
  47. * @param hostIP MySQL数据库所在服务器地址IP
  48. * @param userName 进入数据库所需要的用户名
  49. * @param hostPort 数据库端口
  50. * @param password 进入数据库所需要的密码
  51. * @param savePath 数据库文件保存路径
  52. * @param fileName 数据库导出文件文件名
  53. * @param databaseName 要导出的数据库名
  54. * @return 返回true表示导出成功,否则返回false。
  55. */
  56. @IgnoreAuth
  57. @RequestMapping("/beifen")
  58. public R beifen(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {
  59. File saveFile = new File(savePath);
  60. if (!saveFile.exists()) {// 如果目录不存在 
  61. saveFile.mkdirs();// 创建文件夹 
  62. }
  63. if (!savePath.endsWith(File.separator)) {
  64. savePath = savePath + File.separator;
  65. }
  66. PrintWriter printWriter = null;
  67. BufferedReader bufferedReader = null;
  68. try {
  69. Runtime runtime = Runtime.getRuntime();
  70. String cmd = mysqlUrl + "mysqldump -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName;
  71. runtime.exec(cmd);
  72. Process process = runtime.exec(cmd);
  73. InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream(), "utf8");
  74. bufferedReader = new BufferedReader(inputStreamReader);
  75. printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(savePath + fileName), "utf8"));
  76. String line;
  77. while ((line = bufferedReader.readLine()) != null) {
  78. printWriter.println(line);
  79. }
  80. printWriter.flush();
  81. } catch (Exception e) {
  82. e.printStackTrace();
  83. return R.error("备份数据出错");
  84. } finally {
  85. try {
  86. if (bufferedReader != null) {
  87. bufferedReader.close();
  88. }
  89. if (printWriter != null) {
  90. printWriter.close();
  91. }
  92. } catch (Exception e) {
  93. e.printStackTrace();
  94. }
  95. }
  96. return R.ok();
  97. }
  98. /**
  99. * Java实现MySQL数据库导入
  100. *
  101. * @param mysqlUrl MySQL安装路径
  102. * @param hostIP MySQL数据库所在服务器地址IP
  103. * @param userName 进入数据库所需要的用户名
  104. * @param hostPort 数据库端口
  105. * @param password 进入数据库所需要的密码
  106. * @param savePath 数据库文件保存路径
  107. * @param fileName 数据库导出文件文件名
  108. * @param databaseName 要导出的数据库名
  109. */
  110. @IgnoreAuth
  111. @RequestMapping("/huanyuan")
  112. public R huanyuan(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {
  113. try {
  114. Runtime rt = Runtime.getRuntime();
  115. Process child1 = rt.exec(mysqlUrl+"mysql.exe -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName);
  116. OutputStream out = child1.getOutputStream();//控制台的输入信息作为输出流
  117. String inStr;
  118. StringBuffer sb = new StringBuffer("");
  119. String outStr;
  120. BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(savePath+"/"+fileName), "utf-8"));
  121. while ((inStr = br.readLine()) != null) {
  122. sb.append(inStr + "\r\n");
  123. }
  124. outStr = sb.toString();
  125. OutputStreamWriter writer = new OutputStreamWriter(out, "utf8");
  126. writer.write(outStr);
  127. // 注:这里如果用缓冲方式写入文件的话,会导致中文乱码,用flush()方法则可以避免
  128. writer.flush();
  129. out.close();
  130. br.close();
  131. writer.close();
  132. } catch (Exception e) {
  133. e.printStackTrace();
  134. return R.error("数据导入出错");
  135. }
  136. return R.ok();
  137. }
  138. /**
  139. * 饼状图求和
  140. * @return
  141. */
  142. @RequestMapping("/pieSum")
  143. public R pieSum(@RequestParam Map<String,Object> params) {
  144. logger.debug("饼状图求和:,,Controller:{},,params:{}",this.getClass().getName(),params);
  145. List<Map<String, Object>> result = commonService.pieSum(params);
  146. return R.ok().put("data", result);
  147. }
  148. /**
  149. * 饼状图统计
  150. * @return
  151. */
  152. @RequestMapping("/pieCount")
  153. public R pieCount(@RequestParam Map<String,Object> params) {
  154. logger.debug("饼状图统计:,,Controller:{},,params:{}",this.getClass().getName(),params);
  155. List<Map<String, Object>> result = commonService.pieCount(params);
  156. return R.ok().put("data", result);
  157. }
  158. /**
  159. * 柱状图求和单列
  160. * @return
  161. */
  162. @RequestMapping("/barSumOne")
  163. public R barSumOne(@RequestParam Map<String,Object> params) {
  164. logger.debug("柱状图求和单列:,,Controller:{},,params:{}",this.getClass().getName(),params);
  165. List<Map<String, Object>> result = commonService.barSumOne(params);
  166. List<String> xAxis = new ArrayList<>();//报表x轴
  167. List<List<String>> yAxis = new ArrayList<>();//y轴
  168. List<String> legend = new ArrayList<>();//标题
  169. List<String> yAxis0 = new ArrayList<>();
  170. yAxis.add(yAxis0);
  171. legend.add("");
  172. for(Map<String, Object> map :result){
  173. String oneValue = String.valueOf(map.get("name"));
  174. String value = String.valueOf(map.get("value"));
  175. xAxis.add(oneValue);
  176. yAxis0.add(value);
  177. }
  178. Map<String, Object> resultMap = new HashMap<>();
  179. resultMap.put("xAxis",xAxis);
  180. resultMap.put("yAxis",yAxis);
  181. resultMap.put("legend",legend);
  182. return R.ok().put("data", resultMap);
  183. }
  184. /**
  185. * 柱状图统计单列
  186. * @return
  187. */
  188. @RequestMapping("/barCountOne")
  189. public R barCountOne(@RequestParam Map<String,Object> params) {
  190. logger.debug("柱状图统计单列:,,Controller:{},,params:{}",this.getClass().getName(),params);
  191. List<Map<String, Object>> result = commonService.barCountOne(params);
  192. List<String> xAxis = new ArrayList<>();//报表x轴
  193. List<List<String>> yAxis = new ArrayList<>();//y轴
  194. List<String> legend = new ArrayList<>();//标题
  195. List<String> yAxis0 = new ArrayList<>();
  196. yAxis.add(yAxis0);
  197. legend.add("");
  198. for(Map<String, Object> map :result){
  199. String oneValue = String.valueOf(map.get("name"));
  200. String value = String.valueOf(map.get("value"));
  201. xAxis.add(oneValue);
  202. yAxis0.add(value);
  203. }
  204. Map<String, Object> resultMap = new HashMap<>();
  205. resultMap.put("xAxis",xAxis);
  206. resultMap.put("yAxis",yAxis);
  207. resultMap.put("legend",legend);
  208. return R.ok().put("data", resultMap);
  209. }
  210. /**
  211. * 柱状图统计双列
  212. * @return
  213. */
  214. @RequestMapping("/barSumTwo")
  215. public R barSumTwo(@RequestParam Map<String,Object> params) {
  216. logger.debug("柱状图统计双列:,,Controller:{},,params:{}",this.getClass().getName(),params);
  217. List<Map<String, Object>> result = commonService.barSumTwo(params);
  218. List<String> xAxis = new ArrayList<>();//报表x轴
  219. List<List<String>> yAxis = new ArrayList<>();//y轴
  220. List<String> legend = new ArrayList<>();//标题
  221. Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
  222. for(Map<String, Object> map :result){
  223. String name1Value = String.valueOf(map.get("name1"));
  224. String name2Value = String.valueOf(map.get("name2"));
  225. String value = String.valueOf(map.get("value"));
  226. if(!legend.contains(name2Value)){
  227. legend.add(name2Value);//添加完成后 就是最全的第二列的类型
  228. }
  229. if(dataMap.containsKey(name1Value)){
  230. dataMap.get(name1Value).put(name2Value,value);
  231. }else{
  232. HashMap<String, String> name1Data = new HashMap<>();
  233. name1Data.put(name2Value,value);
  234. dataMap.put(name1Value,name1Data);
  235. }
  236. }
  237. for(int i =0; i<legend.size(); i++){
  238. yAxis.add(new ArrayList<String>());
  239. }
  240. Set<String> keys = dataMap.keySet();
  241. for(String key:keys){
  242. xAxis.add(key);
  243. HashMap<String, String> map = dataMap.get(key);
  244. for(int i =0; i<legend.size(); i++){
  245. List<String> data = yAxis.get(i);
  246. if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
  247. data.add(map.get(legend.get(i)));
  248. }else{
  249. data.add("0");
  250. }
  251. }
  252. }
  253. System.out.println();
  254. Map<String, Object> resultMap = new HashMap<>();
  255. resultMap.put("xAxis",xAxis);
  256. resultMap.put("yAxis",yAxis);
  257. resultMap.put("legend",legend);
  258. return R.ok().put("data", resultMap);
  259. }
  260. /**
  261. * 柱状图统计双列
  262. * @return
  263. */
  264. @RequestMapping("/barCountTwo")
  265. public R barCountTwo(@RequestParam Map<String,Object> params) {
  266. logger.debug("柱状图统计双列:,,Controller:{},,params:{}",this.getClass().getName(),params);
  267. List<Map<String, Object>> result = commonService.barCountTwo(params);
  268. List<String> xAxis = new ArrayList<>();//报表x轴
  269. List<List<String>> yAxis = new ArrayList<>();//y轴
  270. List<String> legend = new ArrayList<>();//标题
  271. Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
  272. for(Map<String, Object> map :result){
  273. String name1Value = String.valueOf(map.get("name1"));
  274. String name2Value = String.valueOf(map.get("name2"));
  275. String value = String.valueOf(map.get("value"));
  276. if(!legend.contains(name2Value)){
  277. legend.add(name2Value);//添加完成后 就是最全的第二列的类型
  278. }
  279. if(dataMap.containsKey(name1Value)){
  280. dataMap.get(name1Value).put(name2Value,value);
  281. }else{
  282. HashMap<String, String> name1Data = new HashMap<>();
  283. name1Data.put(name2Value,value);
  284. dataMap.put(name1Value,name1Data);
  285. }
  286. }
  287. for(int i =0; i<legend.size(); i++){
  288. yAxis.add(new ArrayList<String>());
  289. }
  290. Set<String> keys = dataMap.keySet();
  291. for(String key:keys){
  292. xAxis.add(key);
  293. HashMap<String, String> map = dataMap.get(key);
  294. for(int i =0; i<legend.size(); i++){
  295. List<String> data = yAxis.get(i);
  296. if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
  297. data.add(map.get(legend.get(i)));
  298. }else{
  299. data.add("0");
  300. }
  301. }
  302. }
  303. System.out.println();
  304. Map<String, Object> resultMap = new HashMap<>();
  305. resultMap.put("xAxis",xAxis);
  306. resultMap.put("yAxis",yAxis);
  307. resultMap.put("legend",legend);
  308. return R.ok().put("data", resultMap);
  309. }
  310. /**
  311. tableName 查询表
  312. condition1 条件1
  313. condition1Value 条件1
  314. average 计算平均评分
  315. 取值
  316. 有值 Number(res.data.value.toFixed(1))
  317. 无值 if(res.data){}
  318. * */
  319. @IgnoreAuth
  320. @RequestMapping("/queryScore")
  321. public R queryScore(@RequestParam Map<String, Object> params) {
  322. logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params);
  323. Map<String, Object> queryScore = commonService.queryScore(params);
  324. return R.ok().put("data", queryScore);
  325. }
  326. /**
  327. * 查询字典表的分组统计总条数
  328. * tableName 表名
  329. * groupColumn 分组字段
  330. * @return
  331. */
  332. @RequestMapping("/newSelectGroupCount")
  333. public R newSelectGroupCount(@RequestParam Map<String,Object> params) {
  334. logger.debug("newSelectGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params);
  335. List<Map<String, Object>> result = commonService.newSelectGroupCount(params);
  336. return R.ok().put("data", result);
  337. }
  338. /**
  339. * 查询字典表的分组求和
  340. * tableName 表名
  341. * groupColumn 分组字段
  342. * sumCloum 统计字段
  343. * @return
  344. */
  345. @RequestMapping("/newSelectGroupSum")
  346. public R newSelectGroupSum(@RequestParam Map<String,Object> params) {
  347. logger.debug("newSelectGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params);
  348. List<Map<String, Object>> result = commonService.newSelectGroupSum(params);
  349. return R.ok().put("data", result);
  350. }
  351. /**
  352. * 柱状图求和 老的
  353. */
  354. @RequestMapping("/barSum")
  355. public R barSum(@RequestParam Map<String,Object> params) {
  356. logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
  357. Boolean isJoinTableFlag = false;//是否有级联表相关
  358. String one = "";//第一优先
  359. String two = "";//第二优先
  360. //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
  361. //当前表
  362. Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
  363. params.put("thisTable",thisTable);
  364. //级联表
  365. String joinTableString = String.valueOf(params.get("joinTable"));
  366. if(StringUtil.isNotEmpty(joinTableString)) {
  367. Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
  368. params.put("joinTable", joinTable);
  369. isJoinTableFlag = true;
  370. }
  371. if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
  372. thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
  373. one = "thisDate0";
  374. }
  375. if(isJoinTableFlag){//级联表日期
  376. Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
  377. if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
  378. joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
  379. if(StringUtil.isEmpty(one)){
  380. one ="joinDate0";
  381. }else{
  382. if(StringUtil.isEmpty(two)){
  383. two ="joinDate0";
  384. }
  385. }
  386. }
  387. }
  388. if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
  389. thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
  390. if(StringUtil.isEmpty(one)){
  391. one ="thisString0";
  392. }else{
  393. if(StringUtil.isEmpty(two)){
  394. two ="thisString0";
  395. }
  396. }
  397. }
  398. if(isJoinTableFlag){//级联表字符串
  399. Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
  400. if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
  401. joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
  402. if(StringUtil.isEmpty(one)){
  403. one ="joinString0";
  404. }else{
  405. if(StringUtil.isEmpty(two)){
  406. two ="joinString0";
  407. }
  408. }
  409. }
  410. }
  411. if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
  412. thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
  413. if(StringUtil.isEmpty(one)){
  414. one ="thisTypes0";
  415. }else{
  416. if(StringUtil.isEmpty(two)){
  417. two ="thisTypes0";
  418. }
  419. }
  420. }
  421. if(isJoinTableFlag){//级联表类型
  422. Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
  423. if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
  424. joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
  425. if(StringUtil.isEmpty(one)){
  426. one ="joinTypes0";
  427. }else{
  428. if(StringUtil.isEmpty(two)){
  429. two ="joinTypes0";
  430. }
  431. }
  432. }
  433. }
  434. List<Map<String, Object>> result = commonService.barSum(params);
  435. List<String> xAxis = new ArrayList<>();//报表x轴
  436. List<List<String>> yAxis = new ArrayList<>();//y轴
  437. List<String> legend = new ArrayList<>();//标题
  438. if(StringUtil.isEmpty(two)){//不包含第二列
  439. List<String> yAxis0 = new ArrayList<>();
  440. yAxis.add(yAxis0);
  441. legend.add("");
  442. for(Map<String, Object> map :result){
  443. String oneValue = String.valueOf(map.get(one));
  444. String value = String.valueOf(map.get("value"));
  445. xAxis.add(oneValue);
  446. yAxis0.add(value);
  447. }
  448. }else{//包含第二列
  449. Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
  450. if(StringUtil.isNotEmpty(two)){
  451. for(Map<String, Object> map :result){
  452. String oneValue = String.valueOf(map.get(one));
  453. String twoValue = String.valueOf(map.get(two));
  454. String value = String.valueOf(map.get("value"));
  455. if(!legend.contains(twoValue)){
  456. legend.add(twoValue);//添加完成后 就是最全的第二列的类型
  457. }
  458. if(dataMap.containsKey(oneValue)){
  459. dataMap.get(oneValue).put(twoValue,value);
  460. }else{
  461. HashMap<String, String> oneData = new HashMap<>();
  462. oneData.put(twoValue,value);
  463. dataMap.put(oneValue,oneData);
  464. }
  465. }
  466. }
  467. for(int i =0; i<legend.size(); i++){
  468. yAxis.add(new ArrayList<String>());
  469. }
  470. Set<String> keys = dataMap.keySet();
  471. for(String key:keys){
  472. xAxis.add(key);
  473. HashMap<String, String> map = dataMap.get(key);
  474. for(int i =0; i<legend.size(); i++){
  475. List<String> data = yAxis.get(i);
  476. if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
  477. data.add(map.get(legend.get(i)));
  478. }else{
  479. data.add("0");
  480. }
  481. }
  482. }
  483. System.out.println();
  484. }
  485. Map<String, Object> resultMap = new HashMap<>();
  486. resultMap.put("xAxis",xAxis);
  487. resultMap.put("yAxis",yAxis);
  488. resultMap.put("legend",legend);
  489. return R.ok().put("data", resultMap);
  490. }
  491. /**
  492. * 柱状图统计 老的
  493. */
  494. @RequestMapping("/barCount")
  495. public R barCount(@RequestParam Map<String,Object> params) {
  496. logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
  497. Boolean isJoinTableFlag = false;//是否有级联表相关
  498. String one = "";//第一优先
  499. String two = "";//第二优先
  500. //处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
  501. //当前表
  502. Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
  503. params.put("thisTable",thisTable);
  504. //级联表
  505. String joinTableString = String.valueOf(params.get("joinTable"));
  506. if(StringUtil.isNotEmpty(joinTableString)) {
  507. Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
  508. params.put("joinTable", joinTable);
  509. isJoinTableFlag = true;
  510. }
  511. if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
  512. thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
  513. one = "thisDate0";
  514. }
  515. if(isJoinTableFlag){//级联表日期
  516. Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
  517. if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
  518. joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
  519. if(StringUtil.isEmpty(one)){
  520. one ="joinDate0";
  521. }else{
  522. if(StringUtil.isEmpty(two)){
  523. two ="joinDate0";
  524. }
  525. }
  526. }
  527. }
  528. if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
  529. thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
  530. if(StringUtil.isEmpty(one)){
  531. one ="thisString0";
  532. }else{
  533. if(StringUtil.isEmpty(two)){
  534. two ="thisString0";
  535. }
  536. }
  537. }
  538. if(isJoinTableFlag){//级联表字符串
  539. Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
  540. if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
  541. joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
  542. if(StringUtil.isEmpty(one)){
  543. one ="joinString0";
  544. }else{
  545. if(StringUtil.isEmpty(two)){
  546. two ="joinString0";
  547. }
  548. }
  549. }
  550. }
  551. if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
  552. thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
  553. if(StringUtil.isEmpty(one)){
  554. one ="thisTypes0";
  555. }else{
  556. if(StringUtil.isEmpty(two)){
  557. two ="thisTypes0";
  558. }
  559. }
  560. }
  561. if(isJoinTableFlag){//级联表类型
  562. Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
  563. if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
  564. joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
  565. if(StringUtil.isEmpty(one)){
  566. one ="joinTypes0";
  567. }else{
  568. if(StringUtil.isEmpty(two)){
  569. two ="joinTypes0";
  570. }
  571. }
  572. }
  573. }
  574. List<Map<String, Object>> result = commonService.barCount(params);
  575. List<String> xAxis = new ArrayList<>();//报表x轴
  576. List<List<String>> yAxis = new ArrayList<>();//y轴
  577. List<String> legend = new ArrayList<>();//标题
  578. if(StringUtil.isEmpty(two)){//不包含第二列
  579. List<String> yAxis0 = new ArrayList<>();
  580. yAxis.add(yAxis0);
  581. legend.add("");
  582. for(Map<String, Object> map :result){
  583. String oneValue = String.valueOf(map.get(one));
  584. String value = String.valueOf(map.get("value"));
  585. xAxis.add(oneValue);
  586. yAxis0.add(value);
  587. }
  588. }else{//包含第二列
  589. Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
  590. if(StringUtil.isNotEmpty(two)){
  591. for(Map<String, Object> map :result){
  592. String oneValue = String.valueOf(map.get(one));
  593. String twoValue = String.valueOf(map.get(two));
  594. String value = String.valueOf(map.get("value"));
  595. if(!legend.contains(twoValue)){
  596. legend.add(twoValue);//添加完成后 就是最全的第二列的类型
  597. }
  598. if(dataMap.containsKey(oneValue)){
  599. dataMap.get(oneValue).put(twoValue,value);
  600. }else{
  601. HashMap<String, String> oneData = new HashMap<>();
  602. oneData.put(twoValue,value);
  603. dataMap.put(oneValue,oneData);
  604. }
  605. }
  606. }
  607. for(int i =0; i<legend.size(); i++){
  608. yAxis.add(new ArrayList<String>());
  609. }
  610. Set<String> keys = dataMap.keySet();
  611. for(String key:keys){
  612. xAxis.add(key);
  613. HashMap<String, String> map = dataMap.get(key);
  614. for(int i =0; i<legend.size(); i++){
  615. List<String> data = yAxis.get(i);
  616. if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
  617. data.add(map.get(legend.get(i)));
  618. }else{
  619. data.add("0");
  620. }
  621. }
  622. }
  623. System.out.println();
  624. }
  625. Map<String, Object> resultMap = new HashMap<>();
  626. resultMap.put("xAxis",xAxis);
  627. resultMap.put("yAxis",yAxis);
  628. resultMap.put("legend",legend);
  629. return R.ok().put("data", resultMap);
  630. }
  631. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/106893
推荐阅读
相关标签
  

闽ICP备14008679号