Browse Source

优化代码

1098226878 4 years ago
parent
commit
b72b6223a8

+ 12 - 0
java110-bean/src/main/java/com/java110/po/floor/FloorPo.java

@@ -12,11 +12,15 @@ import java.io.Serializable;
  **/
 public class FloorPo implements Serializable {
 
+    public static final String FLOOR_ATTR_LARGE = "100201912001";//大厦楼栋 属性
+    public static final String FLOOR_ATTR_VALUE = "8008";//大厦楼栋 属性值
+
     private String floorId;
     private String floorNum;
     private String floorArea;
     private String name;
     private String userId;
+    private String bId;
     private String remark;
     private String communityId;
     private String statusCd;
@@ -84,4 +88,12 @@ public class FloorPo implements Serializable {
     public void setStatusCd(String statusCd) {
         this.statusCd = statusCd;
     }
+
+    public String getbId() {
+        return bId;
+    }
+
+    public void setbId(String bId) {
+        this.bId = bId;
+    }
 }

+ 0 - 127
java110-db/src/main/resources/mapper/community/FFloorV1ServiceDaoImplMapper.xml

@@ -1,127 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper
-        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="fFloorV1ServiceDaoImpl">
-
-
-
-
-
-    <!-- 保存楼栋信息 add by wuxw 2018-07-03 -->
-    <insert id="saveFFloorInfo" parameterType="Map">
-        insert into f_floor(
-floor_id,name,remark,b_id,community_id,user_id,floor_num,floor_area
-) values (
-#{floorId},#{name},#{remark},#{bId},#{communityId},#{userId},#{floorNum},#{floorArea}
-)
-    </insert>
-
-
-
-    <!-- 查询楼栋信息 add by wuxw 2018-07-03 -->
-    <select id="getFFloorInfo" parameterType="Map" resultType="Map">
-        select  t.floor_id,t.floor_id floorId,t.name,t.remark,t.b_id,t.b_id bId,t.community_id,t.community_id communityId,t.user_id,t.user_id userId,t.floor_num,t.floor_num floorNum,t.floor_area,t.floor_area floorArea 
-from f_floor t 
-where 1 =1 
-<if test="floorId !=null and floorId != ''">
-   and t.floor_id= #{floorId}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</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="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="userId !=null and userId != ''">
-   and t.user_id= #{userId}
-</if> 
-<if test="floorNum !=null and floorNum != ''">
-   and t.floor_num= #{floorNum}
-</if> 
-<if test="floorArea !=null and floorArea != ''">
-   and t.floor_area= #{floorArea}
-</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="updateFFloorInfo" parameterType="Map">
-        update  f_floor t set t.status_cd = #{statusCd}
-<if test="newBId != null and newBId != ''">
-,t.b_id = #{newBId}
-</if> 
-<if test="name !=null and name != ''">
-, t.name= #{name}
-</if> 
-<if test="remark !=null and remark != ''">
-, t.remark= #{remark}
-</if> 
-<if test="communityId !=null and communityId != ''">
-, t.community_id= #{communityId}
-</if> 
-<if test="userId !=null and userId != ''">
-, t.user_id= #{userId}
-</if> 
-<if test="floorNum !=null and floorNum != ''">
-, t.floor_num= #{floorNum}
-</if> 
-<if test="floorArea !=null and floorArea != ''">
-, t.floor_area= #{floorArea}
-</if> 
- where 1=1 <if test="floorId !=null and floorId != ''">
-and t.floor_id= #{floorId}
-</if> 
-<if test="bId !=null and bId != ''">
-and t.b_id= #{bId}
-</if> 
-
-    </update>
-
-    <!-- 查询楼栋数量 add by wuxw 2018-07-03 -->
-     <select id="queryFFloorsCount" parameterType="Map" resultType="Map">
-        select  count(1) count 
-from f_floor t 
-where 1 =1 
-<if test="floorId !=null and floorId != ''">
-   and t.floor_id= #{floorId}
-</if> 
-<if test="name !=null and name != ''">
-   and t.name= #{name}
-</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="communityId !=null and communityId != ''">
-   and t.community_id= #{communityId}
-</if> 
-<if test="userId !=null and userId != ''">
-   and t.user_id= #{userId}
-</if> 
-<if test="floorNum !=null and floorNum != ''">
-   and t.floor_num= #{floorNum}
-</if> 
-<if test="floorArea !=null and floorArea != ''">
-   and t.floor_area= #{floorArea}
-</if> 
-
-
-     </select>
-
-</mapper>

+ 6 - 4
java110-db/src/main/resources/mapper/community/FloorV1ServiceDaoImplMapper.xml

@@ -22,8 +22,9 @@ floor_id,name,remark,b_id,community_id,user_id,floor_num,floor_area
     <!-- 查询楼栋信息 add by wuxw 2018-07-03 -->
     <select id="getFloorInfo" parameterType="Map" resultType="Map">
         select  t.floor_id,t.floor_id floorId,t.name,t.remark,t.b_id,t.b_id bId,t.community_id,t.community_id communityId,t.user_id,t.user_id userId,t.floor_num,t.floor_num floorNum,t.floor_area,t.floor_area floorArea 
-from f_floor t 
-where 1 =1 
+from f_floor t
+LEFT JOIN f_floor_attr t2 on t.floor_id = t2.floor_id
+where t2.spec_cd='100201912001' and t2.value='8008' and t.status_cd=0
 <if test="floorId !=null and floorId != ''">
    and t.floor_id= #{floorId}
 </if> 
@@ -94,8 +95,9 @@ and t.b_id= #{bId}
     <!-- 查询楼栋数量 add by wuxw 2018-07-03 -->
      <select id="queryFloorsCount" parameterType="Map" resultType="Map">
         select  count(1) count 
-from f_floor t 
-where 1 =1 
+from f_floor t
+LEFT JOIN f_floor_attr t2 on t.floor_id = t2.floor_id
+where t2.spec_cd='100201912001' and t2.value='8008' and t.status_cd=0
 <if test="floorId !=null and floorId != ''">
    and t.floor_id= #{floorId}
 </if> 

+ 0 - 1
service-community/src/main/java/com/java110/community/cmd/floor/DeleteFloorCmd.java

@@ -52,7 +52,6 @@ public class DeleteFloorCmd extends AbstractServiceCmdListener {
     @Override
     protected void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "floorId", "floorId不能为空");
-        Assert.hasKeyAndValue(reqJson, "floorId", "floorId不能为空");
 
     }
 

+ 16 - 3
service-community/src/main/java/com/java110/community/cmd/floor/SaveFloorCmd.java

@@ -22,8 +22,10 @@ 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.intf.community.IFloorAttrInnerServiceSMO;
 import com.java110.intf.community.IFloorV1InnerServiceSMO;
 import com.java110.po.floor.FloorPo;
+import com.java110.po.floorAttr.FloorAttrPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -51,14 +53,13 @@ public class SaveFloorCmd extends AbstractServiceCmdListener {
 
     @Autowired
     private IFloorV1InnerServiceSMO floorV1InnerServiceSMOImpl;
+    @Autowired
+    private IFloorAttrInnerServiceSMO floorAttrInnerServiceSMOImpl;
 
     @Override
     protected void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
-        Assert.hasKeyAndValue(reqJson, "floorId", "请求报文中未包含floorId");
-        Assert.hasKeyAndValue(reqJson, "bId", "请求报文中未包含bId");
         Assert.hasKeyAndValue(reqJson, "floorNum", "请求报文中未包含floorNum");
         Assert.hasKeyAndValue(reqJson, "name", "请求报文中未包含name");
-        Assert.hasKeyAndValue(reqJson, "userId", "请求报文中未包含userId");
         Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含communityId");
         Assert.hasKeyAndValue(reqJson, "floorArea", "请求报文中未包含floorArea");
 
@@ -70,12 +71,24 @@ public class SaveFloorCmd extends AbstractServiceCmdListener {
 
         FloorPo floorPo = BeanConvertUtil.covertBean(reqJson, FloorPo.class);
         floorPo.setFloorId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+        floorPo.setbId("-1");
+        floorPo.setUserId(cmdDataFlowContext.getReqHeaders().get("user-id"));
         int flag = floorV1InnerServiceSMOImpl.saveFloor(floorPo);
 
         if (flag < 1) {
             throw new CmdException("保存数据失败");
         }
 
+        FloorAttrPo floorAttrPo = new FloorAttrPo();
+        floorAttrPo.setAttrId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+        floorAttrPo.setSpecCd(FloorPo.FLOOR_ATTR_LARGE);
+        floorAttrPo.setFloorId(floorPo.getFloorId());
+        floorAttrPo.setCommunityId(floorPo.getCommunityId());
+        floorAttrPo.setValue(FloorPo.FLOOR_ATTR_VALUE);
+        flag = floorAttrInnerServiceSMOImpl.saveFloorAttr(floorAttrPo);
+        if (flag < 1) {
+            throw new CmdException("保存大厦属性数据失败");
+        }
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }

+ 0 - 1
service-community/src/main/java/com/java110/community/cmd/floor/UpdateFloorCmd.java

@@ -55,7 +55,6 @@ public class UpdateFloorCmd extends AbstractServiceCmdListener {
     @Override
     protected void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "floorId", "floorId不能为空");
-        Assert.hasKeyAndValue(reqJson, "floorId", "floorId不能为空");
 
     }