Sfoglia il codice sorgente

优化巡检路线 为cmd 为了适配 spring boot 版

java110 3 anni fa
parent
commit
a100e6c74a
14 ha cambiato i file con 305 aggiunte e 437 eliminazioni
  1. 0 51
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/DeleteInspectionRouteListener.java
  2. 0 58
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/DeleteInspectionRoutePointListener.java
  3. 0 52
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/SaveInspectionRouteListener.java
  4. 0 77
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/SaveInspectionRoutePointListener.java
  5. 0 54
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/UpdateInspectionRouteListener.java
  6. 0 53
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/UpdateInspectionRoutePointRelListener.java
  7. 51 0
      service-community/src/main/java/com/java110/community/cmd/inspectionRoute/DeleteInspectionRouteCmd.java
  8. 54 0
      service-community/src/main/java/com/java110/community/cmd/inspectionRoute/DeleteInspectionRoutePointCmd.java
  9. 14 46
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/ListInspectionRoutePointsListener.java
  10. 13 46
      service-api/src/main/java/com/java110/api/listener/inspectionRoute/ListInspectionRoutesListener.java
  11. 40 0
      service-community/src/main/java/com/java110/community/cmd/inspectionRoute/SaveInspectionRouteCmd.java
  12. 58 0
      service-community/src/main/java/com/java110/community/cmd/inspectionRoute/SaveInspectionRoutePointCmd.java
  13. 39 0
      service-community/src/main/java/com/java110/community/cmd/inspectionRoute/UpdateInspectionRouteCmd.java
  14. 36 0
      service-community/src/main/java/com/java110/community/cmd/inspectionRoute/UpdateInspectionRoutePointRelCmd.java

+ 0 - 51
service-api/src/main/java/com/java110/api/listener/inspectionRoute/DeleteInspectionRouteListener.java

@@ -1,51 +0,0 @@
-package com.java110.api.listener.inspectionRoute;
-
-import com.java110.api.bmo.inspection.IInspectionBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.utils.util.Assert;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-import com.alibaba.fastjson.JSONObject;
-
-/**
- * 保存小区侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("deleteInspectionRouteListener")
-public class DeleteInspectionRouteListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IInspectionBMO inspectionBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线ID不能为空");
-        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        inspectionBMOImpl.deleteInspectionRoute(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.DELETE_INSPECTIONROUTE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-}

+ 0 - 58
service-api/src/main/java/com/java110/api/listener/inspectionRoute/DeleteInspectionRoutePointListener.java

@@ -1,58 +0,0 @@
-package com.java110.api.listener.inspectionRoute;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspection.IInspectionBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.intf.community.IInspectionRoutePointRelInnerServiceSMO;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存小区侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("deleteInspectionRoutePointListener")
-public class DeleteInspectionRoutePointListener extends AbstractServiceApiPlusListener {
-    @Autowired
-    private IInspectionBMO inspectionBMOImpl;
-
-    @Autowired
-    private IInspectionRoutePointRelInnerServiceSMO inspectionRoutePointRelInnerServiceSMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-
-        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线巡检路线不能为空");
-        Assert.hasKeyAndValue(reqJson, "inspectionId", "路线巡检点不能为空");
-        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        inspectionBMOImpl.deleteInspectionRoutePoint(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.DELETE_INSPECTIONROUTE_POINT;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-}

+ 0 - 52
service-api/src/main/java/com/java110/api/listener/inspectionRoute/SaveInspectionRouteListener.java

@@ -1,52 +0,0 @@
-package com.java110.api.listener.inspectionRoute;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspection.IInspectionBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.utils.util.Assert;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
-
-
-import com.java110.core.annotation.Java110Listener;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存小区侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("saveInspectionRouteListener")
-public class SaveInspectionRouteListener extends AbstractServiceApiPlusListener {
-    @Autowired
-    private IInspectionBMO inspectionBMOImpl;
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-        Assert.hasKeyAndValue(reqJson, "routeName", "必填,请填写路线名称,字数100个以内");
-        Assert.hasKeyAndValue(reqJson, "seq", "必填,请选择巡点名称");
-        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-       inspectionBMOImpl.addInspectionRoute(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.ADD_INSPECTIONROUTE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-}

+ 0 - 77
service-api/src/main/java/com/java110/api/listener/inspectionRoute/SaveInspectionRoutePointListener.java

@@ -1,77 +0,0 @@
-package com.java110.api.listener.inspectionRoute;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspection.IInspectionBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.entity.center.AppService;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.CommonConstant;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存小区侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("saveInspectionRoutePointListener")
-public class SaveInspectionRoutePointListener extends AbstractServiceApiPlusListener {
-    @Autowired
-    private IInspectionBMO inspectionBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-        if (reqJson.containsKey("inspectionId")) {
-            Assert.hasKeyAndValue(reqJson, "inspectionId", "必填,请填写巡检点");
-        } else {
-            Assert.hasKeyAndValue(reqJson, "points", "必填,请填写多个巡检点");
-        }
-        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "必填,请填写巡检路线");
-        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-    }
-
-    @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();
-
-        if (reqJson.containsKey("inspectionId")) {
-            //添加单元信息
-           inspectionBMOImpl.addInspectionRoute(reqJson, context, 1);
-        } else { //批量的情况
-            JSONArray points = reqJson.getJSONArray("points");
-            for (int pointIndex = 0; pointIndex < points.size(); pointIndex++) {
-                reqJson.put("inspectionId", points.getJSONObject(pointIndex).getString("inspectionId"));
-                reqJson.put("inspectionName", points.getJSONObject(pointIndex).getString("inspectionName"));
-                inspectionBMOImpl.addInspectionRoute(reqJson, context, pointIndex + 1);
-            }
-        }
-
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.ADD_INSPECTIONROUTE_POINT;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-}

+ 0 - 54
service-api/src/main/java/com/java110/api/listener/inspectionRoute/UpdateInspectionRouteListener.java

@@ -1,54 +0,0 @@
-package com.java110.api.listener.inspectionRoute;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspection.IInspectionBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存巡检路线侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("updateInspectionRouteListener")
-public class UpdateInspectionRouteListener extends AbstractServiceApiPlusListener {
-    @Autowired
-    private IInspectionBMO inspectionBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-
-        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线ID不能为空");
-        Assert.hasKeyAndValue(reqJson, "routeName", "必填,请填写路线名称,字数100个以内");
-        Assert.hasKeyAndValue(reqJson, "seq", "必填,请选择巡点名称");
-        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        inspectionBMOImpl.updateInspectionRoute(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.UPDATE_INSPECTIONROUTE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-}

+ 0 - 53
service-api/src/main/java/com/java110/api/listener/inspectionRoute/UpdateInspectionRoutePointRelListener.java

@@ -1,53 +0,0 @@
-package com.java110.api.listener.inspectionRoute;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspection.IInspectionBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存巡检路线侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("updateInspectionRoutePointRelListener")
-public class UpdateInspectionRoutePointRelListener extends AbstractServiceApiPlusListener {
-    @Autowired
-    private IInspectionBMO inspectionBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-
-        Assert.hasKeyAndValue(reqJson, "irpRelId", "路线巡检点ID不能为空");
-        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线ID不能为空");
-        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        inspectionBMOImpl.updateInspectionRoutePointRel(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.UPDATE_INSPECTIONROUTE_POINT_REL;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-}

+ 51 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionRoute/DeleteInspectionRouteCmd.java

@@ -0,0 +1,51 @@
+package com.java110.community.cmd.inspectionRoute;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.inspectionPlan.InspectionPlanDto;
+import com.java110.intf.community.IInspectionPlanInnerServiceSMO;
+import com.java110.intf.community.IInspectionRouteV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionRoutePo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+@Java110Cmd(serviceCode = "inspectionRoute.deleteInspectionRoute")
+public class DeleteInspectionRouteCmd extends Cmd {
+
+    @Autowired
+    private IInspectionPlanInnerServiceSMO inspectionPlanInnerServiceSMOImpl;
+
+    @Autowired
+    private IInspectionRouteV1InnerServiceSMO inspectionRouteV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+//Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线ID不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
+
+        InspectionPlanDto inspectionPlanDto = new InspectionPlanDto();
+        inspectionPlanDto.setInspectionRouteId(reqJson.getString("inspectionRouteId"));
+        //根据巡检路线id查询巡检计划
+        List<InspectionPlanDto> inspectionPlanDtos = inspectionPlanInnerServiceSMOImpl.queryInspectionPlans(inspectionPlanDto);
+        Assert.listIsNull(inspectionPlanDtos, "该巡检路线正在使用,不能删除!");
+
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        InspectionRoutePo inspectionRoutePo = BeanConvertUtil.covertBean(reqJson, InspectionRoutePo.class);
+        int flag = inspectionRouteV1InnerServiceSMOImpl.deleteInspectionRoute(inspectionRoutePo);
+
+        if (flag < 1) {
+            throw new CmdException("删除巡检路线失败");
+        }
+    }
+}

+ 54 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionRoute/DeleteInspectionRoutePointCmd.java

@@ -0,0 +1,54 @@
+package com.java110.community.cmd.inspectionRoute;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.inspectionPlan.InspectionRoutePointRelDto;
+import com.java110.intf.community.IInspectionRoutePointRelInnerServiceSMO;
+import com.java110.intf.community.IInspectionRoutePointRelV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionRoutePointRelPo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+@Java110Cmd(serviceCode = "inspectionRoute.deleteInspectionRoutePoint")
+public class DeleteInspectionRoutePointCmd extends Cmd {
+
+    @Autowired
+    private IInspectionRoutePointRelInnerServiceSMO inspectionRoutePointRelInnerServiceSMOImpl;
+
+    @Autowired
+    private IInspectionRoutePointRelV1InnerServiceSMO inspectionRoutePointRelV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线巡检路线不能为空");
+        Assert.hasKeyAndValue(reqJson, "inspectionId", "路线巡检点不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        InspectionRoutePointRelDto inspectionRoutePointRelDto = new InspectionRoutePointRelDto();
+        inspectionRoutePointRelDto.setCommunityId(reqJson.getString("communityId"));
+        inspectionRoutePointRelDto.setInspectionId(reqJson.getString("inspectionId"));
+        inspectionRoutePointRelDto.setInspectionRouteId(reqJson.getString("inspectionRouteId"));
+        List<InspectionRoutePointRelDto> inspectionRoutePointRelDtos = inspectionRoutePointRelInnerServiceSMOImpl.queryInspectionRoutePointRels(inspectionRoutePointRelDto);
+
+        Assert.listOnlyOne(inspectionRoutePointRelDtos, "未查询到(或多条)要删除的 巡检路线下的巡检点");
+        JSONObject businessInspectionRoute = new JSONObject();
+        businessInspectionRoute.putAll(BeanConvertUtil.beanCovertMap(inspectionRoutePointRelDtos.get(0)));
+
+        InspectionRoutePointRelPo inspectionRoutePointRelPo = BeanConvertUtil.covertBean(businessInspectionRoute, InspectionRoutePointRelPo.class);
+
+        int flag = inspectionRoutePointRelV1InnerServiceSMOImpl.deleteInspectionRoutePointRel(inspectionRoutePointRelPo);
+        if (flag < 1) {
+            throw new CmdException("删除巡检路线失败");
+        }
+    }
+}

+ 14 - 46
service-api/src/main/java/com/java110/api/listener/inspectionRoute/ListInspectionRoutePointsListener.java

@@ -1,37 +1,32 @@
-package com.java110.api.listener.inspectionRoute;
+package com.java110.community.cmd.inspectionRoute;
 
 import com.alibaba.fastjson.JSONObject;
-import com.java110.api.listener.AbstractServiceApiListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.intf.community.ICommunityInnerServiceSMO;
-import com.java110.intf.community.IInspectionRoutePointRelInnerServiceSMO;
-import com.java110.intf.community.IRoomInnerServiceSMO;
-import com.java110.intf.community.IUnitInnerServiceSMO;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
 import com.java110.dto.RoomDto;
 import com.java110.dto.community.CommunityDto;
 import com.java110.dto.inspectionPlan.InspectionRoutePointRelDto;
 import com.java110.dto.unit.FloorAndUnitDto;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
+import com.java110.intf.community.ICommunityInnerServiceSMO;
+import com.java110.intf.community.IInspectionRoutePointRelInnerServiceSMO;
+import com.java110.intf.community.IRoomInnerServiceSMO;
+import com.java110.intf.community.IUnitInnerServiceSMO;
+import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.api.inspectionPoint.ApiInspectionPointDataVo;
 import com.java110.vo.api.inspectionPoint.ApiInspectionPointVo;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 
 import java.util.ArrayList;
 import java.util.List;
 
-
-/**
- * 查询小区侦听类
- */
-@Java110Listener("listInspectionRoutePointsListener")
-public class ListInspectionRoutePointsListener extends AbstractServiceApiListener {
+@Java110Cmd(serviceCode = "inspectionRoute.listInspectionRoutePoints")
+public class ListInspectionRoutePointsCmd extends Cmd {
 
     @Autowired
     private IInspectionRoutePointRelInnerServiceSMO inspectionRoutePointRelInnerServiceSMOImpl;
@@ -46,40 +41,13 @@ public class ListInspectionRoutePointsListener extends AbstractServiceApiListene
     private IUnitInnerServiceSMO unitInnerServiceSMOImpl;
 
     @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.LIST_INSPECTIONROUTE_POINTS;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.GET;
-    }
-
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-
-    public IInspectionRoutePointRelInnerServiceSMO getInspectionRoutePointRelInnerServiceSMOImpl() {
-        return inspectionRoutePointRelInnerServiceSMOImpl;
-    }
-
-    public void setInspectionRoutePointRelInnerServiceSMOImpl(IInspectionRoutePointRelInnerServiceSMO inspectionRoutePointRelInnerServiceSMOImpl) {
-        this.inspectionRoutePointRelInnerServiceSMOImpl = inspectionRoutePointRelInnerServiceSMOImpl;
-    }
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         super.validatePageInfo(reqJson);
         Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-
     }
 
     @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         InspectionRoutePointRelDto inspectionRoutePointRelDto = BeanConvertUtil.covertBean(reqJson, InspectionRoutePointRelDto.class);
 
         int count = inspectionRoutePointRelInnerServiceSMOImpl.queryInspectionRoutePointRelsCount(inspectionRoutePointRelDto);

+ 13 - 46
service-api/src/main/java/com/java110/api/listener/inspectionRoute/ListInspectionRoutesListener.java

@@ -1,70 +1,38 @@
-package com.java110.api.listener.inspectionRoute;
+package com.java110.community.cmd.inspectionRoute;
 
-import com.java110.api.listener.AbstractServiceApiListener;
-import com.java110.utils.constant.ServiceCodeInspectionRouteConstant;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.inspectionPlan.InspectionRouteDto;
+import com.java110.intf.community.IInspectionRouteInnerServiceSMO;
+import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.intf.community.IInspectionRouteInnerServiceSMO;
-import com.java110.dto.inspectionPlan.InspectionRouteDto;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
 import com.java110.vo.api.inspectionRoute.ApiInspectionRouteDataVo;
 import com.java110.vo.api.inspectionRoute.ApiInspectionRouteVo;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import com.alibaba.fastjson.JSONObject;
 
 import java.util.ArrayList;
 import java.util.List;
 
-
-/**
- * 查询小区侦听类
- */
-@Java110Listener("listInspectionRoutesListener")
-public class ListInspectionRoutesListener extends AbstractServiceApiListener {
+@Java110Cmd(serviceCode = "inspectionRoute.listInspectionRoutes")
+public class ListInspectionRoutesCmd extends Cmd {
 
     @Autowired
     private IInspectionRouteInnerServiceSMO inspectionRouteInnerServiceSMOImpl;
 
     @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionRouteConstant.LIST_INSPECTIONROUTES;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.GET;
-    }
-
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-
-    public IInspectionRouteInnerServiceSMO getInspectionRouteInnerServiceSMOImpl() {
-        return inspectionRouteInnerServiceSMOImpl;
-    }
-
-    public void setInspectionRouteInnerServiceSMOImpl(IInspectionRouteInnerServiceSMO inspectionRouteInnerServiceSMOImpl) {
-        this.inspectionRouteInnerServiceSMOImpl = inspectionRouteInnerServiceSMOImpl;
-    }
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         super.validatePageInfo(reqJson);
         Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
-
     }
 
     @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         InspectionRouteDto inspectionRouteDto = BeanConvertUtil.covertBean(reqJson, InspectionRouteDto.class);
 
         int count = inspectionRouteInnerServiceSMOImpl.queryInspectionRoutesCount(inspectionRouteDto);
@@ -86,6 +54,5 @@ public class ListInspectionRoutesListener extends AbstractServiceApiListener {
         ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiInspectionRouteVo), HttpStatus.OK);
 
         context.setResponseEntity(responseEntity);
-
     }
 }

+ 40 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionRoute/SaveInspectionRouteCmd.java

@@ -0,0 +1,40 @@
+package com.java110.community.cmd.inspectionRoute;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.community.IInspectionRouteV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionRoutePo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@Java110Cmd(serviceCode = "inspectionRoute.saveInspectionRoute")
+public class SaveInspectionRouteCmd extends Cmd {
+
+    @Autowired
+    private IInspectionRouteV1InnerServiceSMO inspectionRouteV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+//Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+        Assert.hasKeyAndValue(reqJson, "routeName", "必填,请填写路线名称,字数100个以内");
+        Assert.hasKeyAndValue(reqJson, "seq", "必填,请选择巡点名称");
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        reqJson.put("inspectionRouteId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_inspectionRouteId));
+        InspectionRoutePo inspectionRoutePo = BeanConvertUtil.covertBean(reqJson, InspectionRoutePo.class);
+
+        int flag = inspectionRouteV1InnerServiceSMOImpl.saveInspectionRoute(inspectionRoutePo);
+        if (flag < 1) {
+            throw new CmdException("删除巡检路线失败");
+        }
+    }
+}

+ 58 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionRoute/SaveInspectionRoutePointCmd.java

@@ -0,0 +1,58 @@
+package com.java110.community.cmd.inspectionRoute;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.community.IInspectionRoutePointRelV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionRoutePointRelPo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@Java110Cmd(serviceCode = "inspectionRoute.saveInspectionRoutePoint")
+public class SaveInspectionRoutePointCmd extends Cmd {
+    @Autowired
+    private IInspectionRoutePointRelV1InnerServiceSMO inspectionRoutePointRelV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+        if (reqJson.containsKey("inspectionId")) {
+            Assert.hasKeyAndValue(reqJson, "inspectionId", "必填,请填写巡检点");
+        } else {
+            Assert.hasKeyAndValue(reqJson, "points", "必填,请填写多个巡检点");
+        }
+        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "必填,请填写巡检路线");
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        if (reqJson.containsKey("inspectionId")) {
+            //添加单元信息
+            addInspectionRoute(reqJson);
+        } else { //批量的情况
+            JSONArray points = reqJson.getJSONArray("points");
+            for (int pointIndex = 0; pointIndex < points.size(); pointIndex++) {
+                reqJson.put("inspectionId", points.getJSONObject(pointIndex).getString("inspectionId"));
+                reqJson.put("inspectionName", points.getJSONObject(pointIndex).getString("inspectionName"));
+                addInspectionRoute(reqJson);
+            }
+        }
+    }
+
+    public void addInspectionRoute(JSONObject paramInJson) {
+
+        paramInJson.put("irpRelId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_irpRelId));
+        InspectionRoutePointRelPo inspectionRoutePointRelPo = BeanConvertUtil.covertBean(paramInJson, InspectionRoutePointRelPo.class);
+        int flag = inspectionRoutePointRelV1InnerServiceSMOImpl.saveInspectionRoutePointRel(inspectionRoutePointRelPo);
+        if (flag < 1) {
+            throw new CmdException("删除巡检路线失败");
+        }
+    }
+}

+ 39 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionRoute/UpdateInspectionRouteCmd.java

@@ -0,0 +1,39 @@
+package com.java110.community.cmd.inspectionRoute;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.intf.community.IInspectionRouteV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionRoutePo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@Java110Cmd(serviceCode = "inspectionRoute.updateInspectionRoute")
+public class UpdateInspectionRouteCmd extends Cmd {
+
+
+    @Autowired
+    private IInspectionRouteV1InnerServiceSMO inspectionRouteV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线ID不能为空");
+        Assert.hasKeyAndValue(reqJson, "routeName", "必填,请填写路线名称,字数100个以内");
+        Assert.hasKeyAndValue(reqJson, "seq", "必填,请选择巡点名称");
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        InspectionRoutePo inspectionRoutePo = BeanConvertUtil.covertBean(reqJson, InspectionRoutePo.class);
+
+        int flag = inspectionRouteV1InnerServiceSMOImpl.updateInspectionRoute(inspectionRoutePo);
+        if (flag < 1) {
+            throw new CmdException("删除巡检路线失败");
+        }
+    }
+}

+ 36 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionRoute/UpdateInspectionRoutePointRelCmd.java

@@ -0,0 +1,36 @@
+package com.java110.community.cmd.inspectionRoute;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.intf.community.IInspectionRoutePointRelV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionRoutePointRelPo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@Java110Cmd(serviceCode = "inspectionRoute.updateInspectionRoutePointRel")
+public class UpdateInspectionRoutePointRelCmd extends Cmd {
+
+    @Autowired
+    private IInspectionRoutePointRelV1InnerServiceSMO inspectionRoutePointRelV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        Assert.hasKeyAndValue(reqJson, "irpRelId", "路线巡检点ID不能为空");
+        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "路线ID不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        InspectionRoutePointRelPo inspectionRoutePointRelPo = BeanConvertUtil.covertBean(reqJson, InspectionRoutePointRelPo.class);
+        int flag = inspectionRoutePointRelV1InnerServiceSMOImpl.updateInspectionRoutePointRel(inspectionRoutePointRelPo);
+        if (flag < 1) {
+            throw new CmdException("删除巡检路线失败");
+        }
+    }
+}