无关风月
2025-07-03 e897513fc65c426c5b0f0dce6f8b887b9cc9010d
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TTaskDetailController.java
@@ -7,6 +7,7 @@
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.applet.dto.AppealDTO;
import com.ruoyi.system.dto.TTaskAuditBatchDTO;
import com.ruoyi.system.dto.TaskDetailDto;
@@ -30,6 +31,7 @@
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;
@@ -67,43 +69,50 @@
        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()));
            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 = 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()));
//
//            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();
//        }
        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);
        // 添加任务详情
        TTaskDetail taskDetail = new TTaskDetail();