Browse Source

加入 小区审核功能

wuxw 6 years ago
parent
commit
4ceda0fd6f

+ 121 - 0
Api/src/main/java/com/java110/api/listener/community/AuditCommunityListener.java

@@ -0,0 +1,121 @@
+package com.java110.api.listener.community;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiListener;
+import com.java110.common.constant.BusinessTypeConstant;
+import com.java110.common.constant.CommonConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.util.Assert;
+import com.java110.common.util.BeanConvertUtil;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.smo.community.ICommunityInnerServiceSMO;
+import com.java110.dto.community.CommunityDto;
+import com.java110.entity.center.AppService;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 保存小区侦听
+ * add by wuxw 2019-06-30
+ */
+@Java110Listener("auditCommunity")
+public class AuditCommunityListener extends AbstractServiceApiListener {
+
+    @Autowired
+    private ICommunityInnerServiceSMO communityInnerServiceSMOImpl;
+
+    @Override
+    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
+
+        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
+        Assert.hasKeyAndValue(reqJson, "state", "必填,请填写小区审核状态");
+        Assert.hasKeyAndValue(reqJson, "remark", "必填,请填写小区审核原因");
+
+    }
+
+    @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(updateCommunity(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 ServiceCodeConstant.SERVICE_CODE_UPDATE_COMMUNITY;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+
+    /**
+     * 添加小区信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    private JSONObject updateCommunity(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
+        CommunityDto communityDto = new CommunityDto();
+        communityDto.setCommunityId(paramInJson.getString("communityId"));
+        List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto);
+        Assert.listOnlyOne(communityDtos, "未查询到该小区信息【" + communityDto.getCommunityId() + "】");
+        communityDto = communityDtos.get(0);
+
+        Map oldCommunityInfo = BeanConvertUtil.beanCovertMap(communityDto);
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_COMMUNITY_INFO);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONObject businessCommunity = new JSONObject();
+        businessCommunity.putAll(oldCommunityInfo);
+        businessCommunity.put("state", paramInJson.getString("state"));
+
+        //审核未通过原因未记录,后期存储在工作流框架中
+
+        //计算 应收金额
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessCommunity", businessCommunity);
+        return business;
+    }
+
+
+    public ICommunityInnerServiceSMO getCommunityInnerServiceSMOImpl() {
+        return communityInnerServiceSMOImpl;
+    }
+
+    public void setCommunityInnerServiceSMOImpl(ICommunityInnerServiceSMO communityInnerServiceSMOImpl) {
+        this.communityInnerServiceSMOImpl = communityInnerServiceSMOImpl;
+    }
+}

+ 2 - 0
CommunityService/src/main/java/com/java110/community/listener/AbstractCommunityBusinessServiceDataFlowListener.java

@@ -43,6 +43,7 @@ public abstract class AbstractCommunityBusinessServiceDataFlowListener extends A
         businessCommunityInfo.put("nearbyLandmarks", businessCommunityInfo.get("nearby_landmarks"));
         businessCommunityInfo.put("mapX", businessCommunityInfo.get("map_x"));
         businessCommunityInfo.put("mapY", businessCommunityInfo.get("map_y"));
+        businessCommunityInfo.put("state", businessCommunityInfo.get("state"));
         businessCommunityInfo.put("statusCd", statusCd);
     }
 
@@ -112,6 +113,7 @@ public abstract class AbstractCommunityBusinessServiceDataFlowListener extends A
         currentCommunityInfo.put("nearbyLandmarks", currentCommunityInfo.get("nearby_landmarks"));
         currentCommunityInfo.put("mapX", currentCommunityInfo.get("map_x"));
         currentCommunityInfo.put("mapY", currentCommunityInfo.get("map_y"));
+        currentCommunityInfo.put("state", currentCommunityInfo.get("state"));
         currentCommunityInfo.put("operate", StatusConstant.OPERATE_DEL);
         getCommunityServiceDaoImpl().saveBusinessCommunityInfo(currentCommunityInfo);
     }

+ 22 - 0
WebService/src/main/java/com/java110/web/components/community/AuditCommunityManageComponent.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.java110.common.constant.CommunityStateConstant;
 import com.java110.core.context.IPageData;
 import com.java110.core.context.PageData;
+import com.java110.web.smo.community.IAuditCommunitySMO;
 import com.java110.web.smo.community.IListCommunitysSMO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
@@ -24,6 +25,9 @@ public class AuditCommunityManageComponent {
     @Autowired
     private IListCommunitysSMO listCommunitysSMOImpl;
 
+    @Autowired
+    private IAuditCommunitySMO auditCommunitySMOImpl;
+
     /**
      * 查询小区列表
      *
@@ -41,6 +45,16 @@ public class AuditCommunityManageComponent {
         return listCommunitysSMOImpl.listCommunitys(newPd);
     }
 
+    /**
+     * 审核 小区
+     *
+     * @param pd 页面数据封装
+     * @return 返回 ResponseEntity 对象
+     */
+    public ResponseEntity<String> audit(IPageData pd) {
+        return auditCommunitySMOImpl.auditCommunity(pd);
+    }
+
     public IListCommunitysSMO getListCommunitysSMOImpl() {
         return listCommunitysSMOImpl;
     }
@@ -48,4 +62,12 @@ public class AuditCommunityManageComponent {
     public void setListCommunitysSMOImpl(IListCommunitysSMO listCommunitysSMOImpl) {
         this.listCommunitysSMOImpl = listCommunitysSMOImpl;
     }
+
+    public IAuditCommunitySMO getAuditCommunitySMOImpl() {
+        return auditCommunitySMOImpl;
+    }
+
+    public void setAuditCommunitySMOImpl(IAuditCommunitySMO auditCommunitySMOImpl) {
+        this.auditCommunitySMOImpl = auditCommunitySMOImpl;
+    }
 }

+ 19 - 0
WebService/src/main/java/com/java110/web/smo/community/IAuditCommunitySMO.java

@@ -0,0 +1,19 @@
+package com.java110.web.smo.community;
+
+import com.java110.core.context.IPageData;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 修改小区接口
+ *
+ * add by wuxw 2019-06-30
+ */
+public interface IAuditCommunitySMO {
+
+    /**
+     * 审核小区
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象
+     */
+    ResponseEntity<String> auditCommunity(IPageData pd);
+}

+ 64 - 0
WebService/src/main/java/com/java110/web/smo/community/impl/AuditCommunitySMOImpl.java

@@ -0,0 +1,64 @@
+package com.java110.web.smo.community.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.PrivilegeCodeConstant;
+import com.java110.common.constant.ServiceConstant;
+import com.java110.common.util.Assert;
+import com.java110.core.context.IPageData;
+import com.java110.web.core.AbstractComponentSMO;
+import com.java110.web.smo.community.IAuditCommunitySMO;
+import com.java110.web.smo.community.IEditCommunitySMO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * 审核小区服务实现类
+ * add by wuxw 2019-06-30
+ */
+@Service("auditCommunitySMOImpl")
+public class AuditCommunitySMOImpl extends AbstractComponentSMO implements IAuditCommunitySMO {
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Override
+    protected void validate(IPageData pd, JSONObject paramIn) {
+
+        //super.validatePageInfo(pd);
+
+        Assert.hasKeyAndValue(paramIn, "communityId", "小区ID不能为空");
+        Assert.hasKeyAndValue(paramIn, "state", "必填,请填写小区审核状态");
+        Assert.hasKeyAndValue(paramIn, "remark", "必填,请填写小区审核原因");
+
+
+        super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.AGENT_HAS_LIST_COMMUNITY);
+
+    }
+
+    @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/community.auditCommunity",
+                HttpMethod.POST);
+        return responseEntity;
+    }
+
+    @Override
+    public ResponseEntity<String> auditCommunity(IPageData pd) {
+        return super.businessProcess(pd);
+    }
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+}

+ 3 - 4
WebService/src/main/java/com/java110/web/smo/community/impl/EditCommunitySMOImpl.java

@@ -29,10 +29,9 @@ public class EditCommunitySMOImpl extends AbstractComponentSMO implements IEditC
         //super.validatePageInfo(pd);
 
         Assert.hasKeyAndValue(paramIn, "communityId", "小区ID不能为空");
-Assert.hasKeyAndValue(paramIn, "name", "必填,请填写小区名称");
-Assert.hasKeyAndValue(paramIn, "address", "必填,请填写小区地址");
-Assert.hasKeyAndValue(paramIn, "nearbyLandmarks", "必填,请填写小区附近地标");
-
+        Assert.hasKeyAndValue(paramIn, "name", "必填,请填写小区名称");
+        Assert.hasKeyAndValue(paramIn, "address", "必填,请填写小区地址");
+        Assert.hasKeyAndValue(paramIn, "nearbyLandmarks", "必填,请填写小区附近地标");
 
 
         super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.AGENT_HAS_LIST_COMMUNITY);

+ 20 - 4
WebService/src/main/resources/components/auditPackage/audit/audit.js

@@ -11,6 +11,19 @@
                 remark:''
             }
         },
+        watch:{
+            "auditInfo.state":{//深度监听,可监听到对象、数组的变化
+                handler(val, oldVal){
+                    if(vc.notNull(val) && vc.component.auditInfo.state == '1200'){
+                        vc.component.auditInfo.remark = "同意";
+                    }else{
+                        vc.component.auditInfo.remark = "";
+                    }
+
+                },
+                deep:true
+            }
+         },
          _initMethod:function(){
 
          },
@@ -37,6 +50,11 @@
                         },
                     ],
                     'auditInfo.remark':[
+                        {
+                            limit:"required",
+                            param:"",
+                            errInfo:"原因内容不能为空"
+                        },
                         {
                             limit:"maxLength",
                             param:"200",
@@ -50,12 +68,10 @@
                     vc.message(vc.validate.errInfo);
                     return ;
                 }
-
-                vc.component.addBasePrivilegeInfo.communityId = vc.getCurrentCommunity().communityId;
                 //不提交数据将数据 回调给侦听处理
                 if(vc.notNull($props.callBackListener)){
-                    vc.emit($props.callBackListener,$props.callBackFunction,vc.component.addBasePrivilegeInfo);
-                    $('#addBasePrivilegeModel').modal('hide');
+                    vc.emit($props.callBackListener,$props.callBackFunction,vc.component.auditInfo);
+                    $('#auditModel').modal('hide');
                     return ;
                 }
 

+ 4 - 1
WebService/src/main/resources/components/communityPackage/audit-community-manage/auditCommunityManage.html

@@ -58,6 +58,9 @@
             </div>
         </div>
     </div>
-    <vc:create name="audit"></vc:create>
+    <vc:create name="audit"
+               callBackListener="auditCommunityManage"
+               callBackFunction="notifyAuditInfo"
+    ></vc:create>
 
 </div>

+ 29 - 2
WebService/src/main/resources/components/communityPackage/audit-community-manage/auditCommunityManage.js

@@ -9,7 +9,8 @@
             auditCommunityManageInfo:{
                 communitys:[],
                 total:0,
-                records:1
+                records:1,
+                currentCommunityId:''
             }
         },
         _initMethod:function(){
@@ -18,6 +19,9 @@
         _initEvent:function(){
             vc.on('communityManage','listCommunity',function(_param){
                   vc.component._listCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
+            });
+            vc.on('communityManage','notifyAuditInfo',function(_auditInfo){
+                  vc.component._auditCommunityState(_auditInfo);
             });
              vc.on('pagination','page_event',function(_currentPage){
                 vc.component._listCommunitys(_currentPage,DEFAULT_ROWS);
@@ -50,8 +54,31 @@
                              }
                            );
             },
-            _openAuditCommunityModal:function(){
+            _openAuditCommunityModal:function(_community){
+                vc.component.auditCommunityManageInfo.currentCommunityId = _community.communityId;
                 vc.emit('audit','openAuditModal',{});
+            },
+            _auditCommunityState:function(_auditInfo){
+                vc.http.post(
+                    'auditCommunityManage',
+                    'audit',
+                    JSON.stringify(_auditInfo),
+                    {
+                        emulateJSON:true
+                     },
+                     function(json,res){
+                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
+                        if(res.status == 200){
+                            //关闭model
+                             vc.component._listCommunitys(DEFAULT_PAGE, DEFAULT_ROWS);
+                            return ;
+                        }
+                        vc.message(json);
+                     },
+                     function(errInfo,error){
+                        console.log('请求失败处理');
+                        vc.message(errInfo);
+                });
             }
 
         }

+ 9 - 6
java110-db/src/main/resources/mapper/community/CommunityServiceDaoImplMapper.xml

@@ -6,8 +6,8 @@
     
     <!-- 保存小区信息 add by wuxw 2018-07-03 -->
     <insert id="saveBusinessCommunityInfo" parameterType="Map">
-        insert into business_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,month,operate)
-        values(#{communityId},#{bId},#{name},#{address},#{cityCode},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{operate})
+        insert into business_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,month,state,operate)
+        values(#{communityId},#{bId},#{name},#{address},#{cityCode},#{nearbyLandmarks},#{mapX},#{mapY},#{month},#{state},#{operate})
     </insert>
     <!-- 保存小区属性信息  add by wuxw 2018-07-03 -->
     <insert id="saveBusinessCommunityAttr" parameterType="Map">
@@ -23,7 +23,7 @@
 
     <!-- 查询小区信息(Business) add by wuxw 2018-07-03 -->
     <select id="getBusinessCommunityInfo" parameterType="Map" resultType="Map">
-        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.operate
+        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.operate,s.state
         from business_community s where 1 = 1
         <if test="operate != null and operate != ''">
             and s.operate = #{operate}
@@ -73,8 +73,8 @@
 
     <!-- 保存小区信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveCommunityInfoInstance" parameterType="Map">
-        insert into s_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,status_cd)
-        values(#{community_id},#{b_id},#{name},#{address},#{city_code},#{nearby_landmarks},#{map_x},#{map_y},'0')
+        insert into s_community(community_id,b_id,name,address,city_code,nearby_landmarks,map_x,map_y,status_cd,state)
+        values(#{community_id},#{b_id},#{name},#{address},#{city_code},#{nearby_landmarks},#{map_x},#{map_y},'0',#{state})
     </insert>
 
     <!-- 保存小区属性信息到 instance add by wuxw 2018-07-03 -->
@@ -102,7 +102,7 @@
 
     <!-- 查询小区信息 add by wuxw 2018-07-03 -->
     <select id="getCommunityInfo" parameterType="Map" resultType="Map">
-        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd
+        select s.community_id,s.b_id,s.name,s.address,s.city_code,s.nearby_landmarks,s.map_x,s.map_y,s.status_cd,s.state
         from s_community s
         where 1=1
         <if test="statusCd != null and statusCd != ''">
@@ -180,6 +180,9 @@
         <if test="mapY != null and mapY != ''">
             ,s.map_y = #{mapY}
         </if>
+        <if test="state != null and state != ''">
+            ,s.state = #{state}
+        </if>
         where 1=1
         <if test="bId != null and bId !=''">
             and s.b_id = #{bId}