Parcourir la source

管道修改BUG

huangxingxing il y a 1 an
Parent
commit
b3e69d2f99

+ 2 - 2
src/main/java/com/miniframe/bisiness/system/D000017Service.java

@@ -33,11 +33,11 @@ public class D000017Service extends D000017BaseModel implements ExecProcessFlow
 		String fileName ="";
 		if(accident.getStype().endsWith("Fire")){
 			outPath=TemplateGenerator.BPATH+"/"+aid+"/"+accident.getJid()+"/fire/out";
-			fileName ="velocity"+step+".txt";
+			fileName ="velocity"+step;
 		}
 		if(accident.getStype().endsWith("Water")){
 			outPath=TemplateGenerator.BPATH+"/"+aid+"/"+accident.getJid()+"/water/out";
-			fileName ="velocity"+step+".txt";
+			fileName ="velocity"+step;
 		}
 		Path path = Paths.get(outPath+"/"+fileName);
 		String mimeType = MFMimeTypeUtils.getMimeType(path);

+ 186 - 89
src/main/java/com/miniframe/bisiness/system/D10021Service.java

@@ -1,16 +1,25 @@
 package com.miniframe.bisiness.system;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
+
+import com.miniframe.constant.MFConstant;
 import com.miniframe.core.ExecProcessFlow;
 import com.miniframe.core.exception.BusinessException;
 import com.miniframe.core.ext.UtilTools;
 import com.miniframe.generate.business.system.model.D10021BaseModel;
-import com.miniframe.model.system.DAccident;
-import com.miniframe.model.system.DGas;
-import com.miniframe.model.system.SysFile;
+import com.miniframe.generate.comm.system.D_D10016_CHVALS_RECODE;
+import com.miniframe.generate.comm.system.D_D10016_COCODES_RECODE;
+import com.miniframe.model.system.*;
 import com.miniframe.model.system.dao.DAccidentMapper;
+import com.miniframe.model.system.dao.DGasGatherAreaMapper;
 import com.miniframe.model.system.dao.DGasMapper;
 import com.miniframe.model.system.dao.SysFileMapper;
+import com.miniframe.tools.XIFileUtils;
 
 import javax.rmi.CORBA.Util;
 
@@ -18,91 +27,179 @@ import javax.rmi.CORBA.Util;
  * 基础系统,“瓦斯灾源添加修改”逻辑处理(重新生成不覆盖)。
  */
 public class D10021Service extends D10021BaseModel implements ExecProcessFlow {
-	
-	private static final long serialVersionUID = -7051358269847459502L;
-		
-	/**
-	 * 基础系统,“瓦斯灾源添加修改”业务核心处理
- 	 */
-	public void transExecute() throws Exception {
-		Integer gid = this.getA_d10021().getGid();
-		String gfid =this.getA_d10021().getGfid();
-		String bfid =this.getA_d10021().getBfid();
-		Integer aid =this.getA_d10021().getAid();
-
-		SysFileMapper sysFileMapper = UtilTools.getBean(SysFileMapper.class);
-		SysFile gf = sysFileMapper.selectByPrimaryKey(gfid);
-		if(gf ==null){
-			throw  new BusinessException("EB3100020");
-		}
-		SysFile bf =sysFileMapper.selectByPrimaryKey(bfid);
-		if(bf==null){
-			throw  new BusinessException("EB3100021");
-		}
-
-		//TODO 解析 边界文件 生成瓦斯积聚区数据
-
-
-
-
-
-		DAccidentMapper accidentMapper = UtilTools.getBean(DAccidentMapper.class);
-		DAccident accident =accidentMapper.selectByPrimaryKey(aid);
-		if(accident ==null) {
-			throw  new BusinessException("EB3000002");
-		}
-
-
-		DGasMapper gasMapper =UtilTools.getBean(DGasMapper.class);
-		if(gid==null||gid<=0){//添加
-			DGas gas =new DGas();
-			gas.setAid(aid);
-			gas.setBfid(bfid);
-			gas.setBfname(bf.getFilename());
-			gas.setGfid(gfid);
-			gas.setGfname(gf.getFilename());
-			gasMapper.insertSelective(gas);
-		}else{//修改
-			DGas gas =gasMapper.selectByPrimaryKey(gid);
-			if(gas ==null){
-				throw new BusinessException("EB3100022");
-			}
-			gas.setAid(aid);
-			gas.setBfid(bfid);
-			gas.setBfname(bf.getFilename());
-			gas.setGfid(gfid);
-			gas.setGfname(gf.getFilename());
-			gasMapper.updateByPrimaryKey(gas);
-		}
-
-
-	}
-	
-	/**
-	 * 基础系统,“瓦斯灾源添加修改”业务前处理
- 	 */
-	public void preTransFlow() throws Exception {
-		this.validater();
-	}
-	
-	/**
-	 * 基础系统,“瓦斯灾源添加修改”业务后处理
- 	 */
-	public void afterTransFlow() throws Exception {
-	
-	}
-	
-	/**
-	 * 基础系统,“瓦斯灾源添加修改”逻辑入口处理方法
- 	 */
- 	@SuppressWarnings("rawtypes")
-	@Override
-	public Map execute(Map vars) throws Exception {
-		this.setTransMap(vars);
-		preTransFlow();// 执行业务开始的规则检查和校验
-		transExecute();// 执行核心业务段
-		afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
-		return this.getTransMap();
-	}
+
+    private static final long serialVersionUID = -7051358269847459502L;
+
+    /**
+     * 基础系统,“瓦斯灾源添加修改”业务核心处理
+     */
+    public void transExecute() throws Exception {
+        Integer gid = this.getA_d10021().getGid();
+        String gfid = this.getA_d10021().getGfid();
+        String bfid = this.getA_d10021().getBfid();
+        Integer aid = this.getA_d10021().getAid();
+
+        SysFileMapper sysFileMapper = UtilTools.getBean(SysFileMapper.class);
+        SysFile gf = sysFileMapper.selectByPrimaryKey(gfid);
+        if (gf == null) {
+            throw new BusinessException("EB3100020");
+        }
+        SysFile bf = sysFileMapper.selectByPrimaryKey(bfid);
+        if (bf == null) {
+            throw new BusinessException("EB3100021");
+        }
+        List<String> blockNames = readBFile(bf);
+
+        DAccidentMapper accidentMapper = UtilTools.getBean(DAccidentMapper.class);
+        DAccident accident = accidentMapper.selectByPrimaryKey(aid);
+        if (accident == null) {
+            throw new BusinessException("EB3000002");
+        }
+
+        DGasGatherAreaMapper areaMapper = UtilTools.getBean(DGasGatherAreaMapper.class);
+        DGasMapper gasMapper = UtilTools.getBean(DGasMapper.class);
+        if (gid == null || gid <= 0) {//添加
+            DGas gas = new DGas();
+            gas.setAid(aid);
+            gas.setBfid(bfid);
+            gas.setBfname(bf.getFilename());
+            gas.setGfid(gfid);
+            gas.setGfname(gf.getFilename());
+            gasMapper.insertSelective(gas);
+
+            DGasSQLBuilder sb = new DGasSQLBuilder();
+            DGasSQLBuilder.Criteria sc = sb.createCriteria();
+            sc.andAidEqualTo(aid);
+            sc.andBfidEqualTo(bfid);
+            sc.andGfidEqualTo(gfid);
+            sb.setOrderByClause("id DESC");
+
+            gas = gasMapper.selectOneByExample(sb);
+
+
+            for (String blockName : blockNames) {
+                DGasGatherArea area =new DGasGatherArea();
+                area.setGasdensity(0f);
+                area.setType("0");
+                area.setAid(aid);
+                area.setGid(gid);
+                area.setName(blockName);
+                areaMapper.insertSelective(area);
+            }
+
+
+        } else {//修改
+            DGas gas = gasMapper.selectByPrimaryKey(gid);
+            if (gas == null) {
+                throw new BusinessException("EB3100022");
+            }
+            if(gas.getBfid()!=bfid){
+                DGasGatherAreaSQLBuilder ggsb = new DGasGatherAreaSQLBuilder();
+                DGasGatherAreaSQLBuilder.Criteria ggsc = ggsb.createCriteria();
+                ggsc.andGidEqualTo(gid);
+                areaMapper.deleteByExample(ggsb);
+                for (String blockName : blockNames) {
+                    DGasGatherArea area =new DGasGatherArea();
+                    area.setGasdensity(0f);
+                    area.setType("0");
+                    area.setAid(aid);
+                    area.setGid(gid);
+                    area.setName(blockName);
+                    areaMapper.insertSelective(area);
+                }
+            }
+            gas.setAid(aid);
+            gas.setBfid(bfid);
+            gas.setBfname(bf.getFilename());
+            gas.setGfid(gfid);
+            gas.setGfname(gf.getFilename());
+            gasMapper.updateByPrimaryKey(gas);
+        }
+
+
+    }
+
+    private List<String> readBFile(SysFile bf) throws BusinessException {
+        //TODO 解析 边界文件 生成瓦斯积聚区数据
+        File bfFile = new File(XIFileUtils.getRootPathStr() + MFConstant.separator + bf.getFilepath());
+        List<String> fileStrs = new ArrayList<>();
+        try {
+            FileReader fileReader = new FileReader(bfFile);
+            BufferedReader reader = new BufferedReader(fileReader);
+            String line;
+            int linNum = 1;
+            while ((line = reader.readLine()) != null) {
+                fileStrs.add(line);
+            }
+            fileReader.close();
+            reader.close();
+
+            if (fileStrs.size() <= 3) {
+                throw new BusinessException("EB3100025");
+            }
+            boolean isBlockStart = false;
+            boolean isBlockNumStart = false;
+            int blockNum = 0;
+            List<String> blockNames = new ArrayList<>();
+            for (int i = 3; i < fileStrs.size(); i++) {
+                if (!isBlockStart) {
+                    isBlockStart = true;
+                    blockNames.add(fileStrs.get(i));
+                    continue;
+                }
+                if (!isBlockNumStart) {
+                    blockNum = Integer.valueOf(fileStrs.get(i));
+                    isBlockNumStart = true;
+                    continue;
+                }
+                int dyhang = 0;
+                for (int j = 0; j < blockNum; j++) {
+                    String linet = fileStrs.get(i + dyhang + j);
+                    String[] t = linet.trim().split(" ");
+                    int last = Integer.valueOf(t[t.length - 1]);
+                    if (last == -1) {
+                        ++dyhang;
+                    }
+                }
+                i = i + dyhang + blockNum;
+                isBlockStart = false;
+                isBlockNumStart = false;
+                return blockNames;
+            }
+        } catch (Exception e) {
+            System.out.println(e);
+            throw new BusinessException("EB3100025");
+        }
+
+        return null;
+
+    }
+
+    /**
+     * 基础系统,“瓦斯灾源添加修改”业务前处理
+     */
+    public void preTransFlow() throws Exception {
+        this.validater();
+    }
+
+    /**
+     * 基础系统,“瓦斯灾源添加修改”业务后处理
+     */
+    public void afterTransFlow() throws Exception {
+
+    }
+
+    /**
+     * 基础系统,“瓦斯灾源添加修改”逻辑入口处理方法
+     */
+    @SuppressWarnings("rawtypes")
+    @Override
+    public Map execute(Map vars) throws Exception {
+        this.setTransMap(vars);
+        preTransFlow();// 执行业务开始的规则检查和校验
+        transExecute();// 执行核心业务段
+        afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
+        return this.getTransMap();
+    }
 
 }

+ 63 - 39
src/main/java/com/miniframe/tools/XIFileUtils.java

@@ -3,6 +3,7 @@ package com.miniframe.tools;
 import com.google.common.io.Resources;
 import com.miniframe.constant.MFConstant;
 import com.miniframe.core.IniFileReader;
+import com.miniframe.core.exception.BusinessException;
 import com.miniframe.core.ext.UtilTools;
 import com.miniframe.generate.appcode.FileType;
 import com.miniframe.model.system.SysFile;
@@ -15,10 +16,7 @@ import org.apache.http.entity.ContentType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.BufferedInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.math.BigDecimal;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -47,42 +45,68 @@ public class XIFileUtils {
 
     }
 
-    public static void main(String[] args) {
-//        Path path = Paths.get("e:/opt/files/a/b/c/d/1111.mp4");
-//        getRelativizePathStr("/opt/files/device.rar");
-//
-//        getAbsolutePathStr("/1/opt/files/device.rar");
-//
-//        String fileName = path.getFileName().toString();
-//
-//        String md5 = XIUtils.getMD5(fileName);
-//        String first = md5.substring(0, 2);//第一级目录
-//        String second = md5.substring(2, 4);//第二级目录
-//
-//
-//        String pathTo = getFilePathStr("group", first, second, fileName);
-//
-//        try {
-//            InputStream inputStream = Files.newInputStream(Paths.get("/opt/files/890adbc8ba984e429464fe782e4fa3e9-1e66ddc664aa43958b690c8c46cdd364_20210203102343.aac"));
-//        } catch (IOException e) {
-//            e.printStackTrace();
-//        }
-//        String mimeType = MFMimeTypeUtils.getMimeType("/opt/files/890adbc8ba984e429464fe782e4fa3e9-1e66ddc664aa43958b690c8c46cdd364_20210203102343.aac");
-//
-//        ContentType contentType = ContentType.create(mimeType);
-//
-//        String suffix = getExtensionWithDot("e:/1/2/3\\5/5.mp4");
-//
-//        String uuid = UtilTools.getUUid();
-//        String uploadDirStr = "/opt/files/";
-//        for (int i = 0; i < 2; i++) {
-//            uploadDirStr += uuid.substring(i * 2, i * 2 + 2) + "/";
-//        }
-//        int x = 0;
+    public static void main(String[] args) throws BusinessException {
 
-        IniFileReader ini = new IniFileReader("userconfig/user.properties");
-        String host = ini.getStrValue("es.host")+"/searchAllLog";
-        System.out.println(host);
+
+        //TODO 解析 边界文件 生成瓦斯积聚区数据
+        File bfFile =new File("D://pipes3.inp");
+        List<String> fileStrs =new ArrayList<>();
+        try{
+            FileReader fileReader = new FileReader(bfFile);
+            BufferedReader reader = new BufferedReader(fileReader);
+            String line;
+            int linNum =1;
+            while ((line = reader.readLine()) != null) {
+                fileStrs.add(line);
+            }
+            fileReader.close();
+            reader.close();
+        }catch (Exception e){
+            System.out.println(e);
+            throw  new BusinessException("EB3100021");
+        }
+        if(fileStrs.size()<=3){
+            throw  new BusinessException("EB3100025");
+        }
+        boolean isBlockStart =false;
+        boolean isBlockNumStart =false;
+        int  blockNum =0;
+        List<String> blockNames =new ArrayList<>();
+        for (int i = 3; i < fileStrs.size(); i++) {
+            if(!isBlockStart){
+                isBlockStart=true;
+                blockNames.add(fileStrs.get(i));
+                continue;
+            }
+            if(!isBlockNumStart){
+                blockNum = Integer.valueOf(fileStrs.get(i));
+                isBlockNumStart=true;
+                continue;
+            }
+            int j = 0;
+            int dyhang =0;
+            for (; j < blockNum; j++) {
+                String line =fileStrs.get(i+dyhang+j);
+                String[] t =line.trim().split(" ");
+                int last =Integer.valueOf(t[t.length-1]);
+                if(last==-1){
+                    ++dyhang;
+                }
+            }
+            i=i+dyhang+blockNum;
+            isBlockStart=false;
+            isBlockNumStart=false;
+        }
+
+        System.out.println(blockNames);
+
+    }
+    public static String replacekg(String line){
+        while (line.lastIndexOf("  ")>0){
+            String s =line.replace("  "," ");
+            return  replacekg(s);
+        }
+        return line;
     }
 
     public static String getRelativizePathStr(Path path) {

+ 3 - 1
系统设计/数据定义/返 回 码/business(业务系统).csv

@@ -91,4 +91,6 @@
 3100021,EB3100021,边界文件不存在!,
 3100022,EB3100022,瓦斯灾源不存在!,
 3100023,EB3100023,瓦斯爆炸区不存在!,
-3100024,EB3100024,瓦斯积聚区不存在!,
+3100024,EB3100024,瓦斯积聚区不存在!,
+
+3100025,EB3100025,边界文件格式错误!,