1
13693261870
2024-11-08 e2988bcd446dfda8cb1be7f15e2afc58bdd4df8c
src/main/java/com/se/simu/service/SimuService.java
@@ -20,10 +20,11 @@
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.File;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -78,7 +79,7 @@
        if (null != vo.getNum()) {
            wrapper.eq("num", vo.getNum());
        }
        if (!StringUtils.isEmpty(vo.getName())) {
        if (!StringHelper.isEmpty(vo.getName())) {
            wrapper.like("lower(name)", vo.getName().trim().toLowerCase());
        }
        if (!CollUtil.isEmpty(vo.getStatus())) {
@@ -103,6 +104,7 @@
                    delDir(config.getInPath() + File.separator + dp.getInPath());
                    delDir(config.getOutPath() + File.separator + dp.getOutPath());
                    FileUtil.del(config.getInPath() + File.separator + dp.getInPath() + ".json");
                } catch (Exception ex) {
                    log.error(ex.getMessage(), ex);
                }
@@ -133,12 +135,32 @@
        return simuMapper.selectOne(wrapper);
    }
    public SimuPo getSimuByServiceName(String serviceName) {
        if (StringHelper.isEmpty(serviceName)) {
            return null;
        }
        QueryWrapper<SimuPo> wrapper = new QueryWrapper<>();
        wrapper.eq("service_name", serviceName);
        wrapper.last("limit 1");
        return simuMapper.selectOne(wrapper);
    }
    public boolean create(CreateSimuVo vo) {
        Date now = new Date();
        String date = StringHelper.YMDHMS2_FORMAT.format(now);
        if (StringHelper.isEmpty(vo.getName())) {
            vo.setName(date);
        }
        DataPo data = BeanUtil.copyProperties(vo, DataPo.class);
        data.setPath(vo.getName(), vo.getName());
        data.setPath(date, date);
        initPath(data);
        SimuPo simu = new SimuPo(vo.getNum(), vo.getPid(), vo.getName(), JSONUtil.toJsonStr(data), 0, vo.getBak());
        simu.setServiceName(date);
        simu.setCreateTime(new Timestamp(now.getTime()));
        int rows = simuMapper.insert(simu);
        if (rows > 0) {
@@ -204,10 +226,10 @@
            uwService.callExe(data);
            update(simu, 7, null);
            uwService.copeWaterFiles();
            //uwService.copeWaterFiles();
            update(simu, 8, null);
            uwService.copeDrainFiles();
            uwService.copeDrainFiles(data);
            update(simu, 9, null);
            resultService.process(data);
@@ -215,7 +237,7 @@
            update(simu, 10, "完成");
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            update(simu, -10, ex.getMessage());
            update(simu, -simu.getStatus(), ex.getMessage());
        }
    }