From 307bc98d632594a5081d1bf21b392277df2b6893 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期五, 28 二月 2025 18:32:55 +0800
Subject: [PATCH] 运营加入 房屋和房屋明细功能
---
service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnersCmd.java | 181 +++++++++++++++++++++++++--------------------
1 files changed, 100 insertions(+), 81 deletions(-)
diff --git a/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnersCmd.java b/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnersCmd.java
index 076209a..346b4bc 100644
--- a/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnersCmd.java
+++ b/service-user/src/main/java/com/java110/user/cmd/owner/QueryOwnersCmd.java
@@ -2,19 +2,26 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.CmdContextUtils;
import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.AbstractServiceCmdListener;
+import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
-import com.java110.dto.RoomDto;
-import com.java110.dto.basePrivilege.BasePrivilegeDto;
+import com.java110.doc.annotation.*;
+import com.java110.dto.room.RoomDto;
+import com.java110.dto.privilege.BasePrivilegeDto;
+import com.java110.dto.file.FileRelDto;
import com.java110.dto.owner.OwnerDto;
+import com.java110.intf.common.IFileRelInnerServiceSMO;
import com.java110.intf.community.IMenuInnerServiceSMO;
import com.java110.intf.community.IRoomInnerServiceSMO;
import com.java110.intf.user.IOwnerInnerServiceSMO;
+import com.java110.user.bmo.owner.IQueryOwnerStatisticsBMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.ListUtil;
import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
import com.java110.vo.api.ApiOwnerDataVo;
import com.java110.vo.api.ApiOwnerVo;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,8 +32,69 @@
import java.util.List;
import java.util.Map;
+@Java110CmdDoc(title = "鏌ヨ涓氫富",
+ description = "绗笁鏂圭郴缁燂紝姣斿鎷涘晢绯荤粺鏌ヨ涓氫富淇℃伅",
+ httpMethod = "get",
+ url = "http://{ip}:{port}/app/owner.queryOwners",
+ resource = "userDoc",
+ author = "鍚村鏂�",
+ serviceCode = "owner.queryOwners",
+ seq = 12
+)
+
+@Java110ParamsDoc(params = {
+ @Java110ParamDoc(name = "page", type = "int", length = 11, remark = "椤垫暟"),
+ @Java110ParamDoc(name = "row", type = "int", length = 11, remark = "琛屾暟"),
+ @Java110ParamDoc(name = "communityId", length = 30, remark = "灏忓尯ID"),
+ @Java110ParamDoc(name = "name", length = 64, remark = "涓氫富鍚嶇О"),
+ @Java110ParamDoc(name = "link", length = 11, remark = "涓氫富鎵嬫満鍙�"),
+ @Java110ParamDoc(name = "idCard", length = 30, remark = "涓氫富韬唤璇佸彿"),
+ @Java110ParamDoc(name = "ownerTypeCd", length = 12, remark = "涓氫富绫诲瀷 1001 涓氫富 2002 瀹跺涵鎴愬憳 瀹跺涵鎴愬憳 闇�瑕佷紶涓氫富鐨刼wnerId"),
+ @Java110ParamDoc(name = "ownerId", length = 30, remark = "涓氫富ID锛屽搴垚鍛樹笟涓籌D"),
+ @Java110ParamDoc(name = "memberId", length = 30, remark = "涓氫富ID锛屼富閿甀D"),
+})
+
+@Java110ResponseDoc(
+ params = {
+ @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "杩斿洖缂栧彿锛�0 鎴愬姛 鍏朵粬澶辫触"),
+ @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "鎴愬姛", remark = "鎻忚堪"),
+ @Java110ParamDoc(name = "owners", type = "Array", length = -1, defaultValue = "鎴愬姛", remark = "鏁版嵁"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "communityId", length = 30, remark = "灏忓尯ID"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "name", length = 64, remark = "涓氫富鍚嶇О"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "link", length = 11, remark = "涓氫富鎵嬫満鍙�"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "idCard", length = 30, remark = "涓氫富韬唤璇佸彿"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "address", length = 512, remark = "鍦板潃"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "sex", length = 12, remark = "鎬у埆 鐢� 1 濂� 0"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "ownerTypeCd", length = 12, remark = "涓氫富绫诲瀷 1001 涓氫富 2002 瀹跺涵鎴愬憳 瀹跺涵鎴愬憳 闇�瑕佷紶涓氫富鐨刼wnerId"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "remark", length = 512, remark = "澶囨敞"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "memberId", length = 30, remark = "涓氫富ID"),
+ @Java110ParamDoc(parentNodeName = "owners", name = "ownerPhoto", length = -1, remark = "涓氫富浜鸿劯 鐢ㄤ簬鍚屾闂ㄧ 浜鸿劯寮�闂�"),
+ }
+)
+
+@Java110ExampleDoc(
+ reqBody = "http://ip:port/app/owner.queryOwners?ownerTypeCd=1001&page=1&row=10&communityId=2022121921870161",
+ resBody = "{\n" +
+ "\t\"owners\": [{\n" +
+ "\t\t\"address\": \"寮犱笁\",\n" +
+ "\t\t\"idCard\": \"\",\n" +
+ "\t\t\"link\": \"18909718888\",\n" +
+ "\t\t\"memberId\": \"772023012589770046\",\n" +
+ "\t\t\"name\": \"鐜嬬帇\",\n" +
+ "\t\t\"ownerId\": \"772023012589770046\",\n" +
+ "\t\t\"ownerTypeCd\": \"1001\",\n" +
+ "\t\t\"remark\": \"\",\n" +
+ "\t\t\"sex\": \"0\",\n" +
+ "\t\t\"userName\": \"浜哄拰鐗╀笟\"\n" +
+ "\t}],\n" +
+ "\t\"page\": 0,\n" +
+ "\t\"records\": 1,\n" +
+ "\t\"rows\": 0,\n" +
+ "\t\"total\": 1\n" +
+ "}"
+)
@Java110Cmd(serviceCode = "owner.queryOwners")
-public class QueryOwnersCmd extends AbstractServiceCmdListener {
+public class QueryOwnersCmd extends Cmd {
@Autowired
private IOwnerInnerServiceSMO ownerInnerServiceSMOImpl;
@@ -37,135 +105,86 @@
@Autowired
private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
+ @Autowired
+ private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
+
+ @Autowired
+ private IQueryOwnerStatisticsBMO queryOwnerStatisticsBMOImpl;
+
@Override
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+ super.validateProperty(cmdDataFlowContext);
Assert.jsonObjectHaveKey(reqJson, "page", "璇锋眰涓湭鍖呭惈page淇℃伅");
Assert.jsonObjectHaveKey(reqJson, "row", "璇锋眰涓湭鍖呭惈row淇℃伅");
- Assert.jsonObjectHaveKey(reqJson, "communityId", "璇锋眰涓湭鍖呭惈communityId淇℃伅");
- Assert.jsonObjectHaveKey(reqJson, "ownerTypeCd", "璇锋眰涓湭鍖呭惈ownerTypeCd淇℃伅");
+ Assert.hasKeyAndValue(reqJson, "communityId", "璇锋眰涓湭鍖呭惈communityId淇℃伅");
Assert.isInteger(reqJson.getString("page"), "涓嶆槸鏈夋晥鏁板瓧");
Assert.isInteger(reqJson.getString("row"), "涓嶆槸鏈夋晥鏁板瓧");
}
@Override
public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
-//鏍规嵁鎴垮眿鏌ヨ鏃� 鍏堢敤 鎴垮眿淇℃伅鏌ヨ 涓氫富ID
- freshRoomId(reqJson);
- if (reqJson.containsKey("name") && !StringUtil.isEmpty(reqJson.getString("name"))) {
- queryByCondition(reqJson, cmdDataFlowContext);
- return;
- }
+ String userId = CmdContextUtils.getUserId(cmdDataFlowContext);
+
+ //todo 鏍规嵁鎴垮眿鏌ヨ鏃� 鍏堢敤 鎴垮眿淇℃伅鏌ヨ 涓氫富ID
+ freshRoomId(reqJson);
+ OwnerDto ownerDto = BeanConvertUtil.covertBean(reqJson, OwnerDto.class);
int row = reqJson.getInteger("row");
-
- ApiOwnerVo apiOwnerVo = new ApiOwnerVo();
-
//鏌ヨ鎬昏褰曟暟
- int total = ownerInnerServiceSMOImpl.queryOwnersCount(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
- apiOwnerVo.setTotal(total);
- List<OwnerDto> ownerDtos = new ArrayList<>();
+ int total = ownerInnerServiceSMOImpl.queryOwnersCount(ownerDto);
+ List<OwnerDto> ownerDtos = null;
if (total > 0) {
- List<OwnerDto> ownerDtoList = ownerInnerServiceSMOImpl.queryOwners(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
- List<Map> mark = getPrivilegeOwnerList("/roomCreateFee", reqJson.getString("userId"));
- for (OwnerDto ownerDto : ownerDtoList) {
+ ownerDtos = ownerInnerServiceSMOImpl.queryOwners(ownerDto);
+ // 鏌ヨ缁熻鏁版嵁
+ ownerDtos = queryOwnerStatisticsBMOImpl.query(ownerDtos);
+ List<Map> mark = getPrivilegeOwnerList("/roomCreateFee", userId);
+ for (OwnerDto tmpOwnerDto : ownerDtos) {
//瀵逛笟涓昏韩浠借瘉鍙烽殣钘忓鐞�
- String idCard = ownerDto.getIdCard();
+ String idCard = tmpOwnerDto.getIdCard();
if (mark.size() == 0 && idCard != null && !idCard.equals("") && idCard.length() > 16) {
idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16);
- ownerDto.setIdCard(idCard);
+ tmpOwnerDto.setIdCard(idCard);
}
//瀵逛笟涓绘墜鏈哄彿闅愯棌澶勭悊
- String link = ownerDto.getLink();
+ String link = tmpOwnerDto.getLink();
if (mark.size() == 0 && link != null && !link.equals("") && link.length() == 11) {
link = link.substring(0, 3) + "****" + link.substring(7);
- ownerDto.setLink(link);
+ tmpOwnerDto.setLink(link);
}
- ownerDtos.add(ownerDto);
}
- apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtos, ApiOwnerDataVo.class));
+ } else {
+ ownerDtos = new ArrayList<>();
}
-
- apiOwnerVo.setRecords((int) Math.ceil((double) total / (double) row));
-
-
- ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiOwnerVo), HttpStatus.OK);
+ ResponseEntity<String> responseEntity = ResultVo.createResponseEntity((int) Math.ceil((double) total / (double) row), total, ownerDtos);
cmdDataFlowContext.setResponseEntity(responseEntity);
}
private void freshRoomId(JSONObject reqJson) {
-
if (!reqJson.containsKey("roomName")) {
return;
}
-
String roomName = reqJson.getString("roomName");
if (StringUtil.isEmpty(roomName)) {
return;
}
-
if (!roomName.contains("-")) {
throw new IllegalArgumentException("鎴垮眿鏍煎紡閿欒,璇峰啓鍏ュ 妤兼爧-鍗曞厓-鎴垮眿 鏍煎紡");
}
-
- String[] params = roomName.split("-");
+ String[] params = roomName.split("-", 3);
if (params.length != 3) {
throw new IllegalArgumentException("鎴垮眿鏍煎紡閿欒,璇峰啓鍏ュ 妤兼爧-鍗曞厓-鎴垮眿 鏍煎紡");
}
-
RoomDto roomDto = new RoomDto();
roomDto.setFloorNum(params[0]);
roomDto.setUnitNum(params[1]);
roomDto.setRoomNum(params[2]);
roomDto.setCommunityId(reqJson.getString("communityId"));
List<RoomDto> roomDtos = roomInnerServiceSMOImpl.queryRooms(roomDto);
-
Assert.listOnlyOne(roomDtos, "鏈煡璇㈠埌鎴垮眿涓嬩笟涓讳俊鎭�");
-
reqJson.put("roomId", roomDtos.get(0).getRoomId());
-
}
- /**
- * 鏍规嵁鏉′欢鏌ヨ
- *
- * @param reqJson 鏌ヨ淇℃伅
- * @param cmdDataFlowContext 涓婁笅鏂�
- */
- private void queryByCondition(JSONObject reqJson, ICmdDataFlowContext cmdDataFlowContext) {
- //鑾峰彇褰撳墠鐢ㄦ埛id
- String userId = reqJson.getString("userId");
- int row = reqJson.getInteger("row");
- ApiOwnerVo apiOwnerVo = new ApiOwnerVo();
- int total = ownerInnerServiceSMOImpl.queryOwnerCountByCondition(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
- apiOwnerVo.setTotal(total);
- List<OwnerDto> ownerDtos = new ArrayList<>();
- if (total > 0) {
- List<OwnerDto> ownerDtoList = ownerInnerServiceSMOImpl.queryOwnersByCondition(BeanConvertUtil.covertBean(reqJson, OwnerDto.class));
- List<Map> mark = getPrivilegeOwnerList("/roomCreateFee", userId);
- for (OwnerDto ownerDto : ownerDtoList) {
- //瀵逛笟涓昏韩浠借瘉鍙烽殣钘忓鐞�
- String idCard = ownerDto.getIdCard();
- if (mark.size() == 0 && !StringUtil.isEmpty(idCard) && idCard.length() > 16) {
- idCard = idCard.substring(0, 6) + "**********" + idCard.substring(16);
- ownerDto.setIdCard(idCard);
- }
- //瀵逛笟涓绘墜鏈哄彿闅愯棌澶勭悊
- String link = ownerDto.getLink();
- if (mark.size() == 0 && !StringUtil.isEmpty(link) && link.length() == 11) {
- link = link.substring(0, 3) + "****" + link.substring(7);
- ownerDto.setLink(link);
- }
- ownerDtos.add(ownerDto);
- }
- apiOwnerVo.setOwners(BeanConvertUtil.covertBeanList(ownerDtos, ApiOwnerDataVo.class));
- }
-
- apiOwnerVo.setRecords((int) Math.ceil((double) total / (double) row));
-
- ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiOwnerVo), HttpStatus.OK);
- cmdDataFlowContext.setResponseEntity(responseEntity);
- }
/**
* 鑴辨晱澶勭悊
--
Gitblit v1.8.0