浏览代码

增加Ai任务后台自动生成code

wangchao 4 年之前
父节点
当前提交
0f9572b6f4

+ 2 - 3
security-protection-service/src/main/java/com/ai/bss/security/protection/controller/SysConfigAiTaskController.java

@ -6,6 +6,7 @@ import com.ai.bss.security.protection.model.AiQuery;
6 6
7 7
import com.ai.bss.security.protection.service.interfaces.SysConfigAiTaskService;
8 8
import com.ai.bss.security.protection.utils.EbcConstant;
9
import com.ai.bss.security.protection.utils.IDUtils;
9 10
import com.ai.bss.work.safety.model.AiModel;
10 11
import com.ai.bss.work.safety.model.AiTask;
11 12
@ -66,8 +67,6 @@ public class SysConfigAiTaskController {
66 67
		params.put("aiIdenModel",aiQuery.getAiIdenModel());
67 68
68 69
		CommonResponse<PageBean<Map<String, Object>>> commonResponse = sysConfigAiTaskService.queryPageAiTask(params, pageNumber, pageSize);
69
70
71 70
		return commonResponse;
72 71
	}
73 72
@ -94,7 +93,7 @@ public class SysConfigAiTaskController {
94 93
	@ResponseBody
95 94
	@RequestMapping("/createAiTask")
96 95
	public  CommonResponse<AiTask> createAiTask(@RequestBody AiTask aiTask) throws Exception {
97
96
		aiTask.setAiTaskCode(IDUtils.createID(6,1));
98 97
		CommonResponse<AiTask> commonResponse = sysConfigAiTaskService.createAiTask(aiTask);
99 98
100 99
		return commonResponse;

+ 33 - 0
security-protection-service/src/main/java/com/ai/bss/security/protection/utils/IDUtils.java

@ -0,0 +1,33 @@
1
package com.ai.bss.security.protection.utils;
2
3
/**
4
 * @Auther: 王超
5
 * @Date: 2020/12/30 13:57
6
 * @Description:
7
 */
8
public class IDUtils {
9
10
    private static byte[] lock = new byte[0];
11
12
    // 位数,默认是8位
13
    private final static long w = 100000000;
14
15
16
    /**
17
     * 创建不重复id
18
     * @param
19
     *          timeSub 时间戳一共13位,截取前端的不需要的位数
20
     *          randSub 生成随机数一共9位,截取前端的不需要的位数
21
     *
22
     */
23
    public static String createID(int timeSub,int randSub) {
24
        long r = 0;
25
        synchronized (lock) {
26
            r = (long) ((Math.random() + 1) * w);
27
        }
28
        long timeMillis = System.currentTimeMillis();
29
        String time = String.valueOf(timeMillis);
30
        return time.substring(timeSub) + String.valueOf(r).substring(randSub);
31
    }
32
33
}