This commit is contained in:
2023-03-02 13:58:13 +08:00
156 changed files with 20186 additions and 1110 deletions
@@ -968,9 +968,6 @@ public class AverageStatisticsController {
*/
public Object baseAction(AverageStatisticsModel model){
Pager pager = model.getPager(25);
if (StringUtils.isBlank(model.getCityDisplay())) {
return model;
}
pager.setTotalRows(avgBaseDao.count(model.getCityDisplay(), model.getRegion(), model.getName(),null, model.getStartDate(), model.getEndDate()));
model.setBaseList(avgBaseDao.findAll(model.getCityDisplay(), model.getRegion(), model.getName(),null, model.getStartDate(), model.getEndDate(), pager));
return model;
@@ -987,6 +984,8 @@ public class AverageStatisticsController {
list.add("是否加入指导价");
list.add("调查时间");
list.add("调查人");
list.add("来源");
list.add("来源小区名");
data.add(list);
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("导入模板");
@@ -994,10 +993,12 @@ public class AverageStatisticsController {
HSSFCell cell0 = row.createCell(0);
HSSFCell cell1 = row.createCell(1);
HSSFCell cell2 = row.createCell(2);
HSSFCell cell3= row.createCell(3);
HSSFCell cell4= row.createCell(4);
HSSFCell cell5= row.createCell(5);
HSSFCell cell6= row.createCell(6);
HSSFCell cell3 = row.createCell(3);
HSSFCell cell4 = row.createCell(4);
HSSFCell cell5 = row.createCell(5);
HSSFCell cell6 = row.createCell(6);
HSSFCell cell7 = row.createCell(7);
HSSFCell cell8 = row.createCell(8);
cell0.setCellValue("城市");
cell1.setCellValue("区域");
cell2.setCellValue("小区名");
@@ -1005,6 +1006,8 @@ public class AverageStatisticsController {
cell4.setCellValue("是否加入指导价");
cell5.setCellValue("调查时间");
cell6.setCellValue("调查人");
cell7.setCellValue("来源");
cell8.setCellValue("来源小区名");
HttpServletResponse response = ActionContext.getContext().getResponse();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/x-download;charset=UTF-8");
@@ -1,6 +1,7 @@
package com.fangjia.bkoff.util;
import com.fangjia.core.Constants;
import com.fangjia.core.RegionData;
import com.fangjia.core.util.DataUtil;
import com.fangjia.core.util.DateUtil;
import com.fangjia.core.util.HttpRequest;
@@ -8,11 +9,13 @@ import com.fangjia.core.util.HttpRequestException;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.common.DistrictKey;
import com.fangjia.dal.mongo.dao.AvgBaseDao;
import com.fangjia.dal.mongo.model.AverageStatistics;
import com.fangjia.dal.mongo.model.AvgBase;
import com.fangjia.dal.mongo.model.bkoff.GuidingPrice;
import com.fangjia.dal.seaweed.model.District;
import com.fangjia.service.datastore.DistrictService;
import com.fangjia.service.mongo.bkoff.GuidingPriceService;
import com.fangjia.service.mongo.fangjia.AverageStatisticsService;
import net.sf.json.JSONObject;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
@@ -47,12 +50,12 @@ import java.util.*;
public class BaseAvgImportServlet extends HttpServlet {
private static final String[] columns = { "城市", "区域", "小区名", "价格", "是否加入指导价", "调查时间", "调查人" };
private static final String[] columns = { "城市", "区域", "小区名", "价格", "是否加入指导价", "调查时间", "调查人" , "来源", "来源小区名"};
private AvgBaseDao avgBaseDao;
private GuidingPriceService guidingPriceService;
private DistrictService districtService;
private AverageStatisticsService averageStatisticsService;
@Override
public void init(ServletConfig config) throws ServletException {
@@ -62,6 +65,7 @@ public class BaseAvgImportServlet extends HttpServlet {
avgBaseDao = (AvgBaseDao) context.getBean("avgBaseDao");
guidingPriceService = (GuidingPriceService) context.getBean("guidingPriceService");
districtService = (DistrictService) context.getBean("districtService");
averageStatisticsService = (AverageStatisticsService) context.getBean("averageStatisticsService");
} catch (Exception e) {
e.printStackTrace();
}
@@ -108,10 +112,6 @@ public class BaseAvgImportServlet extends HttpServlet {
long version = new Date().getTime();
infoMap = checkUploadData(sheet, name, version, infoMap, realName);
infoMap.put("version", version);
// String info = map.get("info");
// if(StringUtils.isNotBlank(info) && info.equals("success")){
// new CookieContext("fangjia.com").saveCookie(response, "upload_version", version);
// }
String json = JSONObject.fromObject(infoMap).toString();
if (infoMap.containsKey("success")) {
response.getWriter().write(infoMap.get("success").toString());
@@ -174,7 +174,7 @@ public class BaseAvgImportServlet extends HttpServlet {
}
private Map<String, Object> checkUploadData(Sheet sheet, String name, long version, Map<String, Object> infoMap,
String realName) {
String realName) {
int totalNum = sheet.getLastRowNum();
System.out.println("上传文件共:" + totalNum + "个");
if (totalNum > 20000) {
@@ -371,7 +371,8 @@ public class BaseAvgImportServlet extends HttpServlet {
} else if (key.equals("价格") && map.get(key) != null) {
String val = formatNumer(map.get(key));
if (StringUtils.isNotBlank(val)) {
int x = Integer.parseInt(val);
double dd = Double.parseDouble(val);
int x = (int) dd;
avgBase.setPrice(x);
}
@@ -385,23 +386,63 @@ public class BaseAvgImportServlet extends HttpServlet {
Date applyDate = (DateUtil.parseDate(map.get(key), "yyyy-MM-dd"));
avgBase.setCreationDate(applyDate == null ? curDate : applyDate);
} else if (key.equals("调查人") && map.get(key) != null) {
avgBase.setUserName(map.get(key));
} else if (key.equals("来源") && map.get(key) !=null){
avgBase.setSource(map.get(key).replaceAll("\\s", ""));
} else if (key.equals("来源小区名") && map.get(key) != null){
avgBase.setSourceCommName(map.get(key).replaceAll("\\s", ""));
}
avgBase.setRegion(RegionData.formatRegion(avgBase.getCity(), avgBase.getRegion()));
avgBase.setCategory("district");
}
if (avgBase.getIsGuidancePrice() == 1) {
DistrictKey districtKey = new DistrictKey(avgBase.getCity(), avgBase.getRegion(),
District dis = null;
if(StringUtils.isNotBlank(avgBase.getSourceCommName()) && !avgBase.getSourceCommName().equals(avgBase.getDistrictName())){
DistrictKey districtKey = new DistrictKey(avgBase.getCity(), RegionData.formatRegion(avgBase.getCity(), avgBase.getRegion()),
avgBase.getDistrictName());
District dis = districtService.findOneByKey(districtKey, "district");
GuidingPrice price = guidingPriceService.findByBizKey(avgBase.getCity(), avgBase.getRegion(),
dis = districtService.findOneByKey(districtKey, "district");
if(dis.getAlias() == null){
dis.setAlias(Collections.singletonList(avgBase.getSourceCommName()));
}else if(!dis.getAlias().contains(avgBase.getSourceCommName())){
dis.getAlias().add(avgBase.getSourceCommName());
}
if(dis.getMappingAlias() == null){
dis.setMappingAlias(Collections.singletonList(avgBase.getSourceCommName()));
}else if(!dis.getMappingAlias().contains(avgBase.getSourceCommName())){
dis.getMappingAlias().add(avgBase.getSourceCommName());
}
districtService.save(dis);
}
if(StringUtils.isNotBlank(avgBase.getSource()) && avgBase.getSource().equalsIgnoreCase("GXD")){
AverageStatistics averageStatistics = averageStatisticsService.findSecendAverageStatictics(avgBase.getCity(), avgBase.getRegion(), avgBase.getDistrictName(), "district");
if(averageStatistics != null){
averageStatistics.setGxdEsfPrice(avgBase.getPrice());
}else{
averageStatistics = new AverageStatistics();
averageStatistics.setGxdEsfPrice(avgBase.getPrice());
averageStatistics.setCategory("district");
averageStatistics.setCity(avgBase.getCity());
averageStatistics.setRegion(avgBase.getRegion());
averageStatistics.setName(avgBase.getDistrictName());
if(dis != null){
averageStatistics.setMasterDistrictName(dis.getDistrictName());
averageStatistics.setModificationDate(new Date());
}
}
averageStatisticsService.save(averageStatistics);
}
if (avgBase.getIsGuidancePrice() == 1) {
if(dis == null){
DistrictKey districtKey = new DistrictKey(avgBase.getCity(), avgBase.getRegion(), avgBase.getDistrictName());
dis = districtService.findOneByKey(districtKey, "district");
}
GuidingPrice price = guidingPriceService.findByBizKey(avgBase.getCity(), RegionData.formatRegion(avgBase.getCity(), avgBase.getRegion()),
avgBase.getDistrictName(),avgBase.getCreationDate());
if (price != null) {
price.setGuidingPerson(avgBase.getUserName());
price.setGuidingDate(avgBase.getCreationDate());
price.setGuidingValue(avgBase.getPrice());
price.setModifyDate(new Date());
guidingPriceService.save(price);
} else {
@@ -414,8 +455,9 @@ public class BaseAvgImportServlet extends HttpServlet {
price.setGuidingPerson(avgBase.getUserName());
price.setGuidingDate(avgBase.getCreationDate());
price.setGuidingValue(avgBase.getPrice());
price.setEstateType(dis.getEstateType2().indexOf("别墅") > -1 ? "别墅" : "普通住宅");
price.setEstateType(dis.getEstateType2().contains("别墅") ? "别墅" : "普通住宅");
price.setCat("district");
price.setModifyDate(new Date());
guidingPriceService.save(price);
HttpRequest request = new HttpRequest();
HashMap<String, String> params = new HashMap<String, String>();
@@ -430,11 +472,10 @@ public class BaseAvgImportServlet extends HttpServlet {
} catch (HttpRequestException e) {
e.printStackTrace();
}
}else{
System.out.println("小区不存在"+ avgBase.getDistrictName());
}
}
if(dis !=null) {
}
}
avgBases.add(avgBase);
@@ -66,6 +66,8 @@
<th style="width:10%;">是否加入指导价</th>
<th style="width:10%;">调查时间</th>
<th style="width:10%;">调查人</th>
<th style="width:10%;">来源</th>
<th style="width:10%;">来源小区名</th>
</tr>
</thead>
<tbody>
@@ -94,7 +96,17 @@
<#if it.userName??>
${it.userName}
</#if>
</td>
</td>
<td align="center">
<#if it.source??>
${it.source}
</#if>
</td>
<td align="center">
<#if it.sourceCommName??>
${it.sourceCommName}
</#if>
</td>
</tr>
</#list>
</#if>
@@ -254,6 +254,9 @@
<#if (it.tsfhouseNewPrice)?? || (it.tsfhouseEsfPrice)??>
<td colspan="2"><b>365房产</b></td>
</#if>
<#if (it.gxdNewPrice)?? || (it.gxdEsfPrice)??>
<td colspan="2"><b>GXD</b></td>
</#if>
</tr>
<tr>
@@ -345,7 +348,10 @@
<td style="width:70px;color:#0C88C7">新房</td>
<td style="width:70px;color:#D3750A">二手房</td>
</#if>
<#if (it.gxdNewPrice)?? || (it.gxdEsfPrice)??>
<td style="width:70px;color:#0C88C7">新房</td>
<td style="width:70px;color:#D3750A">二手房</td>
</#if>
</tr>
<tr>
@@ -430,7 +436,7 @@
<#if (it.ganjiNewPrice)?? || (it.ganjiEsfPrice)??>
<td style ="color:#0C88C7">${it.ganjiNewPrice!}</td>
<td style ="color:#D3750A">${it.ganjiEsfPrice!}</td>
</#if>
</#if>
<#if (it.yungujiaNewPrice)?? || (it.yungujiaEsfPrice)??>
<td style ="color:#0C88C7">${it.yungujiaNewPrice!}</td>
<td style ="color:#D3750A">${it.yungujiaEsfPrice!}</td>
@@ -443,6 +449,10 @@
<td style ="color:#0C88C7">${it.tsfhouseNewPrice!}</td>
<td style ="color:#D3750A">${it.tsfhouseEsfPrice!}</td>
</#if>
<#if (it.gxdNewPrice)?? || (it.gxdEsfPrice)??>
<td style ="color:#0C88C7">${it.gxdNewPrice!}</td>
<td style ="color:#D3750A">${it.gxdEsfPrice!}</td>
</#if>
</tr>
</#list>