Prechádzať zdrojové kódy

“新增生成文档功能”

kangyu 4 mesiacov pred
rodič
commit
c5c0f5e10e

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 19 - 1219
generate/Wl1k.txt


+ 168 - 15
src/main/java/com/ventanaly/FastPlcGenerate.java

@@ -1,6 +1,6 @@
-package com.ventanaly;//import com.ventanaly.device.facility.fanMain.FanMainSXFacility;
-//import com.ventanaly.device.facility.fanMain.FanMainSgtFacility;
+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.*;
@@ -18,13 +18,13 @@ public class FastPlcGenerate {
     public static String FAN_TYPE="Main";
 
     //矿井唯一表示,万里一矿--->Wl1k
-    public static String MINE_NAME="Wl1k";
+    public static String MINE_NAME="chs_2";
 
     //设备名称
-    public static String DEVICE_NAME="万里一矿主扇";
+    public static String DEVICE_NAME="察哈素新增立井主风机2号";
 
     // Excel文件路径
-    public static String EXCEL_FILE_PATH = "template/wl1k.xlsx";
+    public static String EXCEL_FILE_PATH = "template/察哈素二号主风机.xlsx";
 
 
     public static String ENUM_NAME = "Fan"+FAN_TYPE+MINE_NAME+"Enum";
@@ -33,13 +33,15 @@ public class FastPlcGenerate {
 
     public static String FROM_NAME = "Fan"+FAN_TYPE+MINE_NAME+"From";
 
+    public static String FROM_REF_NAME = "fan"+FAN_TYPE+MINE_NAME+"From";
+
     public static String VO_NAME = "Fan"+FAN_TYPE+MINE_NAME+"Vo";
 
     public static String FACILITY_NAME = "Fan"+FAN_TYPE+MINE_NAME+"Facility";
 
     public static String FACILITY_REF_NAME = "fan"+FAN_TYPE+MINE_NAME+"Facility";
 
-
+    public static FormulaEvaluator FE;
 
     public static void main(String[] args)  {
 
@@ -62,6 +64,9 @@ public class FastPlcGenerate {
 
             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<>();
@@ -96,6 +101,8 @@ public class FastPlcGenerate {
             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("业务实现类=====================================================================");
@@ -105,12 +112,10 @@ public class FastPlcGenerate {
             System.out.println();
             System.out.println("监测方法片段====================================================================");
             createServiceMonitor(nowDate);
-            System.out.println("点表配置json====================================================================");
-            creatDBJSON(colArray,pointsArray);
-            System.out.println("点位解释json====================================================================");
-            createInterpret(colArray,notesArray,accessModes);
-            System.out.println("控制请求表格====================================================================");
-            createReqFormDoc(colArray,notesArray,typeArray,accessModes);
+            System.out.println("监测数据文档====================================================================");
+            createMonitorDoc(colArray,notesArray,accessModes,pointsArray);
+            System.out.println("控制请求文档====================================================================");
+            createControlDoc(colArray,notesArray,accessModes,typeArray);
 
         }catch (Exception e){
             e.printStackTrace();
@@ -132,7 +137,8 @@ public class FastPlcGenerate {
             case BOOLEAN:
                 return String.valueOf(cell.getBooleanCellValue());
             case FORMULA:
-                return cell.getCellFormula();
+                CellValue value = FE.evaluate(cell);
+                return value.getStringValue().trim();
             case BLANK:
                 return "";
             default:
@@ -141,6 +147,10 @@ public class FastPlcGenerate {
     }
 
     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("    public boolean controlFan"+FAN_TYPE+MINE_NAME+"(Fan"+FAN_TYPE+"From from, Json json, FanMainPage fm, UserLogPage ulPage) {\n");
         System.out.println("        boolean r = false;\n" +
@@ -188,13 +198,26 @@ public class FastPlcGenerate {
 
 
     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 Fan"+FAN_TYPE+MINE_NAME+"Facility.TYPE:\n" +
                 "                vo = fan"+FAN_TYPE+MINE_NAME+"Facility.status(dr,tableMeta,page);\n" +
                 "                break;");
     }
 
+    public static  void createFormAtt(String nowDate){
+        System.out.println("放在 com.ventanaly.tool.froms.FanMainFrom 下");
+        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.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" +
@@ -216,7 +239,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+" fan"+ FAN_TYPE +MINE_NAME+"Status(DeviceRelationPage dr, Map<String, String> tableMeta, FanMainPage page) {\n");
+        System.out.println("    public "+VO_NAME+" status"+ "(DeviceRelationPage dr, Map<String, String> tableMeta, FanMainPage 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);");
@@ -262,6 +285,7 @@ public class FastPlcGenerate {
                 "        return vo;");
         System.out.println("    }");
         creatControl(colArray,typeArray,notesArray,accessModes);
+        System.out.println("  }");
         System.out.println("}");
     }
 
@@ -281,6 +305,7 @@ public class FastPlcGenerate {
 
     //生成监测实体类
     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 {");
@@ -294,6 +319,7 @@ public class FastPlcGenerate {
 
     //生成控制请求类
     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+"{");
@@ -312,6 +338,7 @@ public class FastPlcGenerate {
      */
     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 Fan"+FAN_TYPE+MINE_NAME+"Enum {");
         for(int i = 0;i<colArray.length;i++){
@@ -370,6 +397,7 @@ public class FastPlcGenerate {
      * @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++)
@@ -428,7 +456,7 @@ public class FastPlcGenerate {
      * @param notesArray
      */
     public static void creatControl(String[] colArray,String[] typeArray,String[] notesArray,String[] accessModes){
-
+        System.out.println("放在 com.ventanaly.device.facility.fan"+FAN_TYPE+"."+FACILITY_NAME);
         for(int i = 0;i<colArray.length;i++){
 
             if ("只读".equals(accessModes[i])){continue;}
@@ -488,6 +516,131 @@ public class FastPlcGenerate {
         }
     }
 
+    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("|"+FACILITY_REF_NAME+"|否|Object|控制命令|");
+        System.out.println("##### "+FACILITY_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");
+
+    }
+
 
 
 

BIN
template/bjhz.xlsx


BIN
template/wl1k_add.xlsx


BIN
template/东沟主扇.xlsx


BIN
template/察哈素一号主风机.xlsx


BIN
template/察哈素二号主风机.xlsx


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov