mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
JeecgBoot 2.4 微服务正式版本发布,基于SpringBoot的低代码平台
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>2.3.0</version>
|
||||
<version>2.4.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -14,11 +14,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-base-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-system-local-api</artifactId>
|
||||
<artifactId>jeecg-boot-base-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -1,20 +1,16 @@
|
||||
//package org.jeecg;
|
||||
//
|
||||
//import org.springframework.boot.SpringApplication;
|
||||
//import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
//import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
//import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
//
|
||||
//import java.net.UnknownHostException;
|
||||
//
|
||||
//@SpringBootApplication
|
||||
//@EnableDiscoveryClient
|
||||
//@EnableFeignClients
|
||||
//@EnableAutoConfiguration(exclude={org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class})
|
||||
//public class JeecgDemoApplication {
|
||||
//
|
||||
// public static void main(String[] args) throws UnknownHostException {
|
||||
// SpringApplication.run(JeecgDemoApplication.class, args);
|
||||
// }
|
||||
//}
|
||||
/*
|
||||
package org.jeecg;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class JeecgDemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(JeecgDemoApplication.class, args);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@ -0,0 +1,234 @@
|
||||
//
|
||||
//package org.jeecg.modules.demo.handler;
|
||||
//
|
||||
//
|
||||
//import com.xxl.job.core.biz.model.ReturnT;
|
||||
//import com.xxl.job.core.handler.IJobHandler;
|
||||
//import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
//import com.xxl.job.core.log.XxlJobLogger;
|
||||
//import com.xxl.job.core.util.ShardingUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.BufferedInputStream;
|
||||
//import java.io.BufferedReader;
|
||||
//import java.io.DataOutputStream;
|
||||
//import java.io.InputStreamReader;
|
||||
//import java.net.HttpURLConnection;
|
||||
//import java.net.URL;
|
||||
//import java.util.Arrays;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * xxl-job定时任务测试
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class DemoJobHandler {
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 简单任务
|
||||
// *
|
||||
// * @param params
|
||||
// * @return
|
||||
// */
|
||||
//
|
||||
// @XxlJob(value = "demoJob")
|
||||
// public ReturnT<String> demoJobHandler(String params) {
|
||||
// log.info("我是定时任务,我执行了...............................");
|
||||
// return ReturnT.SUCCESS;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 2、分片广播任务
|
||||
// */
|
||||
//
|
||||
// @XxlJob("shardingJobHandler")
|
||||
// public ReturnT<String> shardingJobHandler(String param) throws Exception {
|
||||
//
|
||||
// // 分片参数
|
||||
// ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo();
|
||||
// XxlJobLogger.log("分片参数:当前分片序号 = {}, 总分片数 = {}", shardingVO.getIndex(), shardingVO.getTotal());
|
||||
//
|
||||
// // 业务逻辑
|
||||
// for (int i = 0; i < shardingVO.getTotal(); i++) {
|
||||
// if (i == shardingVO.getIndex()) {
|
||||
// XxlJobLogger.log("第 {} 片, 命中分片开始处理", i);
|
||||
// } else {
|
||||
// XxlJobLogger.log("第 {} 片, 忽略", i);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return ReturnT.SUCCESS;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 3、命令行任务
|
||||
// */
|
||||
//
|
||||
// @XxlJob("commandJobHandler")
|
||||
// public ReturnT<String> commandJobHandler(String param) throws Exception {
|
||||
// String command = param;
|
||||
// int exitValue = -1;
|
||||
//
|
||||
// BufferedReader bufferedReader = null;
|
||||
// try {
|
||||
// // command process
|
||||
// Process process = Runtime.getRuntime().exec(command);
|
||||
// BufferedInputStream bufferedInputStream = new BufferedInputStream(process.getInputStream());
|
||||
// bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
|
||||
//
|
||||
// // command log
|
||||
// String line;
|
||||
// while ((line = bufferedReader.readLine()) != null) {
|
||||
// XxlJobLogger.log(line);
|
||||
// }
|
||||
//
|
||||
// // command exit
|
||||
// process.waitFor();
|
||||
// exitValue = process.exitValue();
|
||||
// } catch (Exception e) {
|
||||
// XxlJobLogger.log(e);
|
||||
// } finally {
|
||||
// if (bufferedReader != null) {
|
||||
// bufferedReader.close();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (exitValue == 0) {
|
||||
// return IJobHandler.SUCCESS;
|
||||
// } else {
|
||||
// return new ReturnT<String>(IJobHandler.FAIL.getCode(), "command exit value(" + exitValue + ") is failed");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 4、跨平台Http任务
|
||||
// * 参数示例:
|
||||
// * "url: http://www.baidu.com\n" +
|
||||
// * "method: get\n" +
|
||||
// * "data: content\n";
|
||||
// */
|
||||
//
|
||||
// @XxlJob("httpJobHandler")
|
||||
// public ReturnT<String> httpJobHandler(String param) throws Exception {
|
||||
//
|
||||
// // param parse
|
||||
// if (param == null || param.trim().length() == 0) {
|
||||
// XxlJobLogger.log("param[" + param + "] invalid.");
|
||||
// return ReturnT.FAIL;
|
||||
// }
|
||||
// String[] httpParams = param.split("\n");
|
||||
// String url = null;
|
||||
// String method = null;
|
||||
// String data = null;
|
||||
// for (String httpParam : httpParams) {
|
||||
// if (httpParam.startsWith("url:")) {
|
||||
// url = httpParam.substring(httpParam.indexOf("url:") + 4).trim();
|
||||
// }
|
||||
// if (httpParam.startsWith("method:")) {
|
||||
// method = httpParam.substring(httpParam.indexOf("method:") + 7).trim().toUpperCase();
|
||||
// }
|
||||
// if (httpParam.startsWith("data:")) {
|
||||
// data = httpParam.substring(httpParam.indexOf("data:") + 5).trim();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // param valid
|
||||
// if (url == null || url.trim().length() == 0) {
|
||||
// XxlJobLogger.log("url[" + url + "] invalid.");
|
||||
// return ReturnT.FAIL;
|
||||
// }
|
||||
// if (method == null || !Arrays.asList("GET", "POST").contains(method)) {
|
||||
// XxlJobLogger.log("method[" + method + "] invalid.");
|
||||
// return ReturnT.FAIL;
|
||||
// }
|
||||
//
|
||||
// // request
|
||||
// HttpURLConnection connection = null;
|
||||
// BufferedReader bufferedReader = null;
|
||||
// try {
|
||||
// // connection
|
||||
// URL realUrl = new URL(url);
|
||||
// connection = (HttpURLConnection) realUrl.openConnection();
|
||||
//
|
||||
// // connection setting
|
||||
// connection.setRequestMethod(method);
|
||||
// connection.setDoOutput(true);
|
||||
// connection.setDoInput(true);
|
||||
// connection.setUseCaches(false);
|
||||
// connection.setReadTimeout(5 * 1000);
|
||||
// connection.setConnectTimeout(3 * 1000);
|
||||
// connection.setRequestProperty("connection", "Keep-Alive");
|
||||
// connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
|
||||
// connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
|
||||
//
|
||||
// // do connection
|
||||
// connection.connect();
|
||||
//
|
||||
// // data
|
||||
// if (data != null && data.trim().length() > 0) {
|
||||
// DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream());
|
||||
// dataOutputStream.write(data.getBytes("UTF-8"));
|
||||
// dataOutputStream.flush();
|
||||
// dataOutputStream.close();
|
||||
// }
|
||||
//
|
||||
// // valid StatusCode
|
||||
// int statusCode = connection.getResponseCode();
|
||||
// if (statusCode != 200) {
|
||||
// throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid.");
|
||||
// }
|
||||
//
|
||||
// // result
|
||||
// bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
|
||||
// StringBuilder result = new StringBuilder();
|
||||
// String line;
|
||||
// while ((line = bufferedReader.readLine()) != null) {
|
||||
// result.append(line);
|
||||
// }
|
||||
// String responseMsg = result.toString();
|
||||
//
|
||||
// XxlJobLogger.log(responseMsg);
|
||||
// return ReturnT.SUCCESS;
|
||||
// } catch (Exception e) {
|
||||
// XxlJobLogger.log(e);
|
||||
// return ReturnT.FAIL;
|
||||
// } finally {
|
||||
// try {
|
||||
// if (bufferedReader != null) {
|
||||
// bufferedReader.close();
|
||||
// }
|
||||
// if (connection != null) {
|
||||
// connection.disconnect();
|
||||
// }
|
||||
// } catch (Exception e2) {
|
||||
// XxlJobLogger.log(e2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 5、生命周期任务示例:任务初始化与销毁时,支持自定义相关逻辑;
|
||||
// */
|
||||
//
|
||||
// @XxlJob(value = "demoJobHandler2", init = "init", destroy = "destroy")
|
||||
// public ReturnT<String> demoJobHandler2(String param) throws Exception {
|
||||
// XxlJobLogger.log("XXL-JOB, Hello World.");
|
||||
// return ReturnT.SUCCESS;
|
||||
// }
|
||||
//
|
||||
// public void init() {
|
||||
// log.info("init");
|
||||
// }
|
||||
//
|
||||
// public void destroy() {
|
||||
// log.info("destory");
|
||||
// }
|
||||
//}
|
||||
//
|
||||
@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@RequestMapping("/mock/api")
|
||||
@Slf4j
|
||||
public class MockController {
|
||||
|
||||
@ -181,7 +181,13 @@ public class MockController {
|
||||
return readJson("classpath:org/jeecg/modules/demo/mock/json/sysdatalog.json");
|
||||
}
|
||||
//author:lvdandan-----date:20190315---for:添加数据日志json----
|
||||
|
||||
|
||||
//--update-begin--author:wangshuai-----date:20201023---for:返回用户信息json数据----
|
||||
@GetMapping(value = "/getUserInfo")
|
||||
public String getUserInfo(){
|
||||
return readJson("classpath:org/jeecg/modules/demo/mock/json/userinfo.json");
|
||||
}
|
||||
//--update-end--author:wangshuai-----date:20201023---for:返回用户信息json数据----
|
||||
/**
|
||||
* 读取json格式文件
|
||||
* @param jsonSrc
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"department": "技术部",
|
||||
"post": "主管",
|
||||
"data": "2020年6月25日",
|
||||
"name": "张三",
|
||||
"sex": "男",
|
||||
"birth": "2020年6月25日",
|
||||
"political": "党员",
|
||||
"office": "法院",
|
||||
"nation": "汉",
|
||||
"health": "良好",
|
||||
"register": "农民",
|
||||
"education": "本科",
|
||||
"major": "计算机",
|
||||
"gdata": "2020年6月25日",
|
||||
"mailbox": "123@qq.com",
|
||||
"telphone": "18034569685",
|
||||
"homephone": "",
|
||||
"pworktime": "669633555222",
|
||||
"entrytime": "2020年6月25日",
|
||||
"school": "北京邮电大学",
|
||||
"iDCard": "523698541123333",
|
||||
"party": "2020年6月25日 上海",
|
||||
"marital": "已婚",
|
||||
"children": "有",
|
||||
"hukoustreet": "北京市朝阳区亚运村街道",
|
||||
"hukounum": "050000",
|
||||
"hukoudi": "北京市朝阳区亚运村亚运村小区19号楼7单元901",
|
||||
"Currentdi": "北京市朝阳区亚运村亚运村小区19号楼7单元901",
|
||||
"Currentnum": "050000",
|
||||
"socialsecurity": "是",
|
||||
"providentfund": "是",
|
||||
"hobby": "看书",
|
||||
"sbtype": "城镇社保",
|
||||
"archivesdi": "北京市朝阳区社保局"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
package org.jeecg.modules.demo.test.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.aspect.annotation.PermissionData;
|
||||
@ -19,27 +19,15 @@ import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 单表示例
|
||||
@ -159,7 +147,9 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
|
||||
@RequestMapping(value = "/exportXls")
|
||||
@PermissionData(pageComponent = "jeecg/JeecgDemoList")
|
||||
public ModelAndView exportXls(HttpServletRequest request, JeecgDemo jeecgDemo) {
|
||||
return super.exportXls(request, jeecgDemo, JeecgDemo.class, "单表模型");
|
||||
//获取导出表格字段
|
||||
String exportFields = jeecgDemoService.getExportFields();
|
||||
return super.exportXls(request, jeecgDemo, JeecgDemo.class, "单表模型",exportFields);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,4 +282,18 @@ public class JeecgDemoController extends JeecgController<JeecgDemo, IJeecgDemoSe
|
||||
}
|
||||
/*----------------------------------------外部获取权限示例------------------------------------*/
|
||||
|
||||
|
||||
// /**
|
||||
// * 测试MQ
|
||||
// */
|
||||
// @GetMapping(value = "/rabbitMqClientTest")
|
||||
// public Result<?> rabbitMqClientTest(HttpServletRequest req) {
|
||||
// BaseMap map = new BaseMap();
|
||||
// map.put("orderId", RandomUtil.randomNumbers(10));
|
||||
// rabbitMqClient.sendMessage("jeecg_place_order", map);
|
||||
// rabbitMqClient.sendMessage("jeecg_place_order_time", map,10);
|
||||
// return Result.OK();
|
||||
// }
|
||||
// @Autowired
|
||||
// private RabbitMqClient rabbitMqClient;
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ public class JeecgOrderMainController extends JeecgController<JeecgOrderMain, IJ
|
||||
public Result<?> eidt(@RequestBody JeecgOrderMainPage jeecgOrderMainPage) {
|
||||
JeecgOrderMain jeecgOrderMain = new JeecgOrderMain();
|
||||
BeanUtils.copyProperties(jeecgOrderMainPage, jeecgOrderMain);
|
||||
jeecgOrderMainService.updateMain(jeecgOrderMain, jeecgOrderMainPage.getJeecgOrderCustomerList(), jeecgOrderMainPage.getJeecgOrderTicketList());
|
||||
jeecgOrderMainService.updateCopyMain(jeecgOrderMain, jeecgOrderMainPage.getJeecgOrderCustomerList(), jeecgOrderMainPage.getJeecgOrderTicketList());
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
package org.jeecg.modules.demo.test.controller;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2020/1/12 17:19
|
||||
* @Description: Minio文件服务测试
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test/minio")
|
||||
public class MinioController {
|
||||
|
||||
//minio服务的IP端口
|
||||
private static String url = "http://111.225.?.?:9000";
|
||||
private static String accessKey = "admin";
|
||||
private static String secretKey = "??";
|
||||
private static String bucketName = "??";
|
||||
|
||||
/**
|
||||
* 上传文件到minio服务
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("upload")
|
||||
public String upload(@RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
|
||||
InputStream is = file.getInputStream(); //得到文件流
|
||||
String fileName = "/upload/img/" + file.getOriginalFilename(); //文件名
|
||||
String contentType = file.getContentType(); //类型
|
||||
minioClient.putObject(bucketName, fileName, is, contentType); //把文件放置Minio桶(文件夹)
|
||||
return "上传成功";
|
||||
} catch (Exception e) {
|
||||
return "上传失败";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载minio服务的文件
|
||||
*
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("download")
|
||||
public String download(HttpServletResponse response) {
|
||||
try {
|
||||
MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
|
||||
InputStream fileInputStream = minioClient.getObject(bucketName, "11.jpg");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + "11.jpg");
|
||||
response.setContentType("application/force-download");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
IOUtils.copy(fileInputStream, response.getOutputStream());
|
||||
return "下载完成";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "下载失败";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取minio文件的下载地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("url")
|
||||
public String getUrl() {
|
||||
try {
|
||||
MinioClient minioClient = new MinioClient(url, accessKey, secretKey);
|
||||
String url = minioClient.presignedGetObject(bucketName, "11.jpg");
|
||||
return url;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "获取失败";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -27,4 +27,19 @@ public interface JeecgDemoMapper extends BaseMapper<JeecgDemo> {
|
||||
*/
|
||||
public IPage<JeecgDemo> queryListWithPermission(Page<JeecgDemo> page,@Param("permissionSql")String permissionSql);
|
||||
|
||||
/**
|
||||
* 根据前缀获取所有有效权限
|
||||
* @param permsPrefix
|
||||
* @return
|
||||
*/
|
||||
public List<String> queryAllAuth(@Param("permsPrefix")String permsPrefix);
|
||||
|
||||
/**
|
||||
* 查询用户已授权字段
|
||||
* @param userId
|
||||
* @param permsPrefix
|
||||
* @return
|
||||
*/
|
||||
public List<String> queryUserAuth(@Param("userId")String userId,@Param("permsPrefix")String permsPrefix);
|
||||
|
||||
}
|
||||
|
||||
@ -11,4 +11,24 @@
|
||||
<select id="queryListWithPermission" parameterType="Object" resultType="org.jeecg.modules.demo.test.entity.JeecgDemo">
|
||||
select * from demo where 1=1 ${permissionSql}
|
||||
</select>
|
||||
|
||||
<!-- 查询所有符合前缀且有效字段 -->
|
||||
<select id="queryAllAuth" resultType="java.lang.String">
|
||||
select perms from sys_permission
|
||||
where perms
|
||||
like concat(concat('%',#{permsPrefix}),'%')
|
||||
and del_flag=0
|
||||
and status='1'
|
||||
</select>
|
||||
|
||||
<!-- 查询用户已授权字段 -->
|
||||
<select id="queryUserAuth" resultType="java.lang.String">
|
||||
select perms from sys_user_role sur,
|
||||
sys_role_permission srp,
|
||||
sys_permission sp
|
||||
where sur.role_id = srp.role_id
|
||||
and sp.id = srp.permission_id
|
||||
and user_id = #{userId}
|
||||
and sp.perms like concat(concat('%',#{permsPrefix}),'%')
|
||||
</select>
|
||||
</mapper>
|
||||
@ -24,4 +24,10 @@ public interface IJeecgDemoService extends JeecgService<JeecgDemo> {
|
||||
* @return
|
||||
*/
|
||||
IPage<JeecgDemo> queryListWithPermission(int pageSize,int pageNo);
|
||||
|
||||
/**
|
||||
* 根据用户权限获取导出字段
|
||||
* @return
|
||||
*/
|
||||
String getExportFields();
|
||||
}
|
||||
|
||||
@ -41,4 +41,6 @@ public interface IJeecgOrderMainService extends IService<JeecgOrderMain> {
|
||||
* @param jformOrderMain
|
||||
*/
|
||||
public void delBatchMain (Collection<? extends Serializable> idList);
|
||||
|
||||
public void updateCopyMain(JeecgOrderMain jeecgOrderMain, List<JeecgOrderCustomer> jeecgOrderCustomerList, List<JeecgOrderTicket> jeecgOrderTicketList);
|
||||
}
|
||||
|
||||
@ -3,8 +3,10 @@ package org.jeecg.modules.demo.test.service.impl;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||
@ -13,6 +15,11 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: jeecg 测试demo
|
||||
* @Author: jeecg-boot
|
||||
@ -72,4 +79,33 @@ public class JeecgDemoServiceImpl extends ServiceImpl<JeecgDemoMapper, JeecgDemo
|
||||
return this.baseMapper.queryListWithPermission(page, sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExportFields() {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
//权限配置列导出示例
|
||||
//1.配置前缀与菜单中配置的列前缀一致
|
||||
List<String> noAuthList = new ArrayList<>();
|
||||
List<String> exportFieldsList = new ArrayList<>();
|
||||
String permsPrefix = "testdemo:";
|
||||
//查询配置菜单有效字段
|
||||
List<String> allAuth = this.jeecgDemoMapper.queryAllAuth(permsPrefix);
|
||||
//查询已授权字段
|
||||
List<String> userAuth = this.jeecgDemoMapper.queryUserAuth(sysUser.getId(),permsPrefix);
|
||||
//列出未授权字段
|
||||
for(String perms : allAuth){
|
||||
if(!userAuth.contains(perms)){
|
||||
noAuthList.add(perms.substring(permsPrefix.length()));
|
||||
}
|
||||
}
|
||||
//实体类中字段与未授权字段比较,列出需导出字段
|
||||
Field[] fileds = JeecgDemo.class.getDeclaredFields();
|
||||
List<Field> list = new ArrayList(Arrays.asList(fileds));
|
||||
for(Field field : list){
|
||||
if(!noAuthList.contains(field.getName())){
|
||||
exportFieldsList.add(field.getName());
|
||||
}
|
||||
}
|
||||
return exportFieldsList != null && exportFieldsList.size()>0 ? String.join(",", exportFieldsList) : "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package org.jeecg.modules.demo.test.service.impl;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderCustomer;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderMain;
|
||||
@ -75,6 +76,71 @@ public class JeecgOrderMainServiceImpl extends ServiceImpl<JeecgOrderMainMapper,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 一对多维护逻辑改造 LOWCOD-315
|
||||
* @param jeecgOrderMain
|
||||
* @param jeecgOrderCustomerList
|
||||
* @param jeecgOrderTicketList
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateCopyMain(JeecgOrderMain jeecgOrderMain, List<JeecgOrderCustomer> jeecgOrderCustomerList, List<JeecgOrderTicket> jeecgOrderTicketList) {
|
||||
jeecgOrderMainMapper.updateById(jeecgOrderMain);
|
||||
|
||||
// 循环前台传过来的数据
|
||||
for (JeecgOrderTicket ticket:jeecgOrderTicketList){
|
||||
// 先查询子表数据库
|
||||
JeecgOrderTicket orderTicket = jeecgOrderTicketMapper.selectById(ticket.getId());
|
||||
if(orderTicket == null){
|
||||
// 当传过来的id数据库不存在时,说明数据库没有,走新增逻辑
|
||||
ticket.setOrderId(jeecgOrderMain.getId());
|
||||
jeecgOrderTicketMapper.insert(ticket);
|
||||
break;
|
||||
}
|
||||
if(orderTicket.getId().equals(ticket.getId())){
|
||||
// 传过来的id和数据库id一至时,说明数据库存在该数据,走更新逻辑
|
||||
jeecgOrderTicketMapper.updateById(ticket);
|
||||
}
|
||||
}
|
||||
for (JeecgOrderCustomer customer:jeecgOrderCustomerList){
|
||||
// 先查询子表数据库
|
||||
JeecgOrderCustomer customers = jeecgOrderCustomerMapper.selectById(customer.getId());
|
||||
if(customers == null){
|
||||
// 当传过来的id数据库不存在时,说明数据库没有,走新增逻辑
|
||||
customer.setOrderId(jeecgOrderMain.getId());
|
||||
jeecgOrderCustomerMapper.insert(customer);
|
||||
break;
|
||||
}
|
||||
if(customers.getId().equals(customer.getId())){
|
||||
//TODO 传过来的id和数据库id一至时,说明数据库存在该数据,走更新逻辑
|
||||
jeecgOrderCustomerMapper.updateById(customer);
|
||||
}
|
||||
}
|
||||
// 当跟新和删除之后取差集, 当传过来的id不存在,而数据库存在时,说明已删除,走删除逻辑
|
||||
List<JeecgOrderTicket> jeecgOrderTickets = jeecgOrderTicketMapper.selectTicketsByMainId(jeecgOrderMain.getId());
|
||||
List<JeecgOrderTicket> collect = jeecgOrderTickets.stream()
|
||||
.filter(item -> !jeecgOrderTicketList.stream()
|
||||
.map(e -> e.getId())
|
||||
.collect(Collectors.toList())
|
||||
.contains(item.getId()))
|
||||
.collect(Collectors.toList());
|
||||
// for循环删除id
|
||||
for (JeecgOrderTicket ticket:collect){
|
||||
jeecgOrderTicketMapper.deleteById(ticket.getId());
|
||||
}
|
||||
|
||||
List<JeecgOrderCustomer> jeecgOrderCustomers = jeecgOrderCustomerMapper.selectCustomersByMainId(jeecgOrderMain.getId());
|
||||
List<JeecgOrderCustomer> customersCollect = jeecgOrderCustomers.stream()
|
||||
.filter(item -> !jeecgOrderCustomerList.stream()
|
||||
.map(e -> e.getId())
|
||||
.collect(Collectors.toList())
|
||||
.contains(item.getId()))
|
||||
.collect(Collectors.toList());
|
||||
//TODO for循环删除id
|
||||
for (JeecgOrderCustomer c:customersCollect){
|
||||
jeecgOrderCustomerMapper.deleteById(c.getId());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@Transactional
|
||||
public void delMain(String id) {
|
||||
|
||||
@ -0,0 +1,407 @@
|
||||
package org.jeecg.modules.dlglong.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.MatchTypeEnum;
|
||||
import org.jeecg.common.system.query.QueryCondition;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.constant.VXESocketConst;
|
||||
import org.jeecg.modules.demo.mock.vxe.websocket.VXESocket;
|
||||
import org.jeecg.modules.dlglong.entity.MockEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/mock/dlglong")
|
||||
public class DlMockController {
|
||||
|
||||
/**
|
||||
* 模拟更改状态
|
||||
*
|
||||
* @param id
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/change1")
|
||||
public Result mockChange1(@RequestParam("id") String id, @RequestParam("status") String status) {
|
||||
/* id 为 行的id(rowId),只要获取到rowId,那么只需要调用 VXESocket.sendMessageToAll() 即可 */
|
||||
|
||||
// 封装行数据
|
||||
JSONObject rowData = new JSONObject();
|
||||
// 这个字段就是要更改的行数据ID
|
||||
rowData.put("id", id);
|
||||
// 这个字段就是要更改的列的key和具体的值
|
||||
rowData.put("status", status);
|
||||
// 模拟更改数据
|
||||
this.mockChange(rowData);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟更改拖轮状态
|
||||
*
|
||||
* @param id
|
||||
* @param tug_status
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/change2")
|
||||
public Result mockChange2(@RequestParam("id") String id, @RequestParam("tug_status") String tug_status) {
|
||||
/* id 为 行的id(rowId),只要获取到rowId,那么只需要调用 VXESocket.sendMessageToAll() 即可 */
|
||||
|
||||
// 封装行数据
|
||||
JSONObject rowData = new JSONObject();
|
||||
// 这个字段就是要更改的行数据ID
|
||||
rowData.put("id", id);
|
||||
// 这个字段就是要更改的列的key和具体的值
|
||||
JSONObject tugStatus = JSON.parseObject(tug_status);
|
||||
rowData.put("tug_status", tugStatus);
|
||||
// 模拟更改数据
|
||||
this.mockChange(rowData);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟更改进度条状态
|
||||
*
|
||||
* @param id
|
||||
* @param progress
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/change3")
|
||||
public Result mockChange3(@RequestParam("id") String id, @RequestParam("progress") String progress) {
|
||||
/* id 为 行的id(rowId),只要获取到rowId,那么只需要调用 VXESocket.sendMessageToAll() 即可 */
|
||||
|
||||
// 封装行数据
|
||||
JSONObject rowData = new JSONObject();
|
||||
// 这个字段就是要更改的行数据ID
|
||||
rowData.put("id", id);
|
||||
// 这个字段就是要更改的列的key和具体的值
|
||||
rowData.put("progress", progress);
|
||||
// 模拟更改数据
|
||||
this.mockChange(rowData);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
private void mockChange(JSONObject rowData) {
|
||||
// 封装socket数据
|
||||
JSONObject socketData = new JSONObject();
|
||||
// 这里的 socketKey 必须要和调度计划页面上写的 socketKey 属性保持一致
|
||||
socketData.put("socketKey", "page-dispatch");
|
||||
// 这里的 args 必须得是一个数组,下标0是行数据,下标1是caseId,一般不用传
|
||||
socketData.put("args", new Object[]{rowData, ""});
|
||||
// 封装消息字符串,这里的 type 必须是 VXESocketConst.TYPE_UVT
|
||||
String message = VXESocket.packageMessage(VXESocketConst.TYPE_UVT, socketData);
|
||||
// 调用 sendMessageToAll 发送给所有在线的用户
|
||||
VXESocket.sendMessageToAll(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟更改【大船待审】状态
|
||||
*
|
||||
* @param status
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/change4")
|
||||
public Result mockChange4(@RequestParam("status") String status) {
|
||||
// 封装socket数据
|
||||
JSONObject socketData = new JSONObject();
|
||||
// 这里的 key 是前端注册时使用的key,必须保持一致
|
||||
socketData.put("key", "dispatch-dcds-status");
|
||||
// 这里的 args 必须得是一个数组,每一位都是注册方法的参数,按顺序传递
|
||||
socketData.put("args", new Object[]{status});
|
||||
|
||||
// 封装消息字符串,这里的 type 必须是 VXESocketConst.TYPE_UVT
|
||||
String message = VXESocket.packageMessage(VXESocketConst.TYPE_CSD, socketData);
|
||||
// 调用 sendMessageToAll 发送给所有在线的用户
|
||||
VXESocket.sendMessageToAll(message);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 【模拟】即时保存单行数据
|
||||
*
|
||||
* @param rowData 行数据,实际使用时可以替换成一个实体类
|
||||
*/
|
||||
@PutMapping("/immediateSaveRow")
|
||||
public Result mockImmediateSaveRow(@RequestBody JSONObject rowData) throws Exception {
|
||||
System.out.println("即时保存.rowData:" + rowData.toJSONString());
|
||||
// 延时1.5秒,模拟网慢堵塞真实感
|
||||
Thread.sleep(500);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 【模拟】即时保存整个表格的数据
|
||||
*
|
||||
* @param tableData 表格数据(实际使用时可以替换成一个List实体类)
|
||||
*/
|
||||
@PostMapping("/immediateSaveAll")
|
||||
public Result mockImmediateSaveAll(@RequestBody JSONArray tableData) throws Exception {
|
||||
// 【注】:
|
||||
// 1、tableData里包含该页所有的数据
|
||||
// 2、如果你实现了“即时保存”,那么除了新增的数据,其他的都是已经保存过的了,
|
||||
// 不需要再进行一次update操作了,所以可以在前端传数据的时候就遍历判断一下,
|
||||
// 只传新增的数据给后台insert即可,否者将会造成性能上的浪费。
|
||||
// 3、新增的行是没有id的,通过这一点,就可以判断是否是新增的数据
|
||||
|
||||
System.out.println("即时保存.tableData:" + tableData.toJSONString());
|
||||
// 延时1.5秒,模拟网慢堵塞真实感
|
||||
Thread.sleep(1000);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模拟数据
|
||||
*
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 页大小
|
||||
* @param parentId 父ID,不传则查询顶级
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getData")
|
||||
public Result getMockData(
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
// 父级id,根据父级id查询子级,如果为空则查询顶级
|
||||
@RequestParam(name = "parentId", required = false) String parentId
|
||||
) {
|
||||
// 模拟JSON数据路径
|
||||
String path = "classpath:org/jeecg/modules/dlglong/json/dlglong.json";
|
||||
// 读取JSON数据
|
||||
JSONArray dataList = readJsonData(path);
|
||||
if (dataList == null) {
|
||||
return Result.error("读取数据失败!");
|
||||
}
|
||||
IPage<JSONObject> page = this.queryDataPage(dataList, parentId, pageNo, pageSize);
|
||||
return Result.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模拟“调度计划”页面的数据
|
||||
*
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 页大小
|
||||
* @param parentId 父ID,不传则查询顶级
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDdjhData")
|
||||
public Result getMockDdjhData(
|
||||
// SpringMVC 会自动将参数注入到实体里
|
||||
MockEntity mockEntity,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
// 父级id,根据父级id查询子级,如果为空则查询顶级
|
||||
@RequestParam(name = "parentId", required = false) String parentId,
|
||||
@RequestParam(name = "status", required = false) String status,
|
||||
// 高级查询条件
|
||||
@RequestParam(name = "superQueryParams", required = false) String superQueryParams,
|
||||
// 高级查询模式
|
||||
@RequestParam(name = "superQueryMatchType", required = false) String superQueryMatchType,
|
||||
HttpServletRequest request
|
||||
) {
|
||||
// 获取查询条件(前台传递的查询参数)
|
||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||
// 遍历输出到控制台
|
||||
System.out.println("\ngetDdjhData - 普通查询条件:");
|
||||
for (String key : parameterMap.keySet()) {
|
||||
System.out.println("-- " + key + ": " + JSON.toJSONString(parameterMap.get(key)));
|
||||
}
|
||||
// 输出高级查询
|
||||
try {
|
||||
System.out.println("\ngetDdjhData - 高级查询条件:");
|
||||
// 高级查询模式
|
||||
MatchTypeEnum matchType = MatchTypeEnum.getByValue(superQueryMatchType);
|
||||
if (matchType == null) {
|
||||
System.out.println("-- 高级查询模式:不识别(" + superQueryMatchType + ")");
|
||||
} else {
|
||||
System.out.println("-- 高级查询模式:" + matchType.getValue());
|
||||
}
|
||||
superQueryParams = URLDecoder.decode(superQueryParams, "UTF-8");
|
||||
List<QueryCondition> conditions = JSON.parseArray(superQueryParams, QueryCondition.class);
|
||||
if (conditions != null) {
|
||||
for (QueryCondition condition : conditions) {
|
||||
System.out.println("-- " + JSON.toJSONString(condition));
|
||||
}
|
||||
} else {
|
||||
System.out.println("-- 没有传递任何高级查询条件");
|
||||
}
|
||||
System.out.println();
|
||||
} catch (Exception e) {
|
||||
log.error("-- 高级查询操作失败:" + superQueryParams, e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/* 注:实际使用中不用写上面那种繁琐的代码,这里只是为了直观的输出到控制台里而写的示例,
|
||||
使用下面这种写法更简洁方便 */
|
||||
|
||||
// 封装成 MyBatisPlus 能识别的 QueryWrapper,可以直接使用这个对象进行SQL筛选条件拼接
|
||||
// 这个方法也会自动封装高级查询条件,但是高级查询参数名必须是superQueryParams和superQueryMatchType
|
||||
QueryWrapper<MockEntity> queryWrapper = QueryGenerator.initQueryWrapper(mockEntity, parameterMap);
|
||||
System.out.println("queryWrapper: " + queryWrapper.getCustomSqlSegment());
|
||||
|
||||
// 模拟JSON数据路径
|
||||
String path = "classpath:org/jeecg/modules/dlglong/json/ddjh.json";
|
||||
if ("8".equals(status)) {
|
||||
path = "classpath:org/jeecg/modules/dlglong/json/ddjh_s8.json";
|
||||
}
|
||||
// 读取JSON数据
|
||||
JSONArray dataList = readJsonData(path);
|
||||
if (dataList == null) {
|
||||
return Result.error("读取数据失败!");
|
||||
}
|
||||
|
||||
IPage<JSONObject> page = this.queryDataPage(dataList, parentId, pageNo, pageSize);
|
||||
// 逐行查询子表数据,用于计算拖轮状态
|
||||
List<JSONObject> records = page.getRecords();
|
||||
for (JSONObject record : records) {
|
||||
Map<String, Integer> tugStatusMap = new HashMap<>();
|
||||
String id = record.getString("id");
|
||||
// 查询出主表的拖轮
|
||||
String tugMain = record.getString("tug");
|
||||
// 判断是否有值
|
||||
if (StringUtils.isNotBlank(tugMain)) {
|
||||
// 拖轮根据分号分割
|
||||
String[] tugs = tugMain.split(";");
|
||||
// 查询子表数据
|
||||
List<JSONObject> subRecords = this.queryDataPage(dataList, id, null, null).getRecords();
|
||||
// 遍历子表和拖轮数据,找出进行计算反推拖轮状态
|
||||
for (JSONObject subData : subRecords) {
|
||||
String subTug = subData.getString("tug");
|
||||
if (StringUtils.isNotBlank(subTug)) {
|
||||
for (String tug : tugs) {
|
||||
if (tug.equals(subTug)) {
|
||||
// 计算拖轮状态逻辑
|
||||
int statusCode = 0;
|
||||
|
||||
/* 如果有发船时间、作业开始时间、作业结束时间、回船时间,则主表中的拖轮列中的每个拖轮背景色要即时变色 */
|
||||
|
||||
// 有发船时间,状态 +1
|
||||
String departureTime = subData.getString("departure_time");
|
||||
if (StringUtils.isNotBlank(departureTime)) {
|
||||
statusCode += 1;
|
||||
}
|
||||
// 有作业开始时间,状态 +1
|
||||
String workBeginTime = subData.getString("work_begin_time");
|
||||
if (StringUtils.isNotBlank(workBeginTime)) {
|
||||
statusCode += 1;
|
||||
}
|
||||
// 有作业结束时间,状态 +1
|
||||
String workEndTime = subData.getString("work_end_time");
|
||||
if (StringUtils.isNotBlank(workEndTime)) {
|
||||
statusCode += 1;
|
||||
}
|
||||
// 有回船时间,状态 +1
|
||||
String returnTime = subData.getString("return_time");
|
||||
if (StringUtils.isNotBlank(returnTime)) {
|
||||
statusCode += 1;
|
||||
}
|
||||
// 保存拖轮状态,key是拖轮的值,value是状态,前端根据不同的状态码,显示不同的颜色,这个颜色也可以后台计算完之后返回给前端直接使用
|
||||
tugStatusMap.put(tug, statusCode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 新加一个字段用于保存拖轮状态,不要直接覆盖原来的,这个字段可以不保存到数据库里
|
||||
record.put("tug_status", tugStatusMap);
|
||||
}
|
||||
page.setRecords(records);
|
||||
return Result.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟查询数据,可以根据父ID查询,可以分页
|
||||
*
|
||||
* @param dataList 数据列表
|
||||
* @param parentId 父ID
|
||||
* @param pageNo 页码
|
||||
* @param pageSize 页大小
|
||||
* @return
|
||||
*/
|
||||
private IPage<JSONObject> queryDataPage(JSONArray dataList, String parentId, Integer pageNo, Integer pageSize) {
|
||||
// 根据父级id查询子级
|
||||
JSONArray dataDB = dataList;
|
||||
if (StringUtils.isNotBlank(parentId)) {
|
||||
JSONArray results = new JSONArray();
|
||||
List<String> parentIds = Arrays.asList(parentId.split(","));
|
||||
this.queryByParentId(dataDB, parentIds, results);
|
||||
dataDB = results;
|
||||
}
|
||||
// 模拟分页(实际中应用SQL自带的分页)
|
||||
List<JSONObject> records = new ArrayList<>();
|
||||
IPage<JSONObject> page;
|
||||
long beginIndex, endIndex;
|
||||
// 如果任意一个参数为null,则不分页
|
||||
if (pageNo == null || pageSize == null) {
|
||||
page = new Page<>(0, dataDB.size());
|
||||
beginIndex = 0;
|
||||
endIndex = dataDB.size();
|
||||
} else {
|
||||
page = new Page<>(pageNo, pageSize);
|
||||
beginIndex = page.offset();
|
||||
endIndex = page.offset() + page.getSize();
|
||||
}
|
||||
for (long i = beginIndex; (i < endIndex && i < dataDB.size()); i++) {
|
||||
JSONObject data = dataDB.getJSONObject((int) i);
|
||||
data = JSON.parseObject(data.toJSONString());
|
||||
// 不返回 children
|
||||
data.remove("children");
|
||||
records.add(data);
|
||||
}
|
||||
page.setRecords(records);
|
||||
page.setTotal(dataDB.size());
|
||||
return page;
|
||||
}
|
||||
|
||||
private void queryByParentId(JSONArray dataList, List<String> parentIds, JSONArray results) {
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
JSONObject data = dataList.getJSONObject(i);
|
||||
JSONArray children = data.getJSONArray("children");
|
||||
// 找到了该父级
|
||||
if (parentIds.contains(data.getString("id"))) {
|
||||
if (children != null) {
|
||||
// addAll 的目的是将多个子表的数据合并在一起
|
||||
results.addAll(children);
|
||||
}
|
||||
} else {
|
||||
if (children != null) {
|
||||
queryByParentId(children, parentIds, results);
|
||||
}
|
||||
}
|
||||
}
|
||||
results.addAll(new JSONArray());
|
||||
}
|
||||
|
||||
private JSONArray readJsonData(String path) {
|
||||
try {
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream(path.replace("classpath:", ""));
|
||||
if (stream != null) {
|
||||
String json = IOUtils.toString(stream, "UTF-8");
|
||||
return JSON.parseArray(json);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package org.jeecg.modules.dlglong.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 模拟实体
|
||||
*/
|
||||
@Data
|
||||
public class MockEntity {
|
||||
|
||||
// id
|
||||
private String id;
|
||||
// 父级ID
|
||||
private String parentId;
|
||||
// 状态
|
||||
private String status;
|
||||
|
||||
/* -- 省略其他字段 -- */
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,230 +0,0 @@
|
||||
server:
|
||||
tomcat:
|
||||
max-swallow-size: -1
|
||||
servlet:
|
||||
context-path: /
|
||||
compression:
|
||||
enabled: true
|
||||
min-response-size: 1024
|
||||
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: metrics,httptrace
|
||||
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 10MB
|
||||
mail:
|
||||
host: smtp.163.com
|
||||
username: jeecgos@163.com
|
||||
password: ??
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
auth: true
|
||||
starttls:
|
||||
enable: true
|
||||
required: true
|
||||
## quartz定时任务,采用数据库方式
|
||||
quartz:
|
||||
job-store-type: jdbc
|
||||
initialize-schema: embedded
|
||||
#设置自动启动,默认为 true
|
||||
auto-startup: true
|
||||
#启动时更新己存在的Job
|
||||
overwrite-existing-jobs: true
|
||||
properties:
|
||||
org:
|
||||
quartz:
|
||||
scheduler:
|
||||
instanceName: MyScheduler
|
||||
instanceId: AUTO
|
||||
jobStore:
|
||||
class: org.quartz.impl.jdbcjobstore.JobStoreTX
|
||||
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
||||
tablePrefix: QRTZ_
|
||||
isClustered: true
|
||||
misfireThreshold: 60000
|
||||
clusterCheckinInterval: 10000
|
||||
threadPool:
|
||||
class: org.quartz.simpl.SimpleThreadPool
|
||||
threadCount: 10
|
||||
threadPriority: 5
|
||||
threadsInheritContextClassLoaderOfInitializingThread: true
|
||||
#json 时间戳统一转换
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
aop:
|
||||
proxy-target-class: true
|
||||
activiti:
|
||||
check-process-definitions: false
|
||||
#启用作业执行器
|
||||
async-executor-activate: false
|
||||
#启用异步执行器
|
||||
job-executor-activate: false
|
||||
jpa:
|
||||
open-in-view: false
|
||||
#配置freemarker
|
||||
freemarker:
|
||||
# 设置模板后缀名
|
||||
suffix: .ftl
|
||||
# 设置文档类型
|
||||
content-type: text/html
|
||||
# 设置页面编码格式
|
||||
charset: UTF-8
|
||||
# 设置页面缓存
|
||||
cache: false
|
||||
prefer-file-system-access: false
|
||||
# 设置ftl文件路径
|
||||
template-loader-path:
|
||||
- classpath:/templates
|
||||
# 设置静态文件路径,js,css等
|
||||
mvc:
|
||||
static-path-pattern: /**
|
||||
resource:
|
||||
static-locations: classpath:/static/,classpath:/public/
|
||||
autoconfigure:
|
||||
exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||
datasource:
|
||||
druid:
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
loginUsername: admin
|
||||
loginPassword: 123456
|
||||
allow:
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
dynamic:
|
||||
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
|
||||
# 连接池的配置信息
|
||||
# 初始化大小,最小,最大
|
||||
initial-size: 5
|
||||
min-idle: 5
|
||||
maxActive: 20
|
||||
# 配置获取连接等待超时的时间
|
||||
maxWait: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
poolPreparedStatements: true
|
||||
maxPoolPreparedStatementPerConnectionSize: 20
|
||||
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
|
||||
filters: stat,wall,slf4j
|
||||
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
|
||||
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: root
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 多数据源配置
|
||||
#multi-datasource1:
|
||||
#url: jdbc:mysql://localhost:3306/jeecg-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
#username: root
|
||||
#password: root
|
||||
#driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
#redis 配置
|
||||
redis:
|
||||
database: 0
|
||||
host: 127.0.0.1
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8 #最大连接数据库连接数,设 0 为没有限制
|
||||
max-idle: 8 #最大等待连接中的数量,设 0 为没有限制
|
||||
max-wait: -1ms #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
|
||||
min-idle: 0 #最小等待连接中的数量,设 0 为没有限制
|
||||
shutdown-timeout: 100ms
|
||||
password: ''
|
||||
port: 6379
|
||||
#mybatis plus 设置
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
|
||||
global-config:
|
||||
# 关闭MP3.0自带的banner
|
||||
banner: false
|
||||
db-config:
|
||||
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
|
||||
id-type: 4
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
configuration:
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 返回类型为Map,显示null对应的字段
|
||||
call-setters-on-nulls: true
|
||||
#jeecg专用配置
|
||||
jeecg :
|
||||
# 本地:local\Minio:minio\阿里云:alioss
|
||||
uploadType: local
|
||||
path :
|
||||
#文件上传根目录 设置
|
||||
upload: D://opt//upFiles
|
||||
#webapp文件路径
|
||||
webapp: D://opt//webapp
|
||||
#短信秘钥
|
||||
sms:
|
||||
accessKeyId: ??
|
||||
accessKeySecret: ??
|
||||
shiro:
|
||||
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/category/**,/visual/**,/map/**,/jmreport/bigscreen2/**
|
||||
#阿里云oss存储配置
|
||||
oss:
|
||||
endpoint: oss-cn-beijing.aliyuncs.com
|
||||
accessKey: ??
|
||||
secretKey: ??
|
||||
bucketName: jeecgos
|
||||
staticDomain: https://static.jeecg.com
|
||||
# ElasticSearch 6设置
|
||||
elasticsearch:
|
||||
cluster-name: docker-cluster
|
||||
cluster-nodes: 127.0.0.1:9200
|
||||
check-enabled: false
|
||||
# 表单设计器配置
|
||||
desform:
|
||||
# 主题颜色(仅支持 16进制颜色代码)
|
||||
theme-color: "#1890ff"
|
||||
# 文件、图片上传方式,可选项:qiniu(七牛云)、system(跟随系统配置)
|
||||
upload-type: system
|
||||
# 在线预览文件服务器地址配置
|
||||
file-view-domain: http://fileview.jeecg.com
|
||||
# minio文件上传
|
||||
minio:
|
||||
minio_url: http://minio.jeecg.com
|
||||
minio_name: ??
|
||||
minio_pass: ??
|
||||
bucketName: otatest
|
||||
#大屏报表参数设置
|
||||
jmreport:
|
||||
#是否需要校验token
|
||||
is_verify_token: false
|
||||
#必须校验方法
|
||||
verify_methods: remove,delete,save,add,update
|
||||
#Wps在线文档
|
||||
wps:
|
||||
domain: https://wwo.wps.cn/office/
|
||||
appid: ??
|
||||
appsecret: ??
|
||||
#Mybatis输出sql日志
|
||||
logging:
|
||||
level:
|
||||
org.jeecg.modules.system.mapper : debug
|
||||
#cas单点登录
|
||||
cas:
|
||||
prefixUrl: http://cas.example.org:8443/cas
|
||||
#enable swagger
|
||||
swagger:
|
||||
enable: true
|
||||
|
||||
@ -1,30 +1,5 @@
|
||||
server:
|
||||
port: 7002
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
swagger:
|
||||
production: false
|
||||
basic:
|
||||
enable: false
|
||||
username: jeecg
|
||||
password: jeecg1314
|
||||
# 第三方登录
|
||||
justauth:
|
||||
enabled: true
|
||||
type:
|
||||
GITHUB:
|
||||
client-id: 0277e675495f14a4a183
|
||||
client-secret: ??
|
||||
redirect-uri: http://sso.test.com:8080/jeecg-boot/thirdLogin/github/callback
|
||||
WECHAT_ENTERPRISE:
|
||||
client-id: wwc2a8c8b19c201bcc
|
||||
client-secret: ??
|
||||
redirect-uri: http://sso.test.com:8080/jeecg-boot/thirdLogin/wechat_enterprise/callback
|
||||
agent-id: 1000002
|
||||
DINGTALK:
|
||||
client-id: dingoa33vjqxrbyidnmgwo
|
||||
client-secret: ??
|
||||
redirect-uri: http://sso.test.com:8080/jeecg-boot/thirdLogin/dingtalk/callback
|
||||
cache:
|
||||
type: default
|
||||
prefix: 'demo::'
|
||||
timeout: 1h
|
||||
application:
|
||||
name: jeecg-demo
|
||||
@ -1,14 +0,0 @@
|
||||
server:
|
||||
port: 7002
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
application:
|
||||
name: jeecg-demo
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
Reference in New Issue
Block a user