|
@@ -1,16 +1,20 @@
|
|
|
package fcb.project.manager.core.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.aliyun.oss.internal.OSSUtils;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import fcb.project.manager.base.entity.*;
|
|
|
import fcb.project.manager.base.enums.AuditStatus;
|
|
|
import fcb.project.manager.base.enums.HouseStatus;
|
|
|
+import fcb.project.manager.base.enums.SysUserRoleEnums;
|
|
|
import fcb.project.manager.base.service.custom.PanoService;
|
|
|
import fcb.project.manager.base.service.impl.TmAuditServiceImpl;
|
|
|
import fcb.project.manager.base.service.impl.TmEstateServiceImpl;
|
|
|
import fcb.project.manager.base.service.impl.TmHouseServiceImpl;
|
|
|
import fcb.project.manager.base.service.impl.TmOperationServiceImpl;
|
|
|
import fcb.project.manager.base.utils.DataUtils;
|
|
|
+import fcb.project.manager.base.utils.DateUtil;
|
|
|
+import fcb.project.manager.base.utils.ExcelUtil;
|
|
|
import fcb.project.manager.core.feignInterfaces.SceneFeign;
|
|
|
import fdage.back.sdk.base.entity.Result;
|
|
|
import fdage.back.sdk.base.enums.ResultCodeEnum;
|
|
@@ -31,12 +35,14 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.*;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -64,6 +70,9 @@ public class HouseManagerController extends BaseController{
|
|
|
@Value("${image.local.path}")
|
|
|
private String imageLocalPath;
|
|
|
|
|
|
+ @Value("${excel.local.path}")
|
|
|
+ private String excelLocalPath;
|
|
|
+
|
|
|
@Value("${inner.vr.scene.host}")
|
|
|
private String innerSceneVrHost;
|
|
|
|
|
@@ -130,10 +139,12 @@ public class HouseManagerController extends BaseController{
|
|
|
@ApiOperation(value = "审核管理页面根据条件拉取所有房源")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "houseTitle", value = "房源名称", paramType = "query", required = false, dataType = "String"),
|
|
|
- @ApiImplicitParam(name = "status", value = "状态: 0->草稿;1->待审核;2->已审核;3->未通过", paramType = "query", required = false, dataType = "Integer"),
|
|
|
+ @ApiImplicitParam(name = "status", value = "状态: 0 -> 草稿;1->待集团审核;2->已审核;-1->未通过;3->待地区审核", paramType = "query", required = false, dataType = "Integer"),
|
|
|
@ApiImplicitParam(name = "type", value = "房源类型: 1->新房,2->二手房", paramType = "query", required = true, dataType = "String"),
|
|
|
@ApiImplicitParam(name = "belongCompany", value = "所属公司ID", paramType = "query", required = true, dataType = "String"),
|
|
|
@ApiImplicitParam(name = "estateName", value = "楼盘名称", paramType = "query", required = true, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startTime", value = "审核开始时间(00:00:00)", paramType = "query", required = true, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endTime", value = "审核结束时间(23:59:59)", paramType = "query", required = true, dataType = "String"),
|
|
|
@ApiImplicitParam(name = "pageNum", value = "当前页码", paramType = "query", required = true, dataType = "Long"),
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页大小", paramType = "query", required = true, dataType = "Long")
|
|
|
})
|
|
@@ -142,15 +153,137 @@ public class HouseManagerController extends BaseController{
|
|
|
@RequestParam(required = false , name = "type") Integer type,
|
|
|
@RequestParam(name = "belongCompany") String belongCompany,
|
|
|
@RequestParam(name = "estateName") String estateName,
|
|
|
+ @RequestParam(name = "startTime") String startTime,
|
|
|
+ @RequestParam(name = "endTime") String endTime,
|
|
|
@RequestParam(name = "pageNum")Long pageNum,
|
|
|
@RequestParam(name = "pageSize")Long pageSize){
|
|
|
+ ContextTokenBean tokenMap = getContextUserInfo();
|
|
|
|
|
|
IPage<TmHouse> resultPage = tmHouseService.getAuditHouseList(houseTitle , status ,
|
|
|
- type , belongCompany , estateName , getToken() , pageNum , pageSize);
|
|
|
+ type , belongCompany , estateName , getToken() , startTime, endTime, pageNum , pageSize, tokenMap);
|
|
|
return Result.success(DataUtils.assembleResult(resultPage.getTotal(), resultPage.getPages(),
|
|
|
resultPage.getCurrent(), resultPage.getRecords()));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/exportAuditHouseList")
|
|
|
+ @ApiOperation(value = "审核管理页面根据条件拉取所有房源")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "houseTitle", value = "房源名称", paramType = "query", required = false, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "status", value = "状态: 0->草稿;1->待审核;2->已审核;3->未通过", paramType = "query", required = false, dataType = "Integer"),
|
|
|
+ @ApiImplicitParam(name = "type", value = "房源类型: 1->新房,2->二手房", paramType = "query", required = true, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "belongCompany", value = "所属公司ID", paramType = "query", required = true, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "estateName", value = "楼盘名称", paramType = "query", required = true, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "startTime", value = "审核开始时间(00:00:00)", paramType = "query", required = true, dataType = "String"),
|
|
|
+ @ApiImplicitParam(name = "endTime", value = "审核结束时间(23:59:59)", paramType = "query", required = true, dataType = "String"),
|
|
|
+ })
|
|
|
+ public Result exportAuditHouseList(@RequestParam(required = false) String houseTitle,
|
|
|
+ @RequestParam(required = false) Integer status,
|
|
|
+ @RequestParam(required = false , name = "type") Integer type,
|
|
|
+ @RequestParam(name = "belongCompany") String belongCompany,
|
|
|
+ @RequestParam(name = "estateName") String estateName,
|
|
|
+ @RequestParam(name = "startTime") String startTime,
|
|
|
+ @RequestParam(name = "endTime") String endTime,
|
|
|
+ @RequestParam(name = "pageNum")Long pageNum,
|
|
|
+ @RequestParam(name = "pageSize")Long pageSize, HttpServletResponse response) throws Exception{
|
|
|
+ ContextTokenBean tokenMap = getContextUserInfo();
|
|
|
+
|
|
|
+ List<TmHouse> houseList = tmHouseService.getAuditHouseListAll(houseTitle , status ,
|
|
|
+ type , belongCompany , estateName , startTime, endTime, tokenMap);
|
|
|
+
|
|
|
+ //导出的数据
|
|
|
+ Map<String, String> item = null;
|
|
|
+ List<Map> dataList = new ArrayList<Map>();
|
|
|
+ String outType = "";
|
|
|
+ int num = 0;
|
|
|
+ for(TmHouse house : houseList){
|
|
|
+ num += 1;
|
|
|
+ //楼盘数据
|
|
|
+ item = new HashMap();
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[0], String.valueOf(num));
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[1], house.getId());
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[2], house.getHouseTitle());
|
|
|
+ if(house.getType().intValue() == 1){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[3], "新房");
|
|
|
+ }
|
|
|
+ if(house.getType().intValue() == 2){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[3], "二手房");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[4], house.getEstateName());
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[5], house.getBelongCompanyName());
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[6], house.getCreateByName());
|
|
|
+
|
|
|
+ DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[7], house.getSubmitAuditTime() == null? "" : house.getSubmitAuditTime().format(df));
|
|
|
+ if(house.getStatus().compareTo(HouseStatus.WAITING_AUDIT.getCode()) == 0){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[8], HouseStatus.WAITING_AUDIT.getDesc());
|
|
|
+ }
|
|
|
+ if(house.getStatus().compareTo(HouseStatus.AUDITED.getCode()) == 0){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[8], HouseStatus.AUDITED.getDesc());
|
|
|
+ }
|
|
|
+ if(house.getStatus().compareTo(HouseStatus.REJECT.getCode()) == 0){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[8], HouseStatus.REJECT.getDesc());
|
|
|
+ }
|
|
|
+ if(house.getStatus().compareTo(HouseStatus.DRAFT.getCode()) == 0){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[8], HouseStatus.DRAFT.getDesc());
|
|
|
+ }
|
|
|
+ if(house.getStatus().compareTo(HouseStatus.WAITING_REGION_AUDIT.getCode()) == 0){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[8], HouseStatus.WAITING_REGION_AUDIT.getDesc());
|
|
|
+ }
|
|
|
+ if(house.getStatus().compareTo(HouseStatus.REGION_REJECT.getCode()) == 0){
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[8], HouseStatus.REGION_REJECT.getDesc());
|
|
|
+ }
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[9], house.getAuditorName());
|
|
|
+ item.put(ExcelUtil.AUDIT_EXCEL_COLE_NAME[10], house.getAuditTime() == null? "" : house.getAuditTime().format(df));
|
|
|
+
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ String date = DateUtil.date2String(new Date(), DateUtil.YYYYMMDDHHMMSS_DATA_FORMAT);
|
|
|
+
|
|
|
+ String aduitName = "";
|
|
|
+ if(status.compareTo(HouseStatus.ALL.getCode()) == 0){
|
|
|
+ aduitName = HouseStatus.ALL.getDesc();
|
|
|
+ }
|
|
|
+ if(status.compareTo(HouseStatus.WAITING_AUDIT.getCode()) == 0){
|
|
|
+ aduitName = HouseStatus.WAITING_AUDIT.getDesc();
|
|
|
+ }
|
|
|
+ if(status.compareTo(HouseStatus.AUDITED.getCode()) == 0){
|
|
|
+ aduitName = HouseStatus.AUDITED.getDesc();
|
|
|
+ }
|
|
|
+ if(status.compareTo(HouseStatus.REJECT.getCode()) == 0){
|
|
|
+ aduitName = "未通过";
|
|
|
+ }
|
|
|
+ if(status.compareTo(HouseStatus.WAITING_REGION_AUDIT.getCode()) == 0){
|
|
|
+ aduitName = HouseStatus.WAITING_REGION_AUDIT.getDesc();
|
|
|
+ }
|
|
|
+ String dateStr = "VR看房审核管理-" + aduitName + "-" + date;
|
|
|
+ String fileName = dateStr + ".xls";
|
|
|
+ File file = new File(excelLocalPath + fileName);
|
|
|
+ if(!file.getParentFile().exists()){
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelUtil.writeExcel(dataList, ExcelUtil.AUDIT_EXCEL_COLE_NAME.length, excelLocalPath + fileName, dateStr);
|
|
|
+
|
|
|
+// String agent = request.getHeader("User-Agent");
|
|
|
+// if (agent != null && (agent.contains("MSIE")||agent.contains("Trident"))) {
|
|
|
+// fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
|
+// } else {
|
|
|
+// //非IE浏览器的处理:
|
|
|
+// fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
|
|
|
+// }
|
|
|
+// response.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
|
|
|
+// response.setContentType(request.getServletContext().getMimeType(fileName));
|
|
|
+// response.setContentLength((int) file.length());
|
|
|
+// output(response, file);
|
|
|
+
|
|
|
+ return Result.success((Object) (outerSceneVrHost + "excel/" + dateStr + ".xls"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@GetMapping("/getShareLinks")
|
|
|
@ApiOperation(value = "根据房源ID获取房源所有分享链接")
|
|
|
@ApiImplicitParams({
|
|
@@ -331,6 +464,27 @@ public class HouseManagerController extends BaseController{
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/canEdit")
|
|
|
+ @ApiOperation(value = "根据房源ID获取房源详情")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "houseId", value = "房源ID", paramType = "query", required = true, dataType = "String"),
|
|
|
+ })
|
|
|
+ public Result<Object> canEdit(@RequestParam(required = true) String houseId){
|
|
|
+ if(StringUtils.isBlank(houseId)){
|
|
|
+ return Result.failure("房源ID不能为空");
|
|
|
+ }
|
|
|
+ TmHouse tmHouse = tmHouseService.getById(houseId);
|
|
|
+ if(null == tmHouse || tmHouse.getIsDelete().compareTo(1) == 0){
|
|
|
+ return Result.failure("房源不存在");
|
|
|
+ }
|
|
|
+ if(tmHouse.getStatus().compareTo(HouseStatus.WAITING_AUDIT.getCode()) == 0 ||
|
|
|
+ tmHouse.getStatus().compareTo(HouseStatus.AUDITED.getCode()) == 0){
|
|
|
+ Result.success(false);
|
|
|
+ }
|
|
|
+ return Result.success(true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/houseDetailWithoutAuth")
|
|
|
@ApiOperation(value = "根据房源ID获取房源详情-无需授权,给H5使用")
|
|
|
@ApiImplicitParams({
|
|
@@ -440,6 +594,11 @@ public class HouseManagerController extends BaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ ContextTokenBean tokenMap = getContextUserInfo();
|
|
|
+ if(!dbHouse.getCreateById().equals(tokenMap.getId())){
|
|
|
+ return Result.failure("非本人创建的,无法删除");
|
|
|
+ }
|
|
|
+
|
|
|
int delete = tmHouseService.deleteHouseById(houseId);
|
|
|
if(delete != 1){
|
|
|
return Result.failure("删除失败");
|
|
@@ -555,6 +714,9 @@ public class HouseManagerController extends BaseController{
|
|
|
dbHouse.setAuditId(tmAudit.getId());
|
|
|
dbHouse.setSubmitAuditTime(LocalDateTime.now());
|
|
|
dbHouse.setStatus(HouseStatus.WAITING_AUDIT.getCode());
|
|
|
+ if(SysUserRoleEnums.REGION_SHOOT.getRoleKey().equals(tokenMap.getRoleKey())){
|
|
|
+ dbHouse.setStatus(HouseStatus.WAITING_REGION_AUDIT.getCode());
|
|
|
+ }
|
|
|
dbHouse.setUpdateTime(LocalDateTime.now());
|
|
|
if(!tmHouseService.updateHouse(dbHouse)){
|
|
|
log.info("更新房源的审批id失败");
|
|
@@ -588,7 +750,8 @@ public class HouseManagerController extends BaseController{
|
|
|
if(null == dbHouse || null == dbHouse.getAuditId()){
|
|
|
return Result.failure("房源不存在或者未提交审核");
|
|
|
}
|
|
|
- if(HouseStatus.WAITING_AUDIT.getCode().compareTo(dbHouse.getStatus()) != 0){
|
|
|
+ if(HouseStatus.WAITING_AUDIT.getCode().compareTo(dbHouse.getStatus()) != 0 &&
|
|
|
+ HouseStatus.WAITING_REGION_AUDIT.getCode().compareTo(dbHouse.getStatus()) != 0){
|
|
|
return Result.failure("房源状态非待审核");
|
|
|
}
|
|
|
dbHouse = null;
|
|
@@ -605,6 +768,11 @@ public class HouseManagerController extends BaseController{
|
|
|
if(null != tmAudit.getAuditStatus() && AuditStatus.AUDITED.getCode().compareTo(tmAudit.getAuditStatus()) == 0){
|
|
|
return Result.failure("该房源已经审核过,无法撤回");
|
|
|
}
|
|
|
+
|
|
|
+ ContextTokenBean tokenMap = getContextUserInfo();
|
|
|
+ if(!tokenMap.getId().equals(tmAudit.getCreatorId())){
|
|
|
+ return Result.failure("仅支持撤回本人提交的VR项目");
|
|
|
+ }
|
|
|
//开启事务,抢审批记录的锁
|
|
|
tmAudit = null;
|
|
|
tmAudit = tmAuditService.selectForUpdate(dbHouse.getAuditId());
|
|
@@ -636,5 +804,26 @@ public class HouseManagerController extends BaseController{
|
|
|
return Result.success("撤销成功");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private static void output(HttpServletResponse resp, File file) {
|
|
|
+ OutputStream os = null;
|
|
|
+ BufferedInputStream bis = null;
|
|
|
+ byte[] buff = new byte[1024];
|
|
|
+ try {
|
|
|
+ os = resp.getOutputStream();
|
|
|
+ bis = new BufferedInputStream(new FileInputStream(file));
|
|
|
+ int i = 0;
|
|
|
+ while ((i = bis.read(buff)) != -1) {
|
|
|
+ os.write(buff, 0, i);
|
|
|
+ os.flush();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ bis.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|