Explorar el Código

加入房屋保存接口信息

吴学文 hace 7 años
padre
commit
7276c85268

+ 155 - 0
Api/src/main/java/com/java110/api/listener/room/SaveRoomListener.java

@@ -0,0 +1,155 @@
+package com.java110.api.listener.room;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.api.listener.AbstractServiceApiDataFlowListener;
+import com.java110.common.constant.BusinessTypeConstant;
+import com.java110.common.constant.CommonConstant;
+import com.java110.common.constant.ServiceCodeConstant;
+import com.java110.common.util.Assert;
+import com.java110.core.annotation.Java110Listener;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.smo.unit.IUnitInnerServiceSMO;
+import com.java110.dto.UnitDto;
+import com.java110.entity.center.AppService;
+import com.java110.event.service.api.ServiceDataFlowEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+
+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("saveRoomListener")
+public class SaveRoomListener extends AbstractServiceApiDataFlowListener {
+    private static Logger logger = LoggerFactory.getLogger(SaveRoomListener.class);
+
+
+    @Autowired
+    private IUnitInnerServiceSMO unitInnerServiceSMOImpl;
+
+    @Override
+    public String getServiceCode() {
+        return ServiceCodeConstant.SERVICE_CODE_SAVE_ROOM;
+    }
+
+    @Override
+    public HttpMethod getHttpMethod() {
+        return HttpMethod.POST;
+    }
+
+    @Override
+    public void soService(ServiceDataFlowEvent event) {
+
+        logger.debug("ServiceDataFlowEvent : {}", event);
+
+        DataFlowContext dataFlowContext = event.getDataFlowContext();
+        AppService service = event.getAppService();
+
+        String paramIn = dataFlowContext.getReqData();
+
+        //校验数据
+        validate(paramIn);
+        JSONObject paramObj = JSONObject.parseObject(paramIn);
+
+        HttpHeaders header = new HttpHeaders();
+        dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD, "D");
+        JSONArray businesses = new JSONArray();
+
+        //添加单元信息
+        businesses.add(addRoom(paramObj, dataFlowContext));
+
+        JSONObject paramInObj = super.restToCenterProtocol(businesses, dataFlowContext.getRequestCurrentHeaders());
+
+        //将 rest header 信息传递到下层服务中去
+        super.freshHttpHeader(header, dataFlowContext.getRequestCurrentHeaders());
+
+        ResponseEntity<String> responseEntity = this.callService(dataFlowContext, service.getServiceCode(), paramInObj);
+
+        dataFlowContext.setResponseEntity(responseEntity);
+
+    }
+
+    /**
+     * 添加小区楼信息
+     *
+     * @param paramInJson     接口调用放传入入参
+     * @param dataFlowContext 数据上下文
+     * @return 订单服务能够接受的报文
+     */
+    private JSONObject addRoom(JSONObject paramInJson, DataFlowContext dataFlowContext) {
+
+
+        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_ROOM_INFO);
+        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
+        JSONObject businessUnit = new JSONObject();
+        businessUnit.putAll(paramInJson);
+        businessUnit.put("room_id", "-1");
+        businessUnit.put("userId", dataFlowContext.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
+        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUnit", businessUnit);
+
+        return business;
+    }
+
+    /**
+     * 数据校验
+     *
+     * @param paramIn "communityId": "7020181217000001",
+     *                "memberId": "3456789",
+     *                "memberTypeCd": "390001200001"
+     */
+    private void validate(String paramIn) {
+        Assert.jsonObjectHaveKey(paramIn, "communityId", "请求报文中未包含communityId节点");
+        Assert.jsonObjectHaveKey(paramIn, "unitId", "请求报文中未包含unitId节点");
+        Assert.jsonObjectHaveKey(paramIn, "roomNum", "请求报文中未包含roomNum节点");
+        Assert.jsonObjectHaveKey(paramIn, "layer", "请求报文中未包含layer节点");
+        Assert.jsonObjectHaveKey(paramIn, "section", "请求报文中未包含section节点");
+        Assert.jsonObjectHaveKey(paramIn, "apartment", "请求报文中未包含apartment节点");
+        Assert.jsonObjectHaveKey(paramIn, "builtUpArea", "请求报文中未包含builtUpArea节点");
+        Assert.jsonObjectHaveKey(paramIn, "unitPrice", "请求报文中未包含unitPrice节点");
+        JSONObject reqJson = JSONObject.parseObject(paramIn);
+        Assert.isInteger(reqJson.getString("section"), "房间数不是有效数字");
+        Assert.isMoney(reqJson.getString("builtUpArea"), "建筑面积数据格式错误");
+        Assert.isMoney(reqJson.getString("unitPrice"), "房屋单价数据格式错误");
+
+        if (!"1010".equals(reqJson.getString("apartment")) && !"2020".equals(reqJson.getString("apartment"))) {
+            throw new IllegalArgumentException("不是有效房屋户型 传入数据错误");
+        }
+
+        UnitDto unitDto = new UnitDto();
+        unitDto.setCommunityId(reqJson.getString("communityId"));
+        unitDto.setUnitId(reqJson.getString("unitId"));
+        //校验小区楼ID和小区是否有对应关系
+        List<UnitDto> units = unitInnerServiceSMOImpl.queryUnitsByCommunityId(unitDto);
+
+        if (units == null || units.size() < 1) {
+            throw new IllegalArgumentException("传入单元ID不是该小区的单元");
+        }
+
+    }
+
+    @Override
+    public int getOrder() {
+        return DEFAULT_ORDER;
+    }
+
+    public IUnitInnerServiceSMO getUnitInnerServiceSMOImpl() {
+        return unitInnerServiceSMOImpl;
+    }
+
+    public void setUnitInnerServiceSMOImpl(IUnitInnerServiceSMO unitInnerServiceSMOImpl) {
+        this.unitInnerServiceSMOImpl = unitInnerServiceSMOImpl;
+    }
+}

+ 15 - 12
CommunityService/src/main/java/com/java110/community/dao/IUnitServiceDao.java

@@ -2,11 +2,6 @@ package com.java110.community.dao;
 
 
 import com.java110.common.exception.DAOException;
-import com.java110.entity.merchant.BoMerchant;
-import com.java110.entity.merchant.BoMerchantAttr;
-import com.java110.entity.merchant.Merchant;
-import com.java110.entity.merchant.MerchantAttr;
-
 
 import java.util.List;
 import java.util.Map;
@@ -15,23 +10,24 @@ import java.util.Map;
  * 小区单元组件内部之间使用,没有给外围系统提供服务能力
  * 小区单元服务接口类,要求全部以字符串传输,方便微服务化
  * 新建客户,修改客户,删除客户,查询客户等功能
- *
+ * <p>
  * Created by wuxw on 2016/12/27.
  */
 public interface IUnitServiceDao {
 
     /**
      * 保存 小区单元信息
+     *
      * @param businessUnitInfo 小区单元信息 封装
      * @throws DAOException 操作数据库异常
      */
     public void saveBusinessUnitInfo(Map businessUnitInfo) throws DAOException;
 
 
-
     /**
      * 查询小区单元信息(business过程)
      * 根据bId 查询小区单元信息
+     *
      * @param info bId 信息
      * @return 小区单元信息
      * @throws DAOException
@@ -39,21 +35,19 @@ public interface IUnitServiceDao {
     public List<Map> getBusinessUnitInfo(Map info) throws DAOException;
 
 
-
-
     /**
      * 保存 小区单元信息 Business数据到 Instance中
+     *
      * @param info
      * @throws DAOException
      */
     public void saveUnitInfoInstance(Map info) throws DAOException;
 
 
-
-
     /**
      * 查询小区单元信息(instance过程)
      * 根据bId 查询小区单元信息
+     *
      * @param info bId 信息
      * @return 小区单元信息
      * @throws DAOException
@@ -61,9 +55,9 @@ public interface IUnitServiceDao {
     public List<Map> getUnitInfo(Map info) throws DAOException;
 
 
-
     /**
      * 修改小区单元信息
+     *
      * @param info 修改信息
      * @throws DAOException
      */
@@ -78,4 +72,13 @@ public interface IUnitServiceDao {
      */
     int queryUnitsCount(Map info);
 
+
+    /**
+     * 根据小区ID查询单元信息
+     *
+     * @param info 小区单元信息
+     * @return 小区单元
+     */
+    List<Map> queryUnitsByCommunityId(Map info);
+
 }

+ 11 - 0
CommunityService/src/main/java/com/java110/community/dao/impl/UnitServiceDaoImpl.java

@@ -6,6 +6,7 @@ import com.java110.common.exception.DAOException;
 import com.java110.common.util.DateUtil;
 import com.java110.community.dao.IUnitServiceDao;
 import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.dto.UnitDto;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -131,4 +132,14 @@ public class UnitServiceDaoImpl extends BaseServiceDao implements IUnitServiceDa
     }
 
 
+    @Override
+    public List<Map> queryUnitsByCommunityId(Map info) {
+        logger.debug("查询queryUnitsByCommunityId数据 入参 info : {}", info);
+
+        List<Map> units = sqlSessionTemplate.selectList("unitServiceDaoImpl.queryUnitsByCommunityId", info);
+
+        return units;
+    }
+
+
 }

+ 11 - 3
CommunityService/src/main/java/com/java110/community/smo/impl/UnitInnerServiceSMOImpl.java

@@ -34,7 +34,7 @@ public class UnitInnerServiceSMOImpl extends BaseServiceSMO implements IUnitInne
     private IUserInnerServiceSMO userInnerServiceSMOImpl;
 
     @Override
-    public List<UnitDto> queryUnits(@RequestBody  UnitDto unitDto) {
+    public List<UnitDto> queryUnits(@RequestBody UnitDto unitDto) {
 
         //校验是否传了 分页信息
 
@@ -64,7 +64,7 @@ public class UnitInnerServiceSMOImpl extends BaseServiceSMO implements IUnitInne
     /**
      * 从用户列表中查询用户,将用户中的信息 刷新到 floor对象中
      *
-     * @param unit 小区楼单元信息
+     * @param unit  小区楼单元信息
      * @param users 用户列表
      */
     private void refreshUnit(UnitDto unit, List<UserDto> users) {
@@ -92,7 +92,15 @@ public class UnitInnerServiceSMOImpl extends BaseServiceSMO implements IUnitInne
 
     @Override
     public int queryUnitsCount(@RequestBody UnitDto unitDto) {
-        return unitServiceDaoImpl.queryUnitsCount(BeanConvertUtil.beanCovertMap(unitDto));    }
+        return unitServiceDaoImpl.queryUnitsCount(BeanConvertUtil.beanCovertMap(unitDto));
+    }
+
+    @Override
+    public List<UnitDto> queryUnitsByCommunityId(UnitDto unitDto) {
+        List<UnitDto> units = BeanConvertUtil.covertBeanList(unitServiceDaoImpl.queryUnitsByCommunityId(BeanConvertUtil.beanCovertMap(unitDto)), UnitDto.class);
+        return units;
+    }
+
 
     public IUnitServiceDao getUnitServiceDaoImpl() {
         return unitServiceDaoImpl;

+ 22 - 0
WebService/src/main/java/com/java110/web/components/room/AddRoomComponent.java

@@ -1,6 +1,7 @@
 package com.java110.web.components.room;
 
 import com.java110.core.context.IPageData;
+import com.java110.web.smo.IRoomServiceSMO;
 import com.java110.web.smo.IUnitServiceSMO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
@@ -20,6 +21,9 @@ public class AddRoomComponent {
     @Autowired
     private IUnitServiceSMO unitServiceSMOImpl;
 
+    @Autowired
+    private IRoomServiceSMO roomServiceSMOImpl;
+
     /**
      * 根据 floorId 查询单元信息
      *
@@ -30,6 +34,16 @@ public class AddRoomComponent {
         return unitServiceSMOImpl.listUnits(pd);
     }
 
+    /**
+     * 保存房屋信息
+     *
+     * @param pd 房屋信息
+     * @return 单元信息
+     */
+    public ResponseEntity<String> save(IPageData pd) {
+        return roomServiceSMOImpl.saveRoom(pd);
+    }
+
 
     public IUnitServiceSMO getUnitServiceSMOImpl() {
         return unitServiceSMOImpl;
@@ -38,4 +52,12 @@ public class AddRoomComponent {
     public void setUnitServiceSMOImpl(IUnitServiceSMO unitServiceSMOImpl) {
         this.unitServiceSMOImpl = unitServiceSMOImpl;
     }
+
+    public IRoomServiceSMO getRoomServiceSMOImpl() {
+        return roomServiceSMOImpl;
+    }
+
+    public void setRoomServiceSMOImpl(IRoomServiceSMO roomServiceSMOImpl) {
+        this.roomServiceSMOImpl = roomServiceSMOImpl;
+    }
 }

+ 16 - 8
WebService/src/main/java/com/java110/web/core/VueComponentTemplate.java

@@ -3,7 +3,6 @@ package com.java110.web.core;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.util.StringUtils;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -20,28 +19,28 @@ public class VueComponentTemplate extends PackageScanner {
     /**
      * 默认扫描路径
      */
-    public final static String DEFAULT_COMPONENT_PACKAGE_PATH = "components";
+    public static final String DEFAULT_COMPONENT_PACKAGE_PATH = "components";
 
     /**
      * js 文件
      */
-    public final static String COMPONENT_JS = "js";
+    public static final String COMPONENT_JS = "js";
 
     /**
      * css 文件
      */
-    public final static String COMPONENT_CSS = "css";
+    public static final String COMPONENT_CSS = "css";
 
     /**
      * html 文件
      */
-    public final static String COMPONENT_HTML = "html";
+    public static final String COMPONENT_HTML = "html";
 
 
     /**
      * HTML 文件缓存器
      */
-    private final static Map<String, String> componentTemplate = new HashMap<>();
+    private static final Map<String, String> componentTemplate = new HashMap<>();
 
 
     /**
@@ -88,9 +87,18 @@ public class VueComponentTemplate extends PackageScanner {
                 b.append((char) tempChar);
             }
             sb = b.toString();
-            if (!StringUtils.isEmpty(sb)) {
-                componentTemplate.put(filePath.substring(filePath.lastIndexOf(File.separator) + 1, filePath.length()), sb);
+            if (StringUtils.isEmpty(sb)) {
+                return;
             }
+            String componentKey = "";
+            //这里在window 读取jar包中文件时,也是 / 但是直接启动时 为\这个 所以不能用 File.separator 
+            if (filePath.contains("/")) {
+                componentKey = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.length());
+            } else {
+                componentKey = filePath.substring(filePath.lastIndexOf("\\") + 1, filePath.length());
+            }
+            componentTemplate.put(componentKey, sb);
+
         } catch (IOException e) {
             e.printStackTrace();
         } finally {

+ 18 - 0
WebService/src/main/java/com/java110/web/smo/IRoomServiceSMO.java

@@ -0,0 +1,18 @@
+package com.java110.web.smo;
+
+import com.java110.core.context.IPageData;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 房屋服务类
+ */
+public interface IRoomServiceSMO {
+
+    /**
+     * 添加房屋信息
+     *
+     * @param pd 页面数据封装对象
+     * @return 返回 ResponseEntity对象包含 http状态 信息 body信息
+     */
+    ResponseEntity<String> saveRoom(IPageData pd);
+}

+ 92 - 0
WebService/src/main/java/com/java110/web/smo/impl/RoomServiceSMOImpl.java

@@ -0,0 +1,92 @@
+package com.java110.web.smo.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.PrivilegeCodeConstant;
+import com.java110.common.constant.ServiceConstant;
+import com.java110.common.util.Assert;
+import com.java110.core.context.IPageData;
+import com.java110.web.core.BaseComponentSMO;
+import com.java110.web.smo.IRoomServiceSMO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * 房屋服务实现类
+ */
+@Service("roomServiceSMOImpl")
+public class RoomServiceSMOImpl extends BaseComponentSMO implements IRoomServiceSMO {
+
+    private static Logger logger = LoggerFactory.getLogger(RoomServiceSMOImpl.class);
+
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Override
+    public ResponseEntity<String> saveRoom(IPageData pd) {
+       validateSaveRoom(pd);
+
+        //校验员工是否有权限操作
+        super.checkUserHasPrivilege(pd, restTemplate, PrivilegeCodeConstant.PRIVILEGE_ROOM);
+
+        JSONObject paramIn = JSONObject.parseObject(pd.getReqData());
+        String communityId = paramIn.getString("communityId");
+        ResponseEntity responseEntity = super.getStoreInfo(pd, restTemplate);
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return responseEntity;
+        }
+        Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeId", "根据用户ID查询商户ID失败,未包含storeId节点");
+        Assert.jsonObjectHaveKey(responseEntity.getBody().toString(), "storeTypeCd", "根据用户ID查询商户类型失败,未包含storeTypeCd节点");
+
+        String storeId = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeId");
+        String storeTypeCd = JSONObject.parseObject(responseEntity.getBody().toString()).getString("storeTypeCd");
+        //数据校验是否 商户是否入驻该小区
+        super.checkStoreEnterCommunity(pd, storeId, storeTypeCd, communityId, restTemplate);
+        paramIn.put("userId", pd.getUserId());
+        responseEntity = this.callCenterService(restTemplate, pd, paramIn.toJSONString(),
+                ServiceConstant.SERVICE_API_URL + "/api/room.saveRoom",
+                HttpMethod.POST);
+
+        return responseEntity;
+    }
+
+    /**
+     * 校验前台传入房屋信息
+     * @param pd 页面数据封装
+     */
+    private void validateSaveRoom(IPageData pd) {
+
+        Assert.jsonObjectHaveKey(pd.getReqData(), "communityId", "请求报文中未包含communityId节点");
+        Assert.jsonObjectHaveKey(pd.getReqData(), "unitId", "请求报文中未包含unitId节点");
+        Assert.jsonObjectHaveKey(pd.getReqData(), "roomNum", "请求报文中未包含roomNum节点");
+        Assert.jsonObjectHaveKey(pd.getReqData(), "layer", "请求报文中未包含layer节点");
+        Assert.jsonObjectHaveKey(pd.getReqData(), "section", "请求报文中未包含section节点");
+        Assert.jsonObjectHaveKey(pd.getReqData(), "apartment", "请求报文中未包含apartment节点");
+        Assert.jsonObjectHaveKey(pd.getReqData(), "builtUpArea", "请求报文中未包含builtUpArea节点");
+        Assert.jsonObjectHaveKey(pd.getReqData(), "unitPrice", "请求报文中未包含unitPrice节点");
+        JSONObject reqJson = JSONObject.parseObject(pd.getReqData());
+        Assert.isInteger(reqJson.getString("section"), "房间数不是有效数字");
+        Assert.isMoney(reqJson.getString("builtUpArea"), "建筑面积数据格式错误");
+        Assert.isMoney(reqJson.getString("unitPrice"), "房屋单价数据格式错误");
+
+        if (!"1010".equals(reqJson.getString("apartment")) && !"2020".equals(reqJson.getString("apartment"))) {
+            throw new IllegalArgumentException("不是有效房屋户型 传入数据错误");
+        }
+
+    }
+
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+}

+ 46 - 10
WebService/src/main/resources/components/add-room/addRoom.js

@@ -29,7 +29,7 @@
         },
         methods:{
             /**
-                根据楼ID加载单元
+                根据楼ID加载房屋
             **/
             loadUnits:function(_floorId){
                 vc.component.addRoomUnits = [];
@@ -68,42 +68,78 @@
                         return vc.validate.validate({
                             addRoomInfo:vc.component.addRoomInfo
                         },{
-                            'addRoomInfo.floorId':[
+                            'addRoomInfo.unitId':[
                                 {
                                     limit:"required",
                                     param:"",
-                                    errInfo:"小区楼不能为空"
+                                    errInfo:"小区楼房屋不能为空"
                                 }
                             ],
                             'addRoomInfo.roomNum':[
                                 {
                                     limit:"required",
                                     param:"",
-                                    errInfo:"单元编号不能为空"
+                                    errInfo:"房屋编号不能为空"
                                 },
                                 {
                                     limit:"maxLength",
                                     param:"12",
-                                    errInfo:"单元编号长度不能超过12位"
+                                    errInfo:"房屋编号长度不能超过12位"
                                 },
                             ],
-                            'addRoomInfo.layerCount':[
+                            'addRoomInfo.layer':[
                                 {
                                     limit:"required",
                                     param:"",
-                                    errInfo:"单元楼层高度不能为空"
+                                    errInfo:"房屋楼层高度不能为空"
                                 },
                                 {
                                     limit:"num",
                                     param:"",
-                                    errInfo:"单元楼层高度必须为数字"
+                                    errInfo:"房屋楼层高度必须为数字"
                                 }
                             ],
-                            'addRoomInfo.lift':[
+                            'addRoomInfo.section':[
                                 {
                                     limit:"required",
                                     param:"",
-                                    errInfo:"必须选择单元是否电梯"
+                                    errInfo:"房间数不能为空"
+                                },
+                                {
+                                    limit:"num",
+                                    param:"",
+                                    errInfo:"房间数必须为数字"
+                                }
+                            ],
+                            'addRoomInfo.apartment':[
+                                {
+                                    limit:"required",
+                                    param:"",
+                                    errInfo:"户型不能为空"
+                                }
+                            ],
+                            'addRoomInfo.builtUpArea':[
+                                {
+                                    limit:"required",
+                                    param:"",
+                                    errInfo:"建筑面积不能为空"
+                                },
+                                {
+                                    limit:"money",
+                                    param:"",
+                                    errInfo:"建筑面积错误,如 300.00"
+                                }
+                            ],
+                            'addRoomInfo.unitPrice':[
+                                {
+                                    limit:"required",
+                                    param:"",
+                                    errInfo:"房屋单价不能为空"
+                                },
+                                {
+                                    limit:"money",
+                                    param:"",
+                                    errInfo:"房屋单价错误 如 300.00"
                                 }
                             ],
                             'addRoomInfo.remark':[

+ 11 - 0
WebService/src/main/resources/static/js/vc-validate.js

@@ -104,6 +104,13 @@ vc 校验 工具类 -method
         date:function(str) {
             var regDate = /^(\d{4})-(\d{2})-(\d{2})$/;
             return regDate.test(str);
+        },
+        /**
+            金额校验
+        **/
+        money:function(text){
+            var regMoney = /^\d+\.?\d{0,2}$/;
+            return regMoney.test(text);
         }
 
     };
@@ -201,6 +208,10 @@ vc 校验 工具类 -method
                     if(configObj.limit == 'date'){
                         validate.setState(validate.date(tmpDataObj),configObj.errInfo);
                     }
+
+                    if(configObj.limit == 'money'){
+                        validate.setState(validate.money(tmpDataObj),configObj.errInfo);
+                    }
                 });
 
             }

+ 1 - 0
docs/_sidebar.md

@@ -26,6 +26,7 @@
   * [保存单元信息](api/unit/saveUnit.md)
   * [修改单元信息](api/unit/updateUnit.md)
   * [删除单元信息](api/unit/deleteUnit.md)
+  * [保存房屋信息](api/room/saveRoom.md)
 
 * 服务端接口协议
 

+ 75 - 0
docs/api/room/saveRoom.md

@@ -0,0 +1,75 @@
+
+
+**1\. 保存房屋信息**
+###### 接口功能
+> 用户通过web端或APP保存单元信息接口
+
+###### URL
+> [http://api.java110.com:8008/api/room.saveRoom](http://api.java110.com:8008/api/room.saveRoom)
+
+###### 支持格式
+> JSON
+
+###### HTTP请求方式
+> GET
+
+###### 请求参数(header部分)
+|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-:|
+|app_id|1|String|30|应用ID|Api服务分配                      |
+|transaction_id|1|String|30|请求流水号|不能重复 1000000000+YYYYMMDDhhmmss+6位序列 |
+|sign|1|String|-|签名|请参考签名说明|
+|req_time|1|String|-|请求时间|YYYYMMDDhhmmss|
+
+###### 请求参数
+|参数名称|约束|类型|长度|描述|取值说明|
+| :-: | :-: | :-: | :-: | :-: | :-: |
+|unitPrice|1|String|4|房屋单价|-|
+|section|1|String|4|房间数|-|
+|remark|1|String|200|备注|-|
+|userId|1|String|30|用户ID|-|
+|communityId|1|String|30|小区ID|-|
+|layer|1|String|30|房屋楼层|-|
+|builtUpArea|1|String|30|建筑面积| 如 97.98|
+|roomNum|1|String|12|房间编号|1123|
+|unitId|1|String|30|小区单元ID|-|
+|apartment|1|String|4|户型|1010 一室一厅 1020 一室两厅 2010 两室一厅 2020 两室两厅 3020 三室两厅|
+
+###### 返回协议
+
+当http返回状态不为200 时请求处理失败 body内容为失败的原因
+
+当http返回状态为200时请求处理成功,body内容为返回内容,
+
+成功
+
+
+###### 举例
+> 地址:[http://api.java110.com:8008/api/room.saveRoom](http://api.java110.com:8008/api/room.saveRoom)
+
+``` javascript
+请求头信息:
+Content-Type:application/json
+USER_ID:1234
+APP_ID:8000418002
+TRANSACTION_ID:10029082726
+REQ_TIME:20181113225612
+SIGN:aabdncdhdbd878sbdudn898
+请求报文:
+
+{
+    "communityId":"小区ID",
+    "unitPrice":"填写具体值",
+    "section":"填写具体值",
+    "remark":"填写具体值",
+    "layer":"填写具体值",
+    "builtUpArea":"填写具体值",
+    "roomNum":"填写具体值",
+    "unitId":"填写具体值",
+    "apartment":"填写具体值"
+}
+
+返回报文:
+成功
+
+```

+ 10 - 0
java110-bean/src/main/java/com/java110/dto/UnitDto.java

@@ -19,6 +19,8 @@ public class UnitDto extends PageDto implements Serializable {
      */
     private String unitId;
 
+    private String communityId;
+
     /**
      * 编号
      */
@@ -121,4 +123,12 @@ public class UnitDto extends PageDto implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(String communityId) {
+        this.communityId = communityId;
+    }
 }

+ 4 - 0
java110-common/src/main/java/com/java110/common/constant/PrivilegeCodeConstant.java

@@ -20,4 +20,8 @@ public final class PrivilegeCodeConstant {
 
     //初始化小区楼单元
     public static final String PRIVILEGE_UNIT = "500201904012";
+
+
+    //初始化房屋楼单元
+    public static final String PRIVILEGE_ROOM = "500201904006";
 }

+ 4 - 0
java110-common/src/main/java/com/java110/common/constant/ServiceCodeConstant.java

@@ -379,4 +379,8 @@ public class ServiceCodeConstant {
 
     //删除小区单元
     public static final String SERVICE_CODE_DELETE_UNIT = "unit.deleteUnit";
+
+
+    //保存小区单元
+    public static final String SERVICE_CODE_SAVE_ROOM = "room.saveRoom";
 }

+ 19 - 0
java110-common/src/main/java/com/java110/common/util/Assert.java

@@ -6,6 +6,8 @@ import org.apache.commons.lang3.StringUtils;
 
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * 自定义 断言
@@ -211,4 +213,21 @@ public class Assert extends org.springframework.util.Assert {
             throw new IllegalArgumentException(msg);
         }
     }
+
+
+    /**
+     * 判断字符串是否是金额
+     *
+     * @param str 金额字符串
+     * @param msg 异常时信息
+     */
+    public static void isMoney(String str, String msg) {
+        Pattern pattern = java.util.regex.Pattern.compile("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$"); // 判断小数点后2位的数字的正则表达式
+        Matcher match = pattern.matcher(str);
+        if (!match.matches()) {
+            throw new IllegalArgumentException(msg);
+
+        }
+    }
+
 }

+ 44 - 0
java110-config/src/main/resources/mapper/unit/UnitServiceDaoImplMapper.xml

@@ -198,4 +198,48 @@ where 1 =1
 
      </select>
 
+    <select id="queryUnitsByCommunityId" parameterType="Map" resultType="Map">
+        select  t.floor_id,t.floor_id floorId,t.layer_count,t.layer_count layerCount,t.unit_id,t.unit_id unitId,t.unit_num,t.unit_num unitNum,t.lift,t.status_cd,t.status_cd statusCd,t.remark,t.b_id,t.b_id bId,t.user_id,t.user_id userId
+        from building_unit t,s_community sc,s_community_member scm,f_floor f
+        where 1 =1
+        and t.floor_id = f.floor_id
+        and f.floor_id = scm.member_id
+        and scm.community_id = sc.community_id
+        and scm.member_type_cd = '390001200004'
+        and sc.community_id = #{communityId}
+        and sc.status_cd = '0'
+        and scm.status_cd = '0'
+        and f.status_cd = '0'
+        <if test="floorId !=null and floorId != ''">
+            and t.floor_id= #{floorId}
+        </if>
+        <if test="layerCount !=null and layerCount != ''">
+            and t.layer_count= #{layerCount}
+        </if>
+        <if test="unitId !=null and unitId != ''">
+            and t.unit_id= #{unitId}
+        </if>
+        <if test="unitNum !=null and unitNum != ''">
+            and t.unit_num= #{unitNum}
+        </if>
+        <if test="lift !=null and lift != ''">
+            and t.lift= #{lift}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="remark !=null and remark != ''">
+            and t.remark= #{remark}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="userId !=null and userId != ''">
+            and t.user_id= #{userId}
+        </if>
+        <if test="page != -1 and page != null and page != ''">
+            limit page,row
+        </if>
+    </select>
+
 </mapper>

+ 10 - 1
java110-core/src/main/java/com/java110/core/smo/unit/IUnitInnerServiceSMO.java

@@ -3,6 +3,7 @@ package com.java110.core.smo.unit;
 import com.java110.core.feign.FeignConfiguration;
 import com.java110.dto.UnitDto;
 import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.http.HttpMethod;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -24,7 +25,6 @@ public interface IUnitInnerServiceSMO {
     /**
      * <p>查询小区楼信息</p>
      *
-     *
      * @param unitDto 数据对象分享
      * @return UnitDto 对象数据
      */
@@ -39,4 +39,13 @@ public interface IUnitInnerServiceSMO {
      */
     @RequestMapping(value = "/queryUnitsCount", method = RequestMethod.POST)
     int queryUnitsCount(@RequestBody UnitDto unitDto);
+
+    /**
+     * 根据小区ID查询单元信息
+     *
+     * @param unitDto 单元数据封装信息
+     * @return 单元信息
+     */
+    @RequestMapping(value = "/queryUnitsByCommunityId", method = RequestMethod.POST)
+    List<UnitDto> queryUnitsByCommunityId(@RequestBody UnitDto unitDto);
 }