瀏覽代碼

“新增风门类型支持”

kangyu 3 月之前
父節點
當前提交
0800a6b133
共有 2 個文件被更改,包括 703 次插入11 次删除
  1. 17 11
      src/main/java/com/ventanaly/FastPlcGenerate.java
  2. 686 0
      src/main/java/com/ventanaly/FastPlcGenerate2.java

+ 17 - 11
src/main/java/com/ventanaly/FastPlcGenerate.java

@@ -15,16 +15,16 @@ public class FastPlcGenerate {
 
 
     // 风机类型 主扇:Main 局扇:System
-    public static String FAN_TYPE="Main";
+    public static String FAN_TYPE="System";
 
-    //矿井唯一表示,万里一矿--->Wl1k
-    public static String MINE_NAME="chs_2";
+    //矿井唯一表示,首字母大写例如万里一矿--->Wl1k
+    public static String MINE_NAME="longhua";
 
     //设备名称
-    public static String DEVICE_NAME="察哈素新增立井主风机2号";
+    public static String DEVICE_NAME="龙华矿均压工作面局扇";
 
     // Excel文件路径
-    public static String EXCEL_FILE_PATH = "template/察哈素二号主风机.xlsx";
+    public static String EXCEL_FILE_PATH = "template/龙华局扇.xlsx";
 
 
     public static String ENUM_NAME = "Fan"+FAN_TYPE+MINE_NAME+"Enum";
@@ -152,7 +152,13 @@ public class FastPlcGenerate {
                 "    "+FACILITY_NAME+" "+FACILITY_REF_NAME+";");
         System.out.println("....");
         System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
-        System.out.println("    public boolean controlFan"+FAN_TYPE+MINE_NAME+"(Fan"+FAN_TYPE+"From from, Json json, FanMainPage fm, UserLogPage ulPage) {\n");
+        System.out.println(
+                "                case Fan"+FAN_TYPE+MINE_NAME+"Facility.TYPE:\n" +
+                "                    r = controlFanSystem"+MINE_NAME+"(from, json,fs.get(0), ulPage);\n" +
+                "                    break;");
+        System.out.println("....");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("    public boolean controlFan"+FAN_TYPE+MINE_NAME+"(Fan"+FAN_TYPE+"From from, Json json, Fan"+FAN_TYPE+"Page fm, UserLogPage ulPage) {\n");
         System.out.println("        boolean r = false;\n" +
                 "        ulPage.setDeviceType(4);\n" +
                 "        DeviceRelationPage dr = SubStationStatic.DRMap.get(from.getId());\n" +
@@ -211,7 +217,7 @@ public class FastPlcGenerate {
     }
 
     public static  void createFormAtt(String nowDate){
-        System.out.println("放在 com.ventanaly.tool.froms.FanMainFrom 下");
+        System.out.println("放在 com.ventanaly.tool.froms.Fan"+FAN_TYPE+"From 下");
         System.out.println("    @JsonProperty(value = "+"\""+FROM_REF_NAME+"\""+")"+"\n" +
                 "    private "+FROM_NAME+" "+FROM_REF_NAME+";\n");
     }
@@ -220,7 +226,7 @@ public class FastPlcGenerate {
         System.out.println("放在 com.ventanaly.device.facility.fan"+FAN_TYPE);
         System.out.println("import com.ventanaly.tool.enums.PLCDevice2Enum;\n" +
                 "import com.ventanaly.tool.froms.FanMainFrom;\n" +
-                "import com.ventanaly.tool.page.FanMainPage;\n" +
+                "import com.ventanaly.tool.page.Fan"+FAN_TYPE+"Page;\n" +
                 "import com.ventanaly.tool.utils.Constants;\n" +
                 "import com.ventanaly.tool.page.DeviceRelationPage;\n" +
                 "import com.ventanaly.tool.page.SubStationPage;\n" +
@@ -239,7 +245,7 @@ public class FastPlcGenerate {
         System.out.println("    public static final String TYPE_NAME = "+"\""+DEVICE_NAME+"\""+";\n" +
                 "    private static boolean control = true;\n" +
                 "\n");
-        System.out.println("    public "+VO_NAME+" status"+ "(DeviceRelationPage dr, Map<String, String> tableMeta, FanMainPage page) {\n");
+        System.out.println("    public "+VO_NAME+" status"+ "(DeviceRelationPage dr, Map<String, String> tableMeta, Fan"+FAN_TYPE+"Page page) {\n");
         System.out.println("        "+VO_NAME+" vo = new "+ VO_NAME+"();");
         System.out.println("        vo.setDeviceType(Constants.DEVICE_TYPE_FAN_"+FAN_TYPE.toUpperCase()+");");
         System.out.println("        vo.setSmallType(TYPE);");
@@ -553,8 +559,8 @@ public class FastPlcGenerate {
                 "|:----    |:---|:----- |-----   |\n" +
                 "|id |是  |Integer |分站id   |\n" +
                 "|passWord|是|String|控制密码|");
-        System.out.println("|"+FACILITY_REF_NAME+"|否|Object|控制命令|");
-        System.out.println("##### "+FACILITY_NAME+" 请求参数");
+        System.out.println("|"+FROM_REF_NAME+"|否|Object|控制命令|");
+        System.out.println("##### "+FROM_NAME+" 请求参数");
         System.out.println("|参数名|必选|类型|说明|");
         System.out.println("|:----    |:---|:----- |-----   |");
         for(int i = 0;i<colArray.length;i++){

+ 686 - 0
src/main/java/com/ventanaly/FastPlcGenerate2.java

@@ -0,0 +1,686 @@
+package com.ventanaly;
+
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.FileInputStream;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+
+public class FastPlcGenerate2 {
+
+
+    public static String DEVICE_TYPE = "Gate";
+    // 风机类型 主扇:Main 局扇:System
+
+    //矿井唯一表示,首字母大写,例如万里一矿--->Wl1k
+    public static String MINE_NAME="Longhua";
+
+    //设备名称
+    public static String DEVICE_NAME="龙华矿均压工作面风门";
+
+    // Excel文件路径
+    public static String EXCEL_FILE_PATH = "template/龙华均压工作面液压风门.xlsx";
+
+
+    public static String DEVICE_TYPE_REF = DEVICE_TYPE.substring(0, 1).toLowerCase() + DEVICE_TYPE.substring(1);
+
+
+    public static String ENUM_NAME = DEVICE_TYPE+MINE_NAME+"Enum";
+
+    public static String ENUM_PREFIX = DEVICE_TYPE.toUpperCase()+"_"+MINE_NAME.toUpperCase()+"_ENUM_";
+
+    public static String FROM_NAME = DEVICE_TYPE+MINE_NAME+"From";
+
+    public static String FROM_REF_NAME = DEVICE_TYPE+MINE_NAME+"From";
+
+    public static String VO_NAME = DEVICE_TYPE+MINE_NAME+"Vo";
+
+    public static String FACILITY_NAME = DEVICE_TYPE+MINE_NAME+"Facility";
+
+    public static String FACILITY_REF_NAME = FACILITY_NAME.substring(0, 1).toLowerCase() + FACILITY_NAME.substring(1);
+
+
+    public static FormulaEvaluator FE;
+
+    public static void main(String[] args)  {
+
+        // 指定输出文件的路径
+        String filePath = "generate/"+MINE_NAME+DEVICE_TYPE+".txt";
+
+        LocalDate currentDate = LocalDate.now();
+
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+        String nowDate = currentDate.format(formatter);
+
+
+        try {
+
+            PrintStream out = new PrintStream(Files.newOutputStream(Paths.get(filePath)));
+
+            // 将System.out设置为新的PrintStream实例
+            System.setOut(out);
+
+            FileInputStream fis = new FileInputStream(EXCEL_FILE_PATH);
+            Workbook workbook = new XSSFWorkbook(fis);
+
+            FE = new XSSFFormulaEvaluator((XSSFWorkbook)workbook);
+
+            Sheet sheet = workbook.getSheetAt(0);
+
+            List<String> columnNameList = new ArrayList<>();
+            List<String> typeList = new ArrayList<>();
+            List<String> chineseExplanationList = new ArrayList<>();
+            List<String> accessModeList = new ArrayList<>();
+            List<String> pointsList = new ArrayList<>();
+
+            for (Row row : sheet) {
+                if (row.getRowNum() == 0) continue; // 跳过标题行
+
+                Cell columnNameCell = row.getCell(0);
+                Cell typeCell = row.getCell(1);
+                Cell chineseExplanationCell = row.getCell(2);
+                Cell accessModeCell = row.getCell(3);
+                Cell pointsCell = row.getCell(4);
+
+
+                columnNameList.add(getCellValueAsString(columnNameCell));
+                typeList.add(getCellValueAsString(typeCell));
+                chineseExplanationList.add(getCellValueAsString(chineseExplanationCell));
+                accessModeList.add(getCellValueAsString(accessModeCell));
+                pointsList.add(getCellValueAsString(pointsCell));
+            }
+
+            String[] colArray = columnNameList.toArray(new String[0]);
+            String[] typeArray = typeList.toArray(new String[0]);
+            String[] notesArray = chineseExplanationList.toArray(new String[0]);
+            String[] accessModes = accessModeList.toArray(new String[0]);
+            String[] pointsArray = pointsList.toArray(new String[0]);
+            System.out.println("监测实体类====================================================================");
+            creatVoEntity(colArray,typeArray,notesArray,accessModes,nowDate);
+            System.out.println("控制实体类====================================================================");
+            creatFromEntity(colArray,typeArray,notesArray,accessModes,nowDate);
+            System.out.println("控制属性======================================================================");
+            createFormAtt(nowDate);
+            System.out.println("枚举=========================================================================");
+            creatEnum(colArray,notesArray,pointsArray,accessModes,nowDate);
+            System.out.println("业务实现类=====================================================================");
+            creatFacility(colArray,typeArray,notesArray,accessModes,false,"1","1",nowDate);
+            System.out.println("控制方法实现====================================================================");
+            createServiceControl(colArray,notesArray,accessModes,nowDate);
+            System.out.println();
+            System.out.println("监测方法片段====================================================================");
+            createServiceMonitor(nowDate);
+            System.out.println("监测数据文档====================================================================");
+            createMonitorDoc(colArray,notesArray,accessModes,pointsArray);
+            System.out.println("控制请求文档====================================================================");
+            createControlDoc(colArray,notesArray,accessModes,typeArray);
+
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+
+
+    }
+
+
+    private static String getCellValueAsString(Cell cell) {
+        if (cell == null) return "";
+
+        switch (cell.getCellType()) {
+            case STRING:
+                return cell.getStringCellValue().trim();
+            case NUMERIC:
+                return String.valueOf(cell.getNumericCellValue());
+            case BOOLEAN:
+                return String.valueOf(cell.getBooleanCellValue());
+            case FORMULA:
+                CellValue value = FE.evaluate(cell);
+                return value.getStringValue().trim();
+            case BLANK:
+                return "";
+            default:
+                return "";
+        }
+    }
+
+    public static void createServiceControl(String[] colArray,String[] notesArray,String[] accessModes,String nowDate){
+        System.out.println("放在 com.ventanaly.device.service.impl.ControlServiceImpl 下");
+        System.out.println("    @Resource\n" +
+                "    "+FACILITY_NAME+" "+FACILITY_REF_NAME+";");
+        System.out.println("....");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println(
+                "                case "+DEVICE_TYPE+MINE_NAME+"Facility.TYPE:\n" +
+                "                    r = control"+DEVICE_TYPE+MINE_NAME+"(from, json,fs.get(0), ulPage);\n" +
+                "                    break;");
+        System.out.println("....");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("    public boolean control"+DEVICE_TYPE+MINE_NAME+"("+DEVICE_TYPE+"From from, Json json, "+DEVICE_TYPE+"Page fm, UserLogPage ulPage) {\n");
+        System.out.println("        boolean r = false;\n" +
+                "        ulPage.setDeviceType(4);\n" +
+                "        DeviceRelationPage dr = SubStationStatic.DRMap.get(from.getId());\n" +
+                "        if (null == dr) {\n" +
+                "            throw new ServiceException(\"不存在的分站\");\n" +
+                "        }\n" +
+                "        SubStationPage page = dr.getSubStationPage();\n" +
+                "        try {\n" +
+                "            RelationVo g = (RelationVo) dr.getObjVo();\n" +
+                "            from.setStrInstallPos(g.getStrInstallPos());\n" +
+                "        } catch (Exception e) {\n" +
+                "            e.printStackTrace();\n" +
+                "        }\n" +
+                "        Map<String, String> tableMeta = SubStationStatic.tableMetas.get(dr.getPLC_table());\n" +
+                "        json.setMsg(\"无任何操作\");\n" +
+                "        if (dr.getDevice_id() != fm.getN"+DEVICE_TYPE+"ID()) {\n" +
+                "            throw new ServiceException(\"输入密码不正确\");\n" +
+                "        }\n" +
+                "        SensorNet net = page.getSensorNet();");
+        System.out.println("        if (!dr.getIsFake()) {\n" +
+                "            if (!net.getState()) {\n" +
+                "                json.setMsg(\"无任何操作\");\n" +
+                "                throw new ServiceException(\"无法与设备建立链接\");\n" +
+                "            }\n");
+
+        for(int i = 0;i<colArray.length;i++){
+            if ("只读".equals(accessModes[i])){continue;}
+            Character c = colArray[i].charAt(0);
+            String newCol = c.toUpperCase(c) + colArray[i].substring(1,colArray[i].length());
+            System.out.println("            if (null != from.get"+FROM_NAME+"().get"+newCol+"()) {");
+            System.out.println("               logger.info(\""+notesArray[i]+"--->\" + from.get"+FROM_NAME+"().get"+newCol+"());");
+            System.out.println("               json.setMsg(\""+notesArray[i]+"\");");
+            System.out.println("               ulPage.setRecord(\""+notesArray[i]+":\" + from.get"+FROM_NAME+"().get"+newCol+"());");
+            System.out.println("               r = "+FACILITY_REF_NAME+"."+colArray[i]+"(from, net, tableMeta, null);");
+            System.out.println("            }");
+            System.out.println();
+        }
+        System.out.println("        }");
+        System.out.println("        return r;\n" +
+                "    }");
+
+    }
+
+
+    public static void createServiceMonitor(String nowDate){
+
+        System.out.println("放在 com.ventanaly.device.facility.Monitoring 下");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("    @Resource\n" +
+                "    "+FACILITY_NAME+" "+ FACILITY_REF_NAME+";");
+        System.out.println("......");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("            case "+DEVICE_TYPE+MINE_NAME+"Facility.TYPE:\n" +
+                "                vo = "+FACILITY_REF_NAME+".status(dr,tableMeta,page);\n" +
+                "                break;");
+    }
+
+    public static  void createFormAtt(String nowDate){
+        System.out.println("放在 com.ventanaly.tool.froms."+DEVICE_TYPE+"From 下");
+        System.out.println("    @JsonProperty(value = "+"\""+FROM_REF_NAME+"\""+")"+"\n" +
+                "    private "+FROM_NAME+" "+FROM_REF_NAME+";\n");
+    }
+
+    public static void creatFacility(String[] colArray,String[] typeArray,String[] notesArray,String[] accessModes,boolean flag,String cy,String num,String nowDate){
+        System.out.println("放在 com.ventanaly.device.facility."+DEVICE_TYPE_REF);
+        System.out.println("import com.ventanaly.tool.enums.PLCDevice2Enum;\n" +
+                "import com.ventanaly.tool.froms.FanMainFrom;\n" +
+                "import com.ventanaly.tool.page."+DEVICE_TYPE+"Page;\n" +
+                "import com.ventanaly.tool.utils.Constants;\n" +
+                "import com.ventanaly.tool.page.DeviceRelationPage;\n" +
+                "import com.ventanaly.tool.page.SubStationPage;\n" +
+                "import com.ventanaly.tool.utils.SensorNet;\n" +
+                "import org.slf4j.Logger;\n" +
+                "import org.slf4j.LoggerFactory;\n" +
+                "import org.springframework.stereotype.Component;\n" +
+                "import java.util.Map;");
+
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("@Component");
+        System.out.println("public class "+FACILITY_NAME+" {");
+        System.out.println("\n" +
+                "    private final Logger logger = LoggerFactory.getLogger(getClass());");
+        System.out.println("    public static final String TYPE = \""+DEVICE_TYPE.toLowerCase()+"_"+MINE_NAME.toLowerCase()+"\";");
+        System.out.println("    public static final String TYPE_NAME = "+"\""+DEVICE_NAME+"\""+";\n" +
+                "    private static boolean control = true;\n" +
+                "\n");
+        System.out.println("    public "+VO_NAME+" status"+ "(DeviceRelationPage dr, Map<String, String> tableMeta, "+DEVICE_TYPE+"Page page) {\n");
+        System.out.println("        "+VO_NAME+" vo = new "+ VO_NAME+"();");
+        System.out.println("        vo.setDeviceType(Constants.DEVICE_TYPE_"+DEVICE_TYPE.toUpperCase()+");");
+        System.out.println("        vo.setSmallType(TYPE);");
+        System.out.println("        vo.setDeviceId(dr.getDevice_id());");
+        System.out.println("        vo.setId(dr.getId());");
+        System.out.println("        SubStationPage sp = dr.getSubStationPage();");
+        System.out.println("        if (null == sp) {");
+        System.out.println("            return vo;");
+        System.out.println("        }");
+        System.out.println("        SensorNet net = sp.getSensorNet();");
+        System.out.println("        vo.setNetStatus(net.isLinkState() ? 1 : 0);");
+        System.out.println("        if (1 == vo.getNetStatus()) {");
+        System.out.println("            String address;");
+        System.out.println("            String tName;");
+        System.out.println("            vo.setUrl(net.getIp());");
+        for(int i = 0;i<colArray.length;i++){
+            if ("只写".equals(accessModes[i])){continue;}
+
+            System.out.println("            tName = PLCDevice2Enum."+ENUM_NAME+"."+ENUM_PREFIX + colArray[i].toUpperCase() + ".getName();");
+            System.out.println("            address = tableMeta.get(tName);");
+            if("Boolean".equals(typeArray[i])){
+                System.out.println("            "+typeArray[i] + " " + colArray[i] + " = net.getSensorBoolean(address);");
+            }else{
+                System.out.println("            "+typeArray[i] + " " + colArray[i] + " = net.getSensor" + typeArray[i] + "(address);");
+            }
+            if(flag && !"Boolean".equals(typeArray[i])){
+                System.out.println("            "+"BigDecimal"+" "+ colArray[i] + "Val = StringUtils.roundHalfUp("+colArray[i]+"*"+cy+","+num+");");
+            }
+
+            System.out.println("            "+"logger.debug(\"" + notesArray[i] + "-ID:{}-点位名称:{},address:{},Val:{}\", dr.getId(), tName, address, " + colArray[i] + ");");
+            Character c = colArray[i].charAt(0);
+            String newCol = c.toUpperCase(c) + colArray[i].substring(1,colArray[i].length());
+            if(flag && !"Boolean".equals(typeArray[i])){
+                System.out.println("            "+"vo.set" + newCol + "(" + colArray[i] + "Val.floatValue());");
+            }else{
+                System.out.println("            "+"vo.set" + newCol + "(" + colArray[i] + ");");
+            }
+
+            System.out.println();
+        }
+        System.out.println("        }");
+        System.out.println("        dr.setObjVo(vo);\n" +
+                "        return vo;");
+        System.out.println("    }");
+        creatControl(colArray,typeArray,notesArray,accessModes);
+        System.out.println("  }");
+        System.out.println("}");
+    }
+
+    /**
+     *生成实体类
+     * @param colArray 字段
+     * @param typeArray 字段类型
+     * @param notesArray 字段解释
+     */
+    public static void creatEntity(String[] colArray,String[] typeArray,String[] notesArray){
+        //都用逗号隔开
+        for(int i = 0;i<colArray.length;i++){
+            System.out.println("@JsonProperty(value = " + "\"" + colArray[i] + "\"" + ")");
+            System.out.println("private " + typeArray[i] + " " + colArray[i] + ";  //" + notesArray[i]);
+        }
+    }
+
+    //生成监测实体类
+    public static void creatVoEntity(String[] colArray,String[] typeArray,String[] notesArray,String[] accessModes,String nowDate){
+        System.out.println("放在 com.ventanaly.tool.model下");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("@Data");
+        System.out.println("public class "+VO_NAME+" extends RelationVo {");
+        for(int i = 0;i<colArray.length;i++){
+            if ("只写".equals(accessModes[i])){continue;}
+            System.out.println("    @JsonProperty(value = " + "\"" + colArray[i] + "\"" + ")");
+            System.out.println("    private " + typeArray[i] + " " + colArray[i] + ";  //" + notesArray[i]);
+        }
+        System.out.println("}");
+    }
+
+    //生成控制请求类
+    public static void creatFromEntity(String[] colArray,String[] typeArray,String[] notesArray,String[] accessModes,String nowDate){
+        System.out.println("放在 com.ventanaly.tool.froms 下");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("@Data");
+        System.out.println("public class "+FROM_NAME+"{");
+        for(int i = 0;i<colArray.length;i++){
+            if ("只读".equals(accessModes[i])){continue;}
+            System.out.println("    @JsonProperty(value = " + "\"" + colArray[i] + "\"" + ")");
+            System.out.println("    private " + typeArray[i] + " " + colArray[i] + ";  //" + notesArray[i]);
+        }
+        System.out.println("}");
+    }
+
+    /**
+     * 生成Enum
+     * @param colArray 字段
+     * @param notesArray 字段解释
+     */
+    public static void creatEnum(String[] colArray,String[] notesArray,String[] pointsArray,String[] accessModes,String nowDate){
+        String befStr = ENUM_PREFIX;
+        System.out.println("放在 com.ventanaly.tool.enums.PLCDevice2Enum 下");
+        System.out.println("    //"+DEVICE_NAME+"  "+nowDate);
+        System.out.println("    public enum "+DEVICE_TYPE+MINE_NAME+"Enum {");
+        for(int i = 0;i<colArray.length;i++){
+                if (i!=colArray.length-1){
+
+                    System.out.println("        "+befStr + colArray[i].toUpperCase() + "(" + "\"" + colArray[i] + "\", \"" + notesArray[i] + "\", \"" +pointsArray[i]+ "\"" +"),");
+
+                }else {
+                    System.out.println("        "+befStr + colArray[i].toUpperCase() + "(" + "\"" + colArray[i] + "\", \"" + notesArray[i] + "\", \"" +pointsArray[i]+ "\"" +");");
+
+                }
+        }
+        System.out.println("\n" +
+                "        private String name; //状态位/控制位\n" +
+                "        private String message; //指令描述\n" +
+                "        private String point;");
+        System.out.println("        "+DEVICE_TYPE+MINE_NAME+"Enum(String name, String message,String point) {\n" +
+                "            this.name = name;\n" +
+                "            this.message = message;\n" +
+                "            this.point = point;\n" +
+                "        }\n");
+        System.out.println("        public String getName() {\n" +
+                "            return name;\n" +
+                "        }\n" +
+                "\n" +
+                "        public String getMessage() {\n" +
+                "            return message;\n" +
+                "        }\n" +
+                "\n" +
+                "        public String getPoint(){return point;}\n" +
+                "    }");
+
+    }
+
+    /**
+     * 生成Enum
+     * @param colArray 字段
+     * @param lcsxArray 量程上限字段
+     * @param lcxxArray 量程下限字段
+     * @param bjsxArray 报警上限
+     * @param bjxxArray 报警下限
+     */
+    public static void creatFtpEnum(String[] colArray,String[] lcsxArray,String[] lcxxArray,String[] bjsxArray,String[] bjxxArray,String[] notesArray){
+        String befStr = "FAN_MAIN_TLH_ENUM_";
+        for(int i = 0;i<colArray.length;i++){
+            int id = i + 1;
+            String val ="" + id + "," + lcsxArray[i] + "," + lcxxArray[i] + "," + bjsxArray[i] + "," + bjxxArray[i];
+            System.out.print(befStr + colArray[i].toUpperCase() + "(" + "\"" + colArray[i] + "\", \"" + val + "\"" + "),");
+            System.out.println("//" + notesArray[i]);
+        }
+    }
+
+    /**
+     * 生成点表json字符串
+     * @param colArray 字段
+     * @param dbArray 点位地址/id
+     */
+    public static void creatDBJSON(String[] colArray , String[] dbArray){
+//        System.out.println("放在 showdoc ");
+        StringBuffer str = new StringBuffer();
+        str.append("{");
+        for(int i = 0;i<colArray.length;i++)
+        {
+            str.append("\"");
+            //拼接请求json数据格式["",""]
+            str.append(colArray[i]);
+            str.append("\"");
+            str.append(":");
+            str.append("\"");
+            str.append(dbArray[i]);
+            str.append("\"");
+            if(i==colArray.length-1) {
+                break;
+            }
+            str.append(",");
+        }
+        str.append("}");
+        System.out.println(str.toString());
+    }
+
+    /**
+     * 生成测试模拟数据代码
+     * @param colArray 字段
+     * @param typeArray 字段类型
+     */
+    public static void creatTestData(String[] colArray , String[] typeArray){
+        for(int i = 0;i<colArray.length;i++){
+            Character c = colArray[i].charAt(0);
+            String newCol = c.toUpperCase(c) + colArray[i].substring(1,colArray[i].length());
+            String val = "";
+            if("boolean".equals(typeArray[i]) || "Boolean".equals(typeArray[i])){
+                val = "(true";
+            }else{
+                val = "(setVal(10f, 5f)";
+            }
+            System.out.println("vo.set" + newCol + val + ");");
+        }
+    }
+
+    /**
+     *生成实体类
+     */
+    public static void creatEntity2(String col,String type,String note){
+        //都用逗号隔开
+        for(int i = 0;i<540;i++){
+            System.out.println("@JsonProperty(value = " + "\"" + col + i + "\"" + ")");
+            System.out.println("private " + type + " " + col + i + ";  //" + note);
+        }
+    }
+
+    /**
+     * 生成控制代码
+     * @param colArray
+     * @param typeArray
+     * @param notesArray
+     */
+    public static void creatControl(String[] colArray,String[] typeArray,String[] notesArray,String[] accessModes){
+        System.out.println("放在 com.ventanaly.device.facility."+DEVICE_TYPE_REF+"."+FACILITY_NAME);
+        for(int i = 0;i<colArray.length;i++){
+
+            if ("只读".equals(accessModes[i])){continue;}
+            System.out.println("    //"+notesArray[i]);
+            System.out.println("    public boolean " + colArray[i] + "("+DEVICE_TYPE+"From from, SensorNet net, Map<String, String> tableMeta, Long timeout) {");
+            System.out.println("        boolean result = false;");
+            System.out.println("        if (control) {");
+            System.out.println("            control = false;");
+            Character c = colArray[i].charAt(0);
+            String newCol = c.toUpperCase(c) + colArray[i].substring(1,colArray[i].length());
+            System.out.println("            String tName = PLCDevice2Enum."+ENUM_NAME+"."+ENUM_PREFIX + colArray[i].toUpperCase() + ".getName();");
+            System.out.println("            String address = tableMeta.get(tName);");
+            System.out.println("            try {");
+            if("Boolean".equals(typeArray[i]) || "boolean".equals(typeArray[i])){
+                System.out.println("                result = net.setSensor(address,Constants.PLC_BOOLEAN_TRUE);");
+                System.out.println("                logger.debug(\"设置-" + notesArray[i] + "-点位名称:{},address:{},Val:{}\"" + ", tName, address, Constants.PLC_BOOLEAN_TRUE);");
+                System.out.println("                Thread.sleep(1000);");
+            }else{
+                System.out.println("                result = net.setSensor(address,from.get"+FROM_NAME+"().get" + newCol + "());");
+                System.out.println("                logger.debug(\"设置-" + notesArray[i] + "-点位名称:{},address:{},Val:{}\"" + ", tName, address, from.get"+FROM_NAME+"().get"  + newCol + "());");
+            }
+            System.out.println("            } catch (Throwable e) {");
+            System.out.println("                e.printStackTrace();");
+            System.out.println("            } finally {");
+            System.out.println("                control = true;");
+//            if("Boolean".equals(typeArray[i]) || "boolean".equals(typeArray[i])){
+//                System.out.println("            result = net.setSensor(address,Constants.PLC_BOOLEAN_FALSE);");
+//                System.out.println("            logger.debug(\"回位-" + notesArray[i] + "-点位名称:{},address:{},Val:{}\"" + ", tName, address, Constants.PLC_BOOLEAN_FALSE);");
+//            }
+            System.out.println("            }");
+            System.out.println("        }");
+            System.out.println("        return result;");
+            System.out.println("    }");
+        }
+    }
+    //生成文档中点位表解释
+    public static void createInterpret(String[] colArray,String[] notesArray,String[] accessModes){
+        System.out.println("{");
+        for(int i = 0;i<colArray.length;i++){
+            if ("只写".equals(accessModes[i])){continue;}
+            if (i!=colArray.length-1){
+                System.out.println("\"" + colArray[i] + "\""+":"+"\""+notesArray[i]+"\""+",");
+            }else {
+                System.out.println("\"" + colArray[i] + "\""+":"+"\""+notesArray[i]+"\"");
+
+            }
+        }
+        System.out.println("}");
+    }
+    //生成 文档中控制命令的请求参数表单
+    public static void createReqFormDoc(String[] colArray,String[] notesArray,String[] typeArray,String[] accessModes){
+        System.out.println("|参数名|必选|类型|说明|");
+        System.out.println("|:----    |:---|:----- |-----   |");
+        for(int i = 0;i<colArray.length;i++){
+            if ("只读".equals(accessModes[i])){continue;}
+            System.out.println("|"+colArray[i]+"|否|"+typeArray[i]+"|"+notesArray[i]+"|");
+        }
+    }
+
+    public static void createControlDoc(String[] colArray,String[] notesArray,String[] accessModes,String[] typeArray){
+        System.out.println("\n" +
+                "[TOC]\n" +
+                "\n" +
+                "##### 简要描述\n" +
+                "\n" +
+                "- 主扇控制-设备控制\n" +
+                "\n" +
+                "##### 请求URL\n" +
+                "- ` /control/fanSystem `\n" +
+                "\n" +
+                "##### 请求方式\n" +
+                "- POST\n" +
+                "\n" +
+                "##### 请求示例\n" +
+                "```\n" +
+                "{\n" +
+                "  \"id\": 设备的id,\n" +
+                "  \"passWord\": \"e10adc3949ba59abbe56e057f20f883e\",");
+        System.out.println("  \""+FROM_REF_NAME+"\":{" );
+        for (int i = 0; i < typeArray.length; i++) {
+            if ("Boolean".equals(typeArray[i])){
+                System.out.println("    \""+colArray[i]+"\":true");
+                break;
+            }
+        }
+        System.out.println("  }\n" +
+                "}\n" +
+                "```");
+        System.out.println(
+                "\n" +
+                "##### 请求参数\n" +
+                "\n" +
+                "|参数名|必选|类型|说明|\n" +
+                "|:----    |:---|:----- |-----   |\n" +
+                "|id |是  |Integer |分站id   |\n" +
+                "|passWord|是|String|控制密码|");
+        System.out.println("|"+FROM_REF_NAME+"|否|Object|控制命令|");
+        System.out.println("##### "+FROM_NAME+" 请求参数");
+        System.out.println("|参数名|必选|类型|说明|");
+        System.out.println("|:----    |:---|:----- |-----   |");
+        for(int i = 0;i<colArray.length;i++){
+            if ("只读".equals(accessModes[i])){continue;}
+            System.out.println("|"+colArray[i]+"|否|"+typeArray[i]+"|"+notesArray[i]+"|");
+        }
+        System.out.println("\n" +
+                "\n" +
+                "##### 返回示例\n" +
+                "\n" +
+                "```\n" +
+                "{\n" +
+                "  \"success\": true,\n" +
+                "  \"obj\": null,\n" +
+                "  \"msg\": \"\"\n" +
+                "}\n" +
+                "```\n" +
+                "\n" +
+                "##### 返回参数说明\n" +
+                "\n" +
+                "|参数名|类型|说明|\n" +
+                "|:-----  |:-----|-----                           |\n" +
+                "|success|Boolean|请求状态|\n" +
+                "|obj|ArrayList|null|\n" +
+                "|msg |String|请求状态说明|\n");
+
+    }
+
+    public static void createMonitorDoc(String[] colArray,String[] notesArray,String[] accessModes,String[] pointsArray){
+        System.out.println("\n" +
+                "\n" +
+                "[TOC]\n" +
+                "    \n" +
+                "##### 简要描述\n" +
+                "\n" +
+                "- 通过设备id(支持多个设备id),获取对应设备的实时监测数据,后端每秒监测一次最新数据。\n" +
+                "\n" +
+                "##### 请求URL\n" +
+                "- ` http://127.0.0.1:8086/monitoring/devicestatus `\n" +
+                "  \n" +
+                "##### 请求方式\n" +
+                "- POST \n" +
+                "\n" +
+                "##### 参数\n" +
+                "\n" +
+                "|参数名|必传|类型|说明|\n" +
+                "|:----    |:---|:----- |-----   |\n" +
+                "|obj |是  |int |设备id     |\n" +
+                "\n" +
+                "##### 返回示例 \n" +
+                "\n" +
+                "``` \n" +
+                "  {\n" +
+                "    \"obj\": [402161831000]\n" +
+                "  }\n" +
+                "```\n" +
+                "\n" +
+                "\n" +
+                "##### 返回参数说明 \n" +
+                "\n" +
+                "|参数名|类型|说明|\n" +
+                "|:-----  |:-----|-----                           |\n" +
+                "|success |boolean   |是否成功  |\n" +
+                "|obj |json   |设备实时数据(参考:<a href=\"#点表点位解释\">点表点位解释</a>) |\n" +
+                "|msg |String   |返回结果描述  |\n" +
+                "\n" +
+                "##### 点位表解释\n" +
+                "```");
+        createInterpret(colArray, notesArray, accessModes);
+        System.out.println("\n" +
+                "\n" +
+                "```\n" +
+                "##### 点表\n" +
+                "```");
+        creatDBJSON(colArray,pointsArray);
+        System.out.println("\n" +
+                "\n" +
+                "```\n" +
+                "\n" +
+                "##### 备注 \n" +
+                "\n" +
+                "无\n" +
+                "\n");
+
+    }
+
+
+
+
+    //生成设备接入时控制文档
+//    public static void createControlDoc(){
+//        PLCDevice2Enum.FanMainSgtEnum[] values = PLCDevice2Enum.FanMainSgtEnum.values();
+//        FanMainSgtFacility fanMainSgtFacility = new FanMainSgtFacility();
+//        Class<? extends FanMainSgtFacility> aClass = fanMainSgtFacility.getClass();
+//        Method[] methods = aClass.getMethods();
+//
+//        FanMainSgt fanMainSgt = new FanMainSgt();
+//        Class<? extends FanMainSgt> aClass1 = fanMainSgt.getClass();
+//        Field[] fields = aClass1.getDeclaredFields();
+//
+//        for(Method method:methods){
+//            String name = method.getName();
+//            for(Field field:fields){
+//                if(name.equals(field.getName())){
+//                    String type = field.getType().getSimpleName();
+//                    for(PLCDevice2Enum.FanMainSgtEnum enn:values){
+//                        if(name.equals(enn.getName())){
+//                            String message = PLCDevice2Enum.FanMainSgtEnum.valueOf("FAN_MAIN_SGT_ENUM_"+enn.getName().toUpperCase()).getMessage();
+//                            System.out.println("参数名: "+name+"       类型: "+type+"       说明: "+message);
+//                        }
+//                    }
+//                }
+//            }
+//        }
+//    }
+
+}