From 53d014edd19f57125c355abe71ec5b478500e610 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 05 八月 2025 09:57:40 +0800 Subject: [PATCH] 保洁巡检所有代码 --- ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TTaskDetailController.java | 151 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 111 insertions(+), 40 deletions(-) diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TTaskDetailController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TTaskDetailController.java index fc5d934..289286d 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TTaskDetailController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TTaskDetailController.java @@ -3,21 +3,20 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.applet.dto.AppealDTO; +import com.ruoyi.system.applet.dto.AppealInspectorDTO; +import com.ruoyi.system.dto.InspectorDetailDto; import com.ruoyi.system.dto.TTaskAuditBatchDTO; import com.ruoyi.system.dto.TaskDetailDto; -import com.ruoyi.system.model.TAppeal; -import com.ruoyi.system.model.TLocation; -import com.ruoyi.system.model.TTask; -import com.ruoyi.system.model.TTaskDetail; -import com.ruoyi.system.service.TAppealService; -import com.ruoyi.system.service.TLocationService; -import com.ruoyi.system.service.TTaskCleanService; -import com.ruoyi.system.service.TTaskDetailService; +import com.ruoyi.system.model.*; +import com.ruoyi.system.service.*; import com.ruoyi.web.controller.tool.AmapApiClient; import com.ruoyi.web.controller.tool.GeoChecker; import com.ruoyi.web.controller.tool.PathParser; @@ -30,11 +29,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; import javax.validation.Valid; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * <p> @@ -57,6 +58,10 @@ private TAppealService appealService; @Autowired private TLocationService locationService; + @Resource + private TInspectorService inspectorService; + @Resource + private TInspectorDetailService inspectorDetailService; @ApiOperation(value = "上传任务") @PostMapping(value = "/uploadTask") @@ -64,54 +69,120 @@ double radius = 50; // 单位:米 int segments = 4; // 四段,共 5 个点 TTask task = taskService.getById(dto.getTaskId()); - if (task==null)return R.fail("任务不存在"); - TLocation location = locationService.getById(task.getLocationId()); - if (location==null)return R.fail("点位不存在"); - try { - String routeJson = AmapApiClient.getDrivingRoute(Double.parseDouble(location.getLocationLat()), - Double.parseDouble(location.getLocationLon()), - Double.parseDouble(location.getLocationLatEnd()), - Double.parseDouble(location.getLocationLonEnd())); - // 转化为json对象 - JSONObject jsonObject = JSONObject.parseObject(routeJson); - JSONObject route = jsonObject.getJSONObject("route"); - JSONArray paths = route.getJSONArray("paths"); - JSONObject o = (JSONObject)paths.get(0); - BigDecimal distance = o.getBigDecimal("distance"); - System.err.println( paths); - List<double[]> fivePoints = PathParser.parseAndInterpolate(routeJson, segments, - Double.parseDouble(location.getLocationLat()), - Double.parseDouble(location.getLocationLon()), - Double.parseDouble(location.getLocationLatEnd()), - Double.parseDouble(location.getLocationLonEnd())); + TInspector byId = inspectorService.getById(dto.getTaskId()); + if (byId!=null){ + TLocation location = locationService.getById(byId.getLocationId()); + byId.setClearStatus( dto.getClearStatus()); + byId.setUnqualified(dto.getUnqualified()); + byId.setRemark( dto.getRemark()); + byId.setPicture( dto.getPicture()); + byId.setAudioUrl( dto.getAudioUrl()); + byId.setStatus( 1); + TInspectorDetail tInspectorDetail = new TInspectorDetail(); + BeanUtils.copyProperties(dto, tInspectorDetail); + tInspectorDetail.setInspectorId(byId.getId()); + tInspectorDetail.setHandleType(1); + tInspectorDetail.setInspectorId(byId.getId()); + inspectorDetailService.save(tInspectorDetail); + inspectorService.updateById(byId); + }else{ + TLocation location = locationService.getById(task.getLocationId()); - if (GeoChecker.isInAnyCircle(Double.parseDouble(dto.getLat()), Double.parseDouble(dto.getLon()), - fivePoints, radius)) { - System.out.println("✅ 成功!您位于某个圆形电子围栏范围内。"); - } else { - System.out.println("❌ 失败!您不在任何圆形电子围栏范围内。"); - return R.fail("位置信息与点位不一致,请点击此处更新定位"); - } - } catch (Exception e) { - e.printStackTrace(); + // try { +// String routeJson = AmapApiCalient.getDrivingRoute(Double.parseDouble(location.getLocationLat()), +// Double.parseDouble(location.getLocationLon()), +// Double.parseDouble(location.getLocationLatEnd()), +// Double.parseDouble(location.getLocationLonEnd())); +// // 转化为json对象 +// JSONObject jsonObject = JSONObject.parseObject(routeJson); +// JSONObject route = jsonObject.getJSONObject("route"); +// JSONArray paths = route.getJSONArray("paths"); +// JSONObject o = (JSONObject)paths.get(0); +// BigDecimal distance = o.getBigDecimal("distance"); +// System.err.println( paths); +// List<double[]> fivePoints = PathParser.parseAndInterpolate(routeJson, segments, +// Double.parseDouble(location.getLocationLat()), +// Double.parseDouble(location.getLocationLon()), +// Double.parseDouble(location.getLocationLatEnd()), +// Double.parseDouble(location.getLocationLonEnd())); +// +// if (GeoChecker.isInAnyCircle(Double.parseDouble(dto.getLat()), Double.parseDouble(dto.getLon()), +// fivePoints, radius)) { +// System.out.println("✅ 成功!您位于某个圆形电子围栏范围内。"); +// } else { +// System.out.println("❌ 失败!您不在任何圆形电子围栏范围内。"); +// return R.fail("位置信息与点位不一致,请点击此处更新定位"); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } + dto.setTaskId(task.getId()); + dto.setHandleType(1); + dto.setAuditStatus(1); + dto.setAuditTime(LocalDateTime.now()); + taskDetailService.save(dto); + // 修改任务状态 + taskService.update(Wrappers.<TTask>lambdaUpdate().set(TTask::getStatus, 3).eq(TTask::getId, dto.getTaskId())); } - taskDetailService.save(dto); - // 修改任务状态 - taskService.update(Wrappers.<TTask>lambdaUpdate().set(TTask::getStatus, 3).eq(TTask::getId, dto.getTaskId())); + return R.ok(); } + + @Resource + private TokenService tokenService; @ApiOperation(value = "申诉") @PostMapping(value = "/appeal") public R<Boolean> appeal(@RequestBody AppealDTO dto) { + List<TAppeal> list = appealService.lambdaQuery().eq(TAppeal::getTaskId, dto.getTaskId()).list(); + if (!list.isEmpty()){ + return R.fail("任务只有一次申诉机会"); + } + dto.setAppealPerson(tokenService.getLoginUserApplet().getUserId()+""); appealService.save(dto); + List<TTaskDetail> taskDetails = taskDetailService.lambdaQuery() + .eq(TTaskDetail::getTaskId, dto.getTaskId()) + .eq(TTaskDetail::getAuditStatus, 1) + .eq(TTaskDetail::getHandleType,1) + .isNotNull(TTaskDetail::getClearStatus) + .orderByDesc(TTaskDetail::getCreateTime).list(); + // 使用 stream 去重,保留每个 taskId 最新的一条 + taskDetails = new ArrayList<>(taskDetails.stream() + .collect(Collectors.groupingBy( + TTaskDetail::getTaskId, + Collectors.collectingAndThen( + Collectors.toList(), + listAll -> listAll.get(0) + ) + )) + .values()); // 添加任务详情 TTaskDetail taskDetail = new TTaskDetail(); taskDetail.setTaskId(dto.getTaskId()); taskDetail.setHandleType(4); + taskDetail.setClearStatus(taskDetail.getClearStatus()); + taskDetail.setAppealId(dto.getId()); taskDetailService.save(taskDetail); return R.ok(); } + @ApiOperation(value = "督察申诉") + @PostMapping(value = "/appealInspector") + public R<Boolean> appealInspector(@RequestBody AppealInspectorDTO dto) { + List<TAppeal> list = appealService.lambdaQuery().eq(TAppeal::getInspectorId, dto.getInspectorId()).list(); + if (!list.isEmpty()){ + return R.fail("任务只有一次申诉机会"); + } + dto.setAppealPerson(tokenService.getLoginUserApplet().getUserId()+""); + appealService.save(dto); + // 添加督察任务详情 + TInspectorDetail taskDetail = new TInspectorDetail(); + taskDetail.setInspectorId(dto.getTaskId()); + taskDetail.setHandleType(4); + taskDetail.setClearStatus(taskDetail.getClearStatus()); + taskDetail.setAppealId(dto.getId()); + inspectorDetailService.save(taskDetail); + return R.ok(); + } } -- Gitblit v1.7.1