删除无用数据表
This commit is contained in:
parent
1953732ef3
commit
f7f635f092
@ -1,36 +0,0 @@
|
||||
package com.xkrs.common;
|
||||
|
||||
import com.xkrs.model.qo.SettingQo;
|
||||
import com.xkrs.service.SettingService;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 火点审核开关计划任务
|
||||
*/
|
||||
@Configuration
|
||||
@EnableScheduling
|
||||
public class StaticScheduleTask {
|
||||
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
|
||||
//早上八点打开火点审核开关
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
private void openVerifySwitch() {
|
||||
SettingQo settingQo = new SettingQo();
|
||||
settingQo.setSwitchState("1");
|
||||
settingService.updateSwitchState(settingQo);
|
||||
}
|
||||
|
||||
// //晚上十点关闭火点审核开关
|
||||
// @Scheduled(cron = "0 0 22 * * ?")
|
||||
// private void closeVerifySwitch() {
|
||||
// SettingQo settingQo = new SettingQo();
|
||||
// settingQo.setSwitchState("0");
|
||||
// settingService.updateSwitchState(settingQo);
|
||||
// }
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.xkrs.controller;
|
||||
|
||||
import com.xkrs.model.qo.SettingQo;
|
||||
import com.xkrs.service.SettingService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 设置审核开关状态
|
||||
*/
|
||||
@RestController
|
||||
public class SettingController {
|
||||
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
|
||||
/**
|
||||
* 更新审核开关状态
|
||||
*/
|
||||
@PostMapping("/updateswitchstate")
|
||||
public String updateSwitchState(@RequestBody SettingQo settingQo) {
|
||||
return settingService.updateSwitchState(settingQo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审核开关状态
|
||||
*/
|
||||
@GetMapping("/queryswitchstate")
|
||||
public String querySwitchState() {
|
||||
return settingService.querySwitchState();
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.xkrs.dao;
|
||||
|
||||
import com.xkrs.model.entity.SettingEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xkrs
|
||||
*/
|
||||
@Component
|
||||
public interface SettingDao extends JpaRepository<SettingEntity, Long>, JpaSpecificationExecutor<SettingEntity> {
|
||||
|
||||
@Modifying(clearAutomatically = true)
|
||||
@Query(value = "UPDATE setting SET switch_state = ?2 where id = ?1", nativeQuery = true)
|
||||
void updateSwitchStateById(Long id, String switchState);
|
||||
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.xkrs.model.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xkrs
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "setting")
|
||||
public class SettingEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "setting_seq_gen")
|
||||
@SequenceGenerator(name = "setting_seq_gen", sequenceName = "setting_id_seq", allocationSize = 1)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 0:关,1:开
|
||||
*/
|
||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||
private String switchState;
|
||||
|
||||
public SettingEntity() {
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSwitchState() {
|
||||
return switchState;
|
||||
}
|
||||
|
||||
public void setSwitchState(String switchState) {
|
||||
this.switchState = switchState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SettingEntity{" + "id=" + id + ", switchState='" + switchState + '\'' + '}';
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.xkrs.model.qo;
|
||||
|
||||
import com.xkrs.model.validation.SettingQoUpdate;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class SettingQo {
|
||||
|
||||
@NotNull(message = "{Setting.switchState.blank}", groups = {SettingQoUpdate.class})
|
||||
private String switchState;
|
||||
|
||||
public SettingQo() {
|
||||
}
|
||||
|
||||
public String getSwitchState() {
|
||||
return switchState;
|
||||
}
|
||||
|
||||
public void setSwitchState(String switchState) {
|
||||
this.switchState = switchState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SettingQo{" + "switchState='" + switchState + '\'' + '}';
|
||||
}
|
||||
}
|
@ -63,13 +63,6 @@ public interface FirePointService {
|
||||
*/
|
||||
String selectFirePointNumWeek();
|
||||
|
||||
/**
|
||||
* 根据火点编号更新审核状态
|
||||
* 操作1:将火点编号对应的火点从山东火点表转存到火点表
|
||||
* 操作2:将山东火点表中的这个火点的审核状态更新
|
||||
*/
|
||||
String updateVerifyStateByFireCode(String fireCode, String verifyState);
|
||||
|
||||
/**
|
||||
* download vip user's fire point
|
||||
*
|
||||
|
@ -1,18 +0,0 @@
|
||||
package com.xkrs.service;
|
||||
|
||||
import com.xkrs.model.qo.SettingQo;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
public interface SettingService {
|
||||
|
||||
/**
|
||||
* 更新审核开关状态
|
||||
*/
|
||||
String updateSwitchState(@RequestBody SettingQo settingQo);
|
||||
|
||||
/**
|
||||
* 查询审核开关状态
|
||||
*/
|
||||
String querySwitchState();
|
||||
|
||||
}
|
@ -22,7 +22,6 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.transaction.Transactional;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -50,12 +49,6 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
@Resource
|
||||
private FirePointDao firePointDao;
|
||||
|
||||
@Resource
|
||||
private SettingDao settingDao;
|
||||
|
||||
@Resource
|
||||
private ShanDongFirePointDao shanDongFirePointDao;
|
||||
|
||||
@Resource
|
||||
private SysUserDao sysUserDao;
|
||||
|
||||
@ -162,56 +155,6 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
return duplicatedDataList != null && duplicatedDataList.size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据山东火点生成全国火点
|
||||
*/
|
||||
private FirePointEntity getFirePointByShanDongFirePoint(ShanDongFirePointEntity shanDongFirePoint) {
|
||||
FirePointEntity firePoint = new FirePointEntity();
|
||||
firePoint.setFireCode(shanDongFirePoint.getFireCode());
|
||||
firePoint.setCountyCode(shanDongFirePoint.getCountyCode());
|
||||
firePoint.setCountyName(shanDongFirePoint.getCountyName());
|
||||
firePoint.setSatelliteTime(shanDongFirePoint.getSatelliteTime());
|
||||
firePoint.setLongitude(shanDongFirePoint.getLongitude());
|
||||
firePoint.setLatitude(shanDongFirePoint.getLatitude());
|
||||
firePoint.setFirePointAddress(shanDongFirePoint.getFirePointAddress());
|
||||
firePoint.setSatelliteType(shanDongFirePoint.getSatelliteType());
|
||||
firePoint.setLandType(shanDongFirePoint.getLandType());
|
||||
firePoint.setConfidence(shanDongFirePoint.getConfidence());
|
||||
firePoint.setAddTime(shanDongFirePoint.getAddTime());
|
||||
firePoint.setFireType(shanDongFirePoint.getFireType());
|
||||
firePoint.setFireImage(shanDongFirePoint.getFireImage());
|
||||
firePoint.setSatelliteImage(shanDongFirePoint.getSatelliteImage());
|
||||
firePoint.setStreetCode(shanDongFirePoint.getStreetCode());
|
||||
firePoint.setStreetName(shanDongFirePoint.getStreetName());
|
||||
firePoint.setAuditFireType("0");//初始化火点为未审核状态
|
||||
return firePoint;
|
||||
}
|
||||
|
||||
private ShanDongFirePointEntity getShanDongFirePointByFirePoint(FirePointEntity firePoint) {
|
||||
ShanDongFirePointEntity shanDongFirePoint = new ShanDongFirePointEntity();
|
||||
shanDongFirePoint.setId(firePoint.getId());
|
||||
shanDongFirePoint.setFireCode(firePoint.getFireCode());
|
||||
shanDongFirePoint.setLongitude(firePoint.getLongitude());
|
||||
shanDongFirePoint.setLatitude(firePoint.getLatitude());
|
||||
shanDongFirePoint.setCountyCode(firePoint.getCountyCode());
|
||||
shanDongFirePoint.setCountyName(firePoint.getCountyName());
|
||||
shanDongFirePoint.setSatelliteTime(firePoint.getSatelliteTime());
|
||||
shanDongFirePoint.setSatelliteType(firePoint.getSatelliteType());
|
||||
shanDongFirePoint.setLandType(firePoint.getLandType());
|
||||
shanDongFirePoint.setAddTime(firePoint.getAddTime());
|
||||
shanDongFirePoint.setConfidence(firePoint.getConfidence());
|
||||
shanDongFirePoint.setFirePointAddress(firePoint.getFirePointAddress());
|
||||
shanDongFirePoint.setFireType(firePoint.getFireType());
|
||||
shanDongFirePoint.setFireImage(firePoint.getFireImage());
|
||||
shanDongFirePoint.setSatelliteImage(firePoint.getSatelliteImage());
|
||||
shanDongFirePoint.setBeforeFireImage(firePoint.getBeforeFireImage());
|
||||
shanDongFirePoint.setAfterFireImage(firePoint.getAfterFireImage());
|
||||
shanDongFirePoint.setStreetCode(firePoint.getStreetCode());
|
||||
shanDongFirePoint.setStreetName(firePoint.getStreetName());
|
||||
shanDongFirePoint.setVerifyState("0");
|
||||
return shanDongFirePoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为实体类绑定地址、编号、名称
|
||||
*/
|
||||
@ -231,47 +174,6 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
firePointEntity.setStreetName(addressComponent.getTownship());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据火点编号更新审核状态
|
||||
* 操作1:将火点编号对应的火点从山东火点表转存到火点表
|
||||
* 操作2:将山东火点表中的这个火点的审核状态更新
|
||||
*/
|
||||
@Transactional(rollbackOn = Exception.class)
|
||||
@Override
|
||||
public String updateVerifyStateByFireCode(String fireCode, String verifyState) {
|
||||
if ((!"0".equals(verifyState)) && (!"1".equals(verifyState)) && (!"2".equals(verifyState))) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "审核失败,审核状态参数错误", locale);
|
||||
}
|
||||
ShanDongFirePointEntity existShanDongFirePoint = shanDongFirePointDao.findByFireCode(fireCode);
|
||||
//山东火点表找不到这个火点,返回失败
|
||||
if (existShanDongFirePoint == null) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,没有指定的火点编号", locale);
|
||||
}
|
||||
if ("0".equals(existShanDongFirePoint.getVerifyState()) || "2".equals(existShanDongFirePoint.getVerifyState())) {
|
||||
if ("0".equals(verifyState)) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,审核状态不能被设置为未审核", locale);
|
||||
}
|
||||
if ("1".equals(verifyState)) {
|
||||
//火点表能找到这个火点,返回失败
|
||||
FirePointEntity existFirePoint = firePointDao.findByFireCode(fireCode);
|
||||
if (existFirePoint != null) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "修改失败,火点库已存在指定的火点编号", locale);
|
||||
}
|
||||
//操作1:将火点编号对应的火点从山东火点表转存到火点表
|
||||
FirePointEntity firePoint = getFirePointByShanDongFirePoint(existShanDongFirePoint);
|
||||
log.info("-------转存新火点");
|
||||
firePointDao.save(firePoint);
|
||||
//发送消息通知
|
||||
sendBroadcast(firePoint);
|
||||
}
|
||||
//操作2:将山东火点表中的这个火点的审核状态更新
|
||||
shanDongFirePointDao.updateVerifyStateByFireCode(fireCode, verifyState);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||
}
|
||||
//0或者2可以被审核为1(未审核和未通过可以被审核为通过),已经通过了的就不能再处理了
|
||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "审核失败,火点不能被重复审核", locale);
|
||||
}
|
||||
|
||||
private void sendBroadcast(FirePointEntity firePointEntity) {
|
||||
//发送微信群聊消息
|
||||
sendWeChatGroupMessage(firePointEntity);
|
||||
@ -349,18 +251,6 @@ public class FirePointServiceImpl implements FirePointService {
|
||||
return content;
|
||||
}
|
||||
|
||||
private String getMessageContent(ShanDongFirePointEntity firePointEntity) {
|
||||
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
|
||||
String satelliteTime = firePointEntity.getSatelliteTime();
|
||||
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude());
|
||||
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
|
||||
String countyName = firePointEntity.getCountyName();
|
||||
String streetName = firePointEntity.getStreetName();
|
||||
String landType = firePointEntity.getLandType();
|
||||
String content = firePointEntity.getSatelliteType() + "发现1个待审核火点。\n卫星时间:" + satelliteTime + ";\nlongitude:" + formatLongitude + ";\nlatitude:" + formatLatitude + ";\ncountyName:" + countyName + ";\nstreetName:" + streetName + ";\nlandType:" + landType;
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载VIP用户火点数据
|
||||
*/
|
||||
|
@ -1,61 +0,0 @@
|
||||
package com.xkrs.service.impl;
|
||||
|
||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||
import com.xkrs.dao.SettingDao;
|
||||
import com.xkrs.model.entity.SettingEntity;
|
||||
import com.xkrs.model.qo.SettingQo;
|
||||
import com.xkrs.service.SettingService;
|
||||
import org.apache.http.util.TextUtils;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||
|
||||
@Service
|
||||
public class SettingServiceImpl implements SettingService {
|
||||
|
||||
@Resource
|
||||
private SettingDao settingDao;
|
||||
|
||||
/**
|
||||
* 更新审核开关状态
|
||||
*/
|
||||
@Transactional(rollbackOn = Exception.class)
|
||||
@Override
|
||||
public String updateSwitchState(SettingQo settingQo) {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
if (TextUtils.isEmpty(settingQo.getSwitchState())) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "switchState参数不能为空", locale);
|
||||
}
|
||||
List<SettingEntity> settingEntityList = settingDao.findAll();
|
||||
if (settingEntityList.isEmpty()) {
|
||||
SettingEntity settingEntity = new SettingEntity();
|
||||
settingEntity.setSwitchState(settingQo.getSwitchState());
|
||||
settingDao.save(settingEntity);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||
}
|
||||
for (SettingEntity settingEntity : settingEntityList) {
|
||||
settingDao.updateSwitchStateById(settingEntity.getId(), settingQo.getSwitchState());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询审核开关状态
|
||||
*/
|
||||
@Override
|
||||
public String querySwitchState() {
|
||||
Locale locale = LocaleContextHolder.getLocale();
|
||||
List<SettingEntity> settingEntityList = settingDao.findAll();
|
||||
if (settingEntityList.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有状态信息", locale);
|
||||
}
|
||||
SettingEntity settingEntity = settingEntityList.get(0);
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, settingEntity.getSwitchState(), locale);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user