|
@@ -552,4 +552,77 @@ public class AdminTmHouseController {
|
|
|
return Result.success("删除成功");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增房源")
|
|
|
+ @PostMapping(value = "/add")
|
|
|
+ @ResponseBody
|
|
|
+ @RequiresRoles(value = {"super_admin", "normal_admin", "agency","sub_normal_admin"}, logical = Logical.OR)
|
|
|
+ public Result addHouse(@RequestBody @ApiParam(name = "房源对象", value = "传入json格式", required = true) TmHouse tmHouse) {
|
|
|
+
|
|
|
+ boolean result = false;
|
|
|
+ String houseId = UUidGenerator.generatorUuid(IdStarterEnum.HOUSE.getStarter());
|
|
|
+ if (null != tmHouse) {
|
|
|
+ if (StringUtils.isBlank(tmHouse.getAddress())) {
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D024);
|
|
|
+ }
|
|
|
+ //管控一个场景只能绑定一个房源
|
|
|
+ if (StringUtils.isNoneBlank(tmHouse.getSceneNum())) {
|
|
|
+ QueryWrapper<TmHouse> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("scene_num", tmHouse.getSceneNum());
|
|
|
+ queryWrapper.eq("enable", 1);
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ TmHouse dbhouse = tmHouseDao.selectOne(queryWrapper);
|
|
|
+ if (null != dbhouse) {
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D025);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isNoneBlank(tmHouse.getVrLink())) {
|
|
|
+ String qrCodeUrl = "/pages/web/web?vr_link=" + tmHouse.getVrLink();
|
|
|
+ //生成带看页面的二维码
|
|
|
+ String imageLocalPath = imageFilePath + houseId + "_QRCode.png";
|
|
|
+ WxOpUtils.getWxQRCode(qrCodeUrl, userWxAppId, userWxAppSecret, imageLocalPath);
|
|
|
+ String ossPath = ossImagePath + houseId + "_QRCode.png";
|
|
|
+ ossCheckPointUploadUtil.upload2(imageLocalPath, ossPath);
|
|
|
+ String imageTotalOssUrl = ossQueryUrl + ossPath;
|
|
|
+ tmHouse.setWxAqrCode(imageTotalOssUrl);
|
|
|
+ File file = new File(imageLocalPath);
|
|
|
+ if (file.exists()) {
|
|
|
+ //删除本地缓存的二维码
|
|
|
+ file.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TmAdmin user = ShiroUtils.getAdmin();
|
|
|
+ if(user == null){
|
|
|
+ log.error("用户未登录,登录");
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "未登录,请登录");
|
|
|
+ }
|
|
|
+ if(null == user.getDeptId()){
|
|
|
+ log.error("用户未分配部门,无法新增数据");
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "用户未分配部门,无法新增数据");
|
|
|
+ }
|
|
|
+ tmHouse.setCreateUserDeptId(user.getDeptId());
|
|
|
+ tmHouse.setCreateUserId(user.getAdminId());
|
|
|
+ tmHouse.setUpdateUserId(user.getAdminId());
|
|
|
+// tmHouse.setArea(tmHouse.getBuildingArea());
|
|
|
+ tmHouse.setHouseId(houseId);
|
|
|
+ tmHouse.setDistributeStatus(0);
|
|
|
+ tmHouse.setCreateTime(new Date());
|
|
|
+ tmHouse.setLastModifyDatetime(new Date());
|
|
|
+ tmHouse.setEnable(1);
|
|
|
+ tmHouse.setQueryNum(0L);
|
|
|
+ //TODO:这里添加部门信息
|
|
|
+ int insert = tmHouseDao.insert(tmHouse);
|
|
|
+ if (insert == 1) {
|
|
|
+ result = true;
|
|
|
+ log.info("成功插入房源[{}]数据", houseId);
|
|
|
+ } else {
|
|
|
+ log.info("插入房源失败:{}", insert);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ log.warn("数据非法,无法新增房源");
|
|
|
+ }
|
|
|
+ return result ? Result.success("新增房源成功", houseId) : Result.failure("新增房源失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|