java110
2021-09-18 3c4a0a1edc6d33e9237dd0c1d84f0723c66c8475
优化代码
4个文件已修改
331 ■■■■ 已修改文件
java110-db/src/main/resources/mapper/community/CommunityV1ServiceDaoImplMapper.xml 278 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-service/src/main/java/com/java110/service/smo/impl/CmdServiceSMOImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-community/src/main/java/com/java110/community/cmd/community/SaveCommunityCmd.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-community/src/main/java/com/java110/community/cmd/community/UpdateCommunityCmd.java 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-db/src/main/resources/mapper/community/CommunityV1ServiceDaoImplMapper.xml
@@ -5,165 +5,163 @@
<mapper namespace="communityV1ServiceDaoImpl">
    <!-- 保存小区管理信息 add by wuxw 2018-07-03 -->
    <insert id="saveCommunityInfo" parameterType="Map">
        insert into s_community(
fee_price,address,city_code,map_y,pay_fee_month,map_x,nearby_landmarks,name,tel,state,community_id,community_area
) values (
#{feePrice},#{address},#{cityCode},#{mapY},#{payFeeMonth},#{mapX},#{nearbyLandmarks},#{name},#{tel},#{state},#{communityId},#{communityArea}
)
        fee_price,address,city_code,map_y,pay_fee_month,map_x,nearby_landmarks,name,tel,state,community_id,community_area
        ) values (
        #{feePrice},#{address},#{cityCode},#{mapY},#{payFeeMonth},#{mapX},#{nearbyLandmarks},#{name},#{tel},#{state},#{communityId},#{communityArea}
        )
    </insert>
    <!-- 查询小区管理信息 add by wuxw 2018-07-03 -->
    <select id="getCommunityInfo" parameterType="Map" resultType="Map">
        select  t.fee_price,t.fee_price feePrice,t.address,t.city_code,t.city_code cityCode,t.status_cd,t.status_cd statusCd,t.map_y,t.map_y mapY,t.pay_fee_month,t.pay_fee_month payFeeMonth,t.map_x,t.map_x mapX,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,t.name,t.tel,t.state,t.community_id,t.community_id communityId,t.community_area,t.community_area communityArea
from s_community t
where 1 =1
<if test="feePrice !=null and feePrice != ''">
   and t.fee_price= #{feePrice}
</if>
<if test="address !=null and address != ''">
   and t.address= #{address}
</if>
<if test="cityCode !=null and cityCode != ''">
   and t.city_code= #{cityCode}
</if>
<if test="statusCd !=null and statusCd != ''">
   and t.status_cd= #{statusCd}
</if>
<if test="mapY !=null and mapY != ''">
   and t.map_y= #{mapY}
</if>
<if test="payFeeMonth !=null and payFeeMonth != ''">
   and t.pay_fee_month= #{payFeeMonth}
</if>
<if test="mapX !=null and mapX != ''">
   and t.map_x= #{mapX}
</if>
<if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
   and t.nearby_landmarks= #{nearbyLandmarks}
</if>
<if test="name !=null and name != ''">
   and t.name= #{name}
</if>
<if test="tel !=null and tel != ''">
   and t.tel= #{tel}
</if>
<if test="state !=null and state != ''">
   and t.state= #{state}
</if>
<if test="communityId !=null and communityId != ''">
   and t.community_id= #{communityId}
</if>
<if test="communityArea !=null and communityArea != ''">
   and t.community_area= #{communityArea}
</if>
order by t.create_time desc
<if test="page != -1 and page != null ">
   limit #{page}, #{row}
</if>
        select t.fee_price,t.fee_price feePrice,t.address,t.city_code,t.city_code cityCode,t.status_cd,t.status_cd
        statusCd,t.map_y,t.map_y mapY,t.pay_fee_month,t.pay_fee_month payFeeMonth,t.map_x,t.map_x
        mapX,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,t.name,t.tel,t.state,t.community_id,t.community_id
        communityId,t.community_area,t.community_area communityArea
        from s_community t
        where 1 =1
        <if test="feePrice !=null and feePrice != ''">
            and t.fee_price= #{feePrice}
        </if>
        <if test="address !=null and address != ''">
            and t.address= #{address}
        </if>
        <if test="cityCode !=null and cityCode != ''">
            and t.city_code= #{cityCode}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="mapY !=null and mapY != ''">
            and t.map_y= #{mapY}
        </if>
        <if test="payFeeMonth !=null and payFeeMonth != ''">
            and t.pay_fee_month= #{payFeeMonth}
        </if>
        <if test="mapX !=null and mapX != ''">
            and t.map_x= #{mapX}
        </if>
        <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
            and t.nearby_landmarks= #{nearbyLandmarks}
        </if>
        <if test="name !=null and name != ''">
            and t.name= #{name}
        </if>
        <if test="tel !=null and tel != ''">
            and t.tel= #{tel}
        </if>
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="communityArea !=null and communityArea != ''">
            and t.community_area= #{communityArea}
        </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="updateCommunityInfo" parameterType="Map">
        update  s_community t set t.status_cd = #{statusCd}
<if test="newBId != null and newBId != ''">
,t.b_id = #{newBId}
</if>
<if test="feePrice !=null and feePrice != ''">
, t.fee_price= #{feePrice}
</if>
<if test="address !=null and address != ''">
, t.address= #{address}
</if>
<if test="cityCode !=null and cityCode != ''">
, t.city_code= #{cityCode}
</if>
<if test="mapY !=null and mapY != ''">
, t.map_y= #{mapY}
</if>
<if test="payFeeMonth !=null and payFeeMonth != ''">
, t.pay_fee_month= #{payFeeMonth}
</if>
<if test="mapX !=null and mapX != ''">
, t.map_x= #{mapX}
</if>
<if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
, t.nearby_landmarks= #{nearbyLandmarks}
</if>
<if test="name !=null and name != ''">
, t.name= #{name}
</if>
<if test="tel !=null and tel != ''">
, t.tel= #{tel}
</if>
<if test="state !=null and state != ''">
, t.state= #{state}
</if>
<if test="communityArea !=null and communityArea != ''">
, t.community_area= #{communityArea}
</if>
 where 1=1 <if test="communityId !=null and communityId != ''">
and t.community_id= #{communityId}
</if>
        update s_community t set t.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,t.b_id = #{newBId}
        </if>
        <if test="feePrice !=null and feePrice != ''">
            , t.fee_price= #{feePrice}
        </if>
        <if test="address !=null and address != ''">
            , t.address= #{address}
        </if>
        <if test="cityCode !=null and cityCode != ''">
            , t.city_code= #{cityCode}
        </if>
        <if test="mapY !=null and mapY != ''">
            , t.map_y= #{mapY}
        </if>
        <if test="payFeeMonth !=null and payFeeMonth != ''">
            , t.pay_fee_month= #{payFeeMonth}
        </if>
        <if test="mapX !=null and mapX != ''">
            , t.map_x= #{mapX}
        </if>
        <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
            , t.nearby_landmarks= #{nearbyLandmarks}
        </if>
        <if test="name !=null and name != ''">
            , t.name= #{name}
        </if>
        <if test="tel !=null and tel != ''">
            , t.tel= #{tel}
        </if>
        <if test="state !=null and state != ''">
            , t.state= #{state}
        </if>
        <if test="communityArea !=null and communityArea != ''">
            , t.community_area= #{communityArea}
        </if>
        where 1=1
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
    </update>
    <!-- 查询小区管理数量 add by wuxw 2018-07-03 -->
     <select id="queryCommunitysCount" parameterType="Map" resultType="Map">
        select  count(1) count
from s_community t
where 1 =1
<if test="feePrice !=null and feePrice != ''">
   and t.fee_price= #{feePrice}
</if>
<if test="address !=null and address != ''">
   and t.address= #{address}
</if>
<if test="cityCode !=null and cityCode != ''">
   and t.city_code= #{cityCode}
</if>
<if test="statusCd !=null and statusCd != ''">
   and t.status_cd= #{statusCd}
</if>
<if test="mapY !=null and mapY != ''">
   and t.map_y= #{mapY}
</if>
<if test="payFeeMonth !=null and payFeeMonth != ''">
   and t.pay_fee_month= #{payFeeMonth}
</if>
<if test="mapX !=null and mapX != ''">
   and t.map_x= #{mapX}
</if>
<if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
   and t.nearby_landmarks= #{nearbyLandmarks}
</if>
<if test="name !=null and name != ''">
   and t.name= #{name}
</if>
<if test="tel !=null and tel != ''">
   and t.tel= #{tel}
</if>
<if test="state !=null and state != ''">
   and t.state= #{state}
</if>
<if test="communityId !=null and communityId != ''">
   and t.community_id= #{communityId}
</if>
<if test="communityArea !=null and communityArea != ''">
   and t.community_area= #{communityArea}
</if>
    <select id="queryCommunitysCount" parameterType="Map" resultType="Map">
        select count(1) count
        from s_community t
        where 1 =1
        <if test="feePrice !=null and feePrice != ''">
            and t.fee_price= #{feePrice}
        </if>
        <if test="address !=null and address != ''">
            and t.address= #{address}
        </if>
        <if test="cityCode !=null and cityCode != ''">
            and t.city_code= #{cityCode}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="mapY !=null and mapY != ''">
            and t.map_y= #{mapY}
        </if>
        <if test="payFeeMonth !=null and payFeeMonth != ''">
            and t.pay_fee_month= #{payFeeMonth}
        </if>
        <if test="mapX !=null and mapX != ''">
            and t.map_x= #{mapX}
        </if>
        <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
            and t.nearby_landmarks= #{nearbyLandmarks}
        </if>
        <if test="name !=null and name != ''">
            and t.name= #{name}
        </if>
        <if test="tel !=null and tel != ''">
            and t.tel= #{tel}
        </if>
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="communityArea !=null and communityArea != ''">
            and t.community_area= #{communityArea}
        </if>
     </select>
    </select>
</mapper>
java110-service/src/main/java/com/java110/service/smo/impl/CmdServiceSMOImpl.java
@@ -19,10 +19,10 @@
import com.java110.utils.kafka.KafkaFactory;
import com.java110.utils.log.LoggerEngine;
import com.java110.utils.util.DateUtil;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -67,9 +67,6 @@
        ResponseEntity<String> responseEntity = null;
        String resJson = "";
        //1.0 创建数据流 appId serviceCode
        cmdDataFlowContext = DataFlowFactory.newInstance(CmdDataFlow.class).builder(reqJson, headers);
@@ -82,8 +79,7 @@
        Date endDate = DateUtil.getCurrentDate();
        if (responseEntity == null) {
            //resJson = encrypt(responseJson.toJSONString(),headers);
            responseEntity = new ResponseEntity<String>(resJson, HttpStatus.OK);
            responseEntity = ResultVo.success();
        }
        return responseEntity;
    }
service-community/src/main/java/com/java110/community/cmd/community/SaveCommunityCmd.java
@@ -31,6 +31,7 @@
import com.java110.utils.constant.BusinessTypeConstant;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -122,6 +123,7 @@
        if (flag < 1) {
            throw new IllegalArgumentException("添加流程失败");
        }
        cmdDataFlowContext.setResponseEntity(ResultVo.success());
    }
service-community/src/main/java/com/java110/community/cmd/community/UpdateCommunityCmd.java
@@ -15,17 +15,18 @@
 */
package com.java110.community.cmd.community;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.community.bmo.community.ICommunityBMO;
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.intf.community.ICommunityV1InnerServiceSMO;
import com.java110.po.community.CommunityPo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,9 +52,20 @@
    @Autowired
    private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
    @Autowired
    private ICommunityBMO communityBMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
        Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
        Assert.hasKeyAndValue(reqJson, "communityId", "小区ID不能为空");
        Assert.hasKeyAndValue(reqJson, "name", "必填,请填写小区名称");
        Assert.hasKeyAndValue(reqJson, "address", "必填,请填写小区地址");
        Assert.hasKeyAndValue(reqJson, "nearbyLandmarks", "必填,请填写小区附近地标");
        Assert.judgeAttrValue(reqJson);
    }
@@ -61,11 +73,28 @@
    @Java110Transactional
    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
        CommunityPo communityPo = BeanConvertUtil.covertBean(reqJson, CommunityPo.class);
        int flag = communityV1InnerServiceSMOImpl.updateCommunity(communityPo);
        if (flag < 1) {
            throw new CmdException("更新数据失败");
        communityBMOImpl.updateCommunityOne(reqJson, cmdDataFlowContext);
        if (!reqJson.containsKey("attrs")) {
            return;
        }
        JSONArray attrs = reqJson.getJSONArray("attrs");
        if (attrs.size() < 1) {
            return;
        }
        JSONObject attr = null;
        for (int attrIndex = 0; attrIndex < attrs.size(); attrIndex++) {
            attr = attrs.getJSONObject(attrIndex);
            attr.put("communityId", reqJson.getString("communityId"));
            if (!attr.containsKey("attrId") || attr.getString("attrId").startsWith("-") || StringUtil.isEmpty(attr.getString("attrId"))) {
                communityBMOImpl.addAttr(attr, cmdDataFlowContext);
                continue;
            }
            communityBMOImpl.updateAttr(attr, cmdDataFlowContext);
        }
        cmdDataFlowContext.setResponseEntity(ResultVo.success());