java110 лет назад: 5
Родитель
Сommit
21b39f19d5

+ 11 - 0
java110-bean/src/main/java/com/java110/dto/file/FileRelDto.java

@@ -17,6 +17,8 @@ public class FileRelDto extends PageDto implements Serializable {
 
 
     public static final String REL_TYPE_CD_REPAIR = "14000";//报修图片
+    public static final String REL_TYPE_CD_RENTING = "16000";//租赁图片
+    public static final String SAVE_WAY_FTP = "ftp";//租赁图片
 
     private String relTypeCd;
     private String[] relTypeCds;
@@ -24,6 +26,7 @@ public class FileRelDto extends PageDto implements Serializable {
     private String fileRelId;
     private String fileRealName;
     private String objId;
+    private String[] objIds;
     private String fileSaveName;
 
 
@@ -104,4 +107,12 @@ public class FileRelDto extends PageDto implements Serializable {
     public void setRelTypeCds(String[] relTypeCds) {
         this.relTypeCds = relTypeCds;
     }
+
+    public String[] getObjIds() {
+        return objIds;
+    }
+
+    public void setObjIds(String[] objIds) {
+        this.objIds = objIds;
+    }
 }

+ 12 - 0
java110-bean/src/main/java/com/java110/dto/rentingPool/RentingPoolDto.java

@@ -1,9 +1,11 @@
 package com.java110.dto.rentingPool;
 
 import com.java110.dto.PageDto;
+import com.java110.vo.api.junkRequirement.PhotoVo;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName FloorDto
@@ -66,6 +68,8 @@ public class RentingPoolDto extends PageDto implements Serializable {
     private String servicePrice;
     private String rentingFormula;
 
+    List<String> photos;
+
 
     public String getLatitude() {
         return latitude;
@@ -323,4 +327,12 @@ public class RentingPoolDto extends PageDto implements Serializable {
     public void setApartmentName(String apartmentName) {
         this.apartmentName = apartmentName;
     }
+
+    public List<String> getPhotos() {
+        return photos;
+    }
+
+    public void setPhotos(List<String> photos) {
+        this.photos = photos;
+    }
 }

+ 22 - 6
java110-db/src/main/resources/mapper/common/FileRelServiceDaoImplMapper.xml

@@ -6,12 +6,12 @@
 
     <!-- 保存文件存放信息 add by wuxw 2018-07-03 -->
     <insert id="saveBusinessFileRelInfo" parameterType="Map">
-           insert into business_file_rel(
-rel_type_cd,save_way,operate,file_rel_id,file_real_name,obj_id,file_save_name,b_id
-) values (
-#{relTypeCd},#{saveWay},#{operate},#{fileRelId},#{fileRealName},#{objId},#{fileSaveName},#{bId}
-)
-       </insert>
+        insert into business_file_rel(
+        rel_type_cd,save_way,operate,file_rel_id,file_real_name,obj_id,file_save_name,b_id
+        ) values (
+        #{relTypeCd},#{saveWay},#{operate},#{fileRelId},#{fileRealName},#{objId},#{fileSaveName},#{bId}
+        )
+    </insert>
 
 
     <!-- 查询文件存放信息(Business) add by wuxw 2018-07-03 -->
@@ -80,6 +80,15 @@ rel_type_cd,save_way,operate,file_rel_id,file_real_name,obj_id,file_save_name,b_
 
     </insert>
 
+    <insert id="saveFileRel" parameterType="Map">
+        insert into file_rel(
+            rel_type_cd,save_way,file_rel_id,file_real_name,obj_id,file_save_name,b_id
+        )
+        values(
+            #{relTypeCd},#{saveWay},#{fileRelId},#{fileRealName},#{objId},#{fileSaveName},'-1'
+        )
+    </insert>
+
 
     <!-- 查询文件存放信息 add by wuxw 2018-07-03 -->
     <select id="getFileRelInfo" parameterType="Map" resultType="Map">
@@ -110,6 +119,13 @@ rel_type_cd,save_way,operate,file_rel_id,file_real_name,obj_id,file_save_name,b_
         <if test="objId !=null and objId != ''">
             and t.obj_id= #{objId}
         </if>
+        <if test="objIds !=null">
+            and t.obj_id in
+            <foreach collection="objIds" open="(" close=")"
+                     separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
         <if test="fileSaveName !=null and fileSaveName != ''">
             and t.file_save_name= #{fileSaveName}
         </if>

+ 5 - 0
java110-interface/src/main/java/com/java110/intf/common/IFileRelInnerServiceSMO.java

@@ -2,6 +2,7 @@ package com.java110.intf.common;
 
 import com.java110.config.feign.FeignConfiguration;
 import com.java110.dto.file.FileRelDto;
+import com.java110.po.file.FileRelPo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -30,6 +31,10 @@ public interface IFileRelInnerServiceSMO {
     @RequestMapping(value = "/queryFileRels", method = RequestMethod.POST)
     List<FileRelDto> queryFileRels(@RequestBody FileRelDto fileRelDto);
 
+
+    @RequestMapping(value = "/queryFileRels", method = RequestMethod.POST)
+    public int saveFileRel(@RequestBody FileRelPo fileRelPo);
+
     /**
      * 查询<p>小区楼</p>总记录数
      *

+ 9 - 0
service-common/src/main/java/com/java110/common/dao/IFileRelServiceDao.java

@@ -1,6 +1,7 @@
 package com.java110.common.dao;
 
 
+import com.java110.po.file.FileRelPo;
 import com.java110.utils.exception.DAOException;
 import com.java110.entity.merchant.BoMerchant;
 import com.java110.entity.merchant.BoMerchantAttr;
@@ -49,6 +50,14 @@ public interface IFileRelServiceDao {
     void saveFileRelInfoInstance(Map info) throws DAOException;
 
 
+    /**
+     * 保存文件管理
+     * @param info
+     * @return
+     */
+    int saveFileRel(Map info);
+
+
 
 
     /**

+ 11 - 0
service-common/src/main/java/com/java110/common/dao/impl/FileRelServiceDaoImpl.java

@@ -77,6 +77,17 @@ public class FileRelServiceDaoImpl extends BaseServiceDao implements IFileRelSer
         }
     }
 
+    @Override
+    public int saveFileRel(Map info) {
+        int saveFlag = sqlSessionTemplate.insert("fileRelServiceDaoImpl.saveFileRel", info);
+
+        if (saveFlag < 1) {
+            throw new DAOException(ResponseConstant.RESULT_PARAM_ERROR, "保存文件存放信息Instance数据失败:" + JSONObject.toJSONString(info));
+        }
+
+        return saveFlag;
+    }
+
 
     /**
      * 查询文件存放信息(instance)

+ 13 - 2
service-common/src/main/java/com/java110/common/smo/impl/FileRelInnerServiceSMOImpl.java

@@ -3,10 +3,11 @@ package com.java110.common.smo.impl;
 
 import com.java110.common.dao.IFileRelServiceDao;
 import com.java110.core.base.smo.BaseServiceSMO;
-import com.java110.intf.common.IFileRelInnerServiceSMO;
-import com.java110.intf.user.IUserInnerServiceSMO;
 import com.java110.dto.PageDto;
 import com.java110.dto.file.FileRelDto;
+import com.java110.intf.common.IFileRelInnerServiceSMO;
+import com.java110.intf.user.IUserInnerServiceSMO;
+import com.java110.po.file.FileRelPo;
 import com.java110.utils.util.BeanConvertUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -48,6 +49,16 @@ public class FileRelInnerServiceSMOImpl extends BaseServiceSMO implements IFileR
         return fileRels;
     }
 
+    /**
+     * 保存文件关系
+     * @param fileRelPo
+     * @return
+     */
+    @Override
+    public int saveFileRel(@RequestBody FileRelPo fileRelPo) {
+        return fileRelServiceDaoImpl.saveFileRel(BeanConvertUtil.beanCovertMap(fileRelPo));
+    }
+
 
     @Override
     public int queryFileRelsCount(@RequestBody FileRelDto fileRelDto) {

+ 8 - 1
service-user/src/main/java/com/java110/user/api/RentingApi.java

@@ -1,5 +1,6 @@
 package com.java110.user.api;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyuncs.utils.StringUtils;
 import com.java110.core.factory.GenerateCodeFactory;
@@ -176,10 +177,16 @@ public class RentingApi {
         Assert.hasKeyAndValue(reqJson, "rentingConfigId", "请求报文中未包含rentingConfigId");
         Assert.hasKeyAndValue(reqJson, "ownerName", "请求报文中未包含ownerName");
         Assert.hasKeyAndValue(reqJson, "ownerTel", "请求报文中未包含ownerTel");
+        JSONArray photos = null;
+        if (reqJson.containsKey("photos")) {
+            photos = reqJson.getJSONArray("photos");
+        }else{
+            photos = new JSONArray();
+        }
 
 
         RentingPoolPo rentingPoolPo = BeanConvertUtil.covertBean(reqJson, RentingPoolPo.class);
-        return saveRentingPoolBMOImpl.save(rentingPoolPo);
+        return saveRentingPoolBMOImpl.save(rentingPoolPo,photos);
     }
 
     /**

+ 2 - 1
service-user/src/main/java/com/java110/user/bmo/rentingPool/ISaveRentingPoolBMO.java

@@ -1,5 +1,6 @@
 package com.java110.user.bmo.rentingPool;
 
+import com.alibaba.fastjson.JSONArray;
 import com.java110.po.rentingPool.RentingPoolPo;
 import org.springframework.http.ResponseEntity;
 public interface ISaveRentingPoolBMO {
@@ -11,7 +12,7 @@ public interface ISaveRentingPoolBMO {
      * @param rentingPoolPo
      * @return
      */
-    ResponseEntity<String> save(RentingPoolPo rentingPoolPo);
+    ResponseEntity<String> save(RentingPoolPo rentingPoolPo, JSONArray photos);
 
 
 }

+ 26 - 0
service-user/src/main/java/com/java110/user/bmo/rentingPool/impl/GetRentingPoolBMOImpl.java

@@ -1,7 +1,9 @@
 package com.java110.user.bmo.rentingPool.impl;
 
 import com.java110.dto.RoomDto;
+import com.java110.dto.file.FileRelDto;
 import com.java110.dto.rentingPool.RentingPoolDto;
+import com.java110.intf.common.IFileRelInnerServiceSMO;
 import com.java110.intf.community.IRoomInnerServiceSMO;
 import com.java110.intf.user.IRentingPoolInnerServiceSMO;
 import com.java110.user.bmo.rentingPool.IGetRentingPoolBMO;
@@ -23,6 +25,9 @@ public class GetRentingPoolBMOImpl implements IGetRentingPoolBMO {
     @Autowired
     private IRoomInnerServiceSMO roomInnerServiceSMOImpl;
 
+    @Autowired
+    private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
+
 
     /**
      * @param rentingPoolDto
@@ -53,8 +58,11 @@ public class GetRentingPoolBMOImpl implements IGetRentingPoolBMO {
     private void refreshRoomInfo(List<RentingPoolDto> rentingPoolDtos) {
         List<String> roomIds = new ArrayList<>();
 
+        List<String> rentingIds = new ArrayList<>();
+
         for (RentingPoolDto rentingPoolDto : rentingPoolDtos) {
             roomIds.add(rentingPoolDto.getRoomId());
+            rentingIds.add(rentingPoolDto.getRentingId());
         }
 
         RoomDto roomDto = new RoomDto();
@@ -74,6 +82,24 @@ public class GetRentingPoolBMOImpl implements IGetRentingPoolBMO {
             }
         }
 
+
+        FileRelDto fileRelDto = new FileRelDto();
+        fileRelDto.setObjIds(rentingIds.toArray(new String[rentingIds.size()]));
+        List<FileRelDto> fileRelDtos = fileRelInnerServiceSMOImpl.queryFileRels(fileRelDto);
+
+        //刷入图片信息
+        List<String> photoVos = null;
+        String url = null;
+        for (RentingPoolDto rentingPoolDto : rentingPoolDtos) {
+            photoVos = new ArrayList<>();
+            for (FileRelDto tmpFileRelDto : fileRelDtos) {
+                if (rentingPoolDto.getRentingId().equals(tmpFileRelDto.getObjId())){
+                    url = "/callComponent/download/getFile/file?fileId=" + tmpFileRelDto.getFileRealName() + "&communityId=" + rentingPoolDto.getCommunityId();
+                    photoVos.add(url);
+                }
+            }
+            rentingPoolDto.setPhotos(photoVos);
+        }
     }
 
 }

+ 58 - 1
service-user/src/main/java/com/java110/user/bmo/rentingPool/impl/SaveRentingPoolBMOImpl.java

@@ -1,9 +1,16 @@
 package com.java110.user.bmo.rentingPool.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Transactional;
 import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.file.FileDto;
+import com.java110.dto.file.FileRelDto;
 import com.java110.dto.rentingPool.RentingPoolDto;
+import com.java110.intf.common.IFileInnerServiceSMO;
+import com.java110.intf.common.IFileRelInnerServiceSMO;
 import com.java110.intf.user.IRentingPoolInnerServiceSMO;
+import com.java110.po.file.FileRelPo;
 import com.java110.po.rentingPool.RentingPoolPo;
 import com.java110.user.bmo.rentingPool.ISaveRentingPoolBMO;
 import com.java110.vo.ResultVo;
@@ -19,6 +26,11 @@ public class SaveRentingPoolBMOImpl implements ISaveRentingPoolBMO {
     @Autowired
     private IRentingPoolInnerServiceSMO rentingPoolInnerServiceSMOImpl;
 
+    @Autowired
+    private IFileInnerServiceSMO fileInnerServiceSMOImpl;
+
+    private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
+
     /**
      * 添加小区信息
      *
@@ -26,7 +38,7 @@ public class SaveRentingPoolBMOImpl implements ISaveRentingPoolBMO {
      * @return 订单服务能够接受的报文
      */
     @Java110Transactional
-    public ResponseEntity<String> save(RentingPoolPo rentingPoolPo) {
+    public ResponseEntity<String> save(RentingPoolPo rentingPoolPo, JSONArray photos) {
 
         //查询 是否已经存在 房屋待出租的数据
         RentingPoolDto rentingPoolDto = new RentingPoolDto();
@@ -39,6 +51,11 @@ public class SaveRentingPoolBMOImpl implements ISaveRentingPoolBMO {
             throw new IllegalArgumentException("该房屋当前为" + rentingPoolDtos.get(0).getStateName() + ",不能再次出租");
         }
 
+        if (photos.size() > 0) {
+            savaRentingFile(photos, rentingPoolPo);
+        }
+
+
         rentingPoolPo.setRentingId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_rentingId));
         int flag = rentingPoolInnerServiceSMOImpl.saveRentingPool(rentingPoolPo);
 
@@ -49,4 +66,44 @@ public class SaveRentingPoolBMOImpl implements ISaveRentingPoolBMO {
         return ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "保存失败");
     }
 
+    private void savaRentingFile(JSONArray photos, RentingPoolPo rentingPoolPo) {
+        JSONObject photo = null;
+
+        for (int photoIndex = 0; photoIndex < photos.size(); photoIndex++) {
+            photo = photos.getJSONObject(photoIndex);
+            doSavaRentingFile(photo, rentingPoolPo);
+        }
+    }
+
+    /**
+     * 保存房屋租赁 图片
+     *
+     * @param photo
+     * @param rentingPoolPo
+     */
+    private void doSavaRentingFile(JSONObject photo, RentingPoolPo rentingPoolPo) {
+
+        FileDto fileDto = new FileDto();
+        fileDto.setCommunityId(rentingPoolPo.getCommunityId());
+        fileDto.setContext(photo.getString("photo"));
+        fileDto.setFileId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_file_id));
+        fileDto.setFileName(fileDto.getFileId());
+
+        fileDto.setSuffix("jpeg");
+        String fileName = fileInnerServiceSMOImpl.saveFile(fileDto);
+
+        FileRelPo fileRelPo = new FileRelPo();
+        fileRelPo.setObjId(rentingPoolPo.getRentingId());
+        fileRelPo.setRelTypeCd(FileRelDto.REL_TYPE_CD_RENTING);
+        fileRelPo.setFileRelId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_relId));
+        fileRelPo.setFileRealName(fileName);
+        fileRelPo.setFileSaveName(fileName);
+        fileRelPo.setSaveWay(FileRelDto.SAVE_WAY_FTP);
+        int save = fileRelInnerServiceSMOImpl.saveFileRel(fileRelPo);
+
+        if (save < 1) {
+            throw new IllegalArgumentException("保存文件失败");
+        }
+    }
+
 }