From f7f635f0923244ce4a1f55e9851375c1292f1c20 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Tue, 10 Jan 2023 14:19:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/common/StaticScheduleTask.java | 36 ------ .../xkrs/controller/SettingController.java | 37 ------ src/main/java/com/xkrs/dao/SettingDao.java | 20 ---- .../com/xkrs/model/entity/SettingEntity.java | 50 -------- .../java/com/xkrs/model/qo/SettingQo.java | 27 ----- .../com/xkrs/service/FirePointService.java | 7 -- .../java/com/xkrs/service/SettingService.java | 18 --- .../service/impl/FirePointServiceImpl.java | 110 ------------------ .../xkrs/service/impl/SettingServiceImpl.java | 61 ---------- 9 files changed, 366 deletions(-) delete mode 100644 src/main/java/com/xkrs/common/StaticScheduleTask.java delete mode 100644 src/main/java/com/xkrs/controller/SettingController.java delete mode 100644 src/main/java/com/xkrs/dao/SettingDao.java delete mode 100644 src/main/java/com/xkrs/model/entity/SettingEntity.java delete mode 100644 src/main/java/com/xkrs/model/qo/SettingQo.java delete mode 100644 src/main/java/com/xkrs/service/SettingService.java delete mode 100644 src/main/java/com/xkrs/service/impl/SettingServiceImpl.java diff --git a/src/main/java/com/xkrs/common/StaticScheduleTask.java b/src/main/java/com/xkrs/common/StaticScheduleTask.java deleted file mode 100644 index 234401c..0000000 --- a/src/main/java/com/xkrs/common/StaticScheduleTask.java +++ /dev/null @@ -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); -// } -} \ No newline at end of file diff --git a/src/main/java/com/xkrs/controller/SettingController.java b/src/main/java/com/xkrs/controller/SettingController.java deleted file mode 100644 index 8dd2a85..0000000 --- a/src/main/java/com/xkrs/controller/SettingController.java +++ /dev/null @@ -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(); - } - -} diff --git a/src/main/java/com/xkrs/dao/SettingDao.java b/src/main/java/com/xkrs/dao/SettingDao.java deleted file mode 100644 index 5be593a..0000000 --- a/src/main/java/com/xkrs/dao/SettingDao.java +++ /dev/null @@ -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, JpaSpecificationExecutor { - - @Modifying(clearAutomatically = true) - @Query(value = "UPDATE setting SET switch_state = ?2 where id = ?1", nativeQuery = true) - void updateSwitchStateById(Long id, String switchState); - -} diff --git a/src/main/java/com/xkrs/model/entity/SettingEntity.java b/src/main/java/com/xkrs/model/entity/SettingEntity.java deleted file mode 100644 index caab61d..0000000 --- a/src/main/java/com/xkrs/model/entity/SettingEntity.java +++ /dev/null @@ -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 + '\'' + '}'; - } -} diff --git a/src/main/java/com/xkrs/model/qo/SettingQo.java b/src/main/java/com/xkrs/model/qo/SettingQo.java deleted file mode 100644 index b00a5dd..0000000 --- a/src/main/java/com/xkrs/model/qo/SettingQo.java +++ /dev/null @@ -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 + '\'' + '}'; - } -} diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index 0f33460..163e500 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -63,13 +63,6 @@ public interface FirePointService { */ String selectFirePointNumWeek(); - /** - * 根据火点编号更新审核状态 - * 操作1:将火点编号对应的火点从山东火点表转存到火点表 - * 操作2:将山东火点表中的这个火点的审核状态更新 - */ - String updateVerifyStateByFireCode(String fireCode, String verifyState); - /** * download vip user's fire point * diff --git a/src/main/java/com/xkrs/service/SettingService.java b/src/main/java/com/xkrs/service/SettingService.java deleted file mode 100644 index b1b9ac3..0000000 --- a/src/main/java/com/xkrs/service/SettingService.java +++ /dev/null @@ -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(); - -} diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 566123b..7af8e57 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -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用户火点数据 */ diff --git a/src/main/java/com/xkrs/service/impl/SettingServiceImpl.java b/src/main/java/com/xkrs/service/impl/SettingServiceImpl.java deleted file mode 100644 index f2d4396..0000000 --- a/src/main/java/com/xkrs/service/impl/SettingServiceImpl.java +++ /dev/null @@ -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 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 settingEntityList = settingDao.findAll(); - if (settingEntityList.isEmpty()) { - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有状态信息", locale); - } - SettingEntity settingEntity = settingEntityList.get(0); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, settingEntity.getSwitchState(), locale); - } -}