|
@@ -1,14 +1,11 @@
|
|
|
package cn.com.ty.lift.business.project.service;
|
|
|
|
|
|
import cn.com.ty.lift.business.framework.util.MessageUtils;
|
|
|
-import cn.com.ty.lift.business.project.dao.entity.Project;
|
|
|
-import cn.com.ty.lift.business.project.dao.entity.ProjectHistory;
|
|
|
-import cn.com.ty.lift.business.project.dao.entity.ProjectUser;
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.*;
|
|
|
+import cn.com.ty.lift.business.project.dao.entity.model.ProjectImportModel;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.model.request.ProjectCompanyRequest;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.model.request.ProjectExtensionRequest;
|
|
|
-import cn.com.ty.lift.business.project.dao.entity.*;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.model.request.ProjectRegionRequest;
|
|
|
-import cn.com.ty.lift.business.project.dao.entity.model.ProjectImportModel;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.model.request.ProjectRequest;
|
|
|
import cn.com.ty.lift.business.project.dao.entity.model.response.ProjectResponse;
|
|
|
import cn.com.ty.lift.business.project.dao.mapper.ProjectHistoryMapper;
|
|
@@ -36,7 +33,6 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author bieao
|
|
@@ -235,55 +231,46 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
|
|
|
BeanUtil.copyProperties(item,project,true);
|
|
|
log.info("复制属性后的project:{}",project);
|
|
|
//查找省
|
|
|
- String provname = item.getProvince();
|
|
|
- AreaCode province = provinceList.stream().filter(areaCode -> (StrUtil.equals(areaCode.getName(),provname))).distinct().limit(1).collect(Collectors.toList()).get(0);
|
|
|
+ String provName = item.getProvince();
|
|
|
+ AreaCode province = provinceList.stream().filter(areaCode -> (StrUtil.equals(areaCode.getName(), provName))).distinct().limit(1).findFirst().get();
|
|
|
if(null == province){
|
|
|
- log.error("表格数据有误,行数:{}, {}没有匹配省",rowNum,provname);
|
|
|
- return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配省",rowNum,provname));
|
|
|
+ log.error("表格数据有误,行数:{}, {}没有匹配省",rowNum,provName);
|
|
|
+ return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配省",rowNum,provName));
|
|
|
}
|
|
|
//项目中设置省
|
|
|
project.setProvince(province.getName());
|
|
|
project.setProvinceCode(province.getCode());
|
|
|
// 查找市
|
|
|
- String cityname = item.getCity();
|
|
|
- AreaCode city = cityList.stream().filter(areaCode -> (
|
|
|
- StrUtil.equals(areaCode.getName(), cityname)
|
|
|
- )).distinct().limit(1).collect(Collectors.toList()).get(0);
|
|
|
+ String cityName = item.getCity();
|
|
|
+ AreaCode city = cityList.stream().filter(areaCode -> (StrUtil.equals(areaCode.getName(), cityName))).distinct().limit(1).findFirst().get();
|
|
|
if(null == city){
|
|
|
- log.error("表格数据有误,行数:{}, {}没有匹配市",rowNum,cityname);
|
|
|
- return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配市",rowNum,cityname));
|
|
|
+ log.error("表格数据有误,行数:{}, {}没有匹配市",rowNum,cityName);
|
|
|
+ return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配市",rowNum,cityName));
|
|
|
}
|
|
|
//项目中设置市
|
|
|
project.setCity(city.getName());
|
|
|
project.setCityCode(city.getCode());
|
|
|
//查找区
|
|
|
- String distname = item.getDistrict();
|
|
|
- AreaCode district = districtList.stream().filter(areaCode -> (
|
|
|
- StrUtil.equals(areaCode.getName(),distname)
|
|
|
- )).distinct().limit(1).collect(Collectors.toList()).get(0);
|
|
|
+ String distName = item.getDistrict();
|
|
|
+ AreaCode district = districtList.stream().filter(areaCode -> (StrUtil.equals(areaCode.getName(), distName))).distinct().limit(1).findFirst().get();
|
|
|
if(null == district){
|
|
|
- log.error("表格数据有误,行数:{}, {}没有匹配区",rowNum,distname);
|
|
|
- return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配区",rowNum,distname));
|
|
|
+ log.error("表格数据有误,行数:{}, {}没有匹配区",rowNum,distName);
|
|
|
+ return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配区",rowNum,distName));
|
|
|
}
|
|
|
//项目中设置区
|
|
|
project.setDistrict(district.getName());
|
|
|
project.setDistrictCode(district.getCode());
|
|
|
|
|
|
//根据省市查找区域
|
|
|
- Region region = null;
|
|
|
String areaName = item.getArea();
|
|
|
- List<Region> regionTemp = regionList.stream().filter(r -> (
|
|
|
- StrUtil.equals(r.getProvinceCode(),province.getCode()) &&
|
|
|
- StrUtil.equals(r.getCityCode(),city.getCode()) &&
|
|
|
- StrUtil.equals(r.getAreaName(),areaName)
|
|
|
- )).distinct().limit(1).collect(Collectors.toList());
|
|
|
- if(null != regionTemp && regionTemp.size() > 0){
|
|
|
- region = regionTemp.get(0);
|
|
|
- }
|
|
|
+ Region region = regionList.stream().filter(r -> (
|
|
|
+ StrUtil.equals(r.getProvinceCode(), province.getCode()) &&
|
|
|
+ StrUtil.equals(r.getCityCode(), city.getCode()) &&
|
|
|
+ StrUtil.equals(r.getAreaName(), areaName)
|
|
|
+ )).distinct().limit(1).findFirst().get();
|
|
|
//根据省市查找区域,如果区域不存在就新增
|
|
|
if(null == region) {
|
|
|
-
|
|
|
- log.error("表格数据有误,行数:{}, {}没有匹配区域",rowNum,distname);
|
|
|
+ log.error("表格数据有误,行数:{}, {}没有匹配区域",rowNum,areaName);
|
|
|
return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配区域",rowNum,areaName));
|
|
|
|
|
|
//fixme:待确认,如果表格中导入的区域不存在,直接返回还是新增
|
|
@@ -305,15 +292,11 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
|
|
|
project.setRegionId(region.getId());
|
|
|
|
|
|
//根据名称查询甲方公司
|
|
|
- PropertyCompany propertyCompany = null;
|
|
|
Long ppCompanyId;
|
|
|
String ppCompanyName = item.getPpCompanyName();
|
|
|
- List<PropertyCompany> propertyCompanyTemp = propertyCompanyList.stream().filter(company -> (
|
|
|
+ PropertyCompany propertyCompany = propertyCompanyList.stream().filter(company -> (
|
|
|
StrUtil.equals(company.getName(),ppCompanyName)
|
|
|
- )).distinct().limit(1).collect(Collectors.toList());
|
|
|
- if(null != propertyCompanyTemp && !propertyCompanyTemp.isEmpty()){
|
|
|
- propertyCompany = propertyCompanyTemp.get(0);
|
|
|
- }
|
|
|
+ )).distinct().limit(1).findFirst().get();
|
|
|
//如果维保公司不存在,新建,生成id
|
|
|
if(null == propertyCompany){
|
|
|
propertyCompany = new PropertyCompany();
|
|
@@ -337,17 +320,13 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
|
|
|
project.setPpCompanyId(propertyCompany.getId());
|
|
|
|
|
|
//根据名称查询甲方联系人
|
|
|
- PropertyContact propertyContact = null;
|
|
|
String ppCompanyContact = item.getPpCompanyContact();
|
|
|
String ppTelephone = item.getPpCompanyTelephone();
|
|
|
- List<PropertyContact> propertyContactTemp = propertyContactList.stream().filter(contact -> (
|
|
|
+ PropertyContact propertyContact = propertyContactList.stream().filter(contact -> (
|
|
|
StrUtil.equals(contact.getName(),ppCompanyContact) &&
|
|
|
StrUtil.equals(contact.getTelephone(),ppTelephone) &&
|
|
|
ppCompanyId == contact.getPpCompanyId()
|
|
|
- )).distinct().limit(1).collect(Collectors.toList());
|
|
|
- if(null != propertyContactTemp && propertyContactTemp.size() > 0){
|
|
|
- propertyContact = propertyContactTemp.get(0);
|
|
|
- }
|
|
|
+ )).distinct().limit(1).findFirst().get();
|
|
|
if(null == propertyContact){
|
|
|
propertyContact = new PropertyContact();
|
|
|
Long ppContactId = IdWorker.getId();
|