Explorar el Código

代码生成 报修派单逻辑

wuxw hace 6 años
padre
commit
e5b646eaff

+ 128 - 0
Api/src/main/java/com/java110/api/listener/repairDispatchStep/BindingRepairDispatchStepListener.java

@@ -0,0 +1,128 @@
+package com.java110.api.listener.repairDispatchStep;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.util.StringUtil;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.utils.util.Assert;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.AppService;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.constant.ServiceCodeConstant;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.utils.constant.ServiceCodeRepairDispatchStepConstant;
+
+
+import com.java110.core.annotation.Java110Listener;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 保存小区侦听
+ * add by wuxw 2019-06-30
+ */
+@Java110Listener("bindingRepairDispatchStepListener")
+public class BindingRepairDispatchStepListener extends AbstractServiceApiListener {
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+        JSONArray infos = reqJson.getJSONArray("data");
+
+
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        HttpHeaders header = new HttpHeaders();
+        context.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
+        JSONArray businesses = new JSONArray();
+
+        AppService service = event.getAppService();
+
+
+        JSONArray infos = reqJson.getJSONArray("data");
+
+
+        JSONObject viewOrgInfo = getObj(infos, "viewOrgInfo");
+        //JSONObject viewOrgInfo = getObj(infos, "viewOrgInfo");
+        JSONObject viewStaffInfo = getObj(infos, "viewStaffInfo");
+        if (!hasKey(viewStaffInfo, "userId")) {
+            viewStaffInfo.put("userId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_userId));
+            viewStaffInfo.put("userId", context.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
+            businesses.add(addBusinessRepairUser(viewStaffInfo, context));
+        }
+
+
+        JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders());
+
+        //将 rest header 信息传递到下层服务中去
+        super.freshHttpHeader(header, context.getRequestCurrentHeaders());
+
+        ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj);
+
+        context.setResponseEntity(responseEntity);
+    }
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeRepairDispatchStepConstant.BINDING_REPAIRDISPATCHSTEP;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    private JSONObject addBusinessRepairUser(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_REPAIR_USER);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONObject businessObj = new JSONObject();
+        businessObj.putAll(paramInJson);
+        //计算 应收金额
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessOrg", businessObj);
+        return business;
+    }
+
+
+    private boolean hasKey(JSONObject info, String key) {
+        if (!info.containsKey(key)
+                || StringUtil.isEmpty(info.getString(key))
+                || info.getString(key).startsWith("-")) {
+            return false;
+        }
+        return true;
+
+    }
+
+    private JSONObject getObj(JSONArray infos, String flowComponent) {
+
+        JSONObject serviceInfo = null;
+
+        for (int infoIndex = 0; infoIndex < infos.size(); infoIndex++) {
+
+            Assert.hasKeyAndValue(infos.getJSONObject(infoIndex), "flowComponent", "未包含服务流程组件名称");
+
+            if (flowComponent.equals(infos.getJSONObject(infoIndex).getString("flowComponent"))) {
+                serviceInfo = infos.getJSONObject(infoIndex);
+                Assert.notNull(serviceInfo, "未包含服务信息");
+                return serviceInfo;
+            }
+        }
+
+        throw new IllegalArgumentException("未找到组件编码为【" + flowComponent + "】数据");
+    }
+
+
+}

+ 34 - 0
WebService/src/main/java/com/java110/web/components/ownerRepair/RepairDispatchStepBindingComponent.java

@@ -0,0 +1,34 @@
+package com.java110.web.components.ownerRepair;
+
+import com.java110.core.context.IPageData;
+import com.java110.web.smo.repairDispatchStep.IRepairDispatchStepBindingSMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+/**
+ * 添加报修派单组件
+ */
+@Component("repairDispatchStepBinding")
+public class RepairDispatchStepBindingComponent {
+
+    @Autowired
+    private IRepairDispatchStepBindingSMO repairDispatchStepBindingSMOImpl;
+
+    /**
+     * 添加报修派单数据
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象
+     */
+    public ResponseEntity<String> binding(IPageData pd){
+        return repairDispatchStepBindingSMOImpl.bindingRepairDispatchStep(pd);
+    }
+
+    public IRepairDispatchStepBindingSMO getRepairDispatchStepBindingSMOImpl() {
+        return repairDispatchStepBindingSMOImpl;
+    }
+
+    public void setRepairDispatchStepBindingSMOImpl(IRepairDispatchStepBindingSMO repairDispatchStepBindingSMOImpl) {
+        this.repairDispatchStepBindingSMOImpl = repairDispatchStepBindingSMOImpl;
+    }
+}

+ 19 - 0
WebService/src/main/java/com/java110/web/smo/repairDispatchStep/IRepairDispatchStepBindingSMO.java

@@ -0,0 +1,19 @@
+package com.java110.web.smo.repairDispatchStep;
+
+import com.java110.core.context.IPageData;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 添加报修派单接口
+ *
+ * add by wuxw 2019-06-30
+ */
+public interface IRepairDispatchStepBindingSMO {
+
+    /**
+     * 添加报修派单
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象
+     */
+    ResponseEntity<String> bindingRepairDispatchStep(IPageData pd);
+}

+ 63 - 0
WebService/src/main/java/com/java110/web/smo/repairDispatchStep/impl/RepairDispatchStepBindingSMOImpl.java

@@ -0,0 +1,63 @@
+package com.java110.web.smo.repairDispatchStep.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.PrivilegeCodeConstant;
+import com.java110.utils.constant.ServiceCodeRepairDispatchStepConstant;
+import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.util.Assert;
+import com.java110.core.context.IPageData;
+import com.java110.web.core.AbstractComponentSMO;
+import com.java110.web.smo.repairDispatchStep.IRepairDispatchStepBindingSMO;
+import org.springframework.stereotype.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * 添加小区服务实现类
+ * add by wuxw 2019-06-30
+ */
+@Service("repairDispatchStepBindingSMOImpl")
+public class RepairDispatchStepBindingSMOImpl extends AbstractComponentSMO implements IRepairDispatchStepBindingSMO {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Override
+    protected void validate(IPageData pd, JSONObject paramIn) {
+
+        //super.validatePageInfo(pd);
+        JSONArray infos = paramIn.getJSONArray("data");
+        //Assert.hasKeyAndValue(paramIn, "xxx", "xxx");
+
+
+        super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.REPAIRDISPATCHSTEP);
+
+    }
+
+    @Override
+    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) {
+        ResponseEntity<String> responseEntity = null;
+        super.validateStoreStaffCommunityRelationship(pd, restTemplate);
+
+        responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(),
+                ServiceConstant.SERVICE_API_URL + "/api/" + ServiceCodeRepairDispatchStepConstant.BINDING_REPAIRDISPATCHSTEP,
+                HttpMethod.POST);
+        return responseEntity;
+    }
+
+    @Override
+    public ResponseEntity<String> bindingRepairDispatchStep(IPageData pd) {
+        return super.businessProcess(pd);
+    }
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+}

+ 41 - 0
WebService/src/main/resources/components/ownerRepairPackage/repairDispatchStep/repairDispatchStep.html

@@ -0,0 +1,41 @@
+<div id="component">
+
+    <div class="java110_step">
+        <div id="step"></div>
+    </div>
+
+    <!-- 选择 应用信息 -->
+    <div v-if="repairDispatchStepInfo.index == 0">
+        <vc:create name="viewOrgInfo"
+                   callBackListener="repairDispatchStep"
+                   callBackFunction="notify"
+        ></vc:create>
+    </div>
+    <div v-if="repairDispatchStepInfo.index == 1">
+        <vc:create name="viewOrgInfo"
+                   callBackListener="repairDispatchStep"
+                   callBackFunction="notify"
+        ></vc:create>
+    </div>
+    <div v-if="repairDispatchStepInfo.index == 2">
+        <vc:create name="viewStaffInfo"
+                   callBackListener="repairDispatchStep"
+                   callBackFunction="notify"
+        ></vc:create>
+    </div>
+
+
+    <div class="row">
+        <div class="col-md-10"></div>
+        <div class="col-md-2 " style="margin-bottom:10px; text-align:right">
+            <button type="button" class="btn btn-secondary" v-on:click="_prevStep()">上一步</button>
+            <button v-if="repairDispatchStepInfo.index != 2" type="button" class="btn btn-primary"
+                    style="margin-left:10px;" v-on:click="_nextStep()">下一步
+            </button>
+            <button v-if="repairDispatchStepInfo.index == 2" type="button" class="btn btn-primary"
+                    style="margin-left:10px;" v-on:click="_finishStep()">完成
+            </button>
+        </div>
+    </div>
+
+</div>

+ 93 - 0
WebService/src/main/resources/components/ownerRepairPackage/repairDispatchStep/repairDispatchStep.js

@@ -0,0 +1,93 @@
+/**
+    入驻小区
+**/
+(function(vc){
+    vc.extends({
+        data:{
+            repairDispatchStepInfo:{
+                $step:{},
+                index:0,
+                infos:[]
+            }
+        },
+        _initMethod:function(){
+            vc.component._initStep();
+        },
+        _initEvent:function(){
+            vc.on("repairDispatchStep", "notify", function(_info){
+                vc.component.repairDispatchStepInfo.infos[vc.component.repairDispatchStepInfo.index] = _info;
+            });
+
+        },
+        methods:{
+            _initStep:function(){
+                vc.component.repairDispatchStepInfo.$step = $("#step");
+                vc.component.repairDispatchStepInfo.$step.step({
+                    index: 0,
+                    time: 500,
+                    title: ["选择分公司","选择部门","选择员工"]
+                });
+                vc.component.repairDispatchStepInfo.index = vc.component.repairDispatchStepInfo.$step.getIndex();
+            },
+            _prevStep:function(){
+                vc.component.repairDispatchStepInfo.$step.prevStep();
+                vc.component.repairDispatchStepInfo.index = vc.component.repairDispatchStepInfo.$step.getIndex();
+
+                vc.emit('viewOrgInfo', 'onIndex', vc.component.repairDispatchStepInfo.index);
+                vc.emit('viewOrgInfo', 'onIndex', vc.component.repairDispatchStepInfo.index);
+                vc.emit('viewStaffInfo', 'onIndex', vc.component.repairDispatchStepInfo.index);
+
+            },
+            _nextStep:function(){
+                var _currentData = vc.component.repairDispatchStepInfo.infos[vc.component.repairDispatchStepInfo.index];
+                if( _currentData == null || _currentData == undefined){
+                    vc.message("请选择或填写必选信息");
+                    return ;
+                }
+                vc.component.repairDispatchStepInfo.$step.nextStep();
+                vc.component.repairDispatchStepInfo.index = vc.component.repairDispatchStepInfo.$step.getIndex();
+
+                 vc.emit('viewOrgInfo', 'onIndex', vc.component.repairDispatchStepInfo.index);
+                vc.emit('viewOrgInfo', 'onIndex', vc.component.repairDispatchStepInfo.index);
+                vc.emit('viewStaffInfo', 'onIndex', vc.component.repairDispatchStepInfo.index);
+
+            },
+            _finishStep:function(){
+
+
+                var _currentData = vc.component.repairDispatchStepInfo.infos[vc.component.repairDispatchStepInfo.index];
+                if( _currentData == null || _currentData == undefined){
+                    vc.message("请选择或填写必选信息");
+                    return ;
+                }
+
+                var param = {
+                    data:vc.component.repairDispatchStepInfo.infos
+                }
+
+               vc.http.post(
+                   'repairDispatchStepBinding',
+                   'binding',
+                   JSON.stringify(param),
+                   {
+                       emulateJSON:true
+                    },
+                    function(json,res){
+                       if(res.status == 200){
+
+                           vc.message('处理成功',true);
+                           //关闭model
+                           vc.jumpToPage("/flow/repairDispatch?" + vc.objToGetParam(JSON.parse(json)));
+                           return ;
+                       }
+                       vc.message(json);
+                    },
+                    function(errInfo,error){
+                       console.log('请求失败处理');
+
+                       vc.message(errInfo);
+                    });
+            }
+        }
+    });
+})(window.vc);

+ 38 - 0
WebService/src/main/resources/views/repairDispatchStepFlow.html

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en"
+      xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:th="http://www.thymeleaf.org"
+      xmlns:vc="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8"/>
+    <title>报修派单|java110</title>
+    <vc:create name="commonTop"></vc:create>
+    <link href="/css/jquery.step.css" rel="stylesheet"/>
+    <script src="/js/jquery.step.min.js" ></script>
+</head>
+<body>
+<vc:create name="bodyTop"></vc:create>
+<div id="wrapper">
+    <vc:create name="menu"></vc:create>
+
+
+    <div id="page-wrapper" class="gray-bg dashbard-1">
+        <div class="row border-bottom">
+            <vc:create name="nav"></vc:create>
+        </div>
+        <div class="wrapper wrapper-content" style="padding-bottom: 0px;">
+            <vc:create name="breadcrumb"></vc:create>
+        </div>
+        <!-- id="component" -->
+        <div class="wrapper wrapper-content animated fadeInRight">
+            <vc:create name="repairDispatchStep"></vc:create>
+        </div>
+
+        <vc:create name="copyright"></vc:create>
+
+    </div>
+</div>
+
+<vc:create name="commonBottom"></vc:create>
+</body>
+</html>

+ 10 - 84
java110-code-generator/src/main/resources/relationship/template_1.json

@@ -1,10 +1,10 @@
 {
-  "templateName":"添加员工",
-  "templateCode":"addStaffStep",
-  "templateKey":"userId",
-  "templateKeyName":"员工ID",
-  "package": "staffPackage",
-  "successUrl": "/flow/staff",
+  "templateName":"报修派单",
+  "templateCode":"repairDispatchStep",
+  "templateKey":"ruId",
+  "templateKeyName":"派单ID",
+  "package": "ownerRepairPackage",
+  "successUrl": "/flow/repairDispatch",
   "needAffirm": false,
   "flows":[
     {
@@ -31,85 +31,11 @@
       "index": 2,
       "code":"staff",
       "flowKey": "userId",
-      "cnCode":"填写员工信息",
-      "vcName":"addStaff",
+      "cnCode":"选择员工",
+      "vcName":"viewStaffInfo",
       "businessName": "businessStaff",
       "businessType": "BUSINESS_TYPE_SAVE_STAFF_INFO",
-      "existsComponent": false
+      "existsComponent": true
     }
-  ],
-  "components": {
-      "addStaff": {
-        "templateName":"添加员工",
-        "templateCode":"addStaff",
-        "package": "staffPackage",
-        "columns":[
-          {
-            "code":"username",
-            "cnCode":"员工名称",
-            "desc":"必填,员工名称不能为空",
-            "required":true,
-            "hasDefaultValue":false,
-            "inputType":"input",
-            "limit":"maxin",
-            "limitParam":"2,10",
-            "limitErrInfo":"员工名称长度必须在2位至10位",
-            "show": true
-          },
-          {
-            "code":"sex",
-            "cnCode":"员工性别",
-            "desc":"必填,请选择员工性别",
-            "required":true,
-            "hasDefaultValue":false,
-            "inputType":"select",
-            "selectValue":"1,0",
-            "selectValueName":"男,女",
-            "limit":"num",
-            "limitParam":"",
-            "limitErrInfo":"员工性别不能为空",
-            "show": true
-          },
-          {
-            "code":"email",
-            "cnCode":"员工邮箱",
-            "desc":"必填,请填写员工邮箱",
-            "required":true,
-            "hasDefaultValue":false,
-            "defaultValue":"",
-            "inputType":"input",
-            "limit":"email",
-            "limitParam":"",
-            "limitErrInfo":"员工邮箱不是有效邮箱",
-            "show": true
-          },
-          {
-            "code":"tel",
-            "cnCode":"手机",
-            "desc":"必填,请填写联系方式",
-            "required":false,
-            "hasDefaultValue":false,
-            "defaultValue":"",
-            "inputType":"input",
-            "limit":"photo",
-            "limitParam":"",
-            "limitErrInfo":"联系方式不是有效手机",
-            "show": true
-          },
-          {
-            "code":"address",
-            "cnCode":"家庭住址",
-            "desc":"必填,写家庭住址",
-            "required":true,
-            "hasDefaultValue":false,
-            "defaultValue":"",
-            "inputType":"input",
-            "limit":"maxLength",
-            "limitParam":"200",
-            "limitErrInfo":"家庭住址不能超过200位",
-            "show": false
-          }
-        ]
-      }
-  }
+  ]
 }

+ 115 - 0
java110-code-generator/src/main/resources/relationship/template_staff_step.json

@@ -0,0 +1,115 @@
+{
+  "templateName":"添加员工",
+  "templateCode":"addStaffStep",
+  "templateKey":"userId",
+  "templateKeyName":"员工ID",
+  "package": "staffPackage",
+  "successUrl": "/flow/staff",
+  "needAffirm": false,
+  "flows":[
+    {
+      "index": 0,
+      "code":"branchOrg",
+      "flowKey": "branchOrgId",
+      "cnCode":"选择分公司",
+      "vcName":"viewOrgInfo",
+      "businessName": "businessOrg",
+      "businessType": "BUSINESS_TYPE_SAVE_ORG_INFO",
+      "existsComponent": true
+    },
+    {
+      "index": 1,
+      "code":"departmentOrg",
+      "flowKey": "departmentOrgId",
+      "cnCode":"选择部门",
+      "vcName":"viewOrgInfo",
+      "businessName": "businessOrg",
+      "businessType": "BUSINESS_TYPE_SAVE_ORG_INFO",
+      "existsComponent": true
+    },
+    {
+      "index": 2,
+      "code":"staff",
+      "flowKey": "userId",
+      "cnCode":"填写员工信息",
+      "vcName":"addStaff",
+      "businessName": "businessStaff",
+      "businessType": "BUSINESS_TYPE_SAVE_STAFF_INFO",
+      "existsComponent": false
+    }
+  ],
+  "components": {
+      "addStaff": {
+        "templateName":"添加员工",
+        "templateCode":"addStaff",
+        "package": "staffPackage",
+        "columns":[
+          {
+            "code":"username",
+            "cnCode":"员工名称",
+            "desc":"必填,员工名称不能为空",
+            "required":true,
+            "hasDefaultValue":false,
+            "inputType":"input",
+            "limit":"maxin",
+            "limitParam":"2,10",
+            "limitErrInfo":"员工名称长度必须在2位至10位",
+            "show": true
+          },
+          {
+            "code":"sex",
+            "cnCode":"员工性别",
+            "desc":"必填,请选择员工性别",
+            "required":true,
+            "hasDefaultValue":false,
+            "inputType":"select",
+            "selectValue":"1,0",
+            "selectValueName":"男,女",
+            "limit":"num",
+            "limitParam":"",
+            "limitErrInfo":"员工性别不能为空",
+            "show": true
+          },
+          {
+            "code":"email",
+            "cnCode":"员工邮箱",
+            "desc":"必填,请填写员工邮箱",
+            "required":true,
+            "hasDefaultValue":false,
+            "defaultValue":"",
+            "inputType":"input",
+            "limit":"email",
+            "limitParam":"",
+            "limitErrInfo":"员工邮箱不是有效邮箱",
+            "show": true
+          },
+          {
+            "code":"tel",
+            "cnCode":"手机",
+            "desc":"必填,请填写联系方式",
+            "required":false,
+            "hasDefaultValue":false,
+            "defaultValue":"",
+            "inputType":"input",
+            "limit":"photo",
+            "limitParam":"",
+            "limitErrInfo":"联系方式不是有效手机",
+            "show": true
+          },
+          {
+            "code":"address",
+            "cnCode":"家庭住址",
+            "desc":"必填,写家庭住址",
+            "required":true,
+            "hasDefaultValue":false,
+            "defaultValue":"",
+            "inputType":"input",
+            "limit":"maxLength",
+            "limitParam":"200",
+            "limitErrInfo":"家庭住址不能超过200位",
+            "show": false
+          }
+        ]
+      }
+  }
+}

+ 4 - 0
java110-utils/src/main/java/com/java110/utils/constant/PrivilegeCodeConstant.java

@@ -104,5 +104,9 @@ public final class PrivilegeCodeConstant {
 
     public static final String ADD_STAFF = "";
 
+    public static final String REPAIRDISPATCHSTEP = "";
+
+
+
 
 }

+ 16 - 0
java110-utils/src/main/java/com/java110/utils/constant/ServiceCodeRepairDispatchStepConstant.java

@@ -0,0 +1,16 @@
+package com.java110.utils.constant;
+
+/**
+ * 报修派单常量类
+ * Created by wuxw on 2017/5/20.
+ */
+public class ServiceCodeRepairDispatchStepConstant {
+
+    /**
+     * 添加 报修派单
+     */
+    public static final String BINDING_REPAIRDISPATCHSTEP = "ownerRepair.repairDispatchStep";
+
+
+
+}