|
|
@@ -1,25 +1,23 @@
|
|
|
-package com.java110.api.listener.owner;
|
|
|
-
|
|
|
+package com.java110.user.cmd.owner;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.java110.api.listener.AbstractServiceApiDataFlowListener;
|
|
|
-import com.java110.core.annotation.Java110Listener;
|
|
|
-import com.java110.core.context.DataFlowContext;
|
|
|
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
|
+import com.java110.core.annotation.Java110Cmd;
|
|
|
+import com.java110.core.context.ICmdDataFlowContext;
|
|
|
+import com.java110.core.event.cmd.AbstractServiceCmdListener;
|
|
|
+import com.java110.core.event.cmd.CmdEvent;
|
|
|
import com.java110.dto.RoomDto;
|
|
|
import com.java110.dto.basePrivilege.BasePrivilegeDto;
|
|
|
import com.java110.dto.owner.OwnerDto;
|
|
|
import com.java110.intf.community.IMenuInnerServiceSMO;
|
|
|
import com.java110.intf.community.IRoomInnerServiceSMO;
|
|
|
import com.java110.intf.user.IOwnerInnerServiceSMO;
|
|
|
-import com.java110.utils.constant.ServiceCodeConstant;
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
import com.java110.utils.util.StringUtil;
|
|
|
import com.java110.vo.api.ApiOwnerDataVo;
|
|
|
import com.java110.vo.api.ApiOwnerVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
|
@@ -27,16 +25,8 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-/**
|
|
|
- * @ClassName OwnerDto
|
|
|
- * @Description 小区楼数据层侦听类
|
|
|
- * @Author wuxw
|
|
|
- * @Date 2019/4/24 8:52
|
|
|
- * @Version 1.0
|
|
|
- * add by wuxw 2019/4/24
|
|
|
- **/
|
|
|
-@Java110Listener("queryOwnersListener")
|
|
|
-public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
|
|
|
+@Java110Cmd(serviceCode = "owner.queryOwners")
|
|
|
+public class QueryOwnersCmd extends AbstractServiceCmdListener {
|
|
|
|
|
|
@Autowired
|
|
|
private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
|
|
|
@@ -47,36 +37,23 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
|
|
|
@Autowired
|
|
|
private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
- public String getServiceCode() {
|
|
|
- return ServiceCodeConstant.SERVICE_CODE_QUERY_OWNER;
|
|
|
+ public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
|
|
|
+ Assert.jsonObjectHaveKey(reqJson, "page", "请求中未包含page信息");
|
|
|
+ Assert.jsonObjectHaveKey(reqJson, "row", "请求中未包含row信息");
|
|
|
+ Assert.jsonObjectHaveKey(reqJson, "communityId", "请求中未包含communityId信息");
|
|
|
+ Assert.jsonObjectHaveKey(reqJson, "ownerTypeCd", "请求中未包含ownerTypeCd信息");
|
|
|
+ Assert.isInteger(reqJson.getString("page"), "不是有效数字");
|
|
|
+ Assert.isInteger(reqJson.getString("row"), "不是有效数字");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpMethod getHttpMethod() {
|
|
|
- return HttpMethod.GET;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 业务层数据处理
|
|
|
- *
|
|
|
- * @param event 时间对象
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void soService(ServiceDataFlowEvent event) {
|
|
|
- DataFlowContext dataFlowContext = event.getDataFlowContext();
|
|
|
- //获取请求数据
|
|
|
- JSONObject reqJson = dataFlowContext.getReqJson();
|
|
|
- validateOwnerData(reqJson);
|
|
|
- //获取当前用户id
|
|
|
- String userId = dataFlowContext.getUserId();
|
|
|
-
|
|
|
- //根据房屋查询时 先用 房屋信息查询 业主ID
|
|
|
+ public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
|
|
|
+//根据房屋查询时 先用 房屋信息查询 业主ID
|
|
|
freshRoomId(reqJson);
|
|
|
|
|
|
if (reqJson.containsKey("name")) {
|
|
|
- queryByCondition(reqJson, dataFlowContext);
|
|
|
+ queryByCondition(reqJson, cmdDataFlowContext);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -90,7 +67,7 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
|
|
|
List<OwnerDto> ownerDtos = new ArrayList<>();
|
|
|
if (total > 0) {
|
|
|
List<OwnerDto> ownerDtoList = ownerInnerServiceSMOImpl.queryOwners(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
|
|
|
- List<Map> mark = getPrivilegeOwnerList("/roomCreateFee", userId);
|
|
|
+ List<Map> mark = getPrivilegeOwnerList("/roomCreateFee", reqJson.getString("userId"));
|
|
|
for (OwnerDto ownerDto : ownerDtoList) {
|
|
|
//对业主身份证号隐藏处理
|
|
|
String idCard = ownerDto.getIdCard();
|
|
|
@@ -106,7 +83,6 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
|
|
|
}
|
|
|
ownerDtos.add(ownerDto);
|
|
|
}
|
|
|
- //freshRoomInfo(ownerDtos);
|
|
|
apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtos, ApiOwnerDataVo.class));
|
|
|
}
|
|
|
|
|
|
@@ -114,35 +90,7 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
|
|
|
|
|
|
|
|
|
ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiOwnerVo), HttpStatus.OK);
|
|
|
- dataFlowContext.setResponseEntity(responseEntity);
|
|
|
- }
|
|
|
-
|
|
|
- private void freshRoomInfo(List<OwnerDto> ownerDtos) {
|
|
|
- List<String> roomIds = new ArrayList<>();
|
|
|
- for (OwnerDto ownerDto : ownerDtos) {
|
|
|
- if (!StringUtil.isEmpty(ownerDto.getRoomId())) {
|
|
|
- roomIds.add(ownerDto.getRoomId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (roomIds.size() < 1) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- RoomDto tRoomDto = new RoomDto();
|
|
|
- tRoomDto.setCommunityId(ownerDtos.get(0).getCommunityId());
|
|
|
- tRoomDto.setRoomIds(roomIds.toArray(new String[roomIds.size()]));
|
|
|
- List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(tRoomDto);
|
|
|
-
|
|
|
- for (RoomDto roomDto : roomDtos) {
|
|
|
- for (OwnerDto tOwnerDto : ownerDtos) {
|
|
|
- if (!roomDto.getRoomId().equals(tOwnerDto.getRoomId())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- tOwnerDto.setRoomName(roomDto.getFloorNum() + "栋" + roomDto.getUnitNum() + "单元" + roomDto.getRoomNum());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ cmdDataFlowContext.setResponseEntity(responseEntity);
|
|
|
}
|
|
|
|
|
|
private void freshRoomId(JSONObject reqJson) {
|
|
|
@@ -182,11 +130,11 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
|
|
|
* 根据条件查询
|
|
|
*
|
|
|
* @param reqJson 查询信息
|
|
|
- * @param dataFlowContext 上下文
|
|
|
+ * @param cmdDataFlowContext 上下文
|
|
|
*/
|
|
|
- private void queryByCondition(JSONObject reqJson, DataFlowContext dataFlowContext) {
|
|
|
+ private void queryByCondition(JSONObject reqJson, ICmdDataFlowContext cmdDataFlowContext) {
|
|
|
//获取当前用户id
|
|
|
- String userId = dataFlowContext.getUserId();
|
|
|
+ String userId = reqJson.getString("userId");
|
|
|
int row = reqJson.getInteger("row");
|
|
|
ApiOwnerVo apiOwnerVo = new ApiOwnerVo();
|
|
|
int total = ownerInnerServiceSMOImpl.queryOwnerCountByCondition(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
|
|
|
@@ -216,36 +164,7 @@ public class QueryOwnersListener extends AbstractServiceApiDataFlowListener {
|
|
|
apiOwnerVo.setRecords((int) Math.ceil((double) total / (double) row));
|
|
|
|
|
|
ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiOwnerVo), HttpStatus.OK);
|
|
|
- dataFlowContext.setResponseEntity(responseEntity);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 校验查询条件是否满足条件
|
|
|
- *
|
|
|
- * @param reqJson 包含查询条件
|
|
|
- */
|
|
|
- private void validateOwnerData(JSONObject reqJson) {
|
|
|
- Assert.jsonObjectHaveKey(reqJson, "page", "请求中未包含page信息");
|
|
|
- Assert.jsonObjectHaveKey(reqJson, "row", "请求中未包含row信息");
|
|
|
- Assert.jsonObjectHaveKey(reqJson, "communityId", "请求中未包含communityId信息");
|
|
|
- Assert.jsonObjectHaveKey(reqJson, "ownerTypeCd", "请求中未包含ownerTypeCd信息");
|
|
|
- Assert.isInteger(reqJson.getString("page"), "不是有效数字");
|
|
|
- Assert.isInteger(reqJson.getString("row"), "不是有效数字");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getOrder() {
|
|
|
- return super.DEFAULT_ORDER;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public IOwnerInnerServiceSMO getOwnerInnerServiceSMOImpl() {
|
|
|
- return ownerInnerServiceSMOImpl;
|
|
|
- }
|
|
|
-
|
|
|
- public void setOwnerInnerServiceSMOImpl(IOwnerInnerServiceSMO ownerInnerServiceSMOImpl) {
|
|
|
- this.ownerInnerServiceSMOImpl = ownerInnerServiceSMOImpl;
|
|
|
+ cmdDataFlowContext.setResponseEntity(responseEntity);
|
|
|
}
|
|
|
|
|
|
/**
|