mrzcc пре 6 година
родитељ
комит
b5d456dfd8

+ 92 - 0
Api/src/main/java/com/java110/api/listener/inspectionPlan/DeleteInspectionPlanListener.java

@@ -0,0 +1,92 @@
+package com.java110.api.listener.inspectionPlan;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+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.BusinessTypeConstant;
+
+import com.java110.core.annotation.Java110Listener;
+import com.java110.utils.constant.ServiceCodeInspectionPlanConstant;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 保存小区侦听
+ * add by wuxw 2019-06-30
+ */
+@Java110Listener("deleteInspectionPlanListener")
+public class DeleteInspectionPlanListener extends AbstractServiceApiListener {
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanId", "巡检计划名称不能为空");
+
+    }
+
+    @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();
+
+        //添加单元信息
+        businesses.add(deleteInspectionPlan(reqJson, 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 ServiceCodeInspectionPlanConstant.DELETE_INSPECTIONPLAN;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    /**
+     * 添加小区信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    private JSONObject deleteInspectionPlan(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
+
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_DELETE_INSPECTION_PLAN);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONObject businessInspectionPlan = new JSONObject();
+        businessInspectionPlan.putAll(paramInJson);
+        //计算 应收金额
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessInspectionPlan", businessInspectionPlan);
+        return business;
+    }
+
+}

+ 120 - 0
Api/src/main/java/com/java110/api/listener/inspectionPlan/ListInspectionPlansListener.java

@@ -0,0 +1,120 @@
+package com.java110.api.listener.inspectionPlan;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.core.smo.org.IOrgInnerServiceSMO;
+import com.java110.core.smo.org.IOrgStaffRelInnerServiceSMO;
+import com.java110.core.smo.user.IUserInnerServiceSMO;
+import com.java110.dto.org.OrgStaffRelDto;
+import com.java110.dto.user.UserDto;
+import com.java110.utils.constant.ServiceCodeInspectionPlanConstant;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.smo.inspectionPlan.IInspectionPlanInnerServiceSMO;
+import com.java110.dto.inspectionPlan.InspectionPlanDto;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import com.java110.vo.api.inspectionPlan.ApiInspectionPlanDataVo;
+import com.java110.vo.api.inspectionPlan.ApiInspectionPlanVo;
+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.LinkedList;
+import java.util.List;
+
+
+/**
+ * 查询小区侦听类
+ */
+@Java110Listener("listInspectionPlansListener")
+public class ListInspectionPlansListener extends AbstractServiceApiListener {
+
+    @Autowired
+    private IInspectionPlanInnerServiceSMO inspectionPlanInnerServiceSMOImpl;
+    @Autowired
+    private IOrgStaffRelInnerServiceSMO iOrgStaffRelInnerServiceSMO;
+
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeInspectionPlanConstant.LIST_INSPECTIONPLANS;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.GET;
+    }
+
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    public IInspectionPlanInnerServiceSMO getInspectionPlanInnerServiceSMOImpl() {
+        return inspectionPlanInnerServiceSMOImpl;
+    }
+
+    public void setInspectionPlanInnerServiceSMOImpl(IInspectionPlanInnerServiceSMO inspectionPlanInnerServiceSMOImpl) {
+        this.inspectionPlanInnerServiceSMOImpl = inspectionPlanInnerServiceSMOImpl;
+    }
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        super.validatePageInfo(reqJson);
+    }
+
+    @Override
+    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
+
+        InspectionPlanDto inspectionPlanDto = BeanConvertUtil.covertBean(reqJson, InspectionPlanDto.class);
+
+        int count = inspectionPlanInnerServiceSMOImpl.queryInspectionPlansCount(inspectionPlanDto);
+
+        List<ApiInspectionPlanDataVo> inspectionPlans = null;
+
+        if (count > 0) {
+            inspectionPlans = BeanConvertUtil.covertBeanList(inspectionPlanInnerServiceSMOImpl.queryInspectionPlans(inspectionPlanDto), ApiInspectionPlanDataVo.class);
+            ArrayList staffIds = new ArrayList<>();
+            for( ApiInspectionPlanDataVo Plans : inspectionPlans){
+                if(Plans.getStaffId() != null){
+                    staffIds.add(Plans.getStaffId());
+                }
+            }
+            if(staffIds.size() > 0){
+                OrgStaffRelDto orgStaffRelDto = new OrgStaffRelDto();
+                String[] staffIdsArray=new String[staffIds.size()];
+                staffIds.toArray(staffIdsArray);
+                orgStaffRelDto.setStaffIds(staffIdsArray);
+                List<OrgStaffRelDto> orgStaffRelDtos = iOrgStaffRelInnerServiceSMO.queryOrgInfoByStaffIds(orgStaffRelDto);
+                for( ApiInspectionPlanDataVo planDataVo : inspectionPlans){
+                    for(OrgStaffRelDto orgs : orgStaffRelDtos){
+                        if(planDataVo.getStaffId().equals(orgs.getStaffId())){
+                            planDataVo.setDepartmentId(orgs.getDepartmentId());
+                            planDataVo.setDepartmentName(orgs.getDepartmentName());
+                            planDataVo.setCompanyId(orgs.getCompanyId());
+                            planDataVo.setCompanyName(orgs.getCompanyName());
+                        }
+                    }
+                }
+            }
+        } else {
+            inspectionPlans = new ArrayList<>();
+        }
+
+        ApiInspectionPlanVo apiInspectionPlanVo = new ApiInspectionPlanVo();
+
+        apiInspectionPlanVo.setTotal(count);
+        apiInspectionPlanVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
+        apiInspectionPlanVo.setInspectionPlans(inspectionPlans);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiInspectionPlanVo), HttpStatus.OK);
+
+        context.setResponseEntity(responseEntity);
+
+    }
+}

+ 101 - 0
Api/src/main/java/com/java110/api/listener/inspectionPlan/SaveInspectionPlanListener.java

@@ -0,0 +1,101 @@
+package com.java110.api.listener.inspectionPlan;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+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.BusinessTypeConstant;
+import com.java110.utils.constant.ServiceCodeInspectionPlanConstant;
+
+
+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("saveInspectionPlanListener")
+public class SaveInspectionPlanListener extends AbstractServiceApiListener {
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanName", "必填,请填写巡检计划名称");
+        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "必填,请填写巡检路线");
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanPeriod", "必填,请选择执行周期");
+        Assert.hasKeyAndValue(reqJson, "staffId", "必填,请填写执行人员");
+        Assert.hasKeyAndValue(reqJson, "startTime", "必填,请选择计划开始时间");
+        Assert.hasKeyAndValue(reqJson, "endTime", "必填,请选择结束时间");
+        Assert.hasKeyAndValue(reqJson, "signType", "必填,请填写签到方式");
+        Assert.hasKeyAndValue(reqJson, "state", "必填,请填写签到方式");
+
+    }
+
+    @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();
+
+        //添加单元信息
+        businesses.add(addInspectionPlan(reqJson, 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 ServiceCodeInspectionPlanConstant.ADD_INSPECTIONPLAN;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    /**
+     * 添加小区信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    private JSONObject addInspectionPlan(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
+
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_INSPECTION_PLAN);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONObject businessInspectionPlan = new JSONObject();
+        businessInspectionPlan.putAll(paramInJson);
+        businessInspectionPlan.put("inspectionPlanId", "-1");
+        //计算 应收金额
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessInspectionPlan", businessInspectionPlan);
+        return business;
+    }
+
+}

+ 98 - 0
Api/src/main/java/com/java110/api/listener/inspectionPlan/UpdateInspectionPlanListener.java

@@ -0,0 +1,98 @@
+package com.java110.api.listener.inspectionPlan;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.constant.CommonConstant;
+import com.java110.utils.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.entity.center.AppService;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import com.java110.utils.constant.ServiceCodeInspectionPlanConstant;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 保存巡检计划侦听
+ * add by wuxw 2019-06-30
+ */
+@Java110Listener("updateInspectionPlanListener")
+public class UpdateInspectionPlanListener extends AbstractServiceApiListener {
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanId", "巡检计划名称不能为空");
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanName", "必填,请填写巡检计划名称");
+        Assert.hasKeyAndValue(reqJson, "inspectionRouteId", "必填,请填写巡检路线");
+        Assert.hasKeyAndValue(reqJson, "inspectionPlanPeriod", "必填,请选择执行周期");
+        Assert.hasKeyAndValue(reqJson, "staffId", "必填,请填写执行人员");
+        Assert.hasKeyAndValue(reqJson, "startTime", "必填,请选择计划开始时间");
+        Assert.hasKeyAndValue(reqJson, "endTime", "必填,请选择结束时间");
+        Assert.hasKeyAndValue(reqJson, "signType", "必填,请填写签到方式");
+        Assert.hasKeyAndValue(reqJson, "state", "必填,请填写签到方式");
+
+    }
+
+    @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();
+
+        //添加单元信息
+        businesses.add(updateInspectionPlan(reqJson, 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 ServiceCodeInspectionPlanConstant.UPDATE_INSPECTIONPLAN;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    /**
+     * 添加巡检计划信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    private JSONObject updateInspectionPlan(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
+
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_INSPECTION_PLAN);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONObject businessInspectionPlan = new JSONObject();
+        businessInspectionPlan.putAll(paramInJson);
+        //计算 应收金额
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessInspectionPlan", businessInspectionPlan);
+        return business;
+    }
+
+}