Browse Source

优化巡检 是否

java110 4 years ago
parent
commit
7650a5ae36

+ 0 - 55
service-api/src/main/java/com/java110/api/listener/inspectionPlanStaff/DeleteInspectionPlanStaffListener.java

@@ -1,55 +0,0 @@
-package com.java110.api.listener.inspectionPlanStaff;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspectionPlanStaff.IInspectionPlanStaffBMO;
-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.ServiceCodeInspectionPlanStaffConstant;
-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("deleteInspectionPlanStaffListener")
-public class DeleteInspectionPlanStaffListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IInspectionPlanStaffBMO inspectionPlanStaffBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-
-        Assert.hasKeyAndValue(reqJson, "ipStaffId", "ipStaffId不能为空");
-        Assert.hasKeyAndValue(reqJson, "communityId", "小区信息不能为空");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-       inspectionPlanStaffBMOImpl.deleteInspectionPlanStaff(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionPlanStaffConstant.DELETE_INSPECTIONPLANSTAFF;
-    }
-
-    @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/inspectionPlanStaff/SaveInspectionPlanStaffListener.java

@@ -1,58 +0,0 @@
-package com.java110.api.listener.inspectionPlanStaff;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspectionPlanStaff.IInspectionPlanStaffBMO;
-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.ServiceCodeInspectionPlanStaffConstant;
-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("saveInspectionPlanStaffListener")
-public class SaveInspectionPlanStaffListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IInspectionPlanStaffBMO inspectionPlanStaffBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-
-        Assert.hasKeyAndValue(reqJson, "staffId", "请求报文中未包含staffId");
-        Assert.hasKeyAndValue(reqJson, "staffName", "请求报文中未包含staffName");
-        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
-        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
-        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
-        Assert.hasKeyAndValue(reqJson, "inspectionPlanId", "请求报文中未包含inspectionPlanId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        inspectionPlanStaffBMOImpl.addInspectionPlanStaff(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionPlanStaffConstant.ADD_INSPECTIONPLANSTAFF;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-}

+ 0 - 57
service-api/src/main/java/com/java110/api/listener/inspectionPlanStaff/UpdateInspectionPlanStaffListener.java

@@ -1,57 +0,0 @@
-package com.java110.api.listener.inspectionPlanStaff;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.inspectionPlanStaff.IInspectionPlanStaffBMO;
-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.ServiceCodeInspectionPlanStaffConstant;
-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("updateInspectionPlanStaffListener")
-public class UpdateInspectionPlanStaffListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IInspectionPlanStaffBMO inspectionPlanStaffBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-
-        Assert.hasKeyAndValue(reqJson, "ipStaffId", "ipStaffId不能为空");
-        Assert.hasKeyAndValue(reqJson, "staffId", "请求报文中未包含staffId");
-        Assert.hasKeyAndValue(reqJson, "staffName", "请求报文中未包含staffName");
-        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
-        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
-        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
-        Assert.hasKeyAndValue(reqJson, "inspectionPlanId", "请求报文中未包含inspectionPlanId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        inspectionPlanStaffBMOImpl.updateInspectionPlanStaff(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionPlanStaffConstant.UPDATE_INSPECTIONPLANSTAFF;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-}

+ 36 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionPlanStaff/DeleteInspectionPlanStaffCmd.java

@@ -0,0 +1,36 @@
+package com.java110.community.cmd.inspectionPlanStaff;
+
+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.IInspectionPlanStaffV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionPlanStaffPo;
+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 = "inspectionPlanStaff.deleteInspectionPlanStaff")
+public class DeleteInspectionPlanStaffCmd extends Cmd {
+
+    @Autowired
+    private IInspectionPlanStaffV1InnerServiceSMO inspectionPlanStaffV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+
+        Assert.hasKeyAndValue(reqJson, "ipStaffId", "ipStaffId不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区信息不能为空");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        InspectionPlanStaffPo inspectionPlanStaffPo = BeanConvertUtil.covertBean(reqJson, InspectionPlanStaffPo.class);
+        int flag = inspectionPlanStaffV1InnerServiceSMOImpl.deleteInspectionPlanStaff(inspectionPlanStaffPo);
+        if (flag < 1) {
+            throw new CmdException("删除巡检师傅失败");
+        }
+    }
+}

+ 11 - 41
service-api/src/main/java/com/java110/api/listener/inspectionPlanStaff/ListInspectionPlanStaffsListener.java

@@ -1,66 +1,37 @@
-package com.java110.api.listener.inspectionPlanStaff;
+package com.java110.community.cmd.inspectionPlanStaff;
 
 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.IInspectionPlanStaffInnerServiceSMO;
+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.InspectionPlanStaffDto;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeInspectionPlanStaffConstant;
+import com.java110.intf.community.IInspectionPlanStaffInnerServiceSMO;
+import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.api.inspectionPlanStaff.ApiInspectionPlanStaffDataVo;
 import com.java110.vo.api.inspectionPlanStaff.ApiInspectionPlanStaffVo;
 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;
 
+@Java110Cmd(serviceCode = "inspectionPlanStaff.listInspectionPlanStaffs")
+public class ListInspectionPlanStaffsCmd extends Cmd {
 
-/**
- * 查询小区侦听类
- */
-@Java110Listener("listInspectionPlanStaffsListener")
-public class ListInspectionPlanStaffsListener extends AbstractServiceApiListener {
 
     @Autowired
     private IInspectionPlanStaffInnerServiceSMO inspectionPlanStaffInnerServiceSMOImpl;
 
     @Override
-    public String getServiceCode() {
-        return ServiceCodeInspectionPlanStaffConstant.LIST_INSPECTIONPLANSTAFFS;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.GET;
-    }
-
-
-    @Override
-    public int getOrder() {
-        return DEFAULT_ORDER;
-    }
-
-
-    public IInspectionPlanStaffInnerServiceSMO getInspectionPlanStaffInnerServiceSMOImpl() {
-        return inspectionPlanStaffInnerServiceSMOImpl;
-    }
-
-    public void setInspectionPlanStaffInnerServiceSMOImpl(IInspectionPlanStaffInnerServiceSMO inspectionPlanStaffInnerServiceSMOImpl) {
-        this.inspectionPlanStaffInnerServiceSMOImpl = inspectionPlanStaffInnerServiceSMOImpl;
-    }
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         super.validatePageInfo(reqJson);
     }
 
     @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
 
         InspectionPlanStaffDto inspectionPlanStaffDto = BeanConvertUtil.covertBean(reqJson, InspectionPlanStaffDto.class);
 
@@ -83,6 +54,5 @@ public class ListInspectionPlanStaffsListener extends AbstractServiceApiListener
         ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiInspectionPlanStaffVo), HttpStatus.OK);
 
         context.setResponseEntity(responseEntity);
-
     }
 }

+ 44 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionPlanStaff/SaveInspectionPlanStaffCmd.java

@@ -0,0 +1,44 @@
+package com.java110.community.cmd.inspectionPlanStaff;
+
+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.IInspectionPlanStaffV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionPlanStaffPo;
+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 = "inspectionPlanStaff.saveInspectionPlanStaff")
+public class SaveInspectionPlanStaffCmd extends Cmd {
+
+    @Autowired
+    private IInspectionPlanStaffV1InnerServiceSMO inspectionPlanStaffV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+
+        Assert.hasKeyAndValue(reqJson, "staffId", "请求报文中未包含staffId");
+        Assert.hasKeyAndValue(reqJson, "staffName", "请求报文中未包含staffName");
+        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
+        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
+        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanId", "请求报文中未包含inspectionPlanId");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        reqJson.put("ipStaffId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_ipStaffId));
+
+        InspectionPlanStaffPo inspectionPlanStaffPo = BeanConvertUtil.covertBean(reqJson, InspectionPlanStaffPo.class);
+
+        int flag = inspectionPlanStaffV1InnerServiceSMOImpl.saveInspectionPlanStaff(inspectionPlanStaffPo);
+        if (flag < 1) {
+            throw new CmdException("保存巡检师傅失败");
+        }
+    }
+}

+ 59 - 0
service-community/src/main/java/com/java110/community/cmd/inspectionPlanStaff/UpdateInspectionPlanStaffCmd.java

@@ -0,0 +1,59 @@
+package com.java110.community.cmd.inspectionPlanStaff;
+
+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.InspectionPlanStaffDto;
+import com.java110.intf.community.IInspectionPlanStaffInnerServiceSMO;
+import com.java110.intf.community.IInspectionPlanStaffV1InnerServiceSMO;
+import com.java110.po.inspection.InspectionPlanStaffPo;
+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 = "inspectionPlanStaff.updateInspectionPlanStaff")
+public class UpdateInspectionPlanStaffCmd extends Cmd {
+
+    @Autowired
+    private IInspectionPlanStaffV1InnerServiceSMO inspectionPlanStaffV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IInspectionPlanStaffInnerServiceSMO inspectionPlanStaffInnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+
+        Assert.hasKeyAndValue(reqJson, "ipStaffId", "ipStaffId不能为空");
+        Assert.hasKeyAndValue(reqJson, "staffId", "请求报文中未包含staffId");
+        Assert.hasKeyAndValue(reqJson, "staffName", "请求报文中未包含staffName");
+        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
+        Assert.hasKeyAndValue(reqJson, "startTime", "请求报文中未包含startTime");
+        Assert.hasKeyAndValue(reqJson, "endTime", "请求报文中未包含endTime");
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanId", "请求报文中未包含inspectionPlanId");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        InspectionPlanStaffDto inspectionPlanStaffDto = new InspectionPlanStaffDto();
+        inspectionPlanStaffDto.setIpStaffId(reqJson.getString("ipStaffId"));
+        inspectionPlanStaffDto.setCommunityId(reqJson.getString("communityId"));
+        List<InspectionPlanStaffDto> inspectionPlanStaffDtos = inspectionPlanStaffInnerServiceSMOImpl.queryInspectionPlanStaffs(inspectionPlanStaffDto);
+
+        Assert.listOnlyOne(inspectionPlanStaffDtos, "未找到需要修改的活动 或多条数据");
+
+        JSONObject businessInspectionPlanStaff = new JSONObject();
+        businessInspectionPlanStaff.putAll(BeanConvertUtil.beanCovertMap(inspectionPlanStaffDtos.get(0)));
+        businessInspectionPlanStaff.putAll(reqJson);
+        InspectionPlanStaffPo inspectionPlanStaffPo = BeanConvertUtil.covertBean(businessInspectionPlanStaff, InspectionPlanStaffPo.class);
+
+        int flag = inspectionPlanStaffV1InnerServiceSMOImpl.updateInspectionPlanStaff(inspectionPlanStaffPo);
+        if (flag < 1) {
+            throw new CmdException("修改巡检师傅失败");
+        }
+    }
+}