|
@@ -0,0 +1,104 @@
|
|
|
+package org.springblade.evisa.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.business.entity.Task;
|
|
|
+import org.springblade.business.feign.TaskClient;
|
|
|
+import org.springblade.business.vo.TaskApprovalVO;
|
|
|
+import org.springblade.evisa.service.EVisaService;
|
|
|
+import org.springblade.evisa.vo.EVisaTaskApprovalVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 清表基础数据表 控制器
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2022-05-18
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/evisaInfo")
|
|
|
+@Api(value = "电签类", tags = "电签类接口")
|
|
|
+@Slf4j
|
|
|
+public class EVisaJLController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StringRedisTemplate RedisTemplate;
|
|
|
+
|
|
|
+ // jdbc
|
|
|
+ private final JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
+ //电签服务类
|
|
|
+ private final EVisaService eVisaService;
|
|
|
+
|
|
|
+ // 线程池
|
|
|
+ @Resource(name = "taskExecutor1")
|
|
|
+ private ThreadPoolExecutor executor;
|
|
|
+
|
|
|
+ private final TaskClient taskClient;
|
|
|
+
|
|
|
+ // 电签主类
|
|
|
+ public void SignInfo() {
|
|
|
+ //执行代码
|
|
|
+
|
|
|
+ log.info("扫描开始");
|
|
|
+ String sql = "SELECT * from u_task_batch where is_deleted=0 and id in(SELECT max(id) as id from u_task_batch where is_deleted=0 GROUP BY JSON_EXTRACT(json_data, '$.formDataId')) LIMIT 10 ";
|
|
|
+ List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
|
|
|
+ if (maps != null && maps.size() >= 1 ) {//&& SystemUtils.isLinux()
|
|
|
+ for (Map<String, Object> dataInfo : maps) {
|
|
|
+ if (executor.getQueue().size()<=40 ) {
|
|
|
+ String jsonData = dataInfo.get("json_data") + "";
|
|
|
+ TaskApprovalVO taskApprovalVO = JSON.parseObject(jsonData, TaskApprovalVO.class);
|
|
|
+ String taskBatchId = dataInfo.get("id").toString();
|
|
|
+ Long userId = Long.valueOf(dataInfo.get("create_user") + "");
|
|
|
+ String nickName = dataInfo.get("nick_name") + "";
|
|
|
+ Boolean aBoolean = RedisTemplate.hasKey("sign-" + taskApprovalVO.getFormDataId());
|
|
|
+ taskApprovalVO.setId(taskBatchId);
|
|
|
+ taskApprovalVO.setUserId(userId);
|
|
|
+ taskApprovalVO.setNickName(nickName);
|
|
|
+
|
|
|
+ if (!aBoolean) {
|
|
|
+ RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1",1800, TimeUnit.SECONDS);
|
|
|
+ CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
|
|
|
+ try {
|
|
|
+ /*===============执行批量任务===============*/
|
|
|
+ this.checkIsExsitTaskBatch(taskApprovalVO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }, executor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("队列数量" + executor.getQueue().size());
|
|
|
+ System.out.println("活跃数量" + executor.getActiveCount());
|
|
|
+ System.out.println("总共数量" + executor.getTaskCount());
|
|
|
+ System.out.println("完成数量" + executor.getCompletedTaskCount());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void checkIsExsitTaskBatch(TaskApprovalVO taskApprovalVO){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|