Browse Source

解决 Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test

wuxw 6 years ago
parent
commit
17d4aa9b99

+ 1 - 1
WebService/src/main/resources/components/roomPackage/add-room/addRoom.html

@@ -44,7 +44,7 @@
 
                             <div class="form-group row">
                                 <label class="col-sm-2 col-form-label">房屋单价</label>
-                                <div class="col-sm-10"><input v-model="addRoomInfo.unitPrice" type="number" placeholder="必填,请填写房屋平米单价" class="form-control"></div>
+                                <div class="col-sm-10"><input v-model="addRoomInfo.unitPrice" type="number" placeholder="必填,请填写房屋平米单价" class="form-control"></div>
                             </div>
 
                             <div class="form-group row">

+ 6 - 0
WebService/src/main/resources/components/servicePackage/service-binding/serviceBinding.js

@@ -52,6 +52,12 @@
             },
             _finishStep:function(){
 
+                var _currentData = vc.component.serviceBindingInfo.infos[vc.component.serviceBindingInfo.index];
+                if( _currentData == null || _currentData == undefined){
+                    vc.message("请选择相关信息");
+                    return ;
+                }
+
                 var param = {
                     data:vc.component.serviceBindingInfo.infos
                 }

+ 168 - 12
java110-code-generator/src/main/java/com/java110/code/relationship/GeneratorBindingComponent.java

@@ -17,11 +17,143 @@ public class GeneratorBindingComponent extends BaseGenerator {
         generatorComponentJava(data);
         genneratorIListSmo(data);
         genneratorListSmoImpl(data);
+
+
         //genneratorListListener(data);
 
         //genneratorServiceCodeConstant(data);
 
 
+    }
+
+    private void genneratorAddHtml(JSONObject data, String componentName){
+        StringBuffer sb = readFile(GeneratorStart.class.getResource("/relationship/add/add.html").getFile());
+        String fileContext = sb.toString();
+
+        fileContext = super.replaceBindingTemplateContext(fileContext, data);
+
+        // 处理 th 信息
+
+        StringBuffer thSb = new StringBuffer();
+
+        JSONObject _currentObj = data.getJSONObject("components").getJSONObject(componentName);
+
+        JSONArray columns = _currentObj.getJSONArray("columns");
+        for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) {
+            JSONObject column = columns.getJSONObject(columnIndex);
+            if ("none".equals(column.getString("inputType"))) {
+                continue;
+            }
+            String required = column.getBoolean("required") ? "必填" : "选填";
+            String inputStr = "";
+            if ("select".equals(column.getString("inputType"))) {
+
+                String[] selectValues = column.getString("selectValue").split(",");
+                String[] selectValueNames = column.getString("selectValueName").split(",");
+
+
+                String option = "";
+                for (int valueIndex = 0; valueIndex < selectValues.length; valueIndex++) {
+
+                    String value = selectValues[valueIndex];
+
+                    option += "<option  value=\"" + value + "\">" + selectValueNames[valueIndex] + "</option>\n";
+
+                }
+
+                inputStr = "<select class=\"custom-select\" v-model=\"" + _currentObj.getString("templateCode") + "ViewInfo."+column.getString("code")+"\">\n" +
+                        "         <option selected  disabled value=\"\">"+ required + ",请选择" + column.getString("cnCode") + "</option>\n" +
+                        "         " +option+
+                        "  </select>";
+            } else if("textarea".equals(column.getString("inputType"))){
+                inputStr = "<textarea  placeholder=\"" + required + ",请填写" + column.getString("cnCode") + "\" class=\"form-control\""+
+                        " v-model=\"" + _currentObj.getString("templateCode") + "ViewInfo."+column.getString("code")+"\">"+
+                        "</textarea>";
+            }else {
+                inputStr = "           <input v-model=\"" + _currentObj.getString("templateCode") + "ViewInfo."+column.getString("code")+"\" " +
+                        "                  type=\"text\" placeholder=\"" + required + ",请填写" + column.getString("cnCode") + "\" class=\"form-control\">\n";
+            }
+            thSb.append("<div class=\"form-group row\">\n" +
+                    "         <label class=\"col-sm-2 col-form-label\">" + column.getString("cnCode") + "</label>\n" +
+                    "         <div class=\"col-sm-10\">\n" +
+                    inputStr+
+                    "         </div>\n" +
+                    "</div>\n");
+
+        }
+
+        fileContext = fileContext.replace("@@addTemplateColumns@@", thSb.toString());
+
+
+        String writePath = this.getClass().getResource("/").getPath()
+                + "out/relationship/component/"+_currentObj.getString("package")+"/" + _currentObj.getString("templateCode") + "View/" + toUpperCaseFirstOne(_currentObj.getString("templateCode")) + "View.html";
+        System.out.printf("writePath: " + writePath);
+        writeFile(writePath,
+                fileContext);
+    }
+
+    /**
+     * 生成 html js java 类
+     *
+     * @param data
+     */
+    private void generatorAddJs(JSONObject data, String componentName) {
+
+        StringBuffer sb = readFile(GeneratorStart.class.getResource("/relationship/add/add.js").getFile());
+        String fileContext = sb.toString();
+
+        fileContext = super.replaceBindingTemplateContext(fileContext, data);
+
+
+        JSONObject _currentObj = data.getJSONObject("components").getJSONObject(componentName);
+        fileContext = fileContext.replace("@@columnTemplateCode@@", _currentObj.getString("templateCode"));
+        fileContext = fileContext.replace("@@ColumnTemplateCode@@", toUpperCaseFirstOne(_currentObj.getString("templateCode")));
+
+        //替换 变量@@templateCodeColumns@@
+        JSONArray columns = _currentObj.getJSONArray("columns");
+
+        StringBuffer variable = new StringBuffer();
+        String defaultValue = "";
+
+        String validateInfo = "";
+        for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) {
+            JSONObject column = columns.getJSONObject(columnIndex);
+            defaultValue = column.getBoolean("hasDefaultValue") ? column.getString("defaultValue") : "";
+            defaultValue = "'" + defaultValue + "'";
+            variable.append(column.getString("code") + ":" + defaultValue + ",\n");
+
+            validateInfo += "'"+_currentObj.getString("templateCode")+"ViewInfo."+column.getString("code")+"':[\n" ;
+            if(column.getBoolean("required")) {
+                validateInfo +="{\n" +
+                        "                            limit:\"required\",\n" +
+                        "                            param:\"\",\n" +
+                        "                            errInfo:\""+column.getString("cnCode")+"不能为空\"\n" +
+                        "                        },\n";
+            }
+
+            if(column.containsKey("limit") && !StringUtils.isEmpty(column.getString("limit"))) {
+                validateInfo +=" {\n" +
+                        "                            limit:\""+column.getString("limit")+"\",\n" +
+                        "                            param:\""+column.getString("limitParam")+"\",\n" +
+                        "                            errInfo:\""+column.getString("limitErrInfo")+"\"\n" +
+                        "                        },\n" +
+                        "                    ],\n";
+            }
+
+        }
+        fileContext =  fileContext.replace("@@templateCodeColumns@@", variable.toString());
+        fileContext = fileContext.replace("@@addTemplateCodeValidate@@", validateInfo);
+
+        // 替换 数据校验部分代码
+
+
+        String writePath = this.getClass().getResource("/").getPath()
+                + "out/relationship/component/"+_currentObj.getString("package")+"/" + _currentObj.getString("templateCode") + "View/" + toUpperCaseFirstOne(_currentObj.getString("templateCode")) + "View.js";
+        System.out.printf("writePath: " + writePath);
+        writeFile(writePath,
+                fileContext);
+
+
     }
 
     /**
@@ -69,7 +201,10 @@ public class GeneratorBindingComponent extends BaseGenerator {
                     "                   callBackFunction=\"notify\"\n" +
                     "        ></vc:create>\n" +
                     "    </div>\n");
-
+            //如果相应组件不存在,则根据组件配置自动生成
+            if(!flow.getBoolean("existsComponent")){
+                genneratorAddHtml(data, flow.getString("vcName"));
+            }
         }
 
         int stepLastIndex = data.getBoolean("needAffirm") ? flows.size() : flows.size() - 1;
@@ -117,6 +252,11 @@ public class GeneratorBindingComponent extends BaseGenerator {
 
             validateInfo.append("vc.emit('" + flow.getString("vcName") + "', 'onIndex', vc.component.serviceBindingInfo.index);\n");
 
+            //如果相应组件不存在,则根据组件配置自动生成
+            if(!flow.getBoolean("existsComponent")){
+                generatorAddJs(data, flow.getString("vcName"));
+            }
+
         }
         String showAffirmPage = data.getBoolean("needAffirm") ? "确认信息" : "";
         allStep.append(showAffirmPage);
@@ -187,17 +327,33 @@ public class GeneratorBindingComponent extends BaseGenerator {
 
         fileContext = super.replaceBindingTemplateContext(fileContext, data);
 
-//        //替换校验部分代码 @@validateTemplateColumns@@
-//        JSONArray columns = data.getJSONArray("columns");
-//        StringBuffer validateStr = new StringBuffer();
-//        for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) {
-//            JSONObject column = columns.getJSONObject(columnIndex);
-//            if (column.getBoolean("required")) {
-//                validateStr.append("Assert.hasKeyAndValue(paramIn, \"" + column.getString("code") + "\", \"" + column.getString("desc") + "\");\n");
-//            }
-//        }
-//
-//        fileContext = fileContext.replace("@@validateTemplateColumns@@", validateStr.toString());
+        //替换校验部分代码 @@validateTemplateColumns@@
+
+        JSONArray flows = data.getJSONArray("flows");
+        StringBuffer validateStr = new StringBuffer();
+        for(int flowIndex = 0 ; flowIndex < flows.size() ; flowIndex ++) {
+
+            JSONObject flowObj = flows.getJSONObject(flowIndex);
+
+            if(flowObj.containsKey("existsComponent") && flowObj.getBoolean("existsComponent")){
+                continue;
+            }
+
+            String vcName = flowObj.getString("vcName");
+
+            JSONObject vcObject = data.getJSONObject("components").getJSONObject(vcName);
+
+            JSONArray columns = vcObject.getJSONArray("columns");
+
+            for (int columnIndex = 0; columnIndex < columns.size(); columnIndex++) {
+                JSONObject column = columns.getJSONObject(columnIndex);
+                if (column.getBoolean("required")) {
+                    validateStr.append("Assert.hasKeyByFlowData(infos, \""+ flowObj.getString("vcName") +"\", \"" + column.getString("code") + "\", \"" + column.getString("desc") + "\");\n");
+                }
+            }
+        }
+
+        fileContext = fileContext.replace("@@validateTemplateColumns@@", validateStr.toString());
 
 
         String writePath = this.getClass().getResource("/").getPath()

+ 1 - 1
java110-code-generator/src/main/resources/relationship/add/add.html

@@ -2,7 +2,7 @@
     <div class="col-lg-12">
         <div class="ibox">
             <div class="ibox-title">
-                <h5>添加@@templateName@@</h5>
+                <h5>@@templateName@@</h5>
                 <div class="ibox-tools" style="top:10px;">
 
                 </div>

+ 18 - 13
java110-code-generator/src/main/resources/relationship/add/add.js

@@ -6,37 +6,42 @@
            callBackFunction:vc.propTypes.string //父组件监听方法
         },
         data:{
-            @@templateCode@@ViewInfo:{
+            @@columnTemplateCode@@ViewInfo:{
+                flowComponent:'@@columnTemplateCode@@',
                 @@templateCodeColumns@@
             }
+        },
+        watch:{
+            @@columnTemplateCode@@ViewInfo:{
+                deep: true,
+                handler:function(){
+                    vc.component.save@@ColumnTemplateCode@@Info();
+                }
+             }
         },
          _initMethod:function(){
 
          },
          _initEvent:function(){
 
-            vc.on('@@templateCode@@ViewInfo', 'onIndex', function(_index){
-                vc.component.@@templateCode@@ViewInfo.index = _index;
+            vc.on('@@columnTemplateCode@@ViewInfo', 'onIndex', function(_index){
+                vc.component.@@columnTemplateCode@@ViewInfo.index = _index;
             });
         },
         methods:{
-            add@@TemplateCode@@Validate(){
+            @@columnTemplateCode@@Validate(){
                 return vc.validate.validate({
-                    @@templateCode@@ViewInfo:vc.component.@@templateCode@@ViewInfo
+                    @@columnTemplateCode@@ViewInfo:vc.component.@@columnTemplateCode@@ViewInfo
                 },{
                     @@addTemplateCodeValidate@@
                 });
             },
-            save@@TemplateCode@@Info:function(){
-                if(!vc.component.@@templateCode@@Validate()){
-                    vc.message(vc.validate.errInfo);
-
+            save@@ColumnTemplateCode@@Info:function(){
+                if(vc.component.@@columnTemplateCode@@Validate()){
+                    //侦听回传
+                    vc.emit($props.callBackListener,$props.callBackFunction, vc.component.@@columnTemplateCode@@ViewInfo);
                     return ;
                 }
-
-                vc.component.@@templateCode@@ViewInfo.communityId = vc.getCurrentCommunity().communityId;
-
-                //侦听回传
             }
         }
     });

+ 48 - 13
java110-code-generator/src/main/resources/relationship/binding/SaveListener.java

@@ -23,8 +23,8 @@ import com.java110.core.annotation.Java110Listener;
  * 保存小区侦听
  * add by wuxw 2019-06-30
  */
-@Java110Listener("save@@TemplateCode@@Listener")
-public class Save@@TemplateCode@@Listener extends AbstractServiceApiListener {
+@Java110Listener("binding@@TemplateCode@@Listener")
+public class Binding@@TemplateCode@@Listener extends AbstractServiceApiListener {
     @Override
     protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
         //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
@@ -41,8 +41,17 @@ public class Save@@TemplateCode@@Listener extends AbstractServiceApiListener {
 
         AppService service = event.getAppService();
 
-        //添加单元信息
-        businesses.add(add@@TemplateCode@@(reqJson, context));
+
+        JSONArray infos = reqJson.getJSONArray("data");
+
+        JSONObject appInfo = getObj(infos, "APP"); //应用信息
+        JSONObject serviceInfo = getObj(infos, "SERVICE"); // 服务信息
+
+        //处理 应用信息
+        if(!hasKey(appInfo, "appId")){
+             appInfo.put("appId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_appId));
+             businesses.add(addViewUnitInfo(reqJson, context));
+        }
 
         JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders());
 
@@ -56,7 +65,7 @@ public class Save@@TemplateCode@@Listener extends AbstractServiceApiListener {
 
     @Override
     public String getServiceCode() {
-        return ServiceCode@@TemplateCode@@Constant.ADD_@@TEMPLATECODE@@;
+        return ServiceCode@@TemplateCode@@Constant.@@TEMPLATECODE@@;
     }
 
     @Override
@@ -70,6 +79,8 @@ public class Save@@TemplateCode@@Listener extends AbstractServiceApiListener {
     }
 
 
+    @@bindingMethod@@
+
     /**
      * 添加小区信息
      *
@@ -77,19 +88,43 @@ public class Save@@TemplateCode@@Listener extends AbstractServiceApiListener {
      * @param dataFlowContext 数据上下文
      * @return 订单服务能够接受的报文
      */
-    private JSONObject add@@TemplateCode@@(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-
-
+    private JSONObject addViewUnitInfo(JSONObject paramInJson, DataFlowContext dataFlowContext) {
         JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_@@TEMPLATECODE@@);
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_BIND_@@TEMPLATECODE@@);
         business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
         business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject business@@TemplateCode@@ = new JSONObject();
-        business@@TemplateCode@@.putAll(paramInJson);
-        business@@TemplateCode@@.put("@@templateKey@@", "-1");
+        JSONObject businessObj = new JSONObject();
+        businessObj.putAll(paramInJson);
         //计算 应收金额
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("business@@TemplateCode@@", business@@TemplateCode@@);
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessRoom", businessObj);
         return business;
     }
 
+
+    private boolean hasKey(JSONObject info, String key){
+        if(!info.containsKey(key)
+            || StringUtils.isEmpty(info.getString(key))
+            || info.getString(key).startsWith("-")){
+            return false;
+        }
+        return true;
+
+    }
+
+    private JSONObject getObj(JSONArray infos , String flowComponent){
+
+        for(int infoIndex = 0 ; infoIndex < infos.size(); infoIndex ++){
+
+            Assert.hasKeyAndValue(infos.getJSONObject(infoIndex), "flowComponent", "未包含服务流程组件名称");
+
+            if(flowComponent.equals(infos.getJSONObject(infoIndex).getString("flowComponent"))){
+                Assert.notNull(serviceInfo, "未包含服务信息");
+                return infos.getJSONObject(infoIndex);
+            }
+         }
+
+        throw new IllegalArgumentException("未找到组件编码为【" + flowComponent + "】数据");
+     }
+
+
 }

+ 1 - 1
java110-code-generator/src/main/resources/relationship/binding/BindingSMOImpl.java

@@ -27,7 +27,7 @@ public class @@TemplateCode@@BindingSMOImpl extends AbstractComponentSMO impleme
     protected void validate(IPageData pd, JSONObject paramIn) {
 
         //super.validatePageInfo(pd);
-
+        JSONArray infos = paramIn.getJSONObject("infos")
         //Assert.hasKeyAndValue(paramIn, "xxx", "xxx");
         @@validateTemplateColumns@@
 

+ 8 - 1
java110-code-generator/src/main/resources/relationship/binding/binding.js

@@ -38,7 +38,7 @@
             _nextStep:function(){
                 var _currentData = vc.component.@@templateCode@@Info.infos[vc.component.@@templateCode@@Info.index];
                 if( _currentData == null || _currentData == undefined){
-                    vc.message("请选择相关信息");
+                    vc.message("请选择或填写必选信息");
                     return ;
                 }
                 vc.component.@@templateCode@@Info.$step.nextStep();
@@ -48,6 +48,13 @@
             },
             _finishStep:function(){
 
+
+                var _currentData = vc.component.@@templateCode@@Info.infos[vc.component.@@templateCode@@Info.index];
+                if( _currentData == null || _currentData == undefined){
+                    vc.message("请选择或填写必选信息");
+                    return ;
+                }
+
                 var param = {
                     data:vc.component.@@templateCode@@Info.infos
                 }

+ 92 - 4
java110-code-generator/src/main/resources/relationship/template_1.json

@@ -10,22 +10,28 @@
     {
       "index": 0,
       "code":"floor",
+      "flowKey": "floorId",
       "cnCode":"选择楼",
       "vcName":"viewFloorInfo",
+      "businessName": "businessFloor",
       "existsComponent": true
     },
     {
       "index": 1,
       "code":"unit",
+      "flowKey": "unitId",
       "cnCode":"选择单元",
       "vcName":"viewUnitInfo",
+      "businessName": "businessUnit",
       "existsComponent": true
     },
     {
       "index": 2,
       "code":"room",
+      "flowKey": "roomId",
       "cnCode":"添加房屋",
       "vcName":"addRoomView",
+      "businessName": "businessRoom",
       "existsComponent": false
     }
   ],
@@ -33,17 +39,99 @@
       "addRoomView": {
         "templateName":"添加房屋",
         "templateCode":"addRoom",
+        "package": "roomPackage",
         "columns":[
           {
-            "code":"name",
-            "cnCode":"服务名称",
-            "desc":"必填,请填写服务名称",
+            "code":"roomNum",
+            "cnCode":"房屋编号",
+            "desc":"必填,请填写房屋编号",
             "required":true,
             "hasDefaultValue":false,
             "inputType":"input",
             "limit":"maxLength",
+            "limitParam":"12",
+            "limitErrInfo":"房屋编号长度不能超过12位"
+          },
+          {
+            "code":"layer",
+            "cnCode":"房屋楼层",
+            "desc":"必填,请填写房屋楼层",
+            "required":true,
+            "hasDefaultValue":false,
+            "inputType":"input",
+            "limit":"num",
+            "limitParam":"",
+            "limitErrInfo":"房屋楼层高度必须为数字"
+          },
+          {
+            "code":"section",
+            "cnCode":"房间数",
+            "desc":"必填,请填写房屋楼层",
+            "required":true,
+            "hasDefaultValue":false,
+            "inputType":"input",
+            "limit":"num",
+            "limitParam":"",
+            "limitErrInfo":"房间数必须为数字"
+          },
+          {
+            "code":"apartment",
+            "cnCode":"房屋户型",
+            "desc":"必填,请选择房屋户型",
+            "required":true,
+            "hasDefaultValue":false,
+            "inputType":"select",
+            "selectValue":"一室两厅,两室两厅",
+            "selectValueName":"1010,2020",
+            "limit":"maxLength",
             "limitParam":"50",
-            "limitErrInfo":"服务名称不能超过50"
+            "limitErrInfo":"房屋户型不能大于50"
+          },
+          {
+            "code":"builtUpArea",
+            "cnCode":"建筑面积",
+            "desc":"必填,请填写房屋建筑面积",
+            "required":true,
+            "hasDefaultValue":false,
+            "inputType":"input",
+            "limit":"money",
+            "limitParam":"",
+            "limitErrInfo":"建筑面积错误,如 300.00"
+          },
+          {
+            "code":"unitPrice",
+            "cnCode":"房屋单价",
+            "desc":"必填,请填写房屋每平米单价",
+            "required":true,
+            "hasDefaultValue":false,
+            "inputType":"input",
+            "limit":"money",
+            "limitParam":"",
+            "limitErrInfo":"房屋单价错误 如 300.00"
+          },
+          {
+            "code":"state",
+            "cnCode":"房屋状态",
+            "desc":"必填,请选择房屋状态",
+            "required":true,
+            "hasDefaultValue":true,
+            "defaultValue":"2002",
+            "inputType":"none",
+            "limit":"maxLength",
+            "limitParam":"12",
+            "limitErrInfo":"房屋状态 不能超过12位"
+          },
+          {
+            "code":"remark",
+            "cnCode":"备注",
+            "desc":"可填,请填写备注",
+            "required":false,
+            "hasDefaultValue":false,
+            "defaultValue":"",
+            "inputType":"textarea",
+            "limit":"maxLength",
+            "limitParam":"200",
+            "limitErrInfo":"备注内容不能超过200"
           }
         ]
       }

+ 19 - 0
java110-common/src/main/java/com/java110/common/util/Assert.java

@@ -246,4 +246,23 @@ public class Assert extends org.springframework.util.Assert {
         }
     }
 
+    /**
+     * 检验是否在 infos 中存在 flowComponent 对应组件的key
+     * @param infos
+     * @param flowComponent
+     * @param key
+     * @param message
+     */
+    public static void hasKeyByFlowData(JSONArray infos, String flowComponent, String key, String message){
+
+        for(int infoIndex = 0 ; infoIndex < infos.size() ; infoIndex ++){
+            JSONObject _info = infos.getJSONObject(infoIndex);
+            if(_info.containsKey(flowComponent) && _info.getString("flowComponent").equals(flowComponent)){
+                hasKeyAndValue(_info, key, message);
+                break;
+            }
+        }
+
+    }
+
 }

+ 7 - 0
pom.xml

@@ -479,6 +479,13 @@
                     <artifactId>maven-javadoc-plugin</artifactId>
                     <version>2.10.4</version>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
         </plugins>
     </build>