Compare commits

..

14 Commits

16 changed files with 143 additions and 330 deletions

View File

@ -26,8 +26,8 @@ public class StaticScheduleTask {
firePointSubscribeManager.autoSync();
}
//小时测试一次微信消息推送
@Scheduled(cron = "0 0 * * * ?")
//天中午12点测试一次微信消息推送
@Scheduled(cron = "0 0 */12 * * ?")
private void testPushWeiXinMessage() {
try {
WeiXinMessageUtils.sendMsg("18447024917@chatroom", "微信发消息测试 " + DateTimeUtils.localDateTimeToString(LocalDateTime.now()), 0);

View File

@ -1,18 +1,31 @@
package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.FirePointOrdinaryDao;
import com.xkrs.dao.FirePointPreciseDao;
import com.xkrs.dao.StreetDao;
import com.xkrs.dao.SysUserDao;
import com.xkrs.helper.FirePointSubscribeManager;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.qo.AllFirePointQo;
import com.xkrs.service.DispatchFirePointService;
import com.xkrs.service.impl.FirePointServiceImpl;
import org.apache.hc.core5.util.TextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.i18n.LocaleContextHolder;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
@RestController
public class DispatchFirePointController {
@ -24,9 +37,17 @@ public class DispatchFirePointController {
private DispatchFirePointService firePointService;
@Resource
private FirePointSubscribeManager firePointSubscribeManager;
@Resource
private FirePointOrdinaryDao firePointOrdinaryDao;
@Resource
private FirePointPreciseDao firePointPreciseDao;
@Resource
private StreetDao streetDao;
private final Locale locale = LocaleContextHolder.getLocale();
@GetMapping("/debug")
public String debug() {
// List<SysUserEntity> sysUserEntityList = sysUserDao.findAll();
// for (SysUserEntity sysUserEntity : sysUserEntityList) {
// String addTime = sysUserEntity.getAddTime();
@ -49,7 +70,43 @@ public class DispatchFirePointController {
// sysUserEntity.setVipTimeRangeJson(serialize);
// sysUserDao.save(sysUserEntity);
// }
return "OKkkkkkkk";
List<Map<String, String>> maps = streetDao.selectProCityPair();
// List<FirePointOrdinaryEntity> firePointOrdinaryEntityList = firePointOrdinaryDao.findAll();
List<FirePointOrdinaryEntity> firePointOrdinaryEntityList = firePointOrdinaryDao.finghjhgfdhjk();
List<String> errorList = new ArrayList<>();
for (FirePointOrdinaryEntity firePointOrdinaryEntity : firePointOrdinaryEntityList) {
String countyCode = firePointOrdinaryEntity.getCountyCode();
String proCode = countyCode.substring(0, 2) + "0000";
firePointOrdinaryEntity.setProCode(proCode);
firePointOrdinaryEntity.setProName(obtainProName(maps, proCode));
String cityCode = countyCode.substring(0, 4) + "00";
firePointOrdinaryEntity.setCityCode(cityCode);
firePointOrdinaryEntity.setCityName(obtainCityName(maps, cityCode));
if (TextUtils.isEmpty(firePointOrdinaryEntity.getCountyCode()) || TextUtils.isEmpty(firePointOrdinaryEntity.getCountyName()) || TextUtils.isEmpty(firePointOrdinaryEntity.getCityCode()) || TextUtils.isEmpty(firePointOrdinaryEntity.getCityName()) || TextUtils.isEmpty(firePointOrdinaryEntity.getProCode()) || TextUtils.isEmpty(firePointOrdinaryEntity.getProName())) {
errorList.add(firePointOrdinaryEntity.getFireCode());
}
}
firePointOrdinaryDao.saveAll(firePointOrdinaryEntityList);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, errorList, locale);
}
private String obtainProName(List<Map<String, String>> maps, String proCode) {
for (Map<String, String> map : maps) {
if (map.get("pro_code").equals(proCode)) {
return map.get("pro_name");
}
}
return null;
}
private String obtainCityName(List<Map<String, String>> maps, String cityCode) {
for (Map<String, String> map : maps) {
if (map.get("city_code").equals(cityCode)) {
return map.get("city_name");
}
}
return null;
}
@GetMapping("/autoSync")

View File

@ -1,8 +1,6 @@
package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.SysUserDao;
import com.xkrs.helper.FirePointQueryManager;
import com.xkrs.service.FirePointService;
import com.xkrs.service.StreetService;
import com.xkrs.service.impl.FirePointServiceImpl;
@ -29,31 +27,9 @@ public class FirePointController {
@Resource
private FirePointService firePointService;
@Resource
private SysUserDao sysUserDao;
@Resource
private StreetService streetService;
@Resource
private FirePointQueryManager firePointQueryManager;
// /**
// * Complete
// */
// @RequestMapping(value = "/download/vipuserfirepoint", method = RequestMethod.GET)
// public String downloadVipUserFirePoint(HttpServletResponse response, HttpServletRequest request) {
// return firePointService.downloadVipUserFilePoint(request, response);
// }
// /**
// * Complete
// */
// @RequestMapping(value = "/download/firepoint", method = RequestMethod.GET)
// public String downloadFirePoint(HttpServletResponse response, HttpServletRequest request, @RequestParam(value = "ids") String ids) {
// return firePointService.downloadFirePoint(request, response, ids);
// }
/**
* 查询火点播报无token
*

View File

@ -2,20 +2,16 @@ package com.xkrs.controller;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.model.va.SysUserQoInsert;
import com.xkrs.model.va.SysUserQoUpdate;
import com.xkrs.service.RedisService;
import com.xkrs.dao.SysUserDao;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.qo.SysUserQo;
import com.xkrs.model.qo.SysUserReceiveSmsQo;
import com.xkrs.model.qo.SysUserRemarkQo;
import com.xkrs.model.qo.SysUserVipLevelQo;
import com.xkrs.model.va.SysUserQoInsert;
import com.xkrs.model.va.SysUserQoUpdate;
import com.xkrs.model.vo.SysUserVo;
import com.xkrs.service.RedisService;
import com.xkrs.service.SysUserService;
import com.xkrs.utilsnew.*;
import com.xkrs.utilsnew.AliYunSmsUtils;
import com.xkrs.utilsnew.RandomUtil;
import org.apache.hc.core5.util.TextUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.data.domain.Sort;
@ -62,7 +58,7 @@ public class SysUserController {
*/
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/updateSysUser", method = RequestMethod.POST)
public String updateSysUser(@RequestBody Map<String, String> paramMap) {
public String updateSysUser(@RequestHeader(value = "Authorization") String token, @RequestBody Map<String, String> paramMap) {
String userIdArray = paramMap.get("userIdArray");
String overTime = paramMap.get("overTime");
String remark = paramMap.get("remark");
@ -109,28 +105,6 @@ public class SysUserController {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "修改失败," + builder, locale);
}
/**
* 修改vip等级
*/
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/updateviplevel", method = RequestMethod.POST)
public String updateVipLevel(@RequestBody SysUserVipLevelQo sysUserVipLevelQo) {
String ids = sysUserVipLevelQo.getIds();
List<Long> idList = new ArrayList<>();
if (ids.contains(",")) {
String[] splits = ids.split(",");
for (String split : splits) {
idList.add(Long.parseLong(split));
}
} else {
idList.add(Long.parseLong(ids));
}
for (Long id : idList) {
sysUserDao.updateVipLevel(id, sysUserVipLevelQo.getVipLevel());
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
/**
* 修改是否接收短信
*/
@ -153,18 +127,6 @@ public class SysUserController {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
@Transactional(rollbackFor = Exception.class)
@RequestMapping(value = "/updateremark", method = RequestMethod.POST)
public String updateRemark(@RequestBody SysUserRemarkQo sysUserRemarkQo) {
Long id = sysUserRemarkQo.getId();
Optional<SysUserEntity> optionalById = sysUserDao.findById(id);
if (optionalById.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "修改失败,用户找不到", locale);
}
sysUserDao.updateRemark(id, sysUserRemarkQo.getRemark());
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
/**
* 登录用户Token验证
*/
@ -208,20 +170,6 @@ public class SysUserController {
return sysUserService.deleteSysUser(userName);
}
/**
* 软删除指定id的普通用户
*/
@RequestMapping(value = "/general/delete", method = RequestMethod.DELETE)
public String deleteCustomUser(@RequestParam(value = "userId", required = false) Long id) {
// 验证数据合法性
int res = sysUserService.softDeleteGeneralUser(id);
if (res == 1) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale);
} else {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale);
}
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String updateUser(@Validated({SysUserQoUpdate.class}) @RequestBody SysUserQo userQo, BindingResult bindingResult) {
// 验证数据合法性
@ -273,7 +221,7 @@ public class SysUserController {
*/
@PostMapping("/operateActiveFlag")
public String operateActiveFlag(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) {
Long userId = (Long) map.get("userId");
Integer userId = (Integer) map.get("userId");
String keepType = (String) map.get("keepType");
// 验证token
String tokenUserName = TokenUtil.obtainUserNameByToken(token);
@ -283,10 +231,10 @@ public class SysUserController {
}
// 如果keepType等于1进行启用操作
if ("1".equals(keepType)) {
sysUserService.updateEnable(userId);
sysUserService.updateEnable(Long.valueOf(userId));
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "启用成功", locale);
} else {
sysUserService.updateDisable(userId);
sysUserService.updateDisable(Long.valueOf(userId));
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "禁用成功", locale);
}
}
@ -397,14 +345,4 @@ public class SysUserController {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "true", locale);
}
/**
* 修改账号到期时间
*/
@PostMapping("/updateOverTime")
public String updateOverTime(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) {
Long userId = (Long) map.get("userId");
String overTime = (String) map.get("overTime");
return sysUserService.updateOverTime(userId, overTime);
}
}

View File

@ -3,8 +3,14 @@ package com.xkrs.dao;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public interface FirePointOrdinaryDao extends JpaRepository<FirePointOrdinaryEntity, Long>, JpaSpecificationExecutor<FirePointOrdinaryEntity> {
@Query(value = "SELECT * FROM fire_point_ordinary ORDER BY satellite_time DESC LIMIT 10000", nativeQuery = true)
List<FirePointOrdinaryEntity> finghjhgfdhjk();
}

View File

@ -39,4 +39,7 @@ public interface StreetDao extends JpaRepository<StreetEntity, Integer>, JpaSpec
@Query(value = "SELECT DISTINCT t.street_code AS code, t.street_name AS name FROM street AS t WHERE t.county_code = ?1", nativeQuery = true)
List<Map<String, String>> selectStreetList(String countyCode);
@Query(value = "SELECT t.pro_code, t.pro_name, t.city_code, t.city_name FROM street AS t group by pro_code, pro_name, city_code, city_name", nativeQuery = true)
List<Map<String, String>> selectProCityPair();
}

View File

@ -13,15 +13,6 @@ import java.util.List;
@Component
public interface SysRoleDao extends JpaRepository<SysRoleEntity, Long>, JpaSpecificationExecutor<SysRoleEntity> {
/**
* 查询用户角色列表根据用户id
*
* @param id
* @return
*/
@Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc FROM sys_role,rel_user_role WHERE sys_role.id = rel_user_role.role_id AND rel_user_role.user_id = :id ", nativeQuery = true)
List<SysRoleEntity> selectByUserId(@Param("id") Long id);
/**
* 查询用户角色列表根据用户名
*

View File

@ -11,18 +11,10 @@ import org.springframework.stereotype.Component;
@Component
public interface SysUserDao extends JpaRepository<SysUserEntity, Long>, JpaSpecificationExecutor<SysUserEntity> {
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE sys_user SET vip_level = ?2 WHERE id = ?1", nativeQuery = true)
void updateVipLevel(Long id, Integer vipLevel);
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE sys_user SET receive_sms = ?2 WHERE id = ?1", nativeQuery = true)
void updateReceiveSms(Long id, Integer receiveSms);
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE sys_user SET remark = ?2 WHERE id = ?1", nativeQuery = true)
void updateRemark(Long id, String remark);
/**
* 检查系统用户名是否存在
*/
@ -35,13 +27,6 @@ public interface SysUserDao extends JpaRepository<SysUserEntity, Long>, JpaSpeci
@Query(value = "SELECT * FROM sys_user WHERE user_name = :userName", nativeQuery = true)
SysUserEntity selectByUserName(@Param("userName") String userName);
/**
* 软删除系统用户根据id
*/
@Modifying
@Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE id = :id ;", nativeQuery = true)
void softDeleteGeneralUserById(@Param("id") Long id);
/**
* 删除系统用户危险操作
*/
@ -71,27 +56,14 @@ public interface SysUserDao extends JpaRepository<SysUserEntity, Long>, JpaSpeci
void updatePassword(Long userId, String newPassword);
/**
* 根据id查询用户的信息
*/
@Query(value = "select * from sys_user where id = ?", nativeQuery = true)
SysUserEntity selectByUserId(Long userId);
/**
* 根据id修改账户的到期时间
*/
@Query(value = "update sys_user set over_time = ?2 where id = ?1", nativeQuery = true)
@Modifying(clearAutomatically = true)
void updateOverTime(Long userId, String overTime);
/**
* 记录用户登录次数
* 修改用户登录次数
*/
@Query(value = "update sys_user set login_num = ?2 where id = ?1", nativeQuery = true)
@Modifying(clearAutomatically = true)
void updateLoginNum(Long userId, Integer loginNum);
/**
* 修改登陆时间
* 修改最后登录时间
*/
@Query(value = "update sys_user set login_last_time = ?2 where id = ?1", nativeQuery = true)
@Modifying(clearAutomatically = true)

View File

@ -1,15 +1,15 @@
package com.xkrs.helper;
import com.xkrs.dao.CountyCodeWeiXinDao;
import com.xkrs.model.entity.CountyCodeWeiXinEntity;
import com.xkrs.dao.SysUserDao;
import com.xkrs.model.entity.CountyCodeWeiXinEntity;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.FirePointPreciseEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.helper.PushHelper;
import com.xkrs.model.vo.AllFirePointVo;
import com.xkrs.utilsnew.FirePointConvertUtils;
import com.xkrs.utilsnew.FirePointCodeUtils;
import com.xkrs.utilsnew.FirePointConvertUtils;
import com.xkrs.utilsnew.SMSUtils;
import com.xkrs.utilsnew.WeiXinMessageUtils;
import org.slf4j.Logger;
@ -44,48 +44,48 @@ public class FirePointPushManager {
}
private void pushNotification(AllFirePointVo firePoint, boolean precise) {
//发送微信群聊消息
sendWeChatGroupMessage(firePoint);
if (precise && firePoint.getLandType().contains("耕地")) {
//过滤短信通知收件人
List<SysUserEntity> sysUserList = sysUserDao.findAll();
List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
// //推送
// try {
// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
// pushHelper.dispatchPushMessage(userAccountList, firePointEntity);
// } catch (Exception e) {
// e.printStackTrace();
// //发送微信群聊消息
// sendWeChatGroupMessage(firePoint);
//
// if (precise) {
// //过滤短信通知收件人
// List<SysUserEntity> sysUserList = sysUserDao.findAll();
// List<SysUserEntity> smsReceiverList = FirePointCodeUtils.filterSmsReceiver(firePoint.getTownCode(), sysUserList);
//// //推送
//// try {
//// List<String> userAccountList = pushHelper.obtainUserAccountList(smsReceiverList);
//// pushHelper.dispatchPushMessage(userAccountList, firePointEntity);
//// } catch (Exception e) {
//// e.printStackTrace();
//// }
// if (smsReceiverList.size() > 0) {
// String[] telephoneArray = new String[smsReceiverList.size()];
// for (int i = 0; i < smsReceiverList.size(); i++) {
// telephoneArray[i] = "86" + smsReceiverList.get(i).getUserName();
// }
// int resValue = SMSUtils.sendSmsToUser(telephoneArray, "1425995", new String[]{firePoint.getFirePointAddress()});
// String sendResult;
// if (resValue == 0) {
// //联系人列表发送短信成功在数据库中的已发短信数量字段加一
// for (SysUserEntity smsReceiver : smsReceiverList) {
// smsReceiver.setReceiveSmsCount(smsReceiver.getReceiveSmsCount() + 1);
// }
// sysUserDao.saveAll(smsReceiverList);
// sendResult = "短信通知发送成功!";
// } else {
// sendResult = "短信通知发送失败!";
// }
// //记录短信通知日志
// StringBuilder stringBuilder = new StringBuilder("发送人:青岛星科瑞升信息科技有限公司\n");
// for (String telephone : telephoneArray) {
// stringBuilder.append("接收人:").append(telephone).append("\n");
// }
// stringBuilder.append("模板参数:").append(firePoint.getFirePointAddress()).append("\n");
// stringBuilder.append("超级详细的参数:").append(firePoint.toString()).append("\n");
// stringBuilder.append(sendResult);
// log.info(stringBuilder.toString());
// }
if (smsReceiverList.size() > 0) {
String[] telephoneArray = new String[smsReceiverList.size()];
for (int i = 0; i < smsReceiverList.size(); i++) {
telephoneArray[i] = "86" + smsReceiverList.get(i).getUserName();
}
int resValue = SMSUtils.sendSmsToUser(telephoneArray, "1425995", new String[]{firePoint.getFirePointAddress()});
String sendResult;
if (resValue == 0) {
//联系人列表发送短信成功在数据库中的已发短信数量字段加一
for (SysUserEntity smsReceiver : smsReceiverList) {
smsReceiver.setReceiveSmsCount(smsReceiver.getReceiveSmsCount() + 1);
}
sysUserDao.saveAll(smsReceiverList);
sendResult = "短信通知发送成功!";
} else {
sendResult = "短信通知发送失败!";
}
//记录短信通知日志
StringBuilder stringBuilder = new StringBuilder("发送人:青岛星科瑞升信息科技有限公司\n");
for (String telephone : telephoneArray) {
stringBuilder.append("接收人:").append(telephone).append("\n");
}
stringBuilder.append("模板参数:").append(firePoint.getFirePointAddress()).append("\n");
stringBuilder.append("超级详细的参数:").append(firePoint.toString()).append("\n");
stringBuilder.append(sendResult);
log.info(stringBuilder.toString());
}
}
// }
}
/**
@ -118,7 +118,7 @@ public class FirePointPushManager {
String countyName = firePoint.getCountyName();
String streetName = firePoint.getTownName();
String landType = firePoint.getLandType();
String messageContent = firePoint.getSatelliteType() + "发现1个火点。\n卫星时间" + satelliteTime + "\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName + "\nstreetName" + streetName + "\nlandType" + landType;
String messageContent = "星巡-秸秆焚烧卫星监测系统\n" + firePoint.getSatelliteType() + "发现1个火点。\n卫星时间" + satelliteTime + "\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName + "\nstreetName" + streetName + "\nlandType" + landType;
for (String weixinId : weixinIdList) {
stringBuilder.append(weixinId).append("\n");
try {

View File

@ -123,6 +123,15 @@ public class FirePointSubscribeManager {
private List<String> obtainCountyCodeList(List<SysUserEntity> sysUserEntityList) {
List<String> countyCodeList = new ArrayList<>();
for (SysUserEntity sysUserEntity : sysUserEntityList) {
if (sysUserEntity.getActiveFlag() != 0) {//被禁用的用户不计入订阅
continue;
}
if (sysUserEntity.getReceiveSms() != 1) {//关掉开关的用户不计入订阅
continue;
}
if ("管理员".equals(sysUserEntity.getAccountType())) {//管理员用户不计入订阅
continue;
}
boolean inVipTimeRange = VipTimeRangeUtils.checkIfInVipTimeRange(sysUserEntity.getVipTimeRangeJson());
if (inVipTimeRange) {
countyCodeList.add(sysUserEntity.getCountyCode());

View File

@ -2,10 +2,6 @@ package com.xkrs.service;
public interface FirePointService {
// String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response);
// String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids);
/**
* 查询火点播报无token
*

View File

@ -1,7 +1,7 @@
package com.xkrs.service;
import com.xkrs.model.qo.SysUserQo;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.qo.SysUserQo;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@ -51,14 +51,6 @@ public interface SysUserService {
*/
int updateSysUser(SysUserQo sysUserQo);
/**
* 软删除系统用户
*
* @param id
* @return
*/
int softDeleteGeneralUser(Long id);
/**
* 查询用户的信息
*
@ -109,15 +101,6 @@ public interface SysUserService {
*/
SysUserEntity getUserByUserName(String userName);
/**
* 修改账号到期时间
*
* @param userId
* @param overTime
* @return
*/
String updateOverTime(Long userId, String overTime);
/**
* 记录用户登录次数
*

View File

@ -1,18 +1,14 @@
package com.xkrs.service.impl;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.service.FirePointService;
import com.xkrs.dao.CountyCodeWeiXinDao;
import com.xkrs.dao.FirePointOrdinaryDao;
import com.xkrs.dao.StreetDao;
import com.xkrs.dao.SysUserDao;
import com.xkrs.helper.FirePointQueryManager;
import com.xkrs.model.bean.FirePointQueryResultBean;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.helper.PushHelper;
import com.xkrs.model.vo.AllFirePointVo;
import com.xkrs.service.StreetService;
import com.xkrs.service.FirePointService;
import com.xkrs.utilsnew.DateTimeUtils;
import com.xkrs.utilsnew.FirePointConvertUtils;
import com.xkrs.utilsnew.TokenUtil;
@ -34,9 +30,6 @@ import java.util.Locale;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* @author XinYi Song
*/
@CacheConfig(cacheNames = "FirePointServiceCache")
@Service
public class FirePointServiceImpl implements FirePointService {
@ -48,88 +41,12 @@ public class FirePointServiceImpl implements FirePointService {
@Resource
private SysUserDao sysUserDao;
@Resource
private StreetDao streetDao;
@Resource
private CountyCodeWeiXinDao countyCodeWeiXinDao;
@Resource
private StreetService streetService;
@Resource
private PushHelper pushHelper;
@Resource
private FirePointQueryManager firePointQueryManager;
@Resource
private FirePointOrdinaryDao firePointOrdinaryDao;
// /**
// * 下载VIP用户火点数据
// *
// *
// *
// @Query(value = "select a.really_name 姓名, a.county_name 所在市, a.telephone 手机号, a.vip_level vip, b.satellite_time 扫描时间, " + "round(cast(b.longitude as numeric) ,6) 经度, round(cast(b.latitude as numeric) ,6) 纬度, b.fire_point_address 详细地址 from sys_user a left join fire_point b on " + "case when left(a.county_code, 4) = '0000' then left(b.county_code, 4) = left(a.county_code, 4) " + "when left(a.county_code, 2) = '00' then left(b.county_code, 2) = left(a.county_code, 2) " + "else left(b.county_code, 2) = left(a.county_code, 2) end where a.vip_level > 0 and satellite_time > ?1", nativeQuery = true)
// List<Map<String, String>> downloadFirePointByVip(String yesterday);
//
// */
// @Override
// public String downloadVipUserFilePoint(HttpServletRequest request, HttpServletResponse response) {
// LocalDate now = LocalDate.now();
// List<Map<String, String>> list = firePointDao.downloadFirePointByVip(dateTimeToString(LocalDateTime.of(now.minusDays(1), LocalTime.MIN)));
// if (list.size() == 0) {
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
// }
// int year = now.getYear();
// int month = now.getMonth().getValue();
// int day = now.getDayOfMonth();
// String fileName = String.format("%s_%s_%s_VIP用户火点信息列表.xlsx", year, month, day);
// response.setContentType("application/octet-stream; charset=UTF8");
// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
// try {
// downloadXlsx(list, response.getOutputStream());
// } catch (IOException e) {
// log.error("download vip user's fire point fail: {}", e.getMessage());
// }
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
// }
// @Override
// public String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids) {
//
// List<String> idList = ListUtils.toStringList(ids, ",");
// if (idList.isEmpty()) {
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "无数据!", locale);
// }
// List<Map<String, String>> list = new ArrayList<>();
// List<FirePointEntity> sourceList = firePointDao.findAllById(ListUtils.stringListToLongList(idList));
// for (FirePointEntity source : sourceList) {
// Map<String, String> record = new HashMap<>();
// record.put("所在区县", source.getCountyName());
// record.put("所在街道", source.getStreetName());
// record.put("发现时间", source.getSatelliteTime());
// record.put("地物类型", source.getLandType());
// record.put("经度", String.valueOf(source.getLongitude()));
// record.put("纬度", String.valueOf(source.getLatitude()));
// record.put("详细地址", source.getFirePointAddress());
// list.add(record);
// }
// LocalDate now = LocalDate.now();
// String fileName = String.format("%s_%s_%s_火点信息列表.xlsx", now.getYear(), now.getMonth().getValue(), now.getDayOfMonth());
// response.setContentType("application/octet-stream; charset=UTF8");
// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8));
// response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
// try {
// downloadXlsx(list, response.getOutputStream());
// } catch (IOException e) {
// log.error("download fire point fail: {}", e.getMessage());
// }
// return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "ok", locale);
// }
/**
* 查询火点播报无token
*
@ -171,7 +88,6 @@ public class FirePointServiceImpl implements FirePointService {
/**
* 查询今天的火点信息
*/
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
@Override
public String selectTodayFirePoint(String token, String countyCode) {

View File

@ -1,18 +1,13 @@
package com.xkrs.service.impl;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.StreetDao;
import com.xkrs.model.entity.StreetEntity;
import com.xkrs.model.qo.SysUserQo;
import com.xkrs.service.RedisService;
import com.xkrs.dao.RelRoleAuthorityDao;
import com.xkrs.dao.RelUserRoleDao;
import com.xkrs.dao.SysRoleDao;
import com.xkrs.dao.SysUserDao;
import com.xkrs.dao.*;
import com.xkrs.model.entity.RelRoleAuthorityEntity;
import com.xkrs.model.entity.RelUserRoleEntity;
import com.xkrs.model.entity.SysRoleEntity;
import com.xkrs.model.entity.StreetEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.qo.SysUserQo;
import com.xkrs.service.RedisService;
import com.xkrs.service.SysUserService;
import com.xkrs.utilsnew.VipTimeRangeUtils;
import org.apache.http.util.TextUtils;
@ -32,8 +27,8 @@ import java.util.List;
import java.util.Locale;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
import static com.xkrs.utilsold.DateTimeUtil.dateTimeToString;
import static com.xkrs.utilsnew.EncryptDecryptUtil.encry256;
import static com.xkrs.utilsold.DateTimeUtil.dateTimeToString;
/**
* 系统用户服务实现
@ -211,25 +206,6 @@ public class SysUserServiceImpl implements SysUserService {
return 1;
}
/**
* 软删除普通用户
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int softDeleteGeneralUser(Long id) {
String adminRole = "role_administor";
String sysRole = "role_system_manager";
List<SysRoleEntity> list = sysRoleDao.selectByUserId(id);
if (list.size() > 0) {
SysRoleEntity sysRoleEntity = list.get(1);
if (sysRole.equals(sysRoleEntity.getRoleName()) || adminRole.equals(sysRoleEntity.getRoleName())) {
sysUserDao.softDeleteGeneralUserById(id);
return 0;
}
}
return 1;
}
/**
* 查询用户的信息
*/
@ -283,7 +259,7 @@ public class SysUserServiceImpl implements SysUserService {
if (!newPassword.equals(confirmPassword)) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale);
}
SysUserEntity sysUserEntity = sysUserDao.selectByUserId(userId);
SysUserEntity sysUserEntity = sysUserDao.findById(userId).get();
String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt());
sysUserDao.updatePassword(userId, newAfterPassword);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale);
@ -302,16 +278,6 @@ public class SysUserServiceImpl implements SysUserService {
return sysUserEntityList.get(0);
}
/**
* 修改账号到期时间
*/
@Transactional(rollbackFor = Exception.class)
@Override
public String updateOverTime(Long userId, String overTime) {
sysUserDao.updateOverTime(userId, overTime);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
/**
* 记录用户登录次数
*/

View File

@ -17,10 +17,10 @@ public class FirePointFilterUtils {
}
public static DataWrapper2<Boolean, String> checkLandType(String landType) {
if ("水体".equals(landType)) {
return new DataWrapper2<>(Boolean.FALSE, "添加失败,不接收水体类型");
if ("耕地".equals(landType)) {
return new DataWrapper2<>(Boolean.TRUE, "");
}
return new DataWrapper2<>(Boolean.TRUE, "");
return new DataWrapper2<>(Boolean.FALSE, "添加失败,只接收耕地类型的火点");
}
public static DataWrapper2<Boolean, String> checkSatelliteType(String satelliteType, String confidence) {

View File

@ -23,7 +23,7 @@ spring.datasource.hikari.validation-timeout = 3000
## Spring Data JPA 配置
spring.jpa.database = POSTGRESQL
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql = true
spring.jpa.show-sql = false
# 指定 ddl mode (none, validate, create, create-drop, update)
spring.jpa.hibernate.ddl-auto = update
# 命名策略