|
|
@@ -1,74 +1,44 @@
|
|
|
-/*
|
|
|
- * Copyright 2017-2020 吴学文 and java110 team.
|
|
|
- *
|
|
|
- * Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
- * you may not use this file except in compliance with the License.
|
|
|
- * You may obtain a copy of the License at
|
|
|
- *
|
|
|
- * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
- *
|
|
|
- * Unless required by applicable law or agreed to in writing, software
|
|
|
- * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
- * See the License for the specific language governing permissions and
|
|
|
- * limitations under the License.
|
|
|
- */
|
|
|
-package com.java110.api.listener.room;
|
|
|
+package com.java110.community.cmd.room;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.java110.api.bmo.room.IRoomBMO;
|
|
|
-import com.java110.api.bmo.unit.IUnitBMO;
|
|
|
-import com.java110.api.listener.AbstractServiceApiPlusListener;
|
|
|
-import com.java110.core.annotation.Java110Listener;
|
|
|
+import com.java110.core.annotation.Java110Cmd;
|
|
|
import com.java110.core.context.DataFlowContext;
|
|
|
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
|
|
|
+import com.java110.core.context.ICmdDataFlowContext;
|
|
|
+import com.java110.core.event.cmd.Cmd;
|
|
|
+import com.java110.core.event.cmd.CmdEvent;
|
|
|
import com.java110.core.factory.GenerateCodeFactory;
|
|
|
import com.java110.dto.RoomDto;
|
|
|
import com.java110.dto.UnitDto;
|
|
|
+import com.java110.intf.community.IRoomV1InnerServiceSMO;
|
|
|
import com.java110.intf.community.IUnitInnerServiceSMO;
|
|
|
-import com.java110.utils.constant.ServiceCodeConstant;
|
|
|
+import com.java110.intf.community.IUnitV1InnerServiceSMO;
|
|
|
+import com.java110.po.room.RoomPo;
|
|
|
+import com.java110.po.unit.UnitPo;
|
|
|
+import com.java110.utils.constant.BusinessTypeConstant;
|
|
|
+import com.java110.utils.constant.CommonConstant;
|
|
|
+import com.java110.utils.exception.CmdException;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import com.java110.core.log.LoggerFactory;
|
|
|
+import com.java110.utils.util.BeanConvertUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
import java.util.List;
|
|
|
|
|
|
-/**
|
|
|
- * @ClassName SaveShopsListener
|
|
|
- * @Description TODO 保存商铺信息
|
|
|
- * @Author wuxw
|
|
|
- * @Date 2019/5/3 11:54
|
|
|
- * @Version 1.0
|
|
|
- * add by wuxw 2019/5/3
|
|
|
- **/
|
|
|
-@Java110Listener("saveShopsListener")
|
|
|
-public class SaveShopsListener extends AbstractServiceApiPlusListener {
|
|
|
- private static Logger logger = LoggerFactory.getLogger(SaveShopsListener.class);
|
|
|
-
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IRoomBMO roomBMOImpl;
|
|
|
+@Java110Cmd(serviceCode = "room.saveShops")
|
|
|
+public class SaveShopsCmd extends Cmd {
|
|
|
|
|
|
- @Autowired
|
|
|
- private IUnitBMO unitBMOImpl;
|
|
|
@Autowired
|
|
|
private IUnitInnerServiceSMO unitInnerServiceSMOImpl;
|
|
|
|
|
|
- @Override
|
|
|
- public String getServiceCode() {
|
|
|
- return ServiceCodeConstant.SERVICE_CODE_SAVE_SHOPS;
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IUnitV1InnerServiceSMO unitV1InnerServiceSMOImpl;
|
|
|
|
|
|
- @Override
|
|
|
- public HttpMethod getHttpMethod() {
|
|
|
- return HttpMethod.POST;
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private IRoomV1InnerServiceSMO roomV1InnerServiceSMOImpl;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
|
|
|
+ public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
|
|
|
Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId节点");
|
|
|
Assert.jsonObjectHaveKey(reqJson, "floorId", "请求报文中未包含楼栋信息");
|
|
|
Assert.jsonObjectHaveKey(reqJson, "roomNum", "请求报文中未包含roomNum节点");
|
|
|
@@ -90,12 +60,11 @@ public class SaveShopsListener extends AbstractServiceApiPlusListener {
|
|
|
if (!reqJson.containsKey("roomArea")) {
|
|
|
reqJson.put("roomRent", reqJson.getString("builtUpArea"));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
|
|
|
- //判断 楼栋下是否存在 0单元 如果存在 不插入 不存在插入
|
|
|
+ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
|
|
|
+
|
|
|
UnitDto unitDto = new UnitDto();
|
|
|
unitDto.setCommunityId(reqJson.getString("communityId"));
|
|
|
unitDto.setFloorId(reqJson.getString("floorId"));
|
|
|
@@ -113,7 +82,7 @@ public class SaveShopsListener extends AbstractServiceApiPlusListener {
|
|
|
unit.put("lift", "0");
|
|
|
unit.put("remark", "系统创建");
|
|
|
unit.put("unitArea", "1.00");
|
|
|
- unitBMOImpl.addUnit(unit, context);
|
|
|
+ addUnit(unit);
|
|
|
} else {
|
|
|
unitId = units.get(0).getUnitId();
|
|
|
}
|
|
|
@@ -122,20 +91,45 @@ public class SaveShopsListener extends AbstractServiceApiPlusListener {
|
|
|
reqJson.put("apartment", "10101");
|
|
|
reqJson.put("state", RoomDto.STATE_SHOP_FREE);
|
|
|
reqJson.put("roomType", RoomDto.ROOM_TYPE_SHOPS);
|
|
|
- roomBMOImpl.addRoom(reqJson, context);
|
|
|
+ addRoom(reqJson);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getOrder() {
|
|
|
- return DEFAULT_ORDER;
|
|
|
- }
|
|
|
-
|
|
|
- public IUnitInnerServiceSMO getUnitInnerServiceSMOImpl() {
|
|
|
- return unitInnerServiceSMOImpl;
|
|
|
+ public void addUnit(JSONObject paramInJson) {
|
|
|
+
|
|
|
+ JSONObject businessUnit = new JSONObject();
|
|
|
+ businessUnit.put("floorId", paramInJson.getString("floorId"));
|
|
|
+ businessUnit.put("layerCount", paramInJson.getString("layerCount"));
|
|
|
+ businessUnit.put("unitId", !paramInJson.containsKey("unitId") ? GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_unitId)
|
|
|
+ : paramInJson.getString("unitId"));
|
|
|
+ businessUnit.put("unitNum", paramInJson.getString("unitNum"));
|
|
|
+ businessUnit.put("lift", paramInJson.getString("lift"));
|
|
|
+ businessUnit.put("remark", paramInJson.getString("remark"));
|
|
|
+ businessUnit.put("unitArea", paramInJson.getString("unitArea"));
|
|
|
+ businessUnit.put("userId", "-1");
|
|
|
+ UnitPo unitPo = BeanConvertUtil.covertBean(businessUnit, UnitPo.class);
|
|
|
+
|
|
|
+ int flag = unitV1InnerServiceSMOImpl.saveUnit(unitPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存单元失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public void setUnitInnerServiceSMOImpl(IUnitInnerServiceSMO unitInnerServiceSMOImpl) {
|
|
|
- this.unitInnerServiceSMOImpl = unitInnerServiceSMOImpl;
|
|
|
+ /**
|
|
|
+ * 添加小区楼信息
|
|
|
+ *
|
|
|
+ * @param paramInJson 接口调用放传入入参
|
|
|
+ * @return 订单服务能够接受的报文
|
|
|
+ */
|
|
|
+ public void addRoom(JSONObject paramInJson) {
|
|
|
+
|
|
|
+ JSONObject businessUnit = new JSONObject();
|
|
|
+ businessUnit.putAll(paramInJson);
|
|
|
+ businessUnit.put("roomId",GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_roomId));
|
|
|
+ businessUnit.put("userId", "-1");
|
|
|
+ RoomPo roomPo = BeanConvertUtil.covertBean(businessUnit, RoomPo.class);
|
|
|
+ int flag = roomV1InnerServiceSMOImpl.saveRoom(roomPo);
|
|
|
+ if (flag < 1) {
|
|
|
+ throw new CmdException("保存单元失败");
|
|
|
+ }
|
|
|
}
|
|
|
}
|