Browse Source

导入周边数据

feature/v.2.0.0
caoyizhong 3 years ago
parent
commit
88991ef6f3
  1. 3
      air/src/main/java/com/air/applets/controller/LandListedController.java
  2. 51
      air/src/main/java/com/air/dictitem/entity/DictItem.java
  3. 10
      air/src/main/java/com/air/dictitem/mapper/DictItemMapper.java
  4. 7
      air/src/main/java/com/air/dictitem/service/DictItemService.java
  5. 15
      air/src/main/java/com/air/dictitem/service/Impl/DictItemServiceImpl.java
  6. 14
      air/src/main/java/com/air/facilities/controller/FacilitiesController.java
  7. 6
      air/src/main/java/com/air/facilities/dto/FacilitiesFileDTO.java
  8. 2
      air/src/main/java/com/air/facilities/service/FacilitiesService.java
  9. 73
      air/src/main/java/com/air/facilities/service/impl/FacilitiesServiceImpl.java
  10. 2
      air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java
  11. 6
      air/src/main/resources/mapper/BaseRegionMapper.xml
  12. 7
      air/src/main/resources/mapper/DictItemMapper.xml
  13. 2
      air/src/main/resources/mapper/FacilitiesMapper.xml

3
air/src/main/java/com/air/applets/controller/LandListedController.java

@ -15,6 +15,7 @@ import com.cinderella.framework.common.core.util.R;
import com.cinderella.framework.common.data.mybatis.QueryPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -33,6 +34,7 @@ import java.util.List;
@RestController("applets_landListedController")
@RequestMapping("/applets/landlisted")
@Api(value = "landlisted", tags = "小程序已挂牌地块据管理")
@Slf4j
public class LandListedController {
@Autowired
@ -135,6 +137,7 @@ public class LandListedController {
@ApiOperation(value = "按日期统计地块数量(日历)", notes = "按日期统计地块数量(日历)")
@GetMapping("/calendar")
public R<List<LandListedStatisticsDto>> appletsCalendar(@RequestParam String date , String city,String canton) {
log.info("=================={}===={}=={}"+date,city,canton);
return landListedService.appletsCalendar(date,city,canton);
}

51
air/src/main/java/com/air/dictitem/entity/DictItem.java

@ -0,0 +1,51 @@
package com.air.dictitem.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @program: back-end
* @description:
* @author: cyz
* @create: 2022-07-13 13:53
**/
@Data
@TableName("sys_dict_item")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "字典详情表")
public class DictItem extends Model<DictItem> {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty(value="id")
private int id;
@ApiModelProperty(value="字典父ID")
private int dictId;
@ApiModelProperty(value="值")
private String value;
@ApiModelProperty(value="文本")
private String label;
@ApiModelProperty(value="类型")
private String type;
@ApiModelProperty(value="介绍")
private String description;
@ApiModelProperty(value="排序")
private int sort;
@ApiModelProperty(value="创建时间")
private Date createTime;
@ApiModelProperty(value="修改时间")
private Date updateTime;
@ApiModelProperty(value="备注")
private String remarks;
@ApiModelProperty(value="")
private char delFlag;
@ApiModelProperty(value="所属租户")
private int tenantId;
}

10
air/src/main/java/com/air/dictitem/mapper/DictItemMapper.java

@ -0,0 +1,10 @@
package com.air.dictitem.mapper;
import com.air.dictitem.entity.DictItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
@Repository
public interface DictItemMapper extends BaseMapper<DictItem> {
}

7
air/src/main/java/com/air/dictitem/service/DictItemService.java

@ -0,0 +1,7 @@
package com.air.dictitem.service;
import com.air.dictitem.entity.DictItem;
import com.baomidou.mybatisplus.extension.service.IService;
public interface DictItemService extends IService<DictItem> {
}

15
air/src/main/java/com/air/dictitem/service/Impl/DictItemServiceImpl.java

@ -0,0 +1,15 @@
package com.air.dictitem.service.Impl;
import com.air.dictitem.entity.DictItem;
import com.air.dictitem.mapper.DictItemMapper;
import com.air.dictitem.service.DictItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @program: back-end
* @description:
* @author: cyz
* @create: 2022-07-13 14:10
**/
public class DictItemServiceImpl extends ServiceImpl<DictItemMapper, DictItem> implements DictItemService {
}

14
air/src/main/java/com/air/facilities/controller/FacilitiesController.java

@ -79,10 +79,18 @@ public class FacilitiesController {
@ApiOperation(value = "导入周边信息")
@PostMapping("/importFile")
public R<List<Facilities>> importFile(@RequestParam(value = "uploadFile") MultipartFile file){
public R<String> importFile(@RequestParam(value = "uploadFile") MultipartFile file){
try {
boolean b = facilitiesService.importFile(file);
return R.ok();
int i = facilitiesService.importFile(file);
switch (i){
case 0:
return R.failed("导入失败!");
case 1:
return R.ok();
case 10:
return R.failed("导入文件格式不正确!请上传后缀为.xlsx");
}
return R.failed();
} catch (IOException e) {
e.printStackTrace();
return R.failed();

6
air/src/main/java/com/air/facilities/dto/FacilitiesFileDTO.java

@ -61,5 +61,11 @@ public class FacilitiesFileDTO {
@ExcelProperty(value = "分类", index = 6)
private String classify;
/**
* 分类
*/
@ExcelProperty(value = "分类2", index = 7)
private String classifyTwo;
}

2
air/src/main/java/com/air/facilities/service/FacilitiesService.java

@ -64,5 +64,5 @@ public interface FacilitiesService extends IService<Facilities> {
* @param file
* @return
*/
boolean importFile(MultipartFile file) throws IOException;
int importFile(MultipartFile file) throws IOException;
}

73
air/src/main/java/com/air/facilities/service/impl/FacilitiesServiceImpl.java

@ -1,17 +1,17 @@
package com.air.facilities.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSON;
import com.air.baseRegion.dto.BaseRegionDTO;
import com.air.baseRegion.entity.BaseRegion;
import com.air.baseRegion.mapper.BaseRegionMapper;
import com.air.baseRegion.vo.BaseRegionVO;
import com.air.dictitem.entity.DictItem;
import com.air.dictitem.mapper.DictItemMapper;
import com.air.facilities.dto.FacilitiesDTO;
import com.air.facilities.dto.FacilitiesFileDTO;
import com.air.facilities.entity.Facilities;
import com.air.facilities.mapper.FacilitiesMapper;
import com.air.facilities.service.FacilitiesService;
import com.air.land.entity.LandListed;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -47,6 +47,9 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
@Autowired
private BaseRegionMapper baseRegionMapper;
@Autowired
private DictItemMapper dictItemMapper;
/**
* 查询全部数据
*
@ -107,15 +110,20 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
String srt = "POINT(" + facilitiesDTO.getLon() + " " + facilitiesDTO.getLat() + ")";
facilities.setGeom(srt);
if (StrUtil.isNotBlank(facilitiesDTO.getOldType())) {
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda().
eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), Facilities::getType, facilitiesDTO.getOldType()));
if (facilities1.size() > 0) {
facilities.setType(facilities1.get(0).getType());
facilities.setTypecn(facilities1.get(0).getTypecn());
DictItem rim = dictItemMapper.selectOne(Wrappers.<DictItem>query().lambda()
.eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), DictItem::getValue, facilitiesDTO.getOldType())
.eq(DictItem::getType, "rim")
);
if (ObjectUtil.isNotNull(rim)) {
facilities.setType(rim.getValue());
facilities.setTypecn(rim.getLabel());
return facilitiesMapper.insertFacilities(facilities);
}else{
return 0;
}
}else{
return 0;
}
return facilitiesMapper.insertFacilities(facilities);
}
/**
@ -144,15 +152,21 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
facilities.setGeom(srt);
facilities.setGid(facilitiesDTO.getGid());
if (StrUtil.isNotBlank(facilitiesDTO.getOldType())) {
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda().
eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), Facilities::getType, facilitiesDTO.getOldType()));
if (facilities1.size() > 0) {
facilities.setType(facilities1.get(0).getType());
facilities.setTypecn(facilities1.get(0).getTypecn());
DictItem rim = dictItemMapper.selectOne(Wrappers.<DictItem>query().lambda()
.eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), DictItem::getValue, facilitiesDTO.getOldType())
.eq(DictItem::getType, "rim")
);
if (ObjectUtil.isNotNull(rim)) {
facilities.setType(rim.getValue());
facilities.setTypecn(rim.getLabel());
return facilitiesMapper.updateFacilities(facilities);
}else{
return 0;
}
}else{
return 0;
}
return facilitiesMapper.updateFacilities(facilities);
}
/**
@ -163,11 +177,18 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
*/
@Override
@Transactional
public boolean importFile(MultipartFile file) {
public int importFile(MultipartFile file) {
try {
//判断文件类型是否正确
String originalFilename = file.getOriginalFilename();
String fileType = originalFilename.substring(originalFilename.lastIndexOf("."));
if (!".xls".equalsIgnoreCase(fileType) && !".xlsx".equalsIgnoreCase(fileType)) {
return 10;
}
InputStream inputStream = file.getInputStream();
EasyExcel.read(inputStream, FacilitiesFileDTO.class, new PageReadListener<FacilitiesFileDTO>(dataList -> {
dataList.forEach( demoData -> {
log.info(dataList.size()+"======================");
// for (FacilitiesFileDTO demoData : dataList) {
Facilities facilities = new Facilities();
facilities.setName(demoData.getName());
@ -181,11 +202,13 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
facilities.setLat(bed);//纬度
facilities.setGeom(srt);
//查询周边类型
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda()
.eq(StringUtils.isNotBlank(demoData.getClassify()), Facilities::getTypecn, demoData.getClassify()));
if(facilities1.size() > 0 ){
facilities.setType(facilities1.get(0).getType());
facilities.setTypecn(facilities1.get(0).getTypecn());
DictItem rim = dictItemMapper.selectOne(Wrappers.<DictItem>query().lambda()
.like(StringUtils.isNotBlank(demoData.getClassify()), DictItem::getLabel, demoData.getClassifyTwo())
.eq(DictItem::getType, "rim")
);
if(ObjectUtil.isNotNull(rim) ){
facilities.setType(rim.getValue());
facilities.setTypecn(rim.getLabel());
}else{
throw new BusinessException("没有该分类");
}
@ -202,11 +225,11 @@ public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilit
facilitiesMapper.insertFacilities(facilities);
});
})).sheet().headRowNumber(1).doRead();
return true;
return 1;
} catch (IOException e) {
e.printStackTrace();
}
return false;
return 0;
}

2
air/src/main/java/com/air/land/service/impl/LandListedServiceImpl.java

@ -227,7 +227,7 @@ public class LandListedServiceImpl extends ServiceImpl<LandListedMapper, LandLis
* 定时查询已挂出导出全部数据
*/
@Async
@Scheduled(cron = "0 0/59 * * * ?") // 10分执行一次 “0 0 12 ?” 每天12时执行一次
@Scheduled(cron = "0 0/59 * * * *") // 10分执行一次 “0 0 12 ?” 每天12时执行一次
public void selectCollection() throws IOException {
log.info("定时查询已挂出导出全部数据"+System.currentTimeMillis());
List<LandListed> landListeds = list();

6
air/src/main/resources/mapper/BaseRegionMapper.xml

@ -9,9 +9,9 @@
join sys_base_region sen on sbr.REGION_ID= sen.PAR_REGION_ID
join sys_base_region shi on sen.REGION_ID= shi.PAR_REGION_ID
<where>
<if test="province != null and province != '' "> sbr.REGION_NAME = #{ province }</if>
<if test="city != null and city != ''">and sen.REGION_NAME = #{ city } </if>
<if test="area != null and area != ''">and shi.REGION_NAME= #{area }</if>
<if test="province != null and province != '' "> sbr.REGION_NAME like concat('%',#{ province },'%') </if>
<if test="city != null and city != ''">and sen.REGION_NAME like concat('%', #{ city },'%') </if>
<if test="area != null and area != ''">and shi.REGION_NAME like concat('%', #{ area },'%')</if>
</where>
</select>

7
air/src/main/resources/mapper/DictItemMapper.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.air.dictitem.mapper.DictItemMapper">
</mapper>

2
air/src/main/resources/mapper/FacilitiesMapper.xml

@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.air.facilities.mapper.FacilitiesMapper">
<select id="getAllFacilities" resultType="com.air.facilities.entity.Facilities">
select gid,id,name,typecn,remark,lon,lat,type,geom,mini_geom from facilities
select gid,id,name,typecn,remark,lon,lat,type,geom,mini_geom,address,site from facilities
<where>
<if test="facilities.name != null and facilities.name != ''"> and name like concat('%', #{facilities.name},'%') </if>
<if test="facilities.typecn != null and facilities.typecn != ''"> and typecn = #{facilities.typecn} </if>

Loading…
Cancel
Save