|
|
@@ -1,66 +1,53 @@
|
|
|
-package com.java110.api.listener.room;
|
|
|
+package com.java110.community.cmd.room;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.java110.api.bmo.room.IRoomBMO;
|
|
|
-import com.java110.api.listener.AbstractServiceApiPlusListener;
|
|
|
-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.annotation.Java110Transactional;
|
|
|
+import com.java110.core.context.ICmdDataFlowContext;
|
|
|
+import com.java110.core.event.cmd.AbstractServiceCmdListener;
|
|
|
+import com.java110.core.event.cmd.CmdEvent;
|
|
|
+import com.java110.core.factory.GenerateCodeFactory;
|
|
|
import com.java110.dto.UnitDto;
|
|
|
import com.java110.dto.owner.OwnerRoomRelDto;
|
|
|
-import com.java110.intf.community.IUnitInnerServiceSMO;
|
|
|
+import com.java110.intf.community.*;
|
|
|
import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
|
|
|
import com.java110.po.owner.OwnerRoomRelPo;
|
|
|
+import com.java110.po.room.RoomAttrPo;
|
|
|
import com.java110.po.room.RoomPo;
|
|
|
-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.DateUtil;
|
|
|
import com.java110.utils.util.StringUtil;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import com.java110.core.log.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
|
|
|
-import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
-/**
|
|
|
- * @ClassName SaveUnitListener
|
|
|
- * @Description TODO 修改房屋信息
|
|
|
- * @Author wuxw
|
|
|
- * @Date 2019/5/3 11:54
|
|
|
- * @Version 1.0
|
|
|
- * add by wuxw 2019/5/3
|
|
|
- **/
|
|
|
-@Java110Listener("updateRoomListener")
|
|
|
-public class UpdateRoomListener extends AbstractServiceApiPlusListener {
|
|
|
- private static Logger logger = LoggerFactory.getLogger(UpdateRoomListener.class);
|
|
|
+@Java110Cmd(serviceCode = "room.updateRoom")
|
|
|
+public class UpdateRoomCmd extends AbstractServiceCmdListener {
|
|
|
|
|
|
@Autowired
|
|
|
- private IRoomBMO roomBMOImpl;
|
|
|
-
|
|
|
+ private IUnitV1InnerServiceSMO unitV1InnerServiceSMOImpl;
|
|
|
@Autowired
|
|
|
private IUnitInnerServiceSMO unitInnerServiceSMOImpl;
|
|
|
-
|
|
|
@Autowired
|
|
|
- private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMOImpl;
|
|
|
+ private IFloorV1InnerServiceSMO floorV1InnerServiceSMOImpl;
|
|
|
|
|
|
- @Override
|
|
|
- public String getServiceCode() {
|
|
|
- return ServiceCodeConstant.SERVICE_CODE_UPDATE_ROOMS;
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public HttpMethod getHttpMethod() {
|
|
|
- return HttpMethod.POST;
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IRoomV1InnerServiceSMO roomV1InnerServiceSMOImpl;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IRoomAttrV1InnerServiceSMO roomAttrV1InnerServiceSMOImpl;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMOImpl;
|
|
|
|
|
|
@Override
|
|
|
- protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) throws ParseException {
|
|
|
+ public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws Exception {
|
|
|
Assert.jsonObjectHaveKey(reqJson, "roomId", "请求报文中未包含roomId节点");
|
|
|
Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId节点");
|
|
|
Assert.jsonObjectHaveKey(reqJson, "roomNum", "请求报文中未包含roomNum节点");
|
|
|
@@ -79,13 +66,11 @@ public class UpdateRoomListener extends AbstractServiceApiPlusListener {
|
|
|
String state = reqJson.getString("state");
|
|
|
if (!StringUtil.isEmpty(state) && state.equals("2006")) { //已出租
|
|
|
//获取起租时间
|
|
|
- String startTime = reqJson.getString("startTime");
|
|
|
+ Date startTime = DateUtil.getDateFromString(reqJson.getString("startTime"), DateUtil.DATE_FORMATE_STRING_B);
|
|
|
//获取截租时间
|
|
|
- String endTime = reqJson.getString("endTime");
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- Date beginTime = format.parse(startTime);
|
|
|
- Date finishTime = format.parse(endTime);
|
|
|
- if (beginTime.getTime() > finishTime.getTime()) {
|
|
|
+ Date endTime = DateUtil.getDateFromString(reqJson.getString("endTime"), DateUtil.DATE_FORMATE_STRING_B);
|
|
|
+
|
|
|
+ if (startTime.getTime() > endTime.getTime()) {
|
|
|
throw new IllegalArgumentException("起租时间不能大于截租时间!");
|
|
|
}
|
|
|
}
|
|
|
@@ -101,12 +86,12 @@ public class UpdateRoomListener extends AbstractServiceApiPlusListener {
|
|
|
}
|
|
|
|
|
|
Assert.judgeAttrValue(reqJson);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
|
|
|
- roomBMOImpl.updateShellRoom(reqJson, context);
|
|
|
+ @Java110Transactional
|
|
|
+ public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
|
|
|
+ updateShellRoom(reqJson, cmdDataFlowContext);
|
|
|
String state = reqJson.getString("state");
|
|
|
if (!StringUtil.isEmpty(state) && state.equals("2006")) { //已出租
|
|
|
OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
|
|
|
@@ -129,28 +114,48 @@ public class UpdateRoomListener extends AbstractServiceApiPlusListener {
|
|
|
|
|
|
|
|
|
JSONObject attr = null;
|
|
|
+ int flag = 0;
|
|
|
for (int attrIndex = 0; attrIndex < attrs.size(); attrIndex++) {
|
|
|
attr = attrs.getJSONObject(attrIndex);
|
|
|
attr.put("roomId", reqJson.getString("roomId"));
|
|
|
if (!attr.containsKey("attrId") || attr.getString("attrId").startsWith("-") || StringUtil.isEmpty(attr.getString("attrId"))) {
|
|
|
- roomBMOImpl.addRoomAttr(attr, context);
|
|
|
+ RoomAttrPo roomAttrPo = new RoomAttrPo();
|
|
|
+ roomAttrPo.setAttrId(GenerateCodeFactory.getAttrId());
|
|
|
+ roomAttrPo.setRoomId(attr.getString("roomId"));
|
|
|
+ roomAttrPo.setSpecCd(attr.getString("specCd"));
|
|
|
+ roomAttrPo.setValue(attr.getString("value"));
|
|
|
+ flag = roomAttrV1InnerServiceSMOImpl.saveRoomAttr(roomAttrPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存单元失败");
|
|
|
+ }
|
|
|
continue;
|
|
|
}
|
|
|
- roomBMOImpl.updateRoomAttr(attr, context);
|
|
|
+ RoomAttrPo roomAttrPo = new RoomAttrPo();
|
|
|
+ roomAttrPo.setAttrId(attr.getString("attrId"));
|
|
|
+ roomAttrPo.setRoomId(attr.getString("roomId"));
|
|
|
+ roomAttrPo.setSpecCd(attr.getString("specCd"));
|
|
|
+ roomAttrPo.setValue(attr.getString("value"));
|
|
|
+ flag = roomAttrV1InnerServiceSMOImpl.updateRoomAttr(roomAttrPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存单元失败");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getOrder() {
|
|
|
- return DEFAULT_ORDER;
|
|
|
- }
|
|
|
-
|
|
|
- public IUnitInnerServiceSMO getUnitInnerServiceSMOImpl() {
|
|
|
- return unitInnerServiceSMOImpl;
|
|
|
- }
|
|
|
-
|
|
|
- public void setUnitInnerServiceSMOImpl(IUnitInnerServiceSMO unitInnerServiceSMOImpl) {
|
|
|
- this.unitInnerServiceSMOImpl = unitInnerServiceSMOImpl;
|
|
|
+ /**
|
|
|
+ * 添加小区楼信息
|
|
|
+ *
|
|
|
+ * @param paramInJson 接口调用放传入入参
|
|
|
+ * @param cmdDataFlowContext 数据上下文
|
|
|
+ * @return 订单服务能够接受的报文
|
|
|
+ */
|
|
|
+ public void updateShellRoom(JSONObject paramInJson, ICmdDataFlowContext cmdDataFlowContext) {
|
|
|
+ JSONObject businessUnit = new JSONObject();
|
|
|
+ businessUnit.putAll(paramInJson);
|
|
|
+ RoomPo roomPo = BeanConvertUtil.covertBean(businessUnit, RoomPo.class);
|
|
|
+ int flag = roomV1InnerServiceSMOImpl.updateRoom(roomPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("修改房屋失败");
|
|
|
+ }
|
|
|
}
|
|
|
}
|