Skip to content

Commit 285c5b8

Browse files
committed
物业开发测试完成
1 parent 82f9a4e commit 285c5b8

12 files changed

+415
-607
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"orders": {
3+
"appId": "外系统ID,分配得到",
4+
"transactionId": "100000000020180409224736000001",
5+
"userId": "用户ID",
6+
"orderTypeCd": "订单类型,查询,受理",
7+
"requestTime": "20180409224736",
8+
"remark": "备注",
9+
"sign": "这个服务是否要求MD5签名",
10+
"attrs": [{
11+
"specCd": "配置的字段ID",
12+
"value": "具体值"
13+
}]
14+
},
15+
"business": {
16+
"serviceCode": "delete.property.attr",
17+
"serviceName": "删除物业属性",
18+
"remark": "备注",
19+
"datas": {
20+
"businessPropertyAttr": [{
21+
"attrId":"112018121800000002"
22+
}]
23+
},
24+
"attrs": [{
25+
"specCd": "配置的字段ID",
26+
"value": "具体值"
27+
}]
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"orders": {
3+
"appId": "外系统ID,分配得到",
4+
"transactionId": "100000000020180409224736000001",
5+
"userId": "用户ID",
6+
"orderTypeCd": "订单类型,查询,受理",
7+
"requestTime": "20180409224736",
8+
"remark": "备注",
9+
"sign": "这个服务是否要求MD5签名",
10+
"attrs": [{
11+
"specCd": "配置的字段ID",
12+
"value": "具体值"
13+
}]
14+
},
15+
"business": {
16+
"serviceCode": "delete.property.cerdentials",
17+
"serviceName": "删除商户证件信息",
18+
"remark": "备注",
19+
"datas": {
20+
"businessPropertyCerdentials":[{
21+
"propertyCerdentialsId":"9220181218000002"
22+
}]
23+
},
24+
"attrs": [{
25+
"specCd": "配置的字段ID",
26+
"value": "具体值"
27+
}]
28+
}
29+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"orders": {
3+
"appId": "外系统ID,分配得到",
4+
"transactionId": "100000000020180409224736000001",
5+
"userId": "用户ID",
6+
"orderTypeCd": "订单类型,查询,受理",
7+
"requestTime": "20180409224736",
8+
"remark": "备注",
9+
"sign": "这个服务是否要求MD5签名",
10+
"attrs": [{
11+
"specCd": "配置的字段ID",
12+
"value": "具体值"
13+
}]
14+
},
15+
"business": {
16+
"serviceCode": "delete.property.house",
17+
"serviceName": "删除住户",
18+
"remark": "备注",
19+
"datas": {
20+
"businessPropertyHouse":{
21+
"houseId":"9520181222000005"
22+
},
23+
"businessPropertyHouseAttr": [{
24+
"houseId": "9520181222000005",
25+
"attrId":"112018122200000006"
26+
}]
27+
},
28+
"attrs": [{
29+
"specCd": "配置的字段ID",
30+
"value": "具体值"
31+
}]
32+
}
33+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"orders": {
3+
"appId": "外系统ID,分配得到",
4+
"transactionId": "100000000020180409224736000001",
5+
"userId": "用户ID",
6+
"orderTypeCd": "订单类型,查询,受理",
7+
"requestTime": "20180409224736",
8+
"remark": "备注",
9+
"sign": "这个服务是否要求MD5签名",
10+
"attrs": [{
11+
"specCd": "配置的字段ID",
12+
"value": "具体值"
13+
}]
14+
},
15+
"business": {
16+
"serviceCode": "delete.property.photo",
17+
"serviceName": "删除物业照片信息",
18+
"remark": "备注",
19+
"datas": {
20+
"businessPropertyPhoto":[{
21+
"propertyPhotoId":"12320181218000001"
22+
}]
23+
},
24+
"attrs": [{
25+
"specCd": "配置的字段ID",
26+
"value": "具体值"
27+
}]
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"orders": {
3+
"appId": "外系统ID,分配得到",
4+
"transactionId": "100000000020180409224736000001",
5+
"userId": "用户ID",
6+
"orderTypeCd": "订单类型,查询,受理",
7+
"requestTime": "20180409224736",
8+
"remark": "备注",
9+
"sign": "这个服务是否要求MD5签名",
10+
"attrs": [{
11+
"specCd": "配置的字段ID",
12+
"value": "具体值"
13+
}]
14+
},
15+
"business": {
16+
"serviceCode": "delete.property.user",
17+
"serviceName": "删除住户信息",
18+
"remark": "备注",
19+
"datas": {
20+
"businessPropertyUser":[{
21+
"propertyUserId":"9320181219000001"
22+
}]
23+
},
24+
"attrs": [{
25+
"specCd": "配置的字段ID",
26+
"value": "具体值"
27+
}]
28+
}
29+
}

PropertyService/src/main/java/com/java110/property/listener/AbstractPropertyBusinessServiceDataFlowListener.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ protected void flushBusinessPropertyPhoto(Map businessPropertyPhoto,String statu
9999
businessPropertyPhoto.put("statusCd",statusCd);
100100
}
101101

102+
/**
103+
* 刷新 businessPropertyPhoto 数据
104+
* @param businessPropertyUser
105+
* @param statusCd
106+
*/
107+
protected void flushBusinessPropertyUser(Map businessPropertyUser,String statusCd){
108+
businessPropertyUser.put("propertyId",businessPropertyUser.get("property_id"));
109+
businessPropertyUser.put("propertyUserId",businessPropertyUser.get("property_user_id"));
110+
businessPropertyUser.put("userId",businessPropertyUser.get("user_id"));
111+
businessPropertyUser.put("relCd",businessPropertyUser.get("rel_cd"));
112+
businessPropertyUser.put("newBId",businessPropertyUser.get("b_id"));
113+
businessPropertyUser.put("statusCd",statusCd);
114+
}
115+
116+
102117
/**
103118
* 刷新 businessPropertyPhoto 数据
104119
* @param businessPropertyFee
@@ -270,6 +285,30 @@ protected void autoSaveDelBusinessPropertyPhoto(Business business,JSONObject bus
270285
getPropertyServiceDaoImpl().saveBusinessPropertyPhoto(currentPropertyPhoto);
271286
}
272287

288+
/**
289+
* 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
290+
* @param business
291+
* @param businessPropertyUser 物业用户
292+
*/
293+
protected void autoSaveDelBusinessPropertyUser(Business business,JSONObject businessPropertyUser){
294+
Map info = new HashMap();
295+
info.put("propertyUserId",businessPropertyUser.getString("propertyUserId"));
296+
info.put("propertyId",businessPropertyUser.getString("propertyId"));
297+
info.put("statusCd",StatusConstant.STATUS_CD_VALID);
298+
List<Map> currentPropertyUsers = getPropertyServiceDaoImpl().getPropertyUser(info);
299+
if(currentPropertyUsers == null || currentPropertyUsers.size() != 1){
300+
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"未找到需要修改数据信息,入参错误或数据有问题,请检查"+info);
301+
}
302+
Map currentPropertyUser = currentPropertyUsers.get(0);
303+
currentPropertyUser.put("bId",business.getbId());
304+
currentPropertyUser.put("propertyUserId",currentPropertyUser.get("property_user_id"));
305+
currentPropertyUser.put("propertyId",currentPropertyUser.get("property_id"));
306+
currentPropertyUser.put("userId",currentPropertyUser.get("user_id"));
307+
currentPropertyUser.put("relCd",currentPropertyUser.get("rel_cd"));
308+
currentPropertyUser.put("operate",StatusConstant.OPERATE_DEL);
309+
getPropertyServiceDaoImpl().saveBusinessPropertyUser(currentPropertyUser);
310+
}
311+
273312
/**
274313
* 当修改数据时,查询instance表中的数据 自动保存删除数据到business中
275314
* @param business
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
package com.java110.property.listener;
2+
3+
import com.alibaba.fastjson.JSONArray;
4+
import com.alibaba.fastjson.JSONObject;
5+
import com.java110.common.constant.ResponseConstant;
6+
import com.java110.common.constant.ServiceCodeConstant;
7+
import com.java110.common.constant.StatusConstant;
8+
import com.java110.common.exception.ListenerExecuteException;
9+
import com.java110.common.util.Assert;
10+
import com.java110.core.annotation.Java110Listener;
11+
import com.java110.core.context.DataFlowContext;
12+
import com.java110.entity.center.Business;
13+
import com.java110.property.dao.IPropertyServiceDao;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
16+
import org.springframework.beans.factory.annotation.Autowired;
17+
import org.springframework.transaction.annotation.Transactional;
18+
19+
import java.util.HashMap;
20+
import java.util.List;
21+
import java.util.Map;
22+
23+
/**
24+
* 删除物业信息 侦听
25+
*
26+
* 处理节点
27+
* 1、businessPropertyHouse:{} 物业住户信息节点
28+
* 2、businessPropertyAttr:[{}] 物业属性信息节点
29+
* Created by wuxw on 2018/5/18.
30+
*/
31+
@Java110Listener("deletePropertyAttrListener")
32+
@Transactional
33+
public class DeletePropertyAttrListener extends AbstractPropertyBusinessServiceDataFlowListener {
34+
35+
private final static Logger logger = LoggerFactory.getLogger(DeletePropertyAttrListener.class);
36+
@Autowired
37+
IPropertyServiceDao propertyServiceDaoImpl;
38+
39+
@Override
40+
public int getOrder() {
41+
return 3;
42+
}
43+
44+
@Override
45+
public String getServiceCode() {
46+
return ServiceCodeConstant.SERVICE_CODE_DELETE_PROPERTY_ATTR;
47+
}
48+
49+
/**
50+
* 根据删除信息 查出Instance表中数据 保存至business表 (状态写DEL) 方便撤单时直接更新回去
51+
* @param dataFlowContext 数据对象
52+
* @param business 当前业务对象
53+
*/
54+
@Override
55+
protected void doSaveBusiness(DataFlowContext dataFlowContext, Business business) {
56+
JSONObject data = business.getDatas();
57+
58+
Assert.notEmpty(data,"没有datas 节点,或没有子节点需要处理");
59+
60+
if(data.containsKey("businessPropertyAttr")){
61+
JSONArray businessPropertyAttrs = data.getJSONArray("businessPropertyAttr");
62+
doSaveBusinessPropertyAttrs(business,businessPropertyAttrs);
63+
}
64+
}
65+
66+
/**
67+
* 删除 instance数据
68+
* @param dataFlowContext 数据对象
69+
* @param business 当前业务对象
70+
*/
71+
@Override
72+
protected void doBusinessToInstance(DataFlowContext dataFlowContext, Business business) {
73+
String bId = business.getbId();
74+
//Assert.hasLength(bId,"请求报文中没有包含 bId");
75+
76+
//物业信息
77+
Map info = new HashMap();
78+
info.put("bId",business.getbId());
79+
info.put("operate",StatusConstant.OPERATE_DEL);
80+
81+
//物业属性
82+
List<Map> businessPropertyAttrs = propertyServiceDaoImpl.getBusinessPropertyAttrs(info);
83+
if(businessPropertyAttrs != null && businessPropertyAttrs.size() > 0) {
84+
for(Map businessPropertyAttr : businessPropertyAttrs) {
85+
flushBusinessPropertyAttr(businessPropertyAttr,StatusConstant.STATUS_CD_INVALID);
86+
propertyServiceDaoImpl.updatePropertyAttrInstance(businessPropertyAttr);
87+
}
88+
}
89+
}
90+
91+
/**
92+
* 撤单
93+
* 从business表中查询到DEL的数据 将instance中的数据更新回来
94+
* @param dataFlowContext 数据对象
95+
* @param business 当前业务对象
96+
*/
97+
@Override
98+
protected void doRecover(DataFlowContext dataFlowContext, Business business) {
99+
String bId = business.getbId();
100+
//Assert.hasLength(bId,"请求报文中没有包含 bId");
101+
Map info = new HashMap();
102+
info.put("bId",bId);
103+
info.put("statusCd",StatusConstant.STATUS_CD_INVALID);
104+
105+
Map delInfo = new HashMap();
106+
delInfo.put("bId",business.getbId());
107+
delInfo.put("operate",StatusConstant.OPERATE_DEL);
108+
109+
//物业属性
110+
List<Map> propertyAttrs = propertyServiceDaoImpl.getPropertyAttrs(info);
111+
if(propertyAttrs != null && propertyAttrs.size()>0){
112+
113+
List<Map> businessPropertyAttrs = propertyServiceDaoImpl.getBusinessPropertyAttrs(delInfo);
114+
//除非程序出错了,这里不会为空
115+
if(businessPropertyAttrs == null || businessPropertyAttrs.size() ==0 ){
116+
throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_INNER_ERROR,"撤单失败(property_attr),程序内部异常,请检查! "+delInfo);
117+
}
118+
for(Map businessPropertyAttr : businessPropertyAttrs) {
119+
flushBusinessPropertyAttr(businessPropertyAttr,StatusConstant.STATUS_CD_VALID);
120+
propertyServiceDaoImpl.updatePropertyAttrInstance(businessPropertyAttr);
121+
}
122+
}
123+
}
124+
125+
126+
127+
/**
128+
* 保存物业属性信息
129+
* @param business 当前业务
130+
* @param businessPropertyAttrs 物业属性
131+
*/
132+
private void doSaveBusinessPropertyAttrs(Business business,JSONArray businessPropertyAttrs){
133+
JSONObject data = business.getDatas();
134+
135+
for(int propertyAttrIndex = 0 ; propertyAttrIndex < businessPropertyAttrs.size();propertyAttrIndex ++){
136+
JSONObject propertyAttr = businessPropertyAttrs.getJSONObject(propertyAttrIndex);
137+
Assert.jsonObjectHaveKey(propertyAttr,"attrId","businessPropertyAttr 节点下没有包含 attrId 节点");
138+
if(propertyAttr.getString("attrId").startsWith("-")){
139+
throw new ListenerExecuteException(ResponseConstant.RESULT_PARAM_ERROR,"attrId 错误,不能自动生成(必须已经存在的attrId)"+propertyAttr);
140+
}
141+
142+
autoSaveDelBusinessPropertyAttr(business,propertyAttr);
143+
}
144+
}
145+
146+
public IPropertyServiceDao getPropertyServiceDaoImpl() {
147+
return propertyServiceDaoImpl;
148+
}
149+
150+
public void setPropertyServiceDaoImpl(IPropertyServiceDao propertyServiceDaoImpl) {
151+
this.propertyServiceDaoImpl = propertyServiceDaoImpl;
152+
}
153+
}

0 commit comments

Comments
 (0)