From 3d4f5c71eead6957392885acd757d24d471a4544 Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Thu, 22 Aug 2024 15:42:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=91=E6=8F=B4APP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/CommonErrorCodeConstants.java | 1 + dl-module-rescue/pom.xml | 25 +- .../SysAnnouncementController.java | 8 +- .../impl/SysAnnouncementServiceImpl.java | 4 +- .../controller/admin}/AnnouncementSocket.java | 2 +- .../admin/RescueInfoController.java | 253 +++++++ .../controller/admin/SysLoginController.java | 618 ++++++++++++++++++ .../admin}/UserAnnouncementSocket.java | 2 +- .../yudao/module/rescue/domain/LoginBody.java | 37 ++ .../rescue/mapper/RescueInfoMapper.java | 4 +- .../rescue/service/IRescueInfoService.java | 4 +- .../service/impl/RescueInfoServiceImpl.java | 597 +++++++++-------- .../mapper/rescue/RescueCarInfoMapper.xml | 12 - .../mapper/rescue/RescueInfoMapper.xml | 42 +- .../YudaoWebSecurityConfigurerAdapter.java | 1 + .../src/main/resources/application.yaml | 2 + 16 files changed, 1257 insertions(+), 355 deletions(-) rename dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/controller/{ => admin}/SysAnnouncementController.java (93%) rename dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/{controller/app => app/controller/admin}/AnnouncementSocket.java (98%) create mode 100644 dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java create mode 100644 dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java rename dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/{controller/app => app/controller/admin}/UserAnnouncementSocket.java (98%) create mode 100644 dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/LoginBody.java diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java index f35bdb37..a1712095 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/CommonErrorCodeConstants.java @@ -10,4 +10,5 @@ public interface CommonErrorCodeConstants extends ErrorCodeConstants { ErrorCode STAFF_CHANGE_CREATE_REPEAT = new ErrorCode(2_002_000_001, "该员工工作已交接"); ErrorCode STAFF_NOT_CHANGE = new ErrorCode(2_002_000_003, "该员工还有工作未交接,不可删除"); ErrorCode LOGIN_ACCOUNT_EXIST = new ErrorCode(2_002_000_004, "登录账号已存在"); + ErrorCode LOGIN_ACCOUNT_NOT_EXIST = new ErrorCode(2_002_000_005, "登录账号不存在"); } diff --git a/dl-module-rescue/pom.xml b/dl-module-rescue/pom.xml index 8a6d2aa1..a49ff772 100644 --- a/dl-module-rescue/pom.xml +++ b/dl-module-rescue/pom.xml @@ -11,16 +11,21 @@ dl-module-rescue - - cn.iocoder.boot - dl-module-base - ${revision} - - - cn.iocoder.boot - dl-module-company - ${revision} - + + cn.iocoder.boot + dl-module-base + ${revision} + + + cn.iocoder.boot + dl-module-company + ${revision} + + + cn.iocoder.boot + yudao-module-system-biz + ${revision} + 8 diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/controller/SysAnnouncementController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/controller/admin/SysAnnouncementController.java similarity index 93% rename from dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/controller/SysAnnouncementController.java rename to dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/controller/admin/SysAnnouncementController.java index 9938e6d8..d3ee7be3 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/controller/SysAnnouncementController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/controller/admin/SysAnnouncementController.java @@ -1,5 +1,6 @@ -package cn.iocoder.yudao.module.appBase.controller; +package cn.iocoder.yudao.module.appBase.controller.admin; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.rescue.core.controller.BaseController; import cn.iocoder.yudao.module.rescue.core.page.TableDataInfo; import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -117,7 +118,7 @@ public class SysAnnouncementController extends BaseController public CommonResult getOwnNoRead() { //当前登录用户 - LoginUser loginUser = getLoginUser(); + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); SysAnnouncement sysAnnouncement =new SysAnnouncement(); sysAnnouncement.setToUserId(loginUser.getId()); LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); @@ -132,7 +133,8 @@ public class SysAnnouncementController extends BaseController public CommonResult setAllRead() { //当前登录用户 - LoginUser loginUser = getLoginUser(); +// LoginUser loginUser = getLoginUser(); + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); SysAnnouncement sysAnnouncement =new SysAnnouncement(); sysAnnouncement.setToUserId(loginUser.getId()); LambdaUpdateWrapper queryWrapper =new LambdaUpdateWrapper<>(); diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/service/impl/SysAnnouncementServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/service/impl/SysAnnouncementServiceImpl.java index f8572f1f..77fa4794 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/service/impl/SysAnnouncementServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/appBase/service/impl/SysAnnouncementServiceImpl.java @@ -7,8 +7,8 @@ import cn.hutool.http.HttpRequest; import cn.iocoder.yudao.module.appBase.domain.SysAnnouncement; import cn.iocoder.yudao.module.appBase.mapper.SysAnnouncementMapper; import cn.iocoder.yudao.module.appBase.service.ISysAnnouncementService; -import cn.iocoder.yudao.module.rescue.controller.app.AnnouncementSocket; -import cn.iocoder.yudao.module.rescue.controller.app.UserAnnouncementSocket; +import cn.iocoder.yudao.module.rescue.app.controller.admin.AnnouncementSocket; +import cn.iocoder.yudao.module.rescue.app.controller.admin.UserAnnouncementSocket; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/app/AnnouncementSocket.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/AnnouncementSocket.java similarity index 98% rename from dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/app/AnnouncementSocket.java rename to dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/AnnouncementSocket.java index aee1e776..d2dbdf9b 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/app/AnnouncementSocket.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/AnnouncementSocket.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.rescue.controller.app; +package cn.iocoder.yudao.module.rescue.app.controller.admin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java new file mode 100644 index 00000000..b9f09745 --- /dev/null +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/RescueInfoController.java @@ -0,0 +1,253 @@ +package cn.iocoder.yudao.module.rescue.app.controller.admin; + +import cn.hutool.core.collection.CollectionUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.rescue.core.controller.BaseController; +import cn.iocoder.yudao.module.rescue.domain.RescueInfo; +import cn.iocoder.yudao.module.rescue.service.IRescueInfoService; +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; +import cn.iocoder.yudao.module.system.api.permission.RoleApi; +import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 【请填写功能名称】Controller + * + * @author ruoyi + * @date 2023-07-14 + */ +@RestController +@RequestMapping("/app/rescueInfo") +public class RescueInfoController extends BaseController { + + @Resource + private AdminUserApi userService; + + @Resource + private RoleApi roleApi; + + @Resource + private PermissionApi permissionApi; + @Resource + private IRescueInfoService rescueInfoService; + +// @Autowired +// private ISysUserService userService; +// +// +// + + /** + * 获取救援订单 + */ + @GetMapping("/getRescueList") + public CommonResult getRescueList(RescueInfo rescueInfo, + @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNum, pageSize); + //获取当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + AdminUserRespDTO user = userService.getUser(loginUser.getId()); + List roleIds = permissionApi.getRoleIdsByUserId(user.getId()); + List roleList = roleApi.getRoleList(); + List roles = roleList.stream().filter(item -> roleIds.contains(item.getId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(roles)) { + for (RoleReqDTO role : roles) { + //如果是调度中心 + if (role.getCode().equals("admin") || role.getCode().equals("ddzx") || role.getCode().equals("qt") || role.getCode().equals("kj") || role.getCode().equals("cn")) { + IPage rescueInfos = rescueInfoService.selectRescueInfoListByAdmin(rescueInfo, page); + return success(rescueInfos); + } + } + } + + IPage rescueInfos = rescueInfoService.selectRescueInfoList(rescueInfo, page); + return success(rescueInfos); + } +// @GetMapping("/getRescueStatistics") +// public AjaxResult getRescueStatistics(RescueInfo rescueInfo) +// { +// +// //获取当前登录用户 +// LoginUser loginUser = SecurityUtils.getLoginUser(); +// SysUser user = userService.selectUserById(loginUser.getUserId()); +// List roles = user.getRoles(); +// if (CollectionUtil.isNotEmpty(roles)){ +// for (SysRole role : roles) { +// //如果是调度中心 +// if (role.getRoleKey().equals("admin")||role.getRoleKey().equals("ddzx")||role.getRoleKey().equals("qt")||role.getRoleKey().equals("kj")||role.getRoleKey().equals("cn")){ +// Map res = rescueInfoService.getRescueStatisticsByAdmin(rescueInfo); +// return success(res); +// } +// } +// } +// +// Map res = rescueInfoService.getRescueStatistics(rescueInfo); +// return success(res); +// } +// /** +// * 获取救援订单 +// */ +// @GetMapping("/rescueInfoDetail") +// public AjaxResult rescueInfoDetail(Long rescueId) +// { +// return success(rescueInfoService.rescueInfoDetail(rescueId)); +// } +// +// /** +// * 新增【道路救援发起】 +// */ +// @Log(title = "【道路救援发起】", businessType = BusinessType.INSERT) +// @PostMapping("/add") +// public AjaxResult add(@RequestBody @Valid RescueInfo rescueInfo) +// { +// rescueInfoService.insertRescueInfo(rescueInfo); +// return success(); +// } +// +// /** +// * 新增【道路救援发起】 +// */ +// @Log(title = "【道路救援编辑】", businessType = BusinessType.UPDATE) +// @PostMapping("/edit") +// public AjaxResult edit(@RequestBody @Valid RescueInfo rescueInfo) +// { +// rescueInfoService.updateRescueInfo(rescueInfo); +// return success(); +// } +// /** +// * 取消【道路救援】 +// */ +// @Log(title = "取消【道路救援】", businessType = BusinessType.CLEAN) +// @PostMapping("/cancel") +// public AjaxResult cancel(Long id) +// { +// RescueInfo rescueInfo =new RescueInfo(); +// rescueInfo.setId(id); +// rescueInfo.setRescueStatus("0"); +// return toAjax(rescueInfoService.updateRescueInfo(rescueInfo)); +// } +// +// /** +// * 删除道路救援 +// */ +// @Log(title = "删除道路救援", businessType = BusinessType.DELETE) +// @PostMapping("/delRescueInfo") +// public AjaxResult delRescueInfo(Long id) +// { +// rescueInfoService.deleteRescueInfoById(id); +// return success(); +// } +// +// /** +// * 查询【请填写功能名称】列表 +// */ +// @GetMapping("/driverList") +// public TableDataInfo driverList(DriverInfoDto driverInfoDto) +// { +// startPage(); +// List list = rescueInfoService.driverListApp(driverInfoDto); +// return getDataTable(list); +// } +// /** +// * 查询【请填写功能名称】列表 +// */ +// @GetMapping("/driverInMap") +// public AjaxResult driverInMap(DriverInfoDto driverInfoDto) +// { +// List driverList = rescueInfoService.driverInMap(driverInfoDto); +// return success(driverList); +// } +// /** +// * 查询【请填写功能名称】列表 +// */ +// @GetMapping("/driverInMap2") +// public AjaxResult driverInMap2() +// { +// return success(rescueInfoService.driverInMap2()); +// } +// /** +// * 获取扣车订单 +// */ +// @GetMapping("/getKcList") +// public TableDataInfo getKcList(RescueInfo rescueInfo) +// { +// +// startPage(); +// List rescueInfos = rescueInfoService.getKcList(rescueInfo); +// return getDataTable(rescueInfos); +// } +// +// /** +// * 获取扣车订单 +// */ +// @PostMapping("/openKc") +// public AjaxResult openKc(Long rescueId) throws Exception { +// //获取当前登录用户 +// LoginUser loginUser = SecurityUtils.getLoginUser(); +// SysUser user = userService.selectUserById(loginUser.getUserId()); +// List roles = user.getRoles(); +// if (CollectionUtil.isNotEmpty(roles)){ +// for (SysRole role : roles) { +// //如果是交警大队 +// if (role.getRoleKey().equals("jjdd")){ +// rescueInfoService.openKc(rescueId); +// } +// } +// } +// +// return success(); +// } +// +// /** +// * 进行还车 +// */ +// @PostMapping("/hcOpen") +// public AjaxResult hcOpen(Long rescueId) +// { +// //获取当前登录用户 +// LoginUser loginUser = SecurityUtils.getLoginUser(); +// SysUser user = userService.selectUserById(loginUser.getUserId()); +// RescueInfo rescueInfo = rescueInfoService.getById(rescueId); +// rescueInfo.setHcTime(new Date()); +// rescueInfo.setHcUserId(user.getUserId()); +// rescueInfo.setHcUserName(user.getRealName()); +// rescueInfo.setHcUserPhone(user.getPhonenumber()); +// rescueInfo.setRescueStatus("8"); +// rescueInfoService.updateById(rescueInfo); +// return success(); +// } +// +// /** +// * 获取扣车订单 +// */ +// @GetMapping("/getHcList") +// public TableDataInfo getHcList(RescueInfo rescueInfo) +// { +// +// startPage(); +// List rescueInfos = rescueInfoService.getHcList(rescueInfo); +// return getDataTable(rescueInfos); +// } +// /** +// * 获取扣车订单 +// */ +// @GetMapping("/statisticsInfo") +// public AjaxResult statisticsInfo(String type) +// { +// return success( rescueInfoService.statisticsInfo(type)); +// } +} diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java new file mode 100644 index 00000000..5269d747 --- /dev/null +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java @@ -0,0 +1,618 @@ +package cn.iocoder.yudao.module.rescue.app.controller.admin; + +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.common.CommonErrorCodeConstants; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.rescue.domain.LoginBody; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; +import cn.iocoder.yudao.module.system.api.permission.RoleApi; +import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; +import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; +import cn.iocoder.yudao.module.system.service.permission.MenuService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * 登录验证 + * + * @author ruoyi + */ +@RestController +@Slf4j +@RequestMapping("/rescue") +public class SysLoginController { + @Resource + private AdminAuthService loginService; + + @Resource + private MenuService menuService; + // +// @Autowired +// private SysPermissionService permissionService; + @Resource + private AdminUserApi userService; + + @Resource + private PermissionApi permissionApi; + + + @Resource + private RoleApi roleApi; + + @Resource + private DictDataApi dataApi; + +// @Resource +// @Autowired +// private RedisCache redisCache; +// +// @Autowired +// private RestTemplate restTemplate; +// +// @Resource +// private WechatPayConfig wxConfig; +// @Autowired +// private IUserBalanceService balanceService; +// @Autowired +// private IShopMallPartnersService partnersService; +// @Autowired +// private IPartnerWorkerService jcWorkerService; +// @Autowired +// private IShopConfigService configService; +// @Autowired +// private IDriverInfoService driverInfoService; +// @Autowired +// private IDriveSchoolInfoService driveSchoolInfoService; +// + + /** + * 登录方法 + * + * @param loginBody 登录信息 + * @return 结果 + */ + @PostMapping("/login") + public CommonResult login(@RequestBody LoginBody loginBody) { + return null; +// ajax = success(); +// // 生成令牌 +// String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), +// loginBody.getUuid()); +// ajax.put(Constants.TOKEN, token); +// return ajax; + } + + @GetMapping("/dict/data/type/{type}") + public CommonResult getDictDataByType(@PathVariable("type") String type){ + return success(dataApi.getDictDataList(type)); + } + + /** + * 登录方法 + * + * @param loginBody 登录信息 + * @return 结果 + */ + @PostMapping("/loginApp") + public CommonResult loginApp(@RequestBody LoginBody loginBody) throws Exception { + String userName = loginBody.getUsername(); + AdminUserRespDTO user = userService.getUserByUsername(userName); + if (ObjectUtil.isEmpty(user)) { + return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST); + } + // 获取登录用户的角色信息 + List roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId()); + if (ObjectUtil.isEmpty(roleIdsByUserId) || roleIdsByUserId.size() == 0) { + return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST); + } + List roleList = roleApi.getRoleList(); + List roleNames = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).map(item -> item.getName()).collect(Collectors.toList()); + Boolean flag = (loginBody.getType().equals("0") && roleNames.contains("救援业务管理员")) || (loginBody.getType().equals("1") && roleNames.contains("交警")); + // 角色认证登录 + if (!flag) { + return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST); + } + AuthLoginReqVO authLoginReqVO = new AuthLoginReqVO(); + authLoginReqVO.setUsername(loginBody.getUsername()); + authLoginReqVO.setPassword(loginBody.getPassword()); + return success(loginService.login(authLoginReqVO)); + } +// /** +// * 司机登录方法 +// * +// * @param loginBody 司机登录方法 +// * @return 结果 +// */ +// @PostMapping("/driverLogin") +// public AjaxResult driverLogin(@RequestBody LoginBody loginBody) throws Exception { +// AjaxResult ajax = success(); +// // 生成令牌 +// String token = loginService.driverLogin(loginBody); +// ajax.put(Constants.TOKEN, token); +// return ajax; +// } +// /** +// * 登录获取验证码 +// * +// * @return 结果 +// */ +// @PostMapping("/loginSmsCode") +// public AjaxResult loginSmsCode(String phone) { +// return loginService.loginSmsCode(phone); +// } +// /** +// * 登录方法 +// * +// * @param loginBody 登录信息 +// * @return 结果 +// */ +// @PostMapping("/loginJx") +// public AjaxResult loginJx(@RequestBody LoginBody loginBody) throws Exception { +// AjaxResult ajax = success(); +// // 生成令牌 +// String token = loginService.loginJx(loginBody); +// ajax.put(Constants.TOKEN, token); +// return ajax; +// } +// @PostMapping("/loginSmsCodeJx") +// public AjaxResult loginSmsCodeJx(String phone) { +// return loginService.loginSmsCodeJx(phone); +// } +// /** +// * 忘记密码获取验证码 +// * +// * @return 结果 +// */ +// @PostMapping("/pwdSmsCode") +// public AjaxResult pwdSmsCode(String phone) { +// return loginService.pwdSmsCode(phone); +// } +// /** +// * 更新密码 +// * +// * @return 结果 +// */ +// @PostMapping("/updatePwd") +// public AjaxResult updatePwd(String phone, String msgCode,String password) { +// if (!redisCache.hasKey(phone+"-pwdCode")||!redisCache.getCacheObject(phone+"-pwdCode").equals(msgCode)){ +// return error("验证码错误"); +// } +// SysUser sysUser = userService.selectUserByPhone(phone); +// if (userService.resetUserPwd(sysUser.getUserName(), SecurityUtils.encryptPassword(password)) > 0) +// { +// // 更新缓存用户密码 +// sysUser.setPassword(SecurityUtils.encryptPassword(password)); +// userService.updateUser(sysUser); +// return success(); +// } +// return error("修改密码异常,请联系管理员"); +// } +// +// +// + + /** + * 获取用户信息 + * + * @return 用户信息 + */ + @GetMapping("/getInfo") + public CommonResult getInfo() { + HashMap map = new HashMap<>(); + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + map.put("user", loginUser); + // 角色集合 + List roleIdsByUserId = permissionApi.getRoleIdsByUserId(loginUser.getId()); + List roleList = roleApi.getRoleList(); + List roleNames = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).map(item -> item.getName()).collect(Collectors.toList()); + map.put("roles", roleNames); + // 权限集合 + List menuList = menuService.getMenuList(); +// Set permissions = permissionService.getMenuPermission(user); +// ajax.put("permissions", permissions); + return success(map); + } +// +// +// @Resource +// private DriveSchoolCoachMapper driveSchoolCoachMapper; +// +// @Resource +// private SysUserMapper sysUserMapper; +// +// /** +// * 获取 +// * +// * @return 用户信息 +// */ +// @GetMapping("getJxInfo") +// public AjaxResult getJxInfo() +// { +// SysUser user = SecurityUtils.getLoginUser().getUser(); +// // 角色集合 +// Set roles = permissionService.getRolePermission(user); +// //获取驾校的 +// +// Long userId = SecurityUtils.getUserId(); +// SysUser sysUser = sysUserMapper.selectUserById(userId); +// String phonenumber = sysUser.getPhonenumber(); +// DriveSchoolCoach driveSchoolCoach = driveSchoolCoachMapper.selectByPhonenumber(phonenumber); +// +// if (ObjectUtils.isNotEmpty(driveSchoolCoach)){ +// user.setAvatar(driveSchoolCoach.getImage()); +// } +// DriveSchoolInfo driveSchoolInfo = driveSchoolInfoService.getSchoolInfoByDeptId(); +// +// AjaxResult ajax = success(); +// ajax.put("user", user); +// ajax.put("roles", roles); +// ajax.put("schoolInfo", driveSchoolInfo); +// return ajax; +// } +// /** +// * 获取App用户信息 +// * +// * @return 用户信息 +// */ +// @GetMapping("/getAppInfo") +// public AjaxResult getAppInfo() +// { +// SysUser user = SecurityUtils.getLoginUser().getUser(); +// SysUser sysUser = userService.selectUserById(user.getUserId()); +// // 角色集合 +// Set roles = permissionService.getRolePermission(user); +// UserBalance userBalance = balanceService.selectShopUserBalanceByUserId(user.getUserId()); +// if (ObjectUtil.isNotEmpty(userBalance)) { +// sysUser.setBalance(userBalance.getBalance()); +// } else { +// //新增用户积分表信息 +// userBalance=new UserBalance(); +// userBalance.setUserId(user.getUserId()); +// userBalance.setAllBalance(0L); +// userBalance.setBalance(0L); +// userBalance.setFrozenBalance(0L); +// balanceService.insertShopUserBalance(userBalance); +// sysUser.setBalance(0L); +// } +// AjaxResult ajax = success(); +// ajax.put("user", sysUser); +// ajax.put("role", roles); +// ShopConfig shopConfig = configService.selectShopConfigById(1L); +// if (StringUtils.isEmpty(shopConfig.getOpenRz())||shopConfig.getOpenRz().equals("0")){ +// ajax.put("openRz", "0"); +// }else { +// ajax.put("openRz", "1"); +// } +// return ajax; +// } +// +// /** +// * 获取App用户信息 +// * +// * @return 用户信息 +// */ +// @GetMapping("/getJcgfInfo") +// public AjaxResult getJcgfInfo() throws Exception { +// SysUser user = SecurityUtils.getLoginUser().getUser(); +// SysUser sysUser = userService.selectUserById(user.getUserId()); +// // 角色集合 +// Set roles = permissionService.getRolePermission(user); +// AjaxResult ajax = success(); +// ajax.put("user", sysUser); +// ajax.put("role", roles); +// if (CollectionUtil.isNotEmpty(roles)){ +// AtomicBoolean flag = new AtomicBoolean(false); +// roles.forEach(it->{ +// if (it.equals("jcgf")){ +// flag.set(true); +// } +// }); +// if (!flag.get()){ +// throw new Exception("身份有误"); +// } +// }else { +// throw new Exception("身份有误"); +// } +// +// return ajax; +// } +// //获取交警的信息 +// @GetMapping("/getJjInfo") +// public AjaxResult getJjInfo() throws Exception { +// SysUser user = SecurityUtils.getLoginUser().getUser(); +// SysUser sysUser = userService.selectUserById(user.getUserId()); +// // 角色集合 +// Set roles = permissionService.getRolePermission(user); +// AjaxResult ajax = success(); +// ajax.put("user", sysUser); +// ajax.put("role", roles); +// if (CollectionUtil.isNotEmpty(roles)){ +// AtomicBoolean flag = new AtomicBoolean(false); +// roles.forEach(it->{ +// if (it.equals("jjdd")){ +// flag.set(true); +// } +// }); +// if (!flag.get()){ +// throw new Exception("身份有误"); +// } +// }else { +// throw new Exception("身份有误"); +// } +// +// return ajax; +// } +// /** +// * 获取App用户信息 +// * +// * @return 用户信息 +// */ +// @GetMapping("/getJcPartnerInfo") +// public AjaxResult getJcPartnerInfo() +// { +// LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); +// SysUser user = SecurityUtils.getLoginUser().getUser(); +// queryWrapper.eq(ShopMallPartners::getUserId,user.getUserId()).eq(ShopMallPartners::getType,"jc").eq(ShopMallPartners::getIsBanned,"0"); +// ShopMallPartners partner = partnersService.getOne(queryWrapper); +// if (ObjectUtil.isEmpty(partner)){ +// return error("信息有误"); +// } +// SysUser sysUser = userService.selectUserById(user.getUserId()); +// AjaxResult ajax = success(); +// ajax.put("user", sysUser); +// return ajax; +// } +// +// /** +// * 获取救援司机用户信息 +// * +// * @return 用户信息 +// */ +// @GetMapping("/getRescueDriverInfo") +// public AjaxResult getRescueDriverInfo() +// { +// LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); +// SysUser user = SecurityUtils.getLoginUser().getUser(); +// queryWrapper.eq(DriverInfo::getUserId, user.getUserId()); +// DriverInfo driverInfo = driverInfoService.getOne(queryWrapper); +// if (ObjectUtil.isEmpty(driverInfo)){ +// return error("信息有误"); +// } +// SysUser sysUser = userService.selectUserById(user.getUserId()); +// AjaxResult ajax = success(); +// ajax.put("user", sysUser); +// ajax.put("driverInfo", driverInfo); +// return ajax; +// } +// +// +// /** +// * 获取检测工用户信息 +// * +// * @return 用户信息 +// */ +// @GetMapping("/getJcWorkerInfo") +// public AjaxResult getJcWorkerInfo() +// { +// AjaxResult ajax = success(); +// LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); +// SysUser user = SecurityUtils.getLoginUser().getUser(); +// queryWrapper.eq(PartnerWorker::getUserId,user.getUserId()); +// PartnerWorker worker = jcWorkerService.getOne(queryWrapper); +// if (ObjectUtil.isNotEmpty(worker)){ +// LambdaQueryWrapper queryWrapper1 =new LambdaQueryWrapper<>(); +// queryWrapper1.eq(ShopMallPartners::getPartnerId,worker.getPartnerId()).eq(ShopMallPartners::getType,"jc").eq(ShopMallPartners::getIsBanned,"0"); +// ShopMallPartners partner = partnersService.getOne(queryWrapper1); +// if (ObjectUtil.isEmpty(partner)){ +// return error("信息有误"); +// } +// ajax.put("partnerInfo", partner); +// }else { +// return error("信息有误"); +// } +// SysUser sysUser = userService.selectUserById(user.getUserId()); +// +// ajax.put("user", sysUser); +// +// return ajax; +// } +// /** +// * 获取路由信息 +// * +// * @return 路由信息 +// */ +// @GetMapping("getRouters") +// public AjaxResult getRouters() +// { +// Long userId = SecurityUtils.getUserId(); +// List menus = menuService.selectMenuTreeByUserId(userId); +// return AjaxResult.success(menuService.buildMenus(menus)); +// } +// @ApiOperation("微信登录") +// +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "WxLoginBody",dataType = "WxLoginBody", value = "jscode", required = true, paramType = "body") +// }) +// @PostMapping("/wxLogin") +// public AjaxResult wxLogin(@RequestBody WxLoginBody wxLoginBody) { +// String code = wxLoginBody.getCode(); +// //秘钥 +// String encryptedIv = wxLoginBody.getEncryptedIv(); +// //加密数据 +// String encryptedData = wxLoginBody.getEncryptedData(); +// +// +// //想微信服务器发送请求获取用户信息 +// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code"; +// System.out.println(url); +// String res = restTemplate.getForObject(url, String.class); +// JSONObject jsonObject = JSONObject.parseObject(res); +// +// //获取session_key和openid +// String sessionKey = jsonObject.getString("session_key"); +// String openId = jsonObject.getString("openid"); +// +// System.out.println(sessionKey); +// System.out.println(openId); +// //解密 +// String decryptResult = ""; +// try { +// //如果没有绑定微信开放平台,解析结果是没有unionid的。 +// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData); +// } catch (Exception e) { +// e.printStackTrace(); +// return AjaxResult.error("微信登录失败!"); +// } +// +// if (StringUtils.hasText(decryptResult)) { +// //如果解析成功,获取token +// String token = loginService.wxLogin(decryptResult,openId,wxLoginBody.getInviteId()); +// AjaxResult ajax = AjaxResult.success(); +// ajax.put(Constants.TOKEN, token); +// return ajax; +// } else { +// return AjaxResult.error("微信登录失败!"); +// } +// } +// +// @PostMapping("/wxLoginJc") +// public AjaxResult wxLoginJc(@RequestBody WxLoginBody wxLoginBody) { +// String code = wxLoginBody.getCode(); +// //秘钥 +// String encryptedIv = wxLoginBody.getEncryptedIv(); +// //加密数据 +// String encryptedData = wxLoginBody.getEncryptedData(); +// +// //想微信服务器发送请求获取用户信息 +// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code"; +// System.out.println(url); +// String res = restTemplate.getForObject(url, String.class); +// JSONObject jsonObject = JSONObject.parseObject(res); +// +// //获取session_key和openid +// String sessionKey = jsonObject.getString("session_key"); +// String openId = jsonObject.getString("openid"); +// +// System.out.println(sessionKey); +// System.out.println(openId); +// //解密 +// String decryptResult = ""; +// try { +// //如果没有绑定微信开放平台,解析结果是没有unionid的。 +// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData); +// } catch (Exception e) { +// e.printStackTrace(); +// return AjaxResult.error("微信登录失败!"); +// } +// +// if (StringUtils.hasText(decryptResult)) { +// //如果解析成功,获取token +// String token = loginService.wxLoginJc(decryptResult,openId,wxLoginBody.getInviteId()); +// AjaxResult ajax = AjaxResult.success(); +// ajax.put(Constants.TOKEN, token); +// return ajax; +// } else { +// return AjaxResult.error("微信登录失败!"); +// } +// } +// +// @PostMapping("/wxLoginRescue") +// public AjaxResult wxLoginRescue(@RequestBody WxLoginBody wxLoginBody) { +// String code = wxLoginBody.getCode(); +// //秘钥 +// String encryptedIv = wxLoginBody.getEncryptedIv(); +// //加密数据 +// String encryptedData = wxLoginBody.getEncryptedData(); +// +// +// //想微信服务器发送请求获取用户信息 +// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code"; +// System.out.println(url); +// String res = restTemplate.getForObject(url, String.class); +// JSONObject jsonObject = JSONObject.parseObject(res); +// +// //获取session_key和openid +// String sessionKey = jsonObject.getString("session_key"); +// String openId = jsonObject.getString("openid"); +// +// System.out.println(sessionKey); +// System.out.println(openId); +// //解密 +// String decryptResult = ""; +// try { +// //如果没有绑定微信开放平台,解析结果是没有unionid的。 +// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData); +// } catch (Exception e) { +// e.printStackTrace(); +// return AjaxResult.error("微信登录失败!"); +// } +// +// if (StringUtils.hasText(decryptResult)) { +// //如果解析成功,获取token +// String token = loginService.wxLoginRescue(decryptResult,openId,wxLoginBody.getInviteId()); +// AjaxResult ajax = AjaxResult.success(); +// ajax.put(Constants.TOKEN, token); +// return ajax; +// } else { +// return AjaxResult.error("微信登录失败!"); +// } +// } +// +// /** +// * AES解密 +// */ +// private String decrypt(String sessionKey,String encryptedIv,String encryptedData) throws Exception{ +// // 转化为字节数组 +// byte[] key = Base64.decode(sessionKey); +// byte[] iv = Base64.decode(encryptedIv); +// byte[] encData = Base64.decode(encryptedData); +// // 如果密钥不足16位,那么就补足 +// int base =16; +// if (key.length % base !=0) { +// int groups = key.length / base +(key.length % base != 0 ? 1 : 0); +// byte[] temp = new byte[groups * base]; +// Arrays.fill(temp,(byte) 0); +// System.arraycopy(key,0,temp,0,key.length); +// key = temp; +// } +// // 如果初始向量不足16位,也补足 +// if (iv.length % base !=0) { +// int groups = iv.length / base +(iv.length % base != 0 ? 1 : 0); +// byte[] temp = new byte[groups * base]; +// Arrays.fill(temp,(byte) 0); +// System.arraycopy(iv,0,temp,0,iv.length); +// iv = temp; +// } +// +// AlgorithmParameterSpec ivSpec = new IvParameterSpec(iv); +// String resultStr = null; +// +// try { +// Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); +// SecretKeySpec keySpec = new SecretKeySpec(key,"AES"); +// cipher.init(Cipher.DECRYPT_MODE,keySpec,ivSpec); +// resultStr = new String(cipher.doFinal(encData),"UTF-8"); +// } catch (Exception e){ +//// logger.info("解析错误"); +// e.printStackTrace(); +// } +// +// // 解析加密后的字符串 +// return resultStr; +// } +} diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/app/UserAnnouncementSocket.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/UserAnnouncementSocket.java similarity index 98% rename from dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/app/UserAnnouncementSocket.java rename to dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/UserAnnouncementSocket.java index 1e9209c0..a2b5bc32 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/controller/app/UserAnnouncementSocket.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/UserAnnouncementSocket.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.rescue.controller.app; +package cn.iocoder.yudao.module.rescue.app.controller.admin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/LoginBody.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/LoginBody.java new file mode 100644 index 00000000..624f1236 --- /dev/null +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/domain/LoginBody.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.rescue.domain; + +import lombok.Data; + +/** + * 用户登录对象 + * + * @author ruoyi + */ +@Data +public class LoginBody +{ + /** + * 用户名 + */ + private String username; + + /** + * 用户密码 + */ + private String password; + + /** + * 验证码 + */ + private String code; + + /** + * 唯一标识 + */ + private String uuid; + //0账号密码登录,1手机号登录 2:管理 3:教练 + private String type; + private String types; + private String phone; + private String realName; +} diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueInfoMapper.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueInfoMapper.java index 54296248..575115b8 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueInfoMapper.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/mapper/RescueInfoMapper.java @@ -32,7 +32,7 @@ public interface RescueInfoMapper extends BaseMapper * @param rescueInfo 【请填写功能名称】 * @return 【请填写功能名称】集合 */ - public List selectRescueInfoList(RescueInfo rescueInfo); + IPage selectRescueInfoList(@Param("map") RescueInfo rescueInfo, Page page); IPage selectRescueListSystem2(@Param("map") RescueInfo rescueInfo, Page page); JSONObject listData(RescueInfo rescueInfo); @@ -42,7 +42,7 @@ public interface RescueInfoMapper extends BaseMapper * @param rescueInfo 【请填写功能名称】 * @return 【请填写功能名称】集合 */ - public List selectRescueInfoListApp(RescueInfo rescueInfo); + IPage selectRescueInfoListApp(@Param("map") RescueInfo rescueInfo, Page page); List getKcList(RescueInfo rescueInfo); diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java index bd7f7f5c..bd511097 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/IRescueInfoService.java @@ -38,13 +38,13 @@ public interface IRescueInfoService extends IService * @param rescueInfo 【请填写功能名称】 * @return 【请填写功能名称】集合 */ - public List selectRescueInfoList(RescueInfo rescueInfo); + IPage selectRescueInfoList(RescueInfo rescueInfo, Page page); List getKcList(RescueInfo rescueInfo); List getHcList(RescueInfo rescueInfo); void openKc(Long rescueId) throws Exception; - public List selectRescueInfoListByAdmin(RescueInfo rescueInfo); + IPage selectRescueInfoListByAdmin(RescueInfo rescueInfo, Page page); JSONObject rescueInfoDetail(Long rescueId); List selectRescueListSystem(RescueInfo rescueInfo); IPage selectRescueListSystem2(RescueInfo rescueInfo, Page page); diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java index 371a929d..cd3bea53 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/service/impl/RescueInfoServiceImpl.java @@ -26,6 +26,7 @@ import cn.iocoder.yudao.module.rescue.vo.MoneyManagement; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -57,8 +58,7 @@ import static cn.iocoder.yudao.module.rescue.utils.DistanceUtil.getDistanceMeter * @date 2023-07-14 */ @Service -public class RescueInfoServiceImpl extends ServiceImpl implements IRescueInfoService -{ +public class RescueInfoServiceImpl extends ServiceImpl implements IRescueInfoService { @Resource private AdminUserApi userService; @Resource @@ -94,7 +94,6 @@ public class RescueInfoServiceImpl extends ServiceImpl selectRescueInfoList(RescueInfo rescueInfo) - { + public IPage selectRescueInfoList(RescueInfo rescueInfo, Page page) { LoginUser user = getLoginUser(); //当前用户创建的 rescueInfo.setUserId(user.getId()); AdminUserRespDTO user1 = userService.getUser(user.getId()); //当前用户手机号的 rescueInfo.setConnectionPhone(user1.getMobile()); - List rescueInfos = baseMapper.selectRescueInfoListApp(rescueInfo); + IPage rescueInfos = baseMapper.selectRescueInfoListApp(rescueInfo, page); - for (RescueInfo info : rescueInfos) { + for (RescueInfo info : rescueInfos.getRecords()) { String dljy_type = dictDataService.getDictDataLabel("dljy_type", info.getRescueType()); info.setRescueTypeStr(dljy_type); String rescueStatus = dictDataService.getDictDataLabel("jy_status", info.getRescueStatus()); info.setRescueStatusStr(rescueStatus); //获取当前司机的经纬度 - if (ObjectUtils.isNotEmpty(info.getDriverId())){ - String driverKey = Redis_Driver_Key+info.getDeptId()+":"+info.getDriverId(); - if (redisCache.hasKey(driverKey)){ + if (ObjectUtils.isNotEmpty(info.getDriverId())) { + String driverKey = Redis_Driver_Key + info.getDeptId() + ":" + info.getDriverId(); + if (redisCache.hasKey(driverKey)) { JSONObject driverInfo = (JSONObject) JSONObject.parse(JSONObject.toJSONString(redisCache.getCacheMap(driverKey))); Double longitude = driverInfo.getDouble("longitude"); //纬度 Double latitude = driverInfo.getDouble("latitude"); - Long distanceMeter = getDistanceMeter(Double.parseDouble(info.getRescueLongitude()),Double.parseDouble(info.getRescueLatitude()), longitude, latitude); - info.setDistance(Double.valueOf(distanceMeter*1.3d).longValue()); - info.setNeedTime(5+ (distanceMeter / 1000)*2 +5); + Long distanceMeter = getDistanceMeter(Double.parseDouble(info.getRescueLongitude()), Double.parseDouble(info.getRescueLatitude()), longitude, latitude); + info.setDistance(Double.valueOf(distanceMeter * 1.3d).longValue()); + info.setNeedTime(5 + (distanceMeter / 1000) * 2 + 5); } } - - } return rescueInfos; } @@ -164,18 +159,18 @@ public class RescueInfoServiceImpl extends ServiceImpl wrapper =new LambdaUpdateWrapper<>(); - wrapper.eq(RescueInfo::getId,rescueId).set(RescueInfo::getRescueStatus,"6"); + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(RescueInfo::getId, rescueId).set(RescueInfo::getRescueStatus, "6"); this.update(wrapper); //增加详情 - detailService.save(new RescueInfoDetail(rescueId,"0","解扣通知","解扣通知")); + detailService.save(new RescueInfoDetail(rescueId, "0", "解扣通知", "解扣通知")); //进行websocket通知 //获取当前客户所在的调度中心 - List deptIds =new ArrayList<>(); + List deptIds = new ArrayList<>(); deptIds.add(sysDept.getId().toString()); for (String s : sysDept.getAncestors().split(",")) { deptIds.add(s); @@ -183,127 +178,126 @@ public class RescueInfoServiceImpl extends ServiceImpl ddzxUsers = userService.getUsersByRoleRescue("ddzx", null, deptIds); //消息通知 - SysAnnouncement sysAnnouncement =new SysAnnouncement(); - sysAnnouncement.setType("解扣通知"); - sysAnnouncement.setToUserIds(ddzxUsers.stream().map(AdminUserRespDTO::getId).collect(Collectors.toList())); - sysAnnouncement.setTitle("解扣通知"); - sysAnnouncement.setContent("车牌号为:"+rescueInfo.getLicenseNum()+",已经下发解扣通知"); - announcementService.insertSysAnnouncements2(sysAnnouncement); + SysAnnouncement sysAnnouncement = new SysAnnouncement(); + sysAnnouncement.setType("解扣通知"); + sysAnnouncement.setToUserIds(ddzxUsers.stream().map(AdminUserRespDTO::getId).collect(Collectors.toList())); + sysAnnouncement.setTitle("解扣通知"); + sysAnnouncement.setContent("车牌号为:" + rescueInfo.getLicenseNum() + ",已经下发解扣通知"); + announcementService.insertSysAnnouncements2(sysAnnouncement); - List qtUsers = userService.getUsersByRoleRescue("qt", null,deptIds); + List qtUsers = userService.getUsersByRoleRescue("qt", null, deptIds); //消息通知 - SysAnnouncement sysAnnouncement2 =new SysAnnouncement(); + SysAnnouncement sysAnnouncement2 = new SysAnnouncement(); sysAnnouncement2.setType("解扣通知"); sysAnnouncement2.setToUserIds(qtUsers.stream().map(AdminUserRespDTO::getId).collect(Collectors.toList())); sysAnnouncement2.setTitle("解扣通知"); - sysAnnouncement2.setContent("车牌号为:"+rescueInfo.getLicenseNum()+",已经下发解扣通知"); + sysAnnouncement2.setContent("车牌号为:" + rescueInfo.getLicenseNum() + ",已经下发解扣通知"); announcementService.insertSysAnnouncements2(sysAnnouncement2); - List kjUsers = userService.getUsersByRoleRescue("kj", null,deptIds); + List kjUsers = userService.getUsersByRoleRescue("kj", null, deptIds); //消息通知 - SysAnnouncement sysAnnouncement3 =new SysAnnouncement(); + SysAnnouncement sysAnnouncement3 = new SysAnnouncement(); sysAnnouncement3.setType("解扣通知"); sysAnnouncement3.setToUserIds(kjUsers.stream().map(AdminUserRespDTO::getId).collect(Collectors.toList())); sysAnnouncement3.setTitle("解扣通知"); - sysAnnouncement3.setContent("车牌号为:"+rescueInfo.getLicenseNum()+",已经下发解扣通知"); + sysAnnouncement3.setContent("车牌号为:" + rescueInfo.getLicenseNum() + ",已经下发解扣通知"); announcementService.insertSysAnnouncements2(sysAnnouncement3); - List cnUsers = userService.getUsersByRoleRescue("cn", null,deptIds); + List cnUsers = userService.getUsersByRoleRescue("cn", null, deptIds); //消息通知 - SysAnnouncement sysAnnouncement4 =new SysAnnouncement(); + SysAnnouncement sysAnnouncement4 = new SysAnnouncement(); sysAnnouncement4.setType("解扣通知"); sysAnnouncement4.setToUserIds(cnUsers.stream().map(AdminUserRespDTO::getId).collect(Collectors.toList())); sysAnnouncement4.setTitle("解扣通知"); - sysAnnouncement4.setContent("车牌号为:"+rescueInfo.getLicenseNum()+",已经下发解扣通知"); + sysAnnouncement4.setContent("车牌号为:" + rescueInfo.getLicenseNum() + ",已经下发解扣通知"); announcementService.insertSysAnnouncements2(sysAnnouncement4); } @Override - public List selectRescueInfoListByAdmin(RescueInfo rescueInfo) - { + public IPage selectRescueInfoListByAdmin(RescueInfo rescueInfo, Page page) { LoginUser user = getLoginUser(); - List rescueInfos = baseMapper.selectRescueInfoList(rescueInfo); + IPage rescueInfos = baseMapper.selectRescueInfoList(rescueInfo, page); - for (RescueInfo info : rescueInfos) { - String dljy_type = dictDataService.getDictDataLabel("dljy_type", info.getRescueType()); - info.setRescueTypeStr(dljy_type); - String rescueStatus = dictDataService.getDictDataLabel("jy_status", info.getRescueStatus()); - info.setRescueStatusStr(rescueStatus); - //获取当前司机的经纬度 - if (ObjectUtils.isNotEmpty(info.getDriverId())){ - //所在顶级机构 - - String driverKey = Redis_Driver_Key+user.getTenantId()+":"+info.getDriverId(); - if (redisCache.hasKey(driverKey)){ - try { - JSONObject driverInfo = (JSONObject) JSONObject.parse(JSONObject.toJSONString(redisCache.getCacheMap(driverKey))); - Double longitude = driverInfo.getDouble("longitude"); - //纬度 - Double latitude = driverInfo.getDouble("latitude"); - Long distanceMeter = getDistanceMeter(Double.parseDouble(info.getRescueLongitude()),Double.parseDouble(info.getRescueLatitude()), longitude, latitude); - info.setDistance(Double.valueOf(distanceMeter*1.3d).longValue()); - info.setNeedTime(5+ (distanceMeter / 1000)*2 +5); - }catch (Exception ignored){ - - } - - } - } - - - } +// for (RescueInfo info : rescueInfos) { +// String dljy_type = dictDataService.getDictDataLabel("dljy_type", info.getRescueType()); +// info.setRescueTypeStr(dljy_type); +// String rescueStatus = dictDataService.getDictDataLabel("jy_status", info.getRescueStatus()); +// info.setRescueStatusStr(rescueStatus); +// //获取当前司机的经纬度 +// if (ObjectUtils.isNotEmpty(info.getDriverId())) { +// //所在顶级机构 +// +// String driverKey = Redis_Driver_Key + user.getTenantId() + ":" + info.getDriverId(); +// if (redisCache.hasKey(driverKey)) { +// try { +// JSONObject driverInfo = (JSONObject) JSONObject.parse(JSONObject.toJSONString(redisCache.getCacheMap(driverKey))); +// Double longitude = driverInfo.getDouble("longitude"); +// //纬度 +// Double latitude = driverInfo.getDouble("latitude"); +// Long distanceMeter = getDistanceMeter(Double.parseDouble(info.getRescueLongitude()), Double.parseDouble(info.getRescueLatitude()), longitude, latitude); +// info.setDistance(Double.valueOf(distanceMeter * 1.3d).longValue()); +// info.setNeedTime(5 + (distanceMeter / 1000) * 2 + 5); +// } catch (Exception ignored) { +// +// } +// +// } +// } +// +// +// } return rescueInfos; } + @Override public JSONObject rescueInfoDetail(Long rescueId) { - JSONObject res =new JSONObject(); + JSONObject res = new JSONObject(); RescueInfo rescueInfo = this.getById(rescueId); - LambdaQueryWrapper queryWrapperOrder =new LambdaQueryWrapper<>(); - queryWrapperOrder.eq(RescueOrderInfo::getRescueInfoId,rescueId).last("limit 1"); + LambdaQueryWrapper queryWrapperOrder = new LambdaQueryWrapper<>(); + queryWrapperOrder.eq(RescueOrderInfo::getRescueInfoId, rescueId).last("limit 1"); RescueOrderInfo rescueOrderInfo = rescueOrderInfoService.getOne(queryWrapperOrder); - if (ObjectUtils.isNotEmpty(rescueOrderInfo)){ + if (ObjectUtils.isNotEmpty(rescueOrderInfo)) { rescueInfo.setOrderStatus(rescueOrderInfo.getOrderStatus()); rescueInfo.setCommentDesc(rescueOrderInfo.getCommentDesc()); rescueInfo.setCommentStar(rescueOrderInfo.getCommentStar()); - }else { + } else { rescueInfo.setOrderStatus("0"); } - res.put("rescueInfo",rescueInfo); + res.put("rescueInfo", rescueInfo); //查询司机信息 - if (ObjectUtils.isNotEmpty(rescueInfo.getDriverId())){ + if (ObjectUtils.isNotEmpty(rescueInfo.getDriverId())) { DriverInfo driverInfo = driverInfoService.getById(rescueInfo.getDriverId()); AdminUserRespDTO sysUser = userService.getUser(driverInfo.getUserId()); driverInfo.setNickName(sysUser.getNickname()); driverInfo.setRealName(sysUser.getNickname()); driverInfo.setUserName(sysUser.getNickname()); driverInfo.setAvatar(sysUser.getAvatar()); - res.put("driverInfo",driverInfo); + res.put("driverInfo", driverInfo); //查询司机当前所在经纬度 - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueDriverPosition::getRescueInfoId,rescueId).eq(RescueDriverPosition::getDriverId,rescueInfo.getDriverId()) - .orderByDesc(TenantBaseDO::getCreateTime).last("limit 1"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueDriverPosition::getRescueInfoId, rescueId).eq(RescueDriverPosition::getDriverId, rescueInfo.getDriverId()) + .orderByDesc(TenantBaseDO::getCreateTime).last("limit 1"); RescueDriverPosition position = positionService.getOne(queryWrapper); - res.put("driverPosition",position); - res.put("setMoney",ObjectUtils.isEmpty(rescueOrderInfo.getSetMoney())?"":rescueOrderInfo.getSetMoney()); - }else { - res.put("driverInfo",""); - res.put("driverPosition",""); - res.put("setMoney",""); + res.put("driverPosition", position); + res.put("setMoney", ObjectUtils.isEmpty(rescueOrderInfo.getSetMoney()) ? "" : rescueOrderInfo.getSetMoney()); + } else { + res.put("driverInfo", ""); + res.put("driverPosition", ""); + res.put("setMoney", ""); } //救援详细信息 - LambdaQueryWrapper queryWrapper3 =new LambdaQueryWrapper<>(); - queryWrapper3.eq(RescueInfoDetail::getRescueInfoId,rescueId).orderByAsc(TenantBaseDO::getCreateTime); + LambdaQueryWrapper queryWrapper3 = new LambdaQueryWrapper<>(); + queryWrapper3.eq(RescueInfoDetail::getRescueInfoId, rescueId).orderByAsc(TenantBaseDO::getCreateTime); List details = detailService.list(queryWrapper3); - res.put("detail",details); + res.put("detail", details); return res; } @Override - public List selectRescueListSystem(RescueInfo rescueInfo) - { - - return baseMapper.selectRescueInfoList(rescueInfo); + public List selectRescueListSystem(RescueInfo rescueInfo) { + + return baseMapper.selectList(new QueryWrapper<>()); } @Override @@ -318,7 +312,7 @@ public class RescueInfoServiceImpl extends ServiceImpl queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueDriverInfo::getDriverId,driverId).eq(RescueDriverInfo::getRescueId,rescueId) - .eq(RescueDriverInfo::getDriverAccept,"2").last("limit 1"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueDriverInfo::getDriverId, driverId).eq(RescueDriverInfo::getRescueId, rescueId) + .eq(RescueDriverInfo::getDriverAccept, "2").last("limit 1"); RescueDriverInfo driverInfo = rescueDriverInfoService.getOne(queryWrapper); - if (!ObjectUtils.isEmpty(driverInfo)){ + if (!ObjectUtils.isEmpty(driverInfo)) { throw new Exception("已指派,请勿重复指派"); } - RescueDriverInfo rescueDriverInfo =new RescueDriverInfo(); + RescueDriverInfo rescueDriverInfo = new RescueDriverInfo(); rescueDriverInfo.setDriverId(driverId); rescueDriverInfo.setRescueId(rescueId); rescueDriverInfo.setDriverAccept("2"); @@ -356,7 +350,7 @@ public class RescueInfoServiceImpl extends ServiceImpl { // //自动派单 @@ -408,9 +401,8 @@ public class RescueInfoServiceImpl extends ServiceImpl0){ + public int updateRescueInfo(RescueInfo rescueInfo) { + if (rescueInfo.getRescueStatus().compareTo("9") > 0) { rescueInfo.setRescueStatus(null); } return baseMapper.updateById(rescueInfo); @@ -423,8 +415,7 @@ public class RescueInfoServiceImpl extends ServiceImpl driverList(DriverInfoDto driverInfo, Page page) { IPage driverInfos = baseMapper.driverList(driverInfo, page); for (DriverInfo info : driverInfos.getRecords()) { - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueCarInfo::getCarOwn,"1").eq(RescueCarInfo::getPossessorId,info.getId()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueCarInfo::getCarOwn, "1").eq(RescueCarInfo::getPossessorId, info.getId()); List list = carInfoService.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { info.setCarInfoList(list); - }else { + } else { info.setCarInfoList(new ArrayList<>()); } @@ -478,20 +468,20 @@ public class RescueInfoServiceImpl extends ServiceImpl queryWrapperD =new LambdaQueryWrapper<>(); - queryWrapperD.eq(DriverInfo::getPhonenumber,driverInfoDto.getPhonenumber()); + LambdaQueryWrapper queryWrapperD = new LambdaQueryWrapper<>(); + queryWrapperD.eq(DriverInfo::getPhonenumber, driverInfoDto.getPhonenumber()); List list = driverInfoService.list(queryWrapperD); - if (!CollectionUtil.isEmpty(list)){ - throw new Exception("该手机号已绑定司机,请不要重复添加"); + if (!CollectionUtil.isEmpty(list)) { + throw new Exception("该手机号已绑定司机,请不要重复添加"); } AdminUserRespDTO sysUser = userService.getUserByMobile(driverInfoDto.getPhonenumber()); driverInfoDto.setAuthStatus("2"); - if (!ObjectUtils.isEmpty(sysUser)){ - DriverInfo driverInfoQuery =new DriverInfo(); + if (!ObjectUtils.isEmpty(sysUser)) { + DriverInfo driverInfoQuery = new DriverInfo(); driverInfoQuery.setUserId(sysUser.getId()); List driverInfos = driverInfoService.selectDriverInfoList(driverInfoQuery); - if (CollectionUtil.isEmpty(driverInfos)){ - UserDTO newUser =new UserDTO(); + if (CollectionUtil.isEmpty(driverInfos)) { + UserDTO newUser = new UserDTO(); newUser.setNickname(driverInfoDto.getRealName()); newUser.setSex(driverInfoDto.getSex()); newUser.setAvatar(driverInfoDto.getAvatar()); @@ -502,9 +492,9 @@ public class RescueInfoServiceImpl extends ServiceImpl queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueCarInfo::getRescueCarNum,rescueCarNum); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueCarInfo::getRescueCarNum, rescueCarNum); RescueCarInfo one = carInfoService.getOne(queryWrapper); - if (ObjectUtils.isNotEmpty(one)){ + if (ObjectUtils.isNotEmpty(one)) { rescueCarInfo.setCarOwn("1"); rescueCarInfo.setPossessorId(driverInfoDto.getId()); rescueCarInfo.setId(one.getId()); carInfoService.updateById(rescueCarInfo); - }else { + } else { rescueCarInfo.setCarOwn("1"); rescueCarInfo.setPossessorId(driverInfoDto.getId()); carInfoService.save(rescueCarInfo); @@ -548,22 +538,22 @@ public class RescueInfoServiceImpl extends ServiceImpl queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(RescueCarInfo::getPossessorId,driverInfoDto.getId()).eq(RescueCarInfo::getCarOwn,"1"); + LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(RescueCarInfo::getPossessorId, driverInfoDto.getId()).eq(RescueCarInfo::getCarOwn, "1"); carInfoService.remove(queryWrapper1); //处理车辆信息 - if (!CollectionUtil.isEmpty(driverInfoDto.getCarInfoList())){ + if (!CollectionUtil.isEmpty(driverInfoDto.getCarInfoList())) { for (RescueCarInfo rescueCarInfo : driverInfoDto.getCarInfoList()) { String rescueCarNum = rescueCarInfo.getRescueCarNum(); - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueCarInfo::getRescueCarNum,rescueCarNum); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueCarInfo::getRescueCarNum, rescueCarNum); RescueCarInfo one = carInfoService.getOne(queryWrapper); - if (ObjectUtils.isNotEmpty(one)){ + if (ObjectUtils.isNotEmpty(one)) { rescueCarInfo.setCarOwn("1"); rescueCarInfo.setPossessorId(driverInfoDto.getId()); rescueCarInfo.setId(one.getId()); carInfoService.updateById(rescueCarInfo); - }else { + } else { rescueCarInfo.setCarOwn("1"); rescueCarInfo.setPossessorId(driverInfoDto.getId()); carInfoService.save(rescueCarInfo); @@ -581,8 +571,8 @@ public class RescueInfoServiceImpl extends ServiceImpl queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(RescueCarInfo::getPossessorId,id).eq(RescueCarInfo::getCarOwn,"1"); + LambdaQueryWrapper queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(RescueCarInfo::getPossessorId, id).eq(RescueCarInfo::getCarOwn, "1"); carInfoService.remove(queryWrapper1); } } @@ -596,18 +586,19 @@ public class RescueInfoServiceImpl extends ServiceImpl cacheMap = redisCache.getCacheMap(redisKey2); dto.setDriverLatitude(cacheMap.get("latitude").toString()); dto.setDriverLongitude(cacheMap.get("longitude").toString()); dto.setDriverPositionInfo(cacheMap.get("positionInfo").toString()); dto.setDriverStatus(cacheMap.get("status").toString()); - }else { + } else { dto.setDriverStatus("4"); } } return dtos; } + //获取司机在地图上的位置分布 @Override public List driverInMap(DriverInfoDto driverInfoDto) { @@ -616,27 +607,27 @@ public class RescueInfoServiceImpl extends ServiceImpl dtos = baseMapper.driverListApp(driverInfoDto); //处理其余信息 //获取司机所在经纬度 - int i =1; + int i = 1; for (DriverInfo2Dto dto : dtos) { String redisKey2 = Redis_Driver_Key + loginUser.getTenantId() + ":" + dto.getId(); - if (redisCache.hasKey(redisKey2)){ + if (redisCache.hasKey(redisKey2)) { try { Map cacheMap = redisCache.getCacheMap(redisKey2); dto.setDriverLatitude(cacheMap.get("latitude").toString()); dto.setDriverLongitude(cacheMap.get("longitude").toString()); dto.setDriverPositionInfo(cacheMap.get("positionInfo").toString()); dto.setDriverStatus(cacheMap.get("status").toString()); - }catch (Exception ignored){ + } catch (Exception ignored) { } - }else { + } else { dto.setDriverStatus("4"); } - dto.setCarImage("https://www.nuoyunr.com/lananRsc/rescue/car"+i+".png"); - if (i>=4){ - i=1; - }else { + dto.setCarImage("https://www.nuoyunr.com/lananRsc/rescue/car" + i + ".png"); + if (i >= 4) { + i = 1; + } else { i++; } } @@ -656,16 +647,16 @@ public class RescueInfoServiceImpl extends ServiceImpl userIds = new ArrayList<>(); //给下一级 进行分配 for (RescueInfo rescueInfo : overTimeRescue) { - if (StringUtils.isEmpty(rescueInfo.getDriverLevel()) ) continue; - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueDeptDriver::getDeptId,rescueInfo.getId()); + if (StringUtils.isEmpty(rescueInfo.getDriverLevel())) continue; + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueDeptDriver::getDeptId, rescueInfo.getId()); RescueDeptDriver rescueDeptDriver = deptDriverService.getOne(queryWrapper); - if (rescueInfo.getDriverLevel().equals("1")){ - if (StringUtils.isNotEmpty(rescueDeptDriver.getFirstDriverIds())){ + if (rescueInfo.getDriverLevel().equals("1")) { + if (StringUtils.isNotEmpty(rescueDeptDriver.getFirstDriverIds())) { String[] driverIds = rescueDeptDriver.getSecondDriverIds().split(","); for (String driverId : driverIds) { //此时找到了合适的司机进行任务的指派 - RescueDriverInfo rescueDriverInfo =new RescueDriverInfo(); + RescueDriverInfo rescueDriverInfo = new RescueDriverInfo(); rescueDriverInfo.setDriverId(Long.parseLong(driverId)); rescueDriverInfo.setRescueId(rescueInfo.getId()); rescueDriverInfo.setDriverAccept("2"); @@ -676,12 +667,12 @@ public class RescueInfoServiceImpl extends ServiceImpl cacheMap = redisCache.getCacheMap(redisKey); - List cacheList =new ArrayList<>(); + List cacheList = new ArrayList<>(); cacheMap.forEach((key, value) -> cacheList.add(value)); - if (!CollectionUtil.isEmpty(cacheList)){ + if (!CollectionUtil.isEmpty(cacheList)) { //获取之前拒绝过得司机 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueDriverInfo::getRescueId,rescueId).eq(RescueDriverInfo::getDriverAccept,"0"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueDriverInfo::getRescueId, rescueId).eq(RescueDriverInfo::getDriverAccept, "0"); List rejectDrivers = rescueDriverInfoService.list(queryWrapper); - List rejectDriverIds =new ArrayList<>(); - if (!CollectionUtil.isEmpty(rejectDrivers)){ - rejectDriverIds = rejectDrivers.stream().map(RescueDriverInfo::getDriverId).collect(Collectors.toList()); + List rejectDriverIds = new ArrayList<>(); + if (!CollectionUtil.isEmpty(rejectDrivers)) { + rejectDriverIds = rejectDrivers.stream().map(RescueDriverInfo::getDriverId).collect(Collectors.toList()); } //如果存在司机 - List driverList = JSONArray.parseArray(JSONArray.toJSONString(cacheList),JSONObject.class); + List driverList = JSONArray.parseArray(JSONArray.toJSONString(cacheList), JSONObject.class); List finalRejectDriverIds = rejectDriverIds; - driverList = driverList.stream().filter(it->{ + driverList = driverList.stream().filter(it -> { boolean flag = true; - String driverKey = Redis_Driver_Key+deptId+":"+it.getString("driverId"); - if (!redisCache.hasKey(driverKey)){ + String driverKey = Redis_Driver_Key + deptId + ":" + it.getString("driverId"); + if (!redisCache.hasKey(driverKey)) { return false; } JSONObject driverInfo = (JSONObject) JSONObject.parse(JSONObject.toJSONString(redisCache.getCacheMap(driverKey))); //判断司机是否在线且空闲 - flag= driverInfo.getInteger("status")==1; - if (finalRejectDriverIds.contains(Long.parseLong(it.getString("driverId")))){ - flag =false; + flag = driverInfo.getInteger("status") == 1; + if (finalRejectDriverIds.contains(Long.parseLong(it.getString("driverId")))) { + flag = false; } return flag; - }).sorted((o1,o2)->{ + }).sorted((o1, o2) -> { //经度 Double longitudeO1 = o1.getDouble("longitude"); //纬度 @@ -745,24 +736,24 @@ public class RescueInfoServiceImpl extends ServiceImpldistance1?1:0; + Double distance2 = getDistance(longitudeO2, latitudeO2, Double.parseDouble(longitude), Double.parseDouble(latitude)); + return distance2 > distance1 ? 1 : 0; }).collect(Collectors.toList()); - if (!CollectionUtil.isEmpty(driverList)){ + if (!CollectionUtil.isEmpty(driverList)) { JSONObject selectDriver = driverList.get(0); //此时找到了合适的司机进行任务的指派 - RescueDriverInfo rescueDriverInfo =new RescueDriverInfo(); + RescueDriverInfo rescueDriverInfo = new RescueDriverInfo(); rescueDriverInfo.setDriverId(selectDriver.getLong("driverId")); rescueDriverInfo.setRescueId(rescueId); rescueDriverInfo.setDriverAccept("2"); rescueDriverInfoService.insertRescueDriverInfo(rescueDriverInfo); } } - detailService.save(new RescueInfoDetail(rescueId,"0","等待司机响应","等待司机响应")); + detailService.save(new RescueInfoDetail(rescueId, "0", "等待司机响应", "等待司机响应")); } @Override @@ -773,13 +764,13 @@ public class RescueInfoServiceImpl extends ServiceImpl res =baseMapper.getRescueStatistics(rescueInfo); + Map res = baseMapper.getRescueStatistics(rescueInfo); return res; } @Override public Map getRescueStatisticsByAdmin(RescueInfo rescueInfo) { - Map res =baseMapper.getRescueStatisticsByAdmin(rescueInfo); + Map res = baseMapper.getRescueStatisticsByAdmin(rescueInfo); return res; } @@ -787,43 +778,43 @@ public class RescueInfoServiceImpl extends ServiceImpl queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueDriverPosition::getRescueInfoId,rescueId).orderByAsc(TenantBaseDO::getCreateTime); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueDriverPosition::getRescueInfoId, rescueId).orderByAsc(TenantBaseDO::getCreateTime); List list = positionService.list(queryWrapper); - double totalDistance =0d; - if (CollectionUtil.isNotEmpty(list)&&list.size()>1){ - List latitudes = list.stream().map(it->{ + double totalDistance = 0d; + if (CollectionUtil.isNotEmpty(list) && list.size() > 1) { + List latitudes = list.stream().map(it -> { return Double.parseDouble(it.getLatitude()); }).collect(Collectors.toList()); - List longitudes = list.stream().map(it->{ + List longitudes = list.stream().map(it -> { return Double.parseDouble(it.getLongitude()); }).collect(Collectors.toList()); - totalDistance= calculateTotalDistance(latitudes, longitudes); + totalDistance = calculateTotalDistance(latitudes, longitudes); } - rescueInfo.setRescueDistance(totalDistance*1.5d); + rescueInfo.setRescueDistance(totalDistance * 1.5d); this.updateById(rescueInfo); } //指派司机 - public void appointDriverByBusiness(Long deptId,Long rescueId){ + public void appointDriverByBusiness(Long deptId, Long rescueId) { //根据部门主键获取 第一梯队的司机 - RescueDeptDriver rescueDeptDriver =new RescueDeptDriver(); + RescueDeptDriver rescueDeptDriver = new RescueDeptDriver(); rescueDeptDriver.setDeptId(deptId); List rescueDeptDrivers = deptDriverService.selectRescueDeptDriverList(rescueDeptDriver); - if (CollectionUtil.isEmpty(rescueDeptDrivers)||StringUtils.isEmpty(rescueDeptDrivers.get(0).getFirstDriverIds())){ + if (CollectionUtil.isEmpty(rescueDeptDrivers) || StringUtils.isEmpty(rescueDeptDrivers.get(0).getFirstDriverIds())) { return; } String[] driverIds = rescueDeptDrivers.get(0).getFirstDriverIds().split(","); - List userIds =new ArrayList<>(); + List userIds = new ArrayList<>(); for (String driverId : driverIds) { //此时找到了合适的司机进行任务的指派 - RescueDriverInfo rescueDriverInfo =new RescueDriverInfo(); + RescueDriverInfo rescueDriverInfo = new RescueDriverInfo(); rescueDriverInfo.setDriverId(Long.parseLong(driverId)); rescueDriverInfo.setRescueId(rescueId); rescueDriverInfo.setDriverAccept("2"); @@ -833,84 +824,87 @@ public class RescueInfoServiceImpl extends ServiceImpl getRescueInfoByDriver(RescueInfo rescueInfo){ - return baseMapper.getRescueInfoByDriver(rescueInfo); + + public List getRescueInfoByDriver(RescueInfo rescueInfo) { + return baseMapper.getRescueInfoByDriver(rescueInfo); } - public List moneyManagement2(List rescueInfos, String rescueStart){ - List resList =new ArrayList<>(); + + public List moneyManagement2(List rescueInfos, String rescueStart) { + List resList = new ArrayList<>(); Double rescueTcBig = 0d; Double rescueTcMid = 0d; Double rescueTcSmall = 0d; RescueConfig rescueConfig = rescueConfigService.selectRescueConfigByDeptId(); - if (ObjectUtils.isNotEmpty(rescueConfig)){ + if (ObjectUtils.isNotEmpty(rescueConfig)) { rescueTcBig = Optional.ofNullable(rescueConfig.getRescueTcBig()).orElse(0d); rescueTcMid = Optional.ofNullable(rescueConfig.getRescueTcMid()).orElse(0d); rescueTcSmall = Optional.ofNullable(rescueConfig.getRescueTcSmall()).orElse(0d); } for (RescueInfo info : rescueInfos) { - MoneyManagement moneyManagement =new MoneyManagement(); + MoneyManagement moneyManagement = new MoneyManagement(); moneyManagement.setDriverName(info.getDriverName()); - Double grossWages =0d; - Double tempSetMoney= ObjectUtils.isNotEmpty(info.getSetMoney())?Double.valueOf(info.getSetMoney())/100d:0d; - Double tempCheckpointMoney= ObjectUtils.isNotEmpty(info.getCheckpointMoney())? info.getCheckpointMoney():0d; - JSONObject monthRescueRefuelRecord =new JSONObject(); - monthRescueRefuelRecord.put("refuelMoney",0); - monthRescueRefuelRecord.put("refuelNum",0); - monthRescueRefuelRecord.put("refuelDistance",0); + Double grossWages = 0d; + Double tempSetMoney = ObjectUtils.isNotEmpty(info.getSetMoney()) ? Double.valueOf(info.getSetMoney()) / 100d : 0d; + Double tempCheckpointMoney = ObjectUtils.isNotEmpty(info.getCheckpointMoney()) ? info.getCheckpointMoney() : 0d; + JSONObject monthRescueRefuelRecord = new JSONObject(); + monthRescueRefuelRecord.put("refuelMoney", 0); + monthRescueRefuelRecord.put("refuelNum", 0); + monthRescueRefuelRecord.put("refuelDistance", 0); try { - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueCarInfo::getRescueCarNum,info.getDriverCarNum()).last("limit 1"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueCarInfo::getRescueCarNum, info.getDriverCarNum()).last("limit 1"); RescueCarInfo carInfo = carInfoService.getOne(queryWrapper); monthRescueRefuelRecord = refuelRecordService.getMonthRescueRefuelRecord(info.getDriverId(), DateUtil.format(info.getRescueTime(), "yyyy-MM"), carInfo.getId()); - }catch (Exception ignored){} + } catch (Exception ignored) { + } moneyManagement.setLicenseNum(info.getLicenseNum()); moneyManagement.setFeeType(info.getFeeType()); moneyManagement.setRescueTime(info.getRescueTime()); moneyManagement.setDiverCarNum(info.getDriverCarNum()); moneyManagement.setSetMoney(tempSetMoney); moneyManagement.setCheckpointMoney(info.getCheckpointMoney()); - moneyManagement.setUpMoney(tempSetMoney-tempCheckpointMoney); + moneyManagement.setUpMoney(tempSetMoney - tempCheckpointMoney); moneyManagement.setEmptyingDistance(info.getEmptyNum()); String carType = "3"; - if (StringUtils.isNotEmpty(info.getDriverCarNum())){ + if (StringUtils.isNotEmpty(info.getDriverCarNum())) { RescueCarInfo carInfo = carInfoService.selectRescueCarInfoByNum(info.getDriverCarNum()); carType = carInfo.getRescueCarType(); } - if (carType.equals("1")){ + if (carType.equals("1")) { //大车 moneyManagement.setRoyaltyRatio(rescueTcBig); - moneyManagement.setRoyaltyMoney(tempSetMoney*rescueTcBig); - }else if (carType.equals("2")){ + moneyManagement.setRoyaltyMoney(tempSetMoney * rescueTcBig); + } else if (carType.equals("2")) { //中车 moneyManagement.setRoyaltyRatio(rescueTcMid); - moneyManagement.setRoyaltyMoney(tempSetMoney*rescueTcMid); - }else { + moneyManagement.setRoyaltyMoney(tempSetMoney * rescueTcMid); + } else { //小车 moneyManagement.setRoyaltyRatio(rescueTcSmall); - moneyManagement.setRoyaltyMoney(tempSetMoney*rescueTcSmall); + moneyManagement.setRoyaltyMoney(tempSetMoney * rescueTcSmall); } //获取当前车 当前驾驶员 这个月跑了几次 JSONObject driverInfoObj = baseMapper.getDriverCarNum(info.getDriverId(), info.getDriverCarNum(), rescueStart); //计算平均燃油费和平均油耗 Double avgFuelConsumption = 0d; - Double mglYh =0d; - if (driverInfoObj.getInteger("allNum")!=0){ - avgFuelConsumption = monthRescueRefuelRecord.getDouble("refuelMoney")/driverInfoObj.getInteger("allNum"); - mglYh=monthRescueRefuelRecord.getDouble("refuelNum")/ driverInfoObj.getDouble("allDistance"); + Double mglYh = 0d; + if (driverInfoObj.getInteger("allNum") != 0) { + avgFuelConsumption = monthRescueRefuelRecord.getDouble("refuelMoney") / driverInfoObj.getInteger("allNum"); + mglYh = monthRescueRefuelRecord.getDouble("refuelNum") / driverInfoObj.getDouble("allDistance"); } moneyManagement.setFuelCost(avgFuelConsumption); moneyManagement.setOilConsumption(mglYh); - Double oilSubsidy = Optional.ofNullable(info.getEmptyNum()).orElse(0d)*mglYh; + Double oilSubsidy = Optional.ofNullable(info.getEmptyNum()).orElse(0d) * mglYh; moneyManagement.setOilSubsidy(oilSubsidy); - grossWages = grossWages+moneyManagement.getRoyaltyMoney()+oilSubsidy-avgFuelConsumption; + grossWages = grossWages + moneyManagement.getRoyaltyMoney() + oilSubsidy - avgFuelConsumption; moneyManagement.setGrossWages(grossWages); resList.add(moneyManagement); } @@ -918,77 +912,78 @@ public class RescueInfoServiceImpl extends ServiceImpl moneyManagement(RescueInfo rescueInfo){ + public List moneyManagement(RescueInfo rescueInfo) { List rescueInfos = baseMapper.getRescueInfoByDriver(rescueInfo); - List resList =new ArrayList<>(); + List resList = new ArrayList<>(); Double rescueTcBig = 0d; Double rescueTcMid = 0d; Double rescueTcSmall = 0d; RescueConfig rescueConfig = rescueConfigService.selectRescueConfigByDeptId(); - if (ObjectUtils.isNotEmpty(rescueConfig)){ + if (ObjectUtils.isNotEmpty(rescueConfig)) { rescueTcBig = Optional.ofNullable(rescueConfig.getRescueTcBig()).orElse(0d); rescueTcMid = Optional.ofNullable(rescueConfig.getRescueTcMid()).orElse(0d); rescueTcSmall = Optional.ofNullable(rescueConfig.getRescueTcSmall()).orElse(0d); } - for (RescueInfo info : rescueInfos) { - MoneyManagement moneyManagement =new MoneyManagement(); - moneyManagement.setDriverName(info.getDriverName()); - Double grossWages =0d; - Double tempSetMoney= ObjectUtils.isNotEmpty(info.getSetMoney())?Double.valueOf(info.getSetMoney())/100d:0d; - Double tempCheckpointMoney= ObjectUtils.isNotEmpty(info.getCheckpointMoney())? info.getCheckpointMoney():0d; - JSONObject monthRescueRefuelRecord =new JSONObject(); - monthRescueRefuelRecord.put("refuelMoney",0); - monthRescueRefuelRecord.put("refuelNum",0); - monthRescueRefuelRecord.put("refuelDistance",0); - try { - LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(RescueCarInfo::getRescueCarNum,info.getDriverCarNum()).last("limit 1"); - RescueCarInfo carInfo = carInfoService.getOne(queryWrapper); - monthRescueRefuelRecord = refuelRecordService.getMonthRescueRefuelRecord(info.getDriverId(), DateUtil.format(info.getRescueTime(), "yyyy-MM"), carInfo.getId()); - }catch (Exception ignored){} - moneyManagement.setLicenseNum(info.getLicenseNum()); - moneyManagement.setFeeType(info.getFeeType()); - moneyManagement.setRescueTime(info.getRescueTime()); - moneyManagement.setDiverCarNum(info.getDriverCarNum()); - moneyManagement.setSetMoney(tempSetMoney); - moneyManagement.setCheckpointMoney(info.getCheckpointMoney()); - moneyManagement.setUpMoney(tempSetMoney-tempCheckpointMoney); - moneyManagement.setEmptyingDistance(info.getEmptyNum()); - String carType = "3"; - if (StringUtils.isNotEmpty(info.getDriverCarNum())){ - RescueCarInfo carInfo = carInfoService.selectRescueCarInfoByNum(info.getDriverCarNum()); - carType = carInfo.getRescueCarType(); - } - if (carType.equals("1")){ - //大车 - moneyManagement.setRoyaltyRatio(rescueTcBig); - moneyManagement.setRoyaltyMoney(tempSetMoney*rescueTcBig); - }else if (carType.equals("2")){ - //中车 - moneyManagement.setRoyaltyRatio(rescueTcMid); - moneyManagement.setRoyaltyMoney(tempSetMoney*rescueTcMid); - }else { - //小车 - moneyManagement.setRoyaltyRatio(rescueTcSmall); - moneyManagement.setRoyaltyMoney(tempSetMoney*rescueTcSmall); - } - //获取当前车 当前驾驶员 这个月跑了几次 - JSONObject driverInfoObj = baseMapper.getDriverCarNum(info.getDriverId(), info.getDriverCarNum(), rescueInfo.getRescueStart()); - //计算平均燃油费和平均油耗 - Double avgFuelConsumption = 0d; - Double mglYh =0d; - if (driverInfoObj.getInteger("allNum")!=0){ - avgFuelConsumption = monthRescueRefuelRecord.getDouble("refuelMoney")/driverInfoObj.getInteger("allNum"); - mglYh=monthRescueRefuelRecord.getDouble("refuelNum")/ driverInfoObj.getDouble("allDistance"); - } - moneyManagement.setFuelCost(avgFuelConsumption); - moneyManagement.setOilConsumption(mglYh); - Double oilSubsidy = Optional.ofNullable(info.getEmptyNum()).orElse(0d)*mglYh; - moneyManagement.setOilSubsidy(oilSubsidy); - grossWages = grossWages+moneyManagement.getRoyaltyMoney()+oilSubsidy-avgFuelConsumption; - moneyManagement.setGrossWages(grossWages); - resList.add(moneyManagement); + for (RescueInfo info : rescueInfos) { + MoneyManagement moneyManagement = new MoneyManagement(); + moneyManagement.setDriverName(info.getDriverName()); + Double grossWages = 0d; + Double tempSetMoney = ObjectUtils.isNotEmpty(info.getSetMoney()) ? Double.valueOf(info.getSetMoney()) / 100d : 0d; + Double tempCheckpointMoney = ObjectUtils.isNotEmpty(info.getCheckpointMoney()) ? info.getCheckpointMoney() : 0d; + JSONObject monthRescueRefuelRecord = new JSONObject(); + monthRescueRefuelRecord.put("refuelMoney", 0); + monthRescueRefuelRecord.put("refuelNum", 0); + monthRescueRefuelRecord.put("refuelDistance", 0); + try { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(RescueCarInfo::getRescueCarNum, info.getDriverCarNum()).last("limit 1"); + RescueCarInfo carInfo = carInfoService.getOne(queryWrapper); + monthRescueRefuelRecord = refuelRecordService.getMonthRescueRefuelRecord(info.getDriverId(), DateUtil.format(info.getRescueTime(), "yyyy-MM"), carInfo.getId()); + } catch (Exception ignored) { } + moneyManagement.setLicenseNum(info.getLicenseNum()); + moneyManagement.setFeeType(info.getFeeType()); + moneyManagement.setRescueTime(info.getRescueTime()); + moneyManagement.setDiverCarNum(info.getDriverCarNum()); + moneyManagement.setSetMoney(tempSetMoney); + moneyManagement.setCheckpointMoney(info.getCheckpointMoney()); + moneyManagement.setUpMoney(tempSetMoney - tempCheckpointMoney); + moneyManagement.setEmptyingDistance(info.getEmptyNum()); + String carType = "3"; + if (StringUtils.isNotEmpty(info.getDriverCarNum())) { + RescueCarInfo carInfo = carInfoService.selectRescueCarInfoByNum(info.getDriverCarNum()); + carType = carInfo.getRescueCarType(); + } + if (carType.equals("1")) { + //大车 + moneyManagement.setRoyaltyRatio(rescueTcBig); + moneyManagement.setRoyaltyMoney(tempSetMoney * rescueTcBig); + } else if (carType.equals("2")) { + //中车 + moneyManagement.setRoyaltyRatio(rescueTcMid); + moneyManagement.setRoyaltyMoney(tempSetMoney * rescueTcMid); + } else { + //小车 + moneyManagement.setRoyaltyRatio(rescueTcSmall); + moneyManagement.setRoyaltyMoney(tempSetMoney * rescueTcSmall); + } + //获取当前车 当前驾驶员 这个月跑了几次 + JSONObject driverInfoObj = baseMapper.getDriverCarNum(info.getDriverId(), info.getDriverCarNum(), rescueInfo.getRescueStart()); + //计算平均燃油费和平均油耗 + Double avgFuelConsumption = 0d; + Double mglYh = 0d; + if (driverInfoObj.getInteger("allNum") != 0) { + avgFuelConsumption = monthRescueRefuelRecord.getDouble("refuelMoney") / driverInfoObj.getInteger("allNum"); + mglYh = monthRescueRefuelRecord.getDouble("refuelNum") / driverInfoObj.getDouble("allDistance"); + } + moneyManagement.setFuelCost(avgFuelConsumption); + moneyManagement.setOilConsumption(mglYh); + Double oilSubsidy = Optional.ofNullable(info.getEmptyNum()).orElse(0d) * mglYh; + moneyManagement.setOilSubsidy(oilSubsidy); + grossWages = grossWages + moneyManagement.getRoyaltyMoney() + oilSubsidy - avgFuelConsumption; + moneyManagement.setGrossWages(grossWages); + resList.add(moneyManagement); + } return resList; } @@ -997,18 +992,18 @@ public class RescueInfoServiceImpl extends ServiceImpl statisticsInfo(String type) { //所在顶级机构 String startTime; - String endTime = DateUtil.format(new Date(),"yyyy-MM-dd")+" 24:00:00"; - if (type.equals("day")){ + String endTime = DateUtil.format(new Date(), "yyyy-MM-dd") + " 24:00:00"; + if (type.equals("day")) { //日 - startTime = DateUtil.format(new Date(),"yyyy-MM-dd")+" 00:00:00"; - }else if (type.equals("week")){ + startTime = DateUtil.format(new Date(), "yyyy-MM-dd") + " 00:00:00"; + } else if (type.equals("week")) { //周 - startTime = DateUtil.format(DateUtil.beginOfWeek(new Date()),"yyyy-MM-dd")+" 00:00:00"; - }else { + startTime = DateUtil.format(DateUtil.beginOfWeek(new Date()), "yyyy-MM-dd") + " 00:00:00"; + } else { //月 - startTime = DateUtil.format(DateUtil.beginOfMonth(new Date()),"yyyy-MM-dd")+" 00:00:00"; + startTime = DateUtil.format(DateUtil.beginOfMonth(new Date()), "yyyy-MM-dd") + " 00:00:00"; } - return baseMapper.statisticsInfo(startTime,endTime); + return baseMapper.statisticsInfo(startTime, endTime); } diff --git a/dl-module-rescue/src/main/resources/mapper/rescue/RescueCarInfoMapper.xml b/dl-module-rescue/src/main/resources/mapper/rescue/RescueCarInfoMapper.xml index e72995d0..329e8bbc 100644 --- a/dl-module-rescue/src/main/resources/mapper/rescue/RescueCarInfoMapper.xml +++ b/dl-module-rescue/src/main/resources/mapper/rescue/RescueCarInfoMapper.xml @@ -20,11 +20,6 @@ - - - - - @@ -98,7 +93,6 @@ car_insurance_time, car_check_time, possessor_id, - dept_id, #{rescueCarType}, @@ -115,7 +109,6 @@ #{carInsuranceTime}, #{carCheckTime}, #{possessorId}, - #{deptId}, @@ -136,7 +129,6 @@ car_insurance_time = #{carInsuranceTime}, car_check_time = #{carCheckTime}, possessor_id = #{possessorId}, - dept_id = #{deptId}, where id = #{id} @@ -165,14 +157,10 @@ SELECT * FROM `rescue_car_info` where car_insurance_time #{warnTime} - and dept_id = #{deptId} - diff --git a/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml b/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml index 257ac50a..37e9d38b 100644 --- a/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml +++ b/dl-module-rescue/src/main/resources/mapper/rescue/RescueInfoMapper.xml @@ -13,42 +13,41 @@ left join rescue_order_info roi on roi.rescue_info_id = ri.id 1=1 - + - + and (ri.rescue_status = '1' or ri.rescue_status = '2' or ri.rescue_status = '3') - + and roi.order_status ='1' - + and ri.rescue_status ='6' - + and roi.order_status ='2' - + and roi.order_status ='3' - + and ri.rescue_status ='8' - + and (ri.rescue_type ='5' and ri.rescue_status '6') - - and ri.license_num like concat('%',#{licenseNum},'%') + + and ri.license_num like concat('%',#{map.licenseNum},'%') - ${params.dataScope} order by ri.create_time desc @@ -119,6 +118,7 @@ ${params.dataScope} +