Browse Source

优化代码

java110 5 years ago
parent
commit
c68444e583

+ 11 - 0
java110-core/src/main/java/com/java110/core/smo/user/IOwnerCarAttrInnerServiceSMO.java

@@ -2,6 +2,8 @@ package com.java110.core.smo.user;
 
 import com.java110.config.feign.FeignConfiguration;
 import com.java110.dto.ownerCarAttr.OwnerCarAttrDto;
+import com.java110.po.ownerCarAttr.OwnerCarAttrPo;
+import com.java110.po.parkingAreaAttr.ParkingAreaAttrPo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -39,4 +41,13 @@ public interface IOwnerCarAttrInnerServiceSMO {
      */
     @RequestMapping(value = "/queryOwnerCarAttrsCount", method = RequestMethod.POST)
     int queryOwnerCarAttrsCount(@RequestBody OwnerCarAttrDto ownerCarAttrDto);
+
+    /**
+     * 查询<p>小区楼</p>总记录数
+     *
+     * @param ownerCarAttrPo 数据对象分享
+     * @return 小区下的小区楼记录数
+     */
+    @RequestMapping(value = "/saveOwnerCarAttr", method = RequestMethod.POST)
+    int saveOwnerCarAttr(@RequestBody OwnerCarAttrPo ownerCarAttrPo);
 }

+ 162 - 154
java110-db/src/main/resources/mapper/user/OwnerCarAttrServiceDaoImplMapper.xml

@@ -5,183 +5,191 @@
 <mapper namespace="ownerCarAttrServiceDaoImpl">
 
     <!-- 保存业主车辆属性信息 add by wuxw 2018-07-03 -->
-       <insert id="saveBusinessOwnerCarAttrInfo" parameterType="Map">
-           insert into business_owner_car_attr(
-attr_id,operate,create_time,spec_cd,community_id,b_id,value,car_id
-) values (
-#{attrId},#{operate},#{createTime},#{specCd},#{communityId},#{bId},#{value},#{carId}
-)
-       </insert>
-
-
-       <!-- 查询业主车辆属性信息(Business) add by wuxw 2018-07-03 -->
-       <select id="getBusinessOwnerCarAttrInfo" parameterType="Map" resultType="Map">
-           select  t.attr_id,t.attr_id attrId,t.operate,t.create_time,t.create_time createTime,t.spec_cd,t.spec_cd specCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value,t.car_id,t.car_id carId 
-from business_owner_car_attr t 
-where 1 =1 
-<if test="attrId !=null and attrId != ''">
-   and t.attr_id= #{attrId}
-</if> 
-<if test="operate !=null and operate != ''">
-   and t.operate= #{operate}
-</if> 
-<if test="createTime !=null and createTime != ''">
-   and t.create_time= #{createTime}
-</if> 
-<if test="specCd !=null and specCd != ''">
-   and t.spec_cd= #{specCd}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="value !=null and value != ''">
-   and t.value= #{value}
-</if> 
-<if test="carId !=null and carId != ''">
-   and t.car_id= #{carId}
-</if> 
-
-       </select>
+    <insert id="saveBusinessOwnerCarAttrInfo" parameterType="Map">
+        insert into business_owner_car_attr(
+        attr_id,operate,create_time,spec_cd,community_id,b_id,value,car_id
+        ) values (
+        #{attrId},#{operate},#{createTime},#{specCd},#{communityId},#{bId},#{value},#{carId}
+        )
+    </insert>
+
+
+    <insert id="saveOwnerCarAttr" parameterType="Map">
+        insert into owner_car_attr(
+        attr_id,spec_cd,community_id,b_id,value,car_id
+        ) values (
+        #{attrId},#{specCd},#{communityId},'-1',#{value},#{carId}
+        )
+    </insert>
 
 
+    <!-- 查询业主车辆属性信息(Business) add by wuxw 2018-07-03 -->
+    <select id="getBusinessOwnerCarAttrInfo" parameterType="Map" resultType="Map">
+        select t.attr_id,t.attr_id attrId,t.operate,t.create_time,t.create_time createTime,t.spec_cd,t.spec_cd
+        specCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value,t.car_id,t.car_id carId
+        from business_owner_car_attr t
+        where 1 =1
+        <if test="attrId !=null and attrId != ''">
+            and t.attr_id= #{attrId}
+        </if>
+        <if test="operate !=null and operate != ''">
+            and t.operate= #{operate}
+        </if>
+        <if test="createTime !=null and createTime != ''">
+            and t.create_time= #{createTime}
+        </if>
+        <if test="specCd !=null and specCd != ''">
+            and t.spec_cd= #{specCd}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="value !=null and value != ''">
+            and t.value= #{value}
+        </if>
+        <if test="carId !=null and carId != ''">
+            and t.car_id= #{carId}
+        </if>
 
+    </select>
 
 
     <!-- 保存业主车辆属性信息至 instance表中 add by wuxw 2018-07-03 -->
     <insert id="saveOwnerCarAttrInfoInstance" parameterType="Map">
         insert into owner_car_attr(
-attr_id,create_time,spec_cd,status_cd,community_id,b_id,value,car_id
-) select t.attr_id,t.create_time,t.spec_cd,'0',t.community_id,t.b_id,t.value,t.car_id from business_owner_car_attr t where 1=1
-<if test="attrId !=null and attrId != ''">
-   and t.attr_id= #{attrId}
-</if> 
-   and t.operate= 'ADD'
-<if test="createTime !=null and createTime != ''">
-   and t.create_time= #{createTime}
-</if> 
-<if test="specCd !=null and specCd != ''">
-   and t.spec_cd= #{specCd}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="value !=null and value != ''">
-   and t.value= #{value}
-</if> 
-<if test="carId !=null and carId != ''">
-   and t.car_id= #{carId}
-</if> 
+        attr_id,create_time,spec_cd,status_cd,community_id,b_id,value,car_id
+        ) select t.attr_id,t.create_time,t.spec_cd,'0',t.community_id,t.b_id,t.value,t.car_id from
+        business_owner_car_attr t where 1=1
+        <if test="attrId !=null and attrId != ''">
+            and t.attr_id= #{attrId}
+        </if>
+        and t.operate= 'ADD'
+        <if test="createTime !=null and createTime != ''">
+            and t.create_time= #{createTime}
+        </if>
+        <if test="specCd !=null and specCd != ''">
+            and t.spec_cd= #{specCd}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="value !=null and value != ''">
+            and t.value= #{value}
+        </if>
+        <if test="carId !=null and carId != ''">
+            and t.car_id= #{carId}
+        </if>
 
     </insert>
 
 
-
     <!-- 查询业主车辆属性信息 add by wuxw 2018-07-03 -->
     <select id="getOwnerCarAttrInfo" parameterType="Map" resultType="Map">
-        select  t.attr_id,t.attr_id attrId,t.create_time,t.create_time createTime,t.spec_cd,t.spec_cd specCd,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.value,t.car_id,t.car_id carId 
-from owner_car_attr t 
-where 1 =1 
-<if test="attrId !=null and attrId != ''">
-   and t.attr_id= #{attrId}
-</if> 
-<if test="createTime !=null and createTime != ''">
-   and t.create_time= #{createTime}
-</if> 
-<if test="specCd !=null and specCd != ''">
-   and t.spec_cd= #{specCd}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="value !=null and value != ''">
-   and t.value= #{value}
-</if> 
-<if test="carId !=null and carId != ''">
-   and t.car_id= #{carId}
-</if> 
-order by t.create_time desc
-<if test="page != -1 and page != null ">
-   limit #{page}, #{row}
-</if> 
+        select t.attr_id,t.attr_id attrId,t.create_time,t.create_time createTime,t.spec_cd,t.spec_cd
+        specCd,t.status_cd,t.status_cd statusCd,t.community_id,t.community_id communityId,t.b_id,t.b_id
+        bId,t.value,t.car_id,t.car_id carId
+        from owner_car_attr t
+        where 1 =1
+        <if test="attrId !=null and attrId != ''">
+            and t.attr_id= #{attrId}
+        </if>
+        <if test="createTime !=null and createTime != ''">
+            and t.create_time= #{createTime}
+        </if>
+        <if test="specCd !=null and specCd != ''">
+            and t.spec_cd= #{specCd}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="value !=null and value != ''">
+            and t.value= #{value}
+        </if>
+        <if test="carId !=null and carId != ''">
+            and t.car_id= #{carId}
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
 
     </select>
 
 
-
-
     <!-- 修改业主车辆属性信息 add by wuxw 2018-07-03 -->
     <update id="updateOwnerCarAttrInfoInstance" parameterType="Map">
-        update  owner_car_attr t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="createTime !=null and createTime != ''">
-, t.create_time= #{createTime}
-</if> 
-<if test="specCd !=null and specCd != ''">
-, t.spec_cd= #{specCd}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
-<if test="value !=null and value != ''">
-, t.value= #{value}
-</if> 
-<if test="carId !=null and carId != ''">
-, t.car_id= #{carId}
-</if> 
- where 1=1 <if test="attrId !=null and attrId != ''">
-and t.attr_id= #{attrId}
-</if> 
-<if test="bId !=null and bId != ''">
-and t.b_id= #{bId}
-</if> 
+        update owner_car_attr t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="createTime !=null and createTime != ''">
+            , t.create_time= #{createTime}
+        </if>
+        <if test="specCd !=null and specCd != ''">
+            , t.spec_cd= #{specCd}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            , t.community_id= #{communityId}
+        </if>
+        <if test="value !=null and value != ''">
+            , t.value= #{value}
+        </if>
+        <if test="carId !=null and carId != ''">
+            , t.car_id= #{carId}
+        </if>
+        where 1=1
+        <if test="attrId !=null and attrId != ''">
+            and t.attr_id= #{attrId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
 
     </update>
 
     <!-- 查询业主车辆属性数量 add by wuxw 2018-07-03 -->
-     <select id="queryOwnerCarAttrsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from owner_car_attr t 
-where 1 =1 
-<if test="attrId !=null and attrId != ''">
-   and t.attr_id= #{attrId}
-</if> 
-<if test="createTime !=null and createTime != ''">
-   and t.create_time= #{createTime}
-</if> 
-<if test="specCd !=null and specCd != ''">
-   and t.spec_cd= #{specCd}
-</if> 
-<if test="statusCd !=null and statusCd != ''">
-   and t.status_cd= #{statusCd}
-</if> 
-<if test="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="bId !=null and bId != ''">
-   and t.b_id= #{bId}
-</if> 
-<if test="value !=null and value != ''">
-   and t.value= #{value}
-</if> 
-<if test="carId !=null and carId != ''">
-   and t.car_id= #{carId}
-</if> 
-
-
-     </select>
+    <select id="queryOwnerCarAttrsCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from owner_car_attr t
+        where 1 =1
+        <if test="attrId !=null and attrId != ''">
+            and t.attr_id= #{attrId}
+        </if>
+        <if test="createTime !=null and createTime != ''">
+            and t.create_time= #{createTime}
+        </if>
+        <if test="specCd !=null and specCd != ''">
+            and t.spec_cd= #{specCd}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="bId !=null and bId != ''">
+            and t.b_id= #{bId}
+        </if>
+        <if test="value !=null and value != ''">
+            and t.value= #{value}
+        </if>
+        <if test="carId !=null and carId != ''">
+            and t.car_id= #{carId}
+        </if>
+
+
+    </select>
 
 </mapper>

+ 1 - 0
service-user/src/main/java/com/java110/user/dao/IOwnerCarAttrServiceDao.java

@@ -78,4 +78,5 @@ public interface IOwnerCarAttrServiceDao {
      */
     int queryOwnerCarAttrsCount(Map info);
 
+    int saveOwnerCarAttr(Map beanCovertMap);
 }

+ 36 - 23
service-user/src/main/java/com/java110/user/dao/impl/OwnerCarAttrServiceDaoImpl.java

@@ -1,15 +1,14 @@
 package com.java110.user.dao.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.user.dao.IOwnerCarAttrServiceDao;
 import com.java110.utils.constant.ResponseConstant;
 import com.java110.utils.exception.DAOException;
 import com.java110.utils.util.DateUtil;
-import com.java110.core.base.dao.BaseServiceDao;
-import com.java110.user.dao.IOwnerCarAttrServiceDao;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.Map;
@@ -26,6 +25,7 @@ public class OwnerCarAttrServiceDaoImpl extends BaseServiceDao implements IOwner
 
     /**
      * 业主车辆属性信息封装
+     *
      * @param businessOwnerCarAttrInfo 业主车辆属性信息 封装
      * @throws DAOException DAO异常
      */
@@ -33,17 +33,18 @@ public class OwnerCarAttrServiceDaoImpl extends BaseServiceDao implements IOwner
     public void saveBusinessOwnerCarAttrInfo(Map businessOwnerCarAttrInfo) throws DAOException {
         businessOwnerCarAttrInfo.put("month", DateUtil.getCurrentMonth());
         // 查询business_user 数据是否已经存在
-        logger.debug("保存业主车辆属性信息 入参 businessOwnerCarAttrInfo : {}",businessOwnerCarAttrInfo);
-        int saveFlag = sqlSessionTemplate.insert("ownerCarAttrServiceDaoImpl.saveBusinessOwnerCarAttrInfo",businessOwnerCarAttrInfo);
+        logger.debug("保存业主车辆属性信息 入参 businessOwnerCarAttrInfo : {}", businessOwnerCarAttrInfo);
+        int saveFlag = sqlSessionTemplate.insert("ownerCarAttrServiceDaoImpl.saveBusinessOwnerCarAttrInfo", businessOwnerCarAttrInfo);
 
-        if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存业主车辆属性数据失败:"+ JSONObject.toJSONString(businessOwnerCarAttrInfo));
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存业主车辆属性数据失败:" + JSONObject.toJSONString(businessOwnerCarAttrInfo));
         }
     }
 
 
     /**
      * 查询业主车辆属性信息
+     *
      * @param info bId 信息
      * @return 业主车辆属性信息
      * @throws DAOException DAO异常
@@ -51,43 +52,44 @@ public class OwnerCarAttrServiceDaoImpl extends BaseServiceDao implements IOwner
     @Override
     public List<Map> getBusinessOwnerCarAttrInfo(Map info) throws DAOException {
 
-        logger.debug("查询业主车辆属性信息 入参 info : {}",info);
+        logger.debug("查询业主车辆属性信息 入参 info : {}", info);
 
-        List<Map> businessOwnerCarAttrInfos = sqlSessionTemplate.selectList("ownerCarAttrServiceDaoImpl.getBusinessOwnerCarAttrInfo",info);
+        List<Map> businessOwnerCarAttrInfos = sqlSessionTemplate.selectList("ownerCarAttrServiceDaoImpl.getBusinessOwnerCarAttrInfo", info);
 
         return businessOwnerCarAttrInfos;
     }
 
 
-
     /**
      * 保存业主车辆属性信息 到 instance
-     * @param info   bId 信息
+     *
+     * @param info bId 信息
      * @throws DAOException DAO异常
      */
     @Override
     public void saveOwnerCarAttrInfoInstance(Map info) throws DAOException {
-        logger.debug("保存业主车辆属性信息Instance 入参 info : {}",info);
+        logger.debug("保存业主车辆属性信息Instance 入参 info : {}", info);
 
-        int saveFlag = sqlSessionTemplate.insert("ownerCarAttrServiceDaoImpl.saveOwnerCarAttrInfoInstance",info);
+        int saveFlag = sqlSessionTemplate.insert("ownerCarAttrServiceDaoImpl.saveOwnerCarAttrInfoInstance", info);
 
-        if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"保存业主车辆属性信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存业主车辆属性信息Instance数据失败:" + JSONObject.toJSONString(info));
         }
     }
 
 
     /**
      * 查询业主车辆属性信息(instance)
+     *
      * @param info bId 信息
      * @return List<Map>
      * @throws DAOException DAO异常
      */
     @Override
     public List<Map> getOwnerCarAttrInfo(Map info) throws DAOException {
-        logger.debug("查询业主车辆属性信息 入参 info : {}",info);
+        logger.debug("查询业主车辆属性信息 入参 info : {}", info);
 
-        List<Map> businessOwnerCarAttrInfos = sqlSessionTemplate.selectList("ownerCarAttrServiceDaoImpl.getOwnerCarAttrInfo",info);
+        List<Map> businessOwnerCarAttrInfos = sqlSessionTemplate.selectList("ownerCarAttrServiceDaoImpl.getOwnerCarAttrInfo", info);
 
         return businessOwnerCarAttrInfos;
     }
@@ -95,28 +97,30 @@ public class OwnerCarAttrServiceDaoImpl extends BaseServiceDao implements IOwner
 
     /**
      * 修改业主车辆属性信息
+     *
      * @param info 修改信息
      * @throws DAOException DAO异常
      */
     @Override
     public void updateOwnerCarAttrInfoInstance(Map info) throws DAOException {
-        logger.debug("修改业主车辆属性信息Instance 入参 info : {}",info);
+        logger.debug("修改业主车辆属性信息Instance 入参 info : {}", info);
 
-        int saveFlag = sqlSessionTemplate.update("ownerCarAttrServiceDaoImpl.updateOwnerCarAttrInfoInstance",info);
+        int saveFlag = sqlSessionTemplate.update("ownerCarAttrServiceDaoImpl.updateOwnerCarAttrInfoInstance", info);
 
-        if(saveFlag < 1){
-            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR,"修改业主车辆属性信息Instance数据失败:"+ JSONObject.toJSONString(info));
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "修改业主车辆属性信息Instance数据失败:" + JSONObject.toJSONString(info));
         }
     }
 
-     /**
+    /**
      * 查询业主车辆属性数量
+     *
      * @param info 业主车辆属性信息
      * @return 业主车辆属性数量
      */
     @Override
     public int queryOwnerCarAttrsCount(Map info) {
-        logger.debug("查询业主车辆属性数据 入参 info : {}",info);
+        logger.debug("查询业主车辆属性数据 入参 info : {}", info);
 
         List<Map> businessOwnerCarAttrInfos = sqlSessionTemplate.selectList("ownerCarAttrServiceDaoImpl.queryOwnerCarAttrsCount", info);
         if (businessOwnerCarAttrInfos.size() < 1) {
@@ -126,5 +130,14 @@ public class OwnerCarAttrServiceDaoImpl extends BaseServiceDao implements IOwner
         return Integer.parseInt(businessOwnerCarAttrInfos.get(0).get("count").toString());
     }
 
+    @Override
+    public int saveOwnerCarAttr(Map beanCovertMap) {
+        logger.debug("保存业主车辆属性信息Instance 入参 info : {}", beanCovertMap);
+
+        int saveFlag = sqlSessionTemplate.insert("ownerCarAttrServiceDaoImpl.saveOwnerCarAttr", beanCovertMap);
+
+        return saveFlag;
+    }
+
 
 }

+ 6 - 0
service-user/src/main/java/com/java110/user/smo/impl/OwnerCarAttrInnerServiceSMOImpl.java

@@ -6,6 +6,7 @@ import com.java110.core.smo.user.IOwnerCarAttrInnerServiceSMO;
 import com.java110.dto.PageDto;
 import com.java110.dto.ownerCarAttr.OwnerCarAttrDto;
 import com.java110.dto.user.UserDto;
+import com.java110.po.ownerCarAttr.OwnerCarAttrPo;
 import com.java110.user.dao.IOwnerCarAttrServiceDao;
 import com.java110.utils.util.BeanConvertUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -80,6 +81,11 @@ public class OwnerCarAttrInnerServiceSMOImpl extends BaseServiceSMO implements I
         return ownerCarAttrServiceDaoImpl.queryOwnerCarAttrsCount(BeanConvertUtil.beanCovertMap(ownerCarAttrDto));
     }
 
+    @Override
+    public int saveOwnerCarAttr(@RequestBody OwnerCarAttrPo ownerCarAttrPo) {
+        return ownerCarAttrServiceDaoImpl.saveOwnerCarAttr(BeanConvertUtil.beanCovertMap(ownerCarAttrPo));
+    }
+
     public IOwnerCarAttrServiceDao getOwnerCarAttrServiceDaoImpl() {
         return ownerCarAttrServiceDaoImpl;
     }