From ce64e667815b39efdc2f8bd52be0d43d49db8d84 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期日, 17 七月 2022 00:06:29 +0800
Subject: [PATCH] 优化小区位置
---
service-user/src/main/java/com/java110/user/bmo/rentingPool/impl/SaveRentingPoolBMOImpl.java | 74 ++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 1 deletions(-)
diff --git a/service-user/src/main/java/com/java110/user/bmo/rentingPool/impl/SaveRentingPoolBMOImpl.java b/service-user/src/main/java/com/java110/user/bmo/rentingPool/impl/SaveRentingPoolBMOImpl.java
old mode 100644
new mode 100755
index 974e5c0..de08bf9
--- a/service-user/src/main/java/com/java110/user/bmo/rentingPool/impl/SaveRentingPoolBMOImpl.java
+++ b/service-user/src/main/java/com/java110/user/bmo/rentingPool/impl/SaveRentingPoolBMOImpl.java
@@ -1,8 +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;
@@ -10,11 +18,19 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
+import java.util.List;
+
@Service("saveRentingPoolBMOImpl")
public class SaveRentingPoolBMOImpl implements ISaveRentingPoolBMO {
@Autowired
private IRentingPoolInnerServiceSMO rentingPoolInnerServiceSMOImpl;
+
+ @Autowired
+ private IFileInnerServiceSMO fileInnerServiceSMOImpl;
+
+ @Autowired
+ private IFileRelInnerServiceSMO fileRelInnerServiceSMOImpl;
/**
* 娣诲姞灏忓尯淇℃伅
@@ -23,9 +39,25 @@
* @return 璁㈠崟鏈嶅姟鑳藉鎺ュ彈鐨勬姤鏂�
*/
@Java110Transactional
- public ResponseEntity<String> save(RentingPoolPo rentingPoolPo) {
+ public ResponseEntity<String> save(RentingPoolPo rentingPoolPo, JSONArray photos) {
+ //鏌ヨ 鏄惁宸茬粡瀛樺湪 鎴垮眿寰呭嚭绉熺殑鏁版嵁
+ RentingPoolDto rentingPoolDto = new RentingPoolDto();
+ rentingPoolDto.setCommunityId(rentingPoolPo.getCommunityId());
+ rentingPoolDto.setRoomId(rentingPoolPo.getRoomId());
+ rentingPoolDto.setStates(new String[]{"0", "1", "2", "3", "4", "5", "7"});
+ List<RentingPoolDto> rentingPoolDtos = rentingPoolInnerServiceSMOImpl.queryRentingPools(rentingPoolDto);
+
+ if (rentingPoolDtos != null && rentingPoolDtos.size() > 0) {
+ throw new IllegalArgumentException("璇ユ埧灞嬪綋鍓嶄负" + rentingPoolDtos.get(0).getStateName() + ",涓嶈兘鍐嶆鍑虹");
+ }
rentingPoolPo.setRentingId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_rentingId));
+ if (photos.size() > 0) {
+ savaRentingFile(photos, rentingPoolPo);
+ }
+
+
+
int flag = rentingPoolInnerServiceSMOImpl.saveRentingPool(rentingPoolPo);
if (flag > 0) {
@@ -35,4 +67,44 @@
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("淇濆瓨鏂囦欢澶辫触");
+ }
+ }
+
}
--
Gitblit v1.8.0