|
@@ -2,25 +2,34 @@ package fcb.project.manager.core.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import fcb.project.manager.base.entity.CommonRspBean;
|
|
|
import fcb.project.manager.base.entity.ContextTokenBean;
|
|
|
+import fcb.project.manager.base.entity.SceneRspBean;
|
|
|
+import fcb.project.manager.base.param.house.ExportFyRecords;
|
|
|
+import fcb.project.manager.base.param.house.ExportVrReview;
|
|
|
import fcb.project.manager.base.utils.DateUtil;
|
|
|
-import fdage.back.sdk.base.entity.Result;
|
|
|
+import fcb.project.manager.base.utils.ExcelUtil;
|
|
|
+import fcb.project.manager.core.feignInterfaces.SceneFeign;
|
|
|
+import fcb.project.manager.core.feignInterfaces.UserFeign;
|
|
|
+import fdage.back.sdk.base.enums.ResultCodeEnum;
|
|
|
+import fdage.back.sdk.base.exception.CommonBaseException;
|
|
|
import fdage.back.sdk.utils.HttpClientUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.time.Duration;
|
|
|
import java.time.Instant;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Api(tags = "二手房小区相关接口")
|
|
|
@RestController
|
|
@@ -31,15 +40,34 @@ public class TmRedirectController extends BaseController{
|
|
|
@Value("${fcb.agentsaas}")
|
|
|
private String fcbagentsaas;
|
|
|
|
|
|
+ @Value("${excel.local.path}")
|
|
|
+ private String excelLocalPath;
|
|
|
+
|
|
|
+ @Value("${outer.vr.scene.host}")
|
|
|
+ private String outerSceneVrHost;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserFeign userFeign;
|
|
|
+
|
|
|
+
|
|
|
@PostMapping("/{name}")
|
|
|
@ApiOperation(value = "二手房小区接口转发")
|
|
|
public Object addNewHouse(@PathVariable String name, @RequestBody JSONObject object){
|
|
|
Instant stepTwoStart = Instant.now();
|
|
|
String str = "";
|
|
|
try {
|
|
|
- ContextTokenBean tokenMap = getContextUserInfo();
|
|
|
- log.info("二手房接口转发 : " + name);
|
|
|
|
|
|
+ ContextTokenBean tokenMap = new ContextTokenBean();
|
|
|
+
|
|
|
+ if(object.containsKey("token")){
|
|
|
+ String token = object.getString("token");
|
|
|
+ tokenMap = getContextUserInfo(token);
|
|
|
+ }else {
|
|
|
+ tokenMap = getContextUserInfo();
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("二手房接口转发 : " + name);
|
|
|
+//
|
|
|
String timestamp = String.valueOf(new Date().getTime());
|
|
|
String apiNumber = name;
|
|
|
String nonce = DateUtil.randonNum(5);
|
|
@@ -85,6 +113,44 @@ public class TmRedirectController extends BaseController{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(object.containsKey("rolekey")){
|
|
|
+ String rolekey = object.getString("rolekey");
|
|
|
+ if(rolekey.equals("group") || rolekey.equals("admin")){
|
|
|
+ Map<String , Object> map = new HashMap<>();
|
|
|
+ map.put("id" , tokenMap.getDepartmentId());
|
|
|
+ //获取公司id 集群
|
|
|
+ CommonRspBean rsp = userFeign.findChildrenById(map, getToken());
|
|
|
+
|
|
|
+ log.info("code = {} , msg = {}, data = {}" , rsp.getCode() , rsp.getMsg(), rsp.getData());
|
|
|
+
|
|
|
+ log.info("四维看看翻转状态返回为:{}" , JSON.toJSONString(rsp));
|
|
|
+ if(null == rsp || rsp.getCode() != 0){
|
|
|
+ log.info("调用看看的更新场景[{}]状态微服务失败" , tokenMap.getDepartmentId());
|
|
|
+ if(null != rsp){
|
|
|
+ log.info("code = {} , msg = {}" , rsp.getCode() , rsp.getMsg());
|
|
|
+ }
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D101 , "更新看看场景状态失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray data = (JSONArray) rsp.getData();
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for(int i=0;i<data.size();i++){
|
|
|
+ JSONObject company = data.getJSONObject(i);
|
|
|
+ if(i == data.size() -1 ){
|
|
|
+ sb.append(String.valueOf(company.get("id")));
|
|
|
+ }else{
|
|
|
+ sb.append(String.valueOf(company.get("id")) + ",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(sb.toString())){
|
|
|
+ object.put("companyIdList",sb.toString());
|
|
|
+ }else{
|
|
|
+ object.put("companyIdList","");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if(object.containsKey("operatorCompanyId")){
|
|
|
if(StringUtils.isNotEmpty(tokenMap.getDepartmentId())){
|
|
|
object.put("operatorCompanyId",tokenMap.getDepartmentId());
|
|
@@ -129,6 +195,56 @@ public class TmRedirectController extends BaseController{
|
|
|
if(StringUtils.isNotEmpty(str)){
|
|
|
JSONObject responsemsg = JSONObject.parseObject(str);
|
|
|
|
|
|
+ JSONObject resultDate = (JSONObject) responsemsg.get("resultData");
|
|
|
+
|
|
|
+ if(name.equals("101_getVrGardenExportList")){
|
|
|
+ if(resultDate.containsKey("records")){
|
|
|
+
|
|
|
+ JSONArray recordsArray = resultDate.getJSONArray("records");
|
|
|
+ String recordsString = JSONObject.toJSONString(recordsArray);
|
|
|
+ List<ExportFyRecords> exportFyRecordsList = JSONObject.parseArray(recordsString, ExportFyRecords.class);
|
|
|
+
|
|
|
+ log.info("exportRecordsList" , exportFyRecordsList);
|
|
|
+
|
|
|
+ exprottFyRecords(exportFyRecordsList);
|
|
|
+ responsemsg = new JSONObject();
|
|
|
+ responsemsg.put("resultType",1);
|
|
|
+ responsemsg.put("resultMsg","导出成功");
|
|
|
+ responsemsg.put("resultData", exprottFyRecords(exportFyRecordsList));
|
|
|
+ return responsemsg;
|
|
|
+
|
|
|
+ }else {
|
|
|
+ responsemsg = new JSONObject();
|
|
|
+ responsemsg.put("resultType",-1);
|
|
|
+ responsemsg.put("resultMsg","导出失败,导出数据缺失");
|
|
|
+ responsemsg.put("resultData",str);
|
|
|
+ return responsemsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(name.equals("101_exportVrReviewList")){
|
|
|
+ if(resultDate.containsKey("data")){
|
|
|
+
|
|
|
+ JSONArray recordsArray = resultDate.getJSONArray("data");
|
|
|
+ String recordsString = JSONObject.toJSONString(recordsArray);
|
|
|
+ List<ExportVrReview> exportVrReviewList = JSONObject.parseArray(recordsString, ExportVrReview.class);
|
|
|
+
|
|
|
+ log.info("exportRecordsList" , exportVrReviewList);
|
|
|
+
|
|
|
+ responsemsg = new JSONObject();
|
|
|
+ responsemsg.put("resultType",1);
|
|
|
+ responsemsg.put("resultMsg","导出成功");
|
|
|
+ responsemsg.put("resultData",exprotVrReview(exportVrReviewList));
|
|
|
+ return responsemsg;
|
|
|
+
|
|
|
+ }else {
|
|
|
+ responsemsg = new JSONObject();
|
|
|
+ responsemsg.put("resultType",-1);
|
|
|
+ responsemsg.put("resultMsg","导出失败,导出数据缺失");
|
|
|
+ responsemsg.put("resultData",str);
|
|
|
+ return responsemsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return responsemsg;
|
|
|
}else{
|
|
@@ -159,4 +275,118 @@ public class TmRedirectController extends BaseController{
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public String exprottFyRecords (List<ExportFyRecords> exportFyRecordsList){
|
|
|
+
|
|
|
+ //导出的数据
|
|
|
+ Map<String, String> item = null;
|
|
|
+ List<Map> dataList = new ArrayList<Map>();
|
|
|
+ String outType = "";
|
|
|
+ String[] AUDIT_EXCEL_COLE_NAME = {"序号","VR小区id","创建人","创建时间","城市名称","审核人","审核时间","审核状态" ,"小区id",
|
|
|
+ "小区编码", "小区名称", "区域名称", "商圈名称", "建成开始年代", "建成结束年代", "所属公司", "物业类型"};
|
|
|
+ ExcelUtil excelUtil = new ExcelUtil(Arrays.asList(AUDIT_EXCEL_COLE_NAME));
|
|
|
+ int num = 0;
|
|
|
+
|
|
|
+
|
|
|
+ if(exportFyRecordsList !=null && exportFyRecordsList.size()>0){
|
|
|
+ for(ExportFyRecords er: exportFyRecordsList){
|
|
|
+ num += 1;
|
|
|
+ //楼盘数据
|
|
|
+ item = new HashMap();
|
|
|
+ item.put(excelUtil.getColeNames().get(0), String.valueOf(num));
|
|
|
+ item.put(excelUtil.getColeNames().get(1), er.getVrGardenId()==null ? "":er.getVrGardenId());
|
|
|
+ item.put(excelUtil.getColeNames().get(2), er.getCreatorName()==null ? "":er.getCreatorName());
|
|
|
+ item.put(excelUtil.getColeNames().get(3), er.getCreateTime()==null ? "":er.getCreateTime());
|
|
|
+ item.put(excelUtil.getColeNames().get(4), er.getCityName()==null ? "":er.getCityName());
|
|
|
+ item.put(excelUtil.getColeNames().get(5), er.getAuditorName()==null ? "":er.getAuditorName());
|
|
|
+ item.put(excelUtil.getColeNames().get(6), er.getAuditTime()==null ? "":er.getAuditTime());
|
|
|
+ item.put(excelUtil.getColeNames().get(7), er.getAuditStatus()==null ? "":er.getAuditStatus());
|
|
|
+ item.put(excelUtil.getColeNames().get(8), er.getGardenId()==null ? "":er.getGardenId());
|
|
|
+ item.put(excelUtil.getColeNames().get(9), er.getGardenNumber()==null ? "":er.getGardenNumber());
|
|
|
+ item.put(excelUtil.getColeNames().get(10), er.getGardenName()==null ? "":er.getGardenName());
|
|
|
+ item.put(excelUtil.getColeNames().get(11), er.getRegionName()==null ? "":er.getRegionName());
|
|
|
+ item.put(excelUtil.getColeNames().get(12), er.getGeographyAreaName()==null ? "":er.getGeographyAreaName());
|
|
|
+ item.put(excelUtil.getColeNames().get(13), er.getBuildStartTime()==null ? "":er.getBuildStartTime());
|
|
|
+ item.put(excelUtil.getColeNames().get(14), er.getBuildEndTime()==null ? "":er.getBuildEndTime());
|
|
|
+ item.put(excelUtil.getColeNames().get(15), er.getCompanyName()==null ? "":er.getCompanyName());
|
|
|
+ item.put(excelUtil.getColeNames().get(16), er.getPropertySortName()==null ? "":er.getPropertySortName());
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String date = DateUtil.date2String(new Date(), DateUtil.YYYYMMDDHHMMSS_DATA_FORMAT);
|
|
|
+
|
|
|
+ String dateStr = "VR房源审核管理-"+ date;
|
|
|
+ String fileName = dateStr + ".xls";
|
|
|
+ File file = new File(excelLocalPath + fileName);
|
|
|
+ if(!file.getParentFile().exists()){
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ excelUtil.writeExcel(dataList, excelUtil.getColeNames().size(), excelLocalPath + fileName, dateStr);
|
|
|
+ String url = outerSceneVrHost + "excel/" + dateStr + ".xls";
|
|
|
+ log.info("导出路径-{}", url);
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public String exprotVrReview (List<ExportVrReview> exportVrReviewList){
|
|
|
+
|
|
|
+ //导出的数据
|
|
|
+ Map<String, String> item = null;
|
|
|
+ List<Map> dataList = new ArrayList<Map>();
|
|
|
+ String outType = "";
|
|
|
+ String[] AUDIT_EXCEL_COLE_NAME = {"序号","房间id","添加vr后产生的vrid","楼栋单元","房号","建筑面积","套内面积","创建时间" ,"更新时间",
|
|
|
+ "审核时间", "提审时间", "创建人id", "创建人", "审核人", "审核人Id", "审核id", "审核备注", "状态", "维护人", "维护人Id",
|
|
|
+ "小区id", "小区名字", "房间编号", "公司id", "公司名称"};
|
|
|
+ ExcelUtil excelUtil = new ExcelUtil(Arrays.asList(AUDIT_EXCEL_COLE_NAME));
|
|
|
+ int num = 0;
|
|
|
+
|
|
|
+ if(exportVrReviewList !=null && exportVrReviewList.size()>0){
|
|
|
+ for(ExportVrReview er: exportVrReviewList){
|
|
|
+ num += 1;
|
|
|
+ //楼盘数据
|
|
|
+ item = new HashMap();
|
|
|
+ item.put(excelUtil.getColeNames().get(0), String.valueOf(num));
|
|
|
+ item.put(excelUtil.getColeNames().get(1), er.getId()==null ? "":er.getId());
|
|
|
+ item.put(excelUtil.getColeNames().get(2), er.getVrId()==null ? "":er.getVrId());
|
|
|
+ item.put(excelUtil.getColeNames().get(3), er.getBuildingUnit()==null ? "":er.getBuildingUnit());
|
|
|
+ item.put(excelUtil.getColeNames().get(4), er.getRoomNumber()==null ? "":er.getRoomNumber());
|
|
|
+ item.put(excelUtil.getColeNames().get(5), String.valueOf(er.getBuildArea()));
|
|
|
+ item.put(excelUtil.getColeNames().get(6), String.valueOf(er.getRoomArea()));
|
|
|
+ item.put(excelUtil.getColeNames().get(7), er.getCreateTime()==null ? "": String.valueOf(er.getCreateTime()));
|
|
|
+ item.put(excelUtil.getColeNames().get(8), er.getUpdateTime()==null ? "": String.valueOf(er.getUpdateTime()));
|
|
|
+ item.put(excelUtil.getColeNames().get(9), er.getReviewTime()==null ? "": String.valueOf(er.getReviewTime()));
|
|
|
+ item.put(excelUtil.getColeNames().get(10), er.getGardenName()==null ? "":er.getGardenName());
|
|
|
+ item.put(excelUtil.getColeNames().get(11), er.getArraignmentTime()==null ? "": String.valueOf(er.getArraignmentTime()));
|
|
|
+ item.put(excelUtil.getColeNames().get(12), er.getCreaterId()==null ? "":er.getCreaterId());
|
|
|
+ item.put(excelUtil.getColeNames().get(13), er.getCreater()==null ? "":er.getCreater());
|
|
|
+ item.put(excelUtil.getColeNames().get(14), er.getReviewer()==null ? "":er.getReviewer());
|
|
|
+ item.put(excelUtil.getColeNames().get(15), er.getReviewerId()==null ? "":er.getReviewerId());
|
|
|
+ item.put(excelUtil.getColeNames().get(16), er.getReviewId()==null ? "":er.getReviewId());
|
|
|
+ item.put(excelUtil.getColeNames().get(17), er.getReviewMark()==null ? "":er.getReviewMark());
|
|
|
+ item.put(excelUtil.getColeNames().get(18), er.getAuditStatus()==null ? "":er.getAuditStatus());
|
|
|
+ item.put(excelUtil.getColeNames().get(19), er.getMaintenanceMan()==null ? "":er.getMaintenanceMan());
|
|
|
+ item.put(excelUtil.getColeNames().get(20), er.getMaintenanceManId()==null ? "":er.getMaintenanceManId());
|
|
|
+ item.put(excelUtil.getColeNames().get(21), er.getGardenId()==null ? "":er.getGardenId());
|
|
|
+ item.put(excelUtil.getColeNames().get(22), er.getRoomlistingId()==null ? "":er.getRoomlistingId());
|
|
|
+ item.put(excelUtil.getColeNames().get(23), er.getCompanyId()==null ? "":er.getCompanyId());
|
|
|
+ item.put(excelUtil.getColeNames().get(24), er.getCompanyName()==null ? "":er.getCompanyName());
|
|
|
+
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String date = DateUtil.date2String(new Date(), DateUtil.YYYYMMDDHHMMSS_DATA_FORMAT);
|
|
|
+
|
|
|
+ String dateStr = "VR小区审核管理-"+ date;
|
|
|
+ String fileName = dateStr + ".xls";
|
|
|
+ File file = new File(excelLocalPath + fileName);
|
|
|
+ if(!file.getParentFile().exists()){
|
|
|
+ file.getParentFile().mkdirs();
|
|
|
+ }
|
|
|
+
|
|
|
+ excelUtil.writeExcel(dataList, excelUtil.getColeNames().size(), excelLocalPath + fileName, dateStr);
|
|
|
+ String url = outerSceneVrHost + "excel/" + dateStr + ".xls";
|
|
|
+ log.info("导出路径-{}", url);
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
}
|