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.utils.constant.BusinessTypeConstant;
|
import com.java110.utils.constant.CommonConstant;
|
import com.java110.utils.constant.ServiceCodeConstant;
|
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.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_AUDIT_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;
|
}
|
}
|