|
@@ -1,152 +0,0 @@
|
|
-package org.springblade.evisa.controller;
|
|
|
|
-
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
-import org.springblade.business.vo.ScrSignInfoVO;
|
|
|
|
-import org.springblade.business.vo.TaskSignInfoVO;
|
|
|
|
-import org.springblade.common.utils.CommonUtil;
|
|
|
|
-import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
|
-import org.springblade.core.oss.model.BladeFile;
|
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
|
-import org.springblade.evisa.service.ScrDataService;
|
|
|
|
-import org.springblade.evisa.utils.FileUtils;
|
|
|
|
-import org.springblade.resource.feign.NewIOSSClient;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
|
-import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
-
|
|
|
|
-import javax.annotation.Resource;
|
|
|
|
-import java.io.ByteArrayInputStream;
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
-import java.io.InputStream;
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
-import java.net.URL;
|
|
|
|
-import java.net.URLConnection;
|
|
|
|
-import java.net.URLEncoder;
|
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
-import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * 清表基础数据表 控制器
|
|
|
|
- *
|
|
|
|
- * @author BladeX
|
|
|
|
- * @since 2022-05-18
|
|
|
|
- */
|
|
|
|
-@RestController
|
|
|
|
-@AllArgsConstructor
|
|
|
|
-@Api(value = "电签类", tags = "电签类接口")
|
|
|
|
-@Slf4j
|
|
|
|
-public class Chek {
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private StringRedisTemplate RedisTemplate;
|
|
|
|
- @Autowired
|
|
|
|
- private JdbcTemplate jdbcTemplate;
|
|
|
|
- @Autowired
|
|
|
|
- private NewIOSSClient newIOSSClient;
|
|
|
|
- // 线程池
|
|
|
|
- @Resource(name = "taskExecutor1")
|
|
|
|
- private ThreadPoolExecutor executor;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // @Scheduled(cron = "0/10 * * * * ?")
|
|
|
|
- public void SignInfo() {
|
|
|
|
- // 质检SQL
|
|
|
|
- // String sql = "select id,file_url as eVisaPdfUrl from u_archive_file where length(file_url)!=char_length(file_url) and file_name not in('封面.pdf','封面1.pdf','卷内目录.pdf','卷内目录1.pdf','背脊.pdf','背脊1.pdf','备考表.pdf','备考表1.pdf') and is_deleted<>10 and contract_id in(1890322575534399490,1890328157624541186,1887771910584999937) and file_url is not null and file_url like '%.pdf%' LIMIT 30 ";
|
|
|
|
- String sql = "select id,file_url as eVisaPdfUrl from u_archive_file where file_url like '%//卷内目录.pdf' and file_url is not null and file_url like '%.pdf%' LIMIT 30 ";
|
|
|
|
-
|
|
|
|
- List<ScrSignInfoVO> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ScrSignInfoVO.class));
|
|
|
|
- if (query != null && query.size() >= 1 ) {
|
|
|
|
- for (ScrSignInfoVO dataInfo : query) {
|
|
|
|
- if (executor.getQueue().size()<=60 ) {
|
|
|
|
- Long nodeId = dataInfo.getId();
|
|
|
|
- Boolean aBoolean = RedisTemplate.hasKey("sign-" + nodeId);
|
|
|
|
-
|
|
|
|
- if (!aBoolean) {
|
|
|
|
- RedisTemplate.opsForValue().set("sign-" + nodeId, "1",3600, TimeUnit.SECONDS);
|
|
|
|
- CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
|
|
|
|
- try {
|
|
|
|
- /*===============执行批量任务===============*/
|
|
|
|
- signTaskBatch(dataInfo);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- String dsql = "update u_archive_file set is_deleted=9 where id="+nodeId;
|
|
|
|
- jdbcTemplate.execute(dsql);
|
|
|
|
- RedisTemplate.delete("sign-" +nodeId);
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }, executor);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- System.out.println("队列数量" + executor.getQueue().size());
|
|
|
|
- System.out.println("活跃数量" + executor.getActiveCount());
|
|
|
|
- System.out.println("总共数量" + executor.getTaskCount());
|
|
|
|
- System.out.println("完成数量" + executor.getCompletedTaskCount());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public void signTaskBatch(ScrSignInfoVO taskApp) throws Exception {
|
|
|
|
-
|
|
|
|
- String pdfurl =taskApp.getEVisaPdfUrl();
|
|
|
|
- Long id =taskApp.getId();
|
|
|
|
-
|
|
|
|
- InputStream inputStre =getOSSInputStream2(pdfurl);
|
|
|
|
- String sysLocalFileUrl = FileUtils.getSysLocalFileUrl();
|
|
|
|
- String filecode = SnowFlakeUtil.getId() + "";
|
|
|
|
- String dataFileUrl = sysLocalFileUrl + "/pdf/" + filecode + ".pdf";
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- FileOutputStream fout = new FileOutputStream(dataFileUrl);
|
|
|
|
- int bytesRead = 0;
|
|
|
|
- byte[] buffer = new byte[8192];
|
|
|
|
- while ((bytesRead = inputStre.read(buffer, 0, 8192)) != -1) {
|
|
|
|
- fout.write(buffer, 0, bytesRead);
|
|
|
|
- }
|
|
|
|
- fout.close();
|
|
|
|
-
|
|
|
|
- BladeFile bladeFile = this.newIOSSClient.uploadFile(SnowFlakeUtil.getId() + ".pdf", dataFileUrl);
|
|
|
|
-
|
|
|
|
- if (bladeFile != null && Func.isNotEmpty(bladeFile.getLink())) {
|
|
|
|
- String dsql = "update u_archive_file set file_url='"+bladeFile.getLink()+"' ,is_deleted=10 where id="+id;
|
|
|
|
- jdbcTemplate.execute(dsql);
|
|
|
|
- System.out.println("成功");
|
|
|
|
- System.out.println(dsql);
|
|
|
|
- }
|
|
|
|
- RedisTemplate.delete("sign-" + taskApp.getId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public static InputStream getOSSInputStream2(String urlStr) {
|
|
|
|
- try {
|
|
|
|
- //获取OSS文件流
|
|
|
|
- // String encodedUrl = URLEncoder.encode(urlStr, StandardCharsets.UTF_8.toString());
|
|
|
|
-
|
|
|
|
- URL url = new URL(urlStr);
|
|
|
|
- URLConnection conn = url.openConnection();
|
|
|
|
- conn.setRequestProperty("User-Agent", "Mozilla/5.0");
|
|
|
|
- // conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
|
|
|
- return conn.getInputStream();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- System.out.println("zw-----------");
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-/* public static void main(String[] args) throws UnsupportedEncodingException {
|
|
|
|
- String data ="https://xinan1.zos.ctyun.cn/huazheng2021/archivedFile/cover/6eae7ee55e6ca24a2cc819534715//卷内目录.pdf";
|
|
|
|
-
|
|
|
|
- getOSSInputStream2(data);
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
-}
|
|
|