添加福建茶园地块

This commit is contained in:
qdxkrs 2022-06-22 15:55:02 +08:00
parent c9abb90c97
commit b9bb66bfd9
8 changed files with 504 additions and 9 deletions

View File

@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.8</version>
<version>2.5.14</version>
<relativePath/>
</parent>

View File

@ -39,14 +39,14 @@ public class SaticScheduleTask {
//
// }
/**
* 定时获取气象站数据 5 分钟触发
*/
@Scheduled(cron = "0 0/5 * * * ?")
private void configureTasks() {
logger.info("执行静态定时任务时间: " + LocalDateTime.now());
weatherGet.findWeather();
}
// /**
// * 定时获取气象站数据 5 分钟触发
// */
// @Scheduled(cron = "0 0/5 * * * ?")
// private void configureTasks() {
// logger.info("执行静态定时任务时间: " + LocalDateTime.now());
// weatherGet.findWeather();
// }
public static void main(String[] args) {
String url = "http://47.105.215.208:8005/intfa/queryData/16079680";

View File

@ -0,0 +1,69 @@
package com.xkrs.microservice.controller;
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
import com.xkrs.microservice.model.entity.TeaGardenPlotEntity;
import com.xkrs.microservice.model.qo.TeaGardenPlotQo;
import com.xkrs.microservice.service.TeaGardenPlotService;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Locale;
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* 茶园地块管理
* @author tajochen
*/
@RestController
@RequestMapping("/api/tea-garden-plot")
public class TeaGardenPlotController {
/**
* 获取区域信息
*/
Locale locale = LocaleContextHolder.getLocale();
@Resource
private TeaGardenPlotService teaGardenPlotService;
@RequestMapping(value="/get/all",method = RequestMethod.GET)
@CrossOrigin
public String getAllRecord() {
Iterable<TeaGardenPlotEntity> list = teaGardenPlotService.getAllRecord();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale);
}
@RequestMapping(value="/update",method = RequestMethod.POST)
// @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')")
@CrossOrigin
public String dataUpdate(@RequestBody TeaGardenPlotQo teaGardenPlotQo) {
teaGardenPlotService.update(teaGardenPlotQo);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
@RequestMapping(value="/add",method = RequestMethod.POST)
// @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')")
@CrossOrigin
public String dataAdd(@RequestBody TeaGardenPlotQo teaGardenPlotQo) {
// 监测地块编号是否存在
TeaGardenPlotEntity teaGardenPlotEntity = teaGardenPlotService.getAllRecordByDkbh(teaGardenPlotQo.getDkbh());
if(teaGardenPlotEntity!=null){
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"地块编号已存在",locale);
}
teaGardenPlotService.add(teaGardenPlotQo);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
@RequestMapping(value="/delete",method = RequestMethod.DELETE)
// @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor','auth_farm_user')")
@CrossOrigin
public String dataDelete(@RequestParam("id") Integer id) {
int res = teaGardenPlotService.delete(id);
if(res == 1){
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
}

View File

@ -0,0 +1,20 @@
package com.xkrs.microservice.dao;
import com.xkrs.microservice.model.entity.TeaGardenPlotEntity;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* TypicalPlotDao
* @author tajochen
*/
public interface TeaGardenPlotDao extends JpaRepository<TeaGardenPlotEntity,Integer> {
/**
* 根据 地块编号 查找
* @param dkbh
* @return
*/
TeaGardenPlotEntity findAllByDkbh(String dkbh);
}

View File

@ -0,0 +1,156 @@
package com.xkrs.microservice.model.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.micrometer.core.instrument.util.StringUtils;
import org.geolatte.geom.Geometry;
import javax.persistence.*;
/**
* TeaGardenPlotEntity 表实体类
* @author tajochen
*/
@Entity
@Table(name="tea_garden_plot")
public class TeaGardenPlotEntity {
private static final long serialVersionUID = 4359709211352400087L;
/**
* 指定主键建立自增序列主键值取自序列
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tea_garden_plot_gen")
@SequenceGenerator(name = "tea_garden_plot_seq_gen", sequenceName = "tea_garden_plot_seq",allocationSize = 1)
private Integer id;
@Column( length = 255, columnDefinition = "varchar(255)")
private String dkbh;
@Column( length = 255, columnDefinition = "varchar(255)")
private String dlmc;
private Double tbmj;
@Column( length = 255, columnDefinition = "varchar(255)")
private String trlx;
@Column( length = 255, columnDefinition = "varchar(255)")
private String lxr;
@Column( length = 255, columnDefinition = "varchar(255)")
private String lxdh;
@Column( length = 255, columnDefinition = "varchar(255)")
private String zuowu;
private Geometry geom;
@Transient
private String wktGeom;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDkbh() {
return dkbh;
}
public void setDkbh(String dkbh) {
this.dkbh = dkbh;
}
public String getDlmc() {
return dlmc;
}
public void setDlmc(String dlmc) {
this.dlmc = dlmc;
}
public Double getTbmj() {
return tbmj;
}
public void setTbmj(Double tbmj) {
this.tbmj = tbmj;
}
public String getLxr() {
return lxr;
}
public void setLxr(String lxr) {
this.lxr = lxr;
}
public String getTrlx() {
return trlx;
}
public void setTrlx(String trlx) {
this.trlx = trlx;
}
public String getLxdh() {
return lxdh;
}
public void setLxdh(String lxdh) {
this.lxdh = lxdh;
}
public String getZuowu() {
return zuowu;
}
public void setZuowu(String zuowu) {
this.zuowu = zuowu;
}
@JsonIgnore
public Geometry getGeom() {
return geom;
}
@JsonIgnore
public void setGeom(Geometry geom) {
this.geom = geom;
}
public String getWktGeom() {
if(StringUtils.isNotBlank(wktGeom)){
return wktGeom;
} else if(geom == null){
return "";
} else {
return geom.toString();
}
}
public void setWktGeom(String wktGeom) {
this.wktGeom = wktGeom;
}
@Override
public String toString() {
return "TeaGardenPlot{" +
"id=" + id +
", dkbh='" + dkbh + '\'' +
", dlmc='" + dlmc + '\'' +
", tbmj=" + tbmj +
", trlx='" + trlx + '\'' +
", lxr='" + lxr + '\'' +
", lxdh='" + lxdh + '\'' +
", zuowu='" + zuowu + '\'' +
", geom=" + geom +
", wktGeom='" + wktGeom + '\'' +
'}';
}
}

View File

@ -0,0 +1,99 @@
package com.xkrs.microservice.model.qo;
/**
* TeaGardenPlotQo
* @author tajochen
*/
public class TeaGardenPlotQo {
private Integer id;
private String dkbh;
private String dlmc;
private Double tbmj;
private String trlx;
private String lxr;
private String lxdh;
private String zuowu;
private String geomStr;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDkbh() {
return dkbh;
}
public void setDkbh(String dkbh) {
this.dkbh = dkbh;
}
public String getDlmc() {
return dlmc;
}
public void setDlmc(String dlmc) {
this.dlmc = dlmc;
}
public Double getTbmj() {
return tbmj;
}
public void setTbmj(Double tbmj) {
this.tbmj = tbmj;
}
public String getTrlx() {
return trlx;
}
public void setTrlx(String trlx) {
this.trlx = trlx;
}
public String getLxr() {
return lxr;
}
public void setLxr(String lxr) {
this.lxr = lxr;
}
public String getLxdh() {
return lxdh;
}
public void setLxdh(String lxdh) {
this.lxdh = lxdh;
}
public String getZuowu() {
return zuowu;
}
public void setZuowu(String zuowu) {
this.zuowu = zuowu;
}
public String getGeomStr() {
return geomStr;
}
public void setGeomStr(String geomStr) {
this.geomStr = geomStr;
}
}

View File

@ -0,0 +1,47 @@
package com.xkrs.microservice.service;
import com.xkrs.microservice.model.entity.TeaGardenPlotEntity;
import com.xkrs.microservice.model.qo.TeaGardenPlotQo;
import com.xkrs.microservice.model.qo.TypicalPlotQo;
/**
* 茶园地块服务管理接口
* @author tajochen
*/
public interface TeaGardenPlotService {
/**
* 获取所有典型地块记录
* @return
*/
Iterable<TeaGardenPlotEntity> getAllRecord();
/**
* 获取指定地块编号记录
* @param dkbh
* @return
*/
TeaGardenPlotEntity getAllRecordByDkbh(String dkbh);
/**
* 新增典型地块记录
* @param teaGardenPlotQo
*/
void add(TeaGardenPlotQo teaGardenPlotQo);
/**
* 更新典型地块记录
* @param teaGardenPlotQo
*/
void update(TeaGardenPlotQo teaGardenPlotQo);
/**
* 删除典型地块记录
* @param id
* @return
*/
int delete(Integer id);
}

View File

@ -0,0 +1,104 @@
package com.xkrs.microservice.service.impl;
import com.xkrs.microservice.dao.TeaGardenPlotDao;
import com.xkrs.microservice.model.entity.TeaGardenPlotEntity;
import com.xkrs.microservice.model.qo.TeaGardenPlotQo;
import com.xkrs.microservice.service.TeaGardenPlotService;
import com.xkrs.microservice.util.CopyPropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
import static com.xkrs.microservice.util.OpenGeoUtil.wktStrToGeom;
/**
* 茶园地块服务管理接口
* @author tajochen
*/
@Service
@CacheConfig(cacheNames = "TeaGardenPlotServiceCache")
public class TeaGardenPlotServiceImpl implements TeaGardenPlotService {
Logger logger = LoggerFactory.getLogger(TeaGardenPlotServiceImpl.class);
@Resource
private TeaGardenPlotDao teaGardenPlotDao;
/**
* 获取所有典型地块记录
* @return
*/
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override
public List<TeaGardenPlotEntity> getAllRecord(){
return teaGardenPlotDao.findAll();
}
/**
* 获取指定地块编号记录
* @param dkbh
* @return
*/
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override
public TeaGardenPlotEntity getAllRecordByDkbh(String dkbh){
return teaGardenPlotDao.findAllByDkbh(dkbh);
}
/**
* 新增典型地块记录
* @param teaGardenPlotQo
*/
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override
public void add(TeaGardenPlotQo teaGardenPlotQo){
TeaGardenPlotEntity teaGardenPlotEntity = new TeaGardenPlotEntity();
CopyPropertiesUtil.copy( teaGardenPlotQo, teaGardenPlotEntity);
if( !teaGardenPlotQo.getGeomStr().isEmpty()){
// 转化geometry
teaGardenPlotEntity.setGeom(wktStrToGeom(teaGardenPlotQo.getGeomStr()));
}
teaGardenPlotDao.save(teaGardenPlotEntity);
}
/**
* 更新典型地块记录
* @param teaGardenPlotQo
*/
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override
public void update(TeaGardenPlotQo teaGardenPlotQo){
TeaGardenPlotEntity teaGardenPlotEntity = new TeaGardenPlotEntity();
CopyPropertiesUtil.copy( teaGardenPlotQo, teaGardenPlotEntity);
if( !teaGardenPlotQo.getGeomStr().isEmpty()){
// 转化geometry
teaGardenPlotEntity.setGeom(wktStrToGeom(teaGardenPlotQo.getGeomStr()));
}
teaGardenPlotDao.save(teaGardenPlotEntity);
}
/**
* 删除典型地块记录
* @param id
* @return
*/
@Cacheable(keyGenerator = "keyGenerator", unless="#result == null")
@Override
public int delete(Integer id){
Optional<TeaGardenPlotEntity> teaGardenPlotEntityOptional = teaGardenPlotDao.findById(id);
if(teaGardenPlotEntityOptional.isPresent()){
return 1;
}
teaGardenPlotDao.deleteById(id);
return 0;
}
}