管道基础大数据平台系统开发-【后端】-Server
13693261870
2024-03-13 7d536d24aa867e9dd4304db39f267373679a6480
解决定时器启动计算数据时报错
已修改4个文件
60 ■■■■ 文件已修改
src/main/java/com/lf/server/config/ScheduleConfig.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/show/OneMapController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/FmeService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/OneMapService.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/config/ScheduleConfig.java
@@ -6,9 +6,11 @@
import com.lf.server.service.all.ScheduleService;
import com.lf.server.service.all.WebSocketService;
import com.lf.server.service.show.AutoQueryService;
import com.lf.server.service.show.OneMapService;
import com.lf.server.service.sys.AttachService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ibatis.annotations.Result;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -32,6 +34,9 @@
    @Resource
    AutoQueryService autoQueryService;
    @Resource
    OneMapService oneMapService;
    private static boolean isBusy = false;
    private static final Log log = LogFactory.getLog(ScheduleConfig.class);
@@ -41,6 +46,11 @@
        autoQueryService.autoQuery();
    }
    @Scheduled(cron = "0 0 2 * * ?")
    public void calcData() {
        oneMapService.calcData();
    }
    @Scheduled(fixedRate = 15 * 1000)
    public void pushMonitorInfo() {
        try {
src/main/java/com/lf/server/controller/show/OneMapController.java
@@ -403,4 +403,18 @@
            return fail(ex.getMessage());
        }
    }
    @SysLog()
    @ApiOperation(value = "查询计算数据")
    @GetMapping("/selectCalcData")
    public ResponseMsg<Object> selectCalcData(){
        try {
            String rs = oneMapService.calcData();
            return success(rs);
        }catch (Exception ex){
            log.error(ex.getMessage(), ex);
            return fail(ex.getMessage());
        }
    }
}
src/main/java/com/lf/server/service/data/FmeService.java
@@ -322,8 +322,8 @@
    /**
     * f.计算面积
     */
    public String calcArea(String sjfl, String id, String wjlj, HttpServletRequest req) {
        String url = getUrl("datax/task/run/数据占地面积计算", req);
    public String calcArea(String sjfl, String id, String wjlj) {
        String url = getUrl("datax/task/run/数据占地面积计算");
        List<NameValueEntity> list = new ArrayList<>();
        list.add(new NameValueEntity("_name", String.format("%s_%s", "数据占地面积计算", StringHelper.YMDHMS2_FORMAT.format(new Date()))));
src/main/java/com/lf/server/service/show/OneMapService.java
@@ -418,26 +418,28 @@
     */
    public String calcData() {
        Integer rows = selectLineBuffer();
        List<Map<String, Object>> list = selectMetaByType();
        if (null != list && list.size() > 0) {
            HttpServletRequest req = WebHelper.getRequest();
            String rootPath = pathHelper.getUploadFullPath();
            for (Map<String, Object> map : list) {
                String sjfl = map.get("type").toString();
                String id = map.get("id").toString();
                String wjlj = rootPath + File.separator + map.get("path").toString();
            try {
                String rootPath = pathHelper.getConfig().getUploadPath();
                for (Map<String, Object> map : list) {
                    String sjfl = map.get("type").toString();
                    String id = map.get("id").toString();
                    String wjlj = rootPath + File.separator + map.get("path").toString();
                File file = new File(wjlj);
                if (!file.exists() || file.isDirectory()) {
                    continue;
                }
                    File file = new File(wjlj);
                    if (!file.exists() || file.isDirectory()) {
                        continue;
                    }
                String str = fmeService.calcArea(sjfl, id, wjlj, req);
                if (null != str) {
                    System.out.println(str);
                    String str = fmeService.calcArea(sjfl, id, wjlj);
                    if (null != str) {
                        System.out.println(str);
                    }
                    rows++;
                }
                rows++;
            } catch (Exception ex) {
                log.error(ex.getMessage(), ex);
            }
        }