|
@@ -0,0 +1,141 @@
|
|
|
|
|
+package com.onemap.analyse.task;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.onemap.analyse.domain.Ztzt.ZttMbkDTO;
|
|
|
|
|
+import com.onemap.analyse.domain.Ztzt.ZttkDTO;
|
|
|
|
|
+import com.onemap.analyse.mapper.ztzt.ZttKMapper;
|
|
|
|
|
+import com.onemap.analyse.mapper.ztzt.ZttMbKMapper;
|
|
|
|
|
+import com.onemap.common.core.utils.StringUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import java.io.File;
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @ClassName ZttKSchedule
|
|
|
|
|
+ * @Description TODO
|
|
|
|
|
+ * @Author 北京四维空间数码科技有限公司
|
|
|
|
|
+ * @Date 2025/10/9 8:30
|
|
|
|
|
+ * @Version 1.0
|
|
|
|
|
+ */
|
|
|
|
|
+@Component
|
|
|
|
|
+public class ZttKSchedule
|
|
|
|
|
+{
|
|
|
|
|
+ //间隔时间 单位ms
|
|
|
|
|
+ public static final long TIME_INTERVAL = 1 * 20000;
|
|
|
|
|
+ //制图图片拼接时间戳格式
|
|
|
|
|
+ private SimpleDateFormat timeFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ZttKMapper zttKMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private ZttMbKMapper zttmbkmapper;
|
|
|
|
|
+
|
|
|
|
|
+// @Value("${yzt.ztzt}")
|
|
|
|
|
+// private String ztztUrl;
|
|
|
|
|
+
|
|
|
|
|
+ //专题图出图文件夹 需要已创建好的 后面会拼接编制时间文件夹加主标题文件名
|
|
|
|
|
+ @Value("${Ztt.exportLocation}")
|
|
|
|
|
+ private String exportLocation;
|
|
|
|
|
+ @Value("${Ztt.functionId}")
|
|
|
|
|
+ private String functionId;
|
|
|
|
|
+ @Value("${Hgxfx.temp}")
|
|
|
|
|
+ private String temp;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Scheduled 定时器参数
|
|
|
|
|
+ * cron表达式:指定任务在特定时间执行
|
|
|
|
|
+ * fixedDelay:表示上一次任务执行完成后多久再执行,参数类型long,单位:ms
|
|
|
|
|
+ * fixedDelayString:与fixedDelay一样,只是参数类型是String
|
|
|
|
|
+ * fixedRate:表示按一定的频率执行任务,参数类型long,单位:ms 如: fixedRate(5000),表示这个定时器任务每5秒执行一次
|
|
|
|
|
+ * fixedRateString:与fixedRate一样,只是参数类型变为String
|
|
|
|
|
+ * initialDelay:表示延迟多久再第一次执行任务,参数类型为long ,单位:ms
|
|
|
|
|
+ * initialDelayString:与initialDelay一样,只是参数类型String
|
|
|
|
|
+ */
|
|
|
|
|
+ @Async("taskExecutor")
|
|
|
|
|
+ @Scheduled(fixedDelay = TIME_INTERVAL)
|
|
|
|
|
+ public void ZtztStatus()
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ QueryWrapper<ZttkDTO> wrapper = new QueryWrapper<ZttkDTO>();
|
|
|
|
|
+ wrapper.eq("ztzt", "0"); //查找没做的专题图
|
|
|
|
|
+ wrapper.orderByAsc("cjsj");
|
|
|
|
|
+ //每次只操作一条记录,按照时间正序排列
|
|
|
|
|
+ List<ZttkDTO> ress = zttKMapper.selectList(wrapper);
|
|
|
|
|
+ if (ress.size() > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ ZttkDTO res = ress.get(0);
|
|
|
|
|
+ //更新数据库信息 开始时间 制图状态
|
|
|
|
|
+ res.setKssj(new Date());
|
|
|
|
|
+ res.setZtzt(1);
|
|
|
|
|
+ QueryWrapper<ZttkDTO> update = new QueryWrapper<ZttkDTO>();
|
|
|
|
|
+ update.eq("bsm", res.getBsm());
|
|
|
|
|
+ zttKMapper.update(res, update);
|
|
|
|
|
+
|
|
|
|
|
+ //查询模板位置
|
|
|
|
|
+ QueryWrapper<ZttMbkDTO> mb = new QueryWrapper<ZttMbkDTO>();
|
|
|
|
|
+ mb.eq("bsm", res.getMbbsm());
|
|
|
|
|
+ ZttMbkDTO mbDto = zttmbkmapper.selectOne(mb);
|
|
|
|
|
+ String mbposition = mbDto.getMbwj();
|
|
|
|
|
+
|
|
|
|
|
+ //判断目标文件夹是否存在,不存在则创建
|
|
|
|
|
+ String curTime = timeFormat.format(new Date());
|
|
|
|
|
+ String newfile = res.getZzsj() + "\\" + res.getName() + curTime + ".jpg";
|
|
|
|
|
+ String jpgpath = exportLocation + "\\" + newfile;
|
|
|
|
|
+ File file = new File(jpgpath);
|
|
|
|
|
+ if (!file.getParentFile().exists()) {
|
|
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //执行python脚本 封装参数
|
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
|
|
+ params.put("bsm", res.getBsm());
|
|
|
|
|
+ params.put("mbposition", mbposition);
|
|
|
|
|
+ params.put("jpgpath", jpgpath);
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+ String result = PythonExecute.Run(functionId, params);
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ if (!StringUtils.isEmpty(result) && result.contains("OK")) {//成功
|
|
|
|
|
+ res.setZtzt(2);
|
|
|
|
|
+ res.setBz(result);
|
|
|
|
|
+ res.setJssj(now);
|
|
|
|
|
+ res.setZttwj(StringUtils.getFileStaticPath(jpgpath, temp));
|
|
|
|
|
+ zttKMapper.update(res, update);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ res.setJssj(now);
|
|
|
|
|
+ res.setZtzt(3);
|
|
|
|
|
+ res.setBz(result);
|
|
|
|
|
+ QueryWrapper<ZttkDTO> update2 = new QueryWrapper<ZttkDTO>();
|
|
|
|
|
+ update2.eq("bsm", res.getBsm());
|
|
|
|
|
+ zttKMapper.update(res, update2);
|
|
|
|
|
+ }
|
|
|
|
|
+ //调用地址出图
|
|
|
|
|
+// String getUrl = ztztUrl + "" + res.getBsm()+"&mbposition="+ URLEncoder.encode(mbposition,"UTF-8")+"&jpgpath="+ URLEncoder.encode(jpgpath,"UTF-8")+"&newfile="+URLEncoder.encode(newfile,"UTF-8");
|
|
|
|
|
+// System.out.println("开始进行专题制图,调用地址" + getUrl);
|
|
|
|
|
+// String msg = HttpClientUtil.doGet(getUrl);
|
|
|
|
|
+// System.out.println("专题制图检查结果" + msg);
|
|
|
|
|
+// System.out.println("专题制图检查结果:" + res.getBsm() + "制图任务调用成果!!!!!!!! " + new Date().toString());
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ res.setZtzt(3);
|
|
|
|
|
+ res.setBz(e.getMessage());
|
|
|
|
|
+ QueryWrapper<ZttkDTO> update2 = new QueryWrapper<ZttkDTO>();
|
|
|
|
|
+ update2.eq("bsm", res.getBsm());
|
|
|
|
|
+ zttKMapper.update(res, update2);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|