From 0caa1b9f5c708ab60ea06c1430b9c3c79613830c Mon Sep 17 00:00:00 2001 From: wang-hao-jie <1550036656@qq.com> Date: 星期一, 27 十二月 2021 14:25:55 +0800 Subject: [PATCH] 违章记录 --- xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/wx/IndexController.java | 210 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 176 insertions(+), 34 deletions(-) diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/wx/IndexController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/wx/IndexController.java index 88ef15f..81c6e5c 100644 --- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/wx/IndexController.java +++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/wx/IndexController.java @@ -1,20 +1,27 @@ package cn.exrick.xboot.your.controller.wx; +import cn.exrick.xboot.core.common.utils.PageUtil; import cn.exrick.xboot.core.common.utils.ResultUtil; +import cn.exrick.xboot.core.common.vo.PageVo; +import cn.exrick.xboot.core.common.vo.Result; import cn.exrick.xboot.your.entity.*; import cn.exrick.xboot.your.service.*; +import cn.exrick.xboot.your.util.HaiKangPost; import cn.exrick.xboot.your.util.HttpUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; +import java.text.DecimalFormat; import java.util.*; /** @@ -22,7 +29,7 @@ */ @Slf4j @RestController -@Api(tags = "璁㈠崟鎺ュ彛") +@Api(tags = "灏忕▼搴忔帴鍙�") @RequestMapping("/xboot/wx") @Transactional public class IndexController { @@ -36,44 +43,22 @@ @Autowired private IOrderDetailService iOrderDetailService; + @Autowired + private ICarService iCarService; - //4.鑾峰彇浠婃棩閰嶉�佽鍗� - @RequestMapping("/getTodayOrder") - public Object getTodayOrder(String customerId){ - QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); - String format = DateUtil.format(new Date(), "yyyy-MM-dd"); - wrapper2.eq("customer_id",customerId); - wrapper2.eq("send_date",format); - OrderTask orderTask = iOrderTaskService.getOne(wrapper2); - if(orderTask==null){ - return ResultUtil.data(new ArrayList<>()); - }else{ - QueryWrapper<OrderDetail> wrapper = new QueryWrapper<OrderDetail>(); - wrapper.eq("order_id",orderTask.getId()); - List<OrderDetail> list = iOrderDetailService.list(wrapper); - return ResultUtil.data(list); - } - } + @Autowired + private HaiKangPost haiKangPost; - //3.寰俊缁戝畾闆跺敭璁稿彲璇� - //licence:闆跺敭璁稿彲璇佸彿 - //openId锛氬井淇d - @RequestMapping("/bindWx") - public Object bindWx(String licence,String openId){ - QueryWrapper<Customer> wrapper = new QueryWrapper<>(); - wrapper.eq("licence",licence); - Customer one = iCustomerService.getOne(wrapper); - if(one==null){ - return ResultUtil.error("闆跺敭璁稿彲璇佹棤鏁�");//棣栨鐧婚檰闇�缁戝畾闆跺敭璁稿彲璇� - }else { - one.setOpenId(openId); - iCustomerService.saveOrUpdate(one); - return ResultUtil.data(one,"鐧诲綍鎴愬姛"); - } - } + @Autowired + private ISuggestService iSuggestService; + + @Autowired + private ICustomerReceiveService iCustomerReceiveService; + //2.寰俊鐧婚檰 @RequestMapping("/login") + @ApiOperation(value = "寰俊鐧婚檰") public Object doLogin(String code){ JSONObject SessionKeyOpenId = getSessionKeyOrOpenId( code ); @@ -101,4 +86,161 @@ JSONObject jsonObject = JSONUtil.parseObj( HttpUtil.get(requestUrl)); return jsonObject; } + + //3.寰俊缁戝畾闆跺敭璁稿彲璇� + //licence:闆跺敭璁稿彲璇佸彿 + //openId锛氬井淇d + @RequestMapping("/bindWx") + @ApiOperation(value = "寰俊缁戝畾闆跺敭璁稿彲璇�") + public Object bindWx(String licence,String openId){ + QueryWrapper<Customer> wrapper = new QueryWrapper<>(); + wrapper.eq("licence",licence); + Customer one = iCustomerService.getOne(wrapper); + if(one==null){ + return ResultUtil.error("闆跺敭璁稿彲璇佹棤鏁�");//棣栨鐧婚檰闇�缁戝畾闆跺敭璁稿彲璇� + }else { + one.setOpenId(openId); + iCustomerService.saveOrUpdate(one); + return ResultUtil.data(one,"鐧诲綍鎴愬姛"); + } + } + + //4.鑾峰彇浠婃棩閰嶉�佽鍗� + @RequestMapping("/getTodayOrder") + @ApiOperation(value = "鑾峰彇浠婃棩閰嶉�佽鍗�") + public Object getTodayOrder(String customerId){ + OrderTask orderTask = getOrder(customerId); + if(orderTask==null){ + return ResultUtil.data(new ArrayList<>()); + }else{ + QueryWrapper<OrderDetail> wrapper = new QueryWrapper<OrderDetail>(); + wrapper.eq("order_id",orderTask.getId()); + List<OrderDetail> list = iOrderDetailService.list(wrapper); + return ResultUtil.data(list); + } + } + + public OrderTask getOrder(String customerId){ + QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); + String format = DateUtil.format(new Date(), "yyyy-MM-dd"); + wrapper2.eq("customer_id",customerId); + wrapper2.eq("send_date",format); + OrderTask orderTask = iOrderTaskService.getOne(wrapper2); + return orderTask; + } + + //5.鑾峰彇杞﹁締浣嶇疆 + @RequestMapping("/getCarInfo") + @ApiOperation(value = "鑾峰彇杞﹁締浣嶇疆") + public Object getCarInfo(String customerId){ + QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); + String format = DateUtil.format(new Date(), "yyyy-MM-dd"); + wrapper2.eq("customer_id",customerId); + wrapper2.eq("send_date",format); + OrderTask orderTask = iOrderTaskService.getOne(wrapper2); + String carId = orderTask.getCarId(); + Car car = iCarService.getById(carId); + String[] carids = new String[1]; + carids[0]= car.getCode(); + String latestGps = haiKangPost.findLatestGps(carids); + JSONObject jsonObject = JSONUtil.parseObj(latestGps); + String data = jsonObject.getStr("data"); + JSONObject jsonObject2 = JSONUtil.parseObj(data); + Integer lng = jsonObject2.getInt("longitude"); + Integer lat = jsonObject2.getInt("latitude"); + + DecimalFormat df = new DecimalFormat("#.000000"); + Map<String,Object> map = new HashMap<>(); + map.put("lng",df.format(lng/360000.0)); + map.put("lat",df.format(lat/360000.0)); + map.put("content","杩樻湁3鍗曪紝棰勮10锛�22閫佽揪"); + return ResultUtil.data(map); + } + + //6.鍔犳补鍔╁姏 + @RequestMapping("/likes") + @ApiOperation(value = "鍔犳补鍔╁姏") + public Object likes(String customerId){ + OrderTask order = getOrder(customerId); + order.setLikes(1); + iOrderTaskService.saveOrUpdate(order); + return ResultUtil.success("鍔╁姏鎴愬姛"); + } + + //7.鑾峰彇璁㈠崟鍒楄〃 + @RequestMapping("/getOrderList") + @ApiOperation(value = "鑾峰彇璁㈠崟鍒楄〃") + public Object getOrderList(String customerId, String startTime, String endTime, PageVo page){ + page.setSort("sendDate"); + page.setOrder("desc"); + QueryWrapper<OrderTask> wrapper = new QueryWrapper<>(); + wrapper.eq("customer_id",customerId); + if(StrUtil.isNotEmpty(startTime)){ + wrapper.ge("send_date",startTime); + } + if(StrUtil.isNotEmpty(endTime)){ + wrapper.le("send_date",endTime); + } + IPage<OrderTask> page1 = iOrderTaskService.page(PageUtil.initMpPage(page), wrapper); + return ResultUtil.data(page1.getRecords()); + } + + //8.鑾峰彇璁㈠崟璇︽儏鍒楄〃 + @RequestMapping("/getOrderDetail") + @ApiOperation(value = "鑾峰彇璁㈠崟璇︽儏鍒楄〃") + public Object getOrderDetail(String orderId){ + QueryWrapper<OrderDetail> wrapper = new QueryWrapper<>(); + wrapper.eq("order_id",orderId); + List<OrderDetail> list1 = iOrderDetailService.list(wrapper); + return ResultUtil.data(list1); + } + + //9.璇勪环 + @RequestMapping("/remark") + @ApiOperation(value = "璇勪环") + public Object remark(int level,String orderId){ + OrderTask byId = iOrderTaskService.getById(orderId); + byId.setLevel(level); + iOrderTaskService.saveOrUpdate(byId); + return ResultUtil.success("璇勪环鎴愬姛"); + } + + + //10.鑾峰彇鎰忚寤鸿鍒楄〃 + @RequestMapping(value = "/getSuggestByPage", method = RequestMethod.GET) + @ApiOperation(value = "鑾峰彇鎰忚寤鸿鍒楄〃") + public Result<IPage<Suggest>> getByPage(String customerId,PageVo page) { + QueryWrapper<Suggest> wrapper = new QueryWrapper<>(); + wrapper.eq("customer_id",customerId); + IPage<Suggest> data = iSuggestService.page2(PageUtil.initMpPage(page),wrapper); + return new ResultUtil<IPage<Suggest>>().setData(data); + } + + //12.鏂板鎰忚寤鸿 + @RequestMapping(value = "/insertSuggest", method = RequestMethod.POST) + @ApiOperation(value = "鏂板鎰忚寤鸿") + public Result<Suggest> insertSuggest(String customerId,String content) { + Suggest suggest = new Suggest(); + suggest.setContent(content); + suggest.setCustomerId(customerId); + if (iSuggestService.saveOrUpdate(suggest)) { + return new ResultUtil<Suggest>().setSuccessMsg("鎿嶄綔鎴愬姛"); + } + return new ResultUtil<Suggest>().setErrorMsg("鎿嶄綔澶辫触"); + } + + //13.鏂板绛炬敹浜� + @RequestMapping(value = "/insertReceive", method = RequestMethod.POST) + @ApiOperation(value = "鏂板绛炬敹浜�") + public Result<CustomerReceive> insertReceive(String customerId,String name,String phone) { + CustomerReceive customerReceive = new CustomerReceive(); + customerReceive.setCustomerId(customerId); + customerReceive.setPhone(phone); + customerReceive.setName(name); + customerReceive.setFstatus(0); + if (iCustomerReceiveService.saveOrUpdate(customerReceive)) { + return new ResultUtil<CustomerReceive>().setSuccessMsg("鎿嶄綔鎴愬姛"); + } + return new ResultUtil<CustomerReceive>().setErrorMsg("鎿嶄綔澶辫触"); + } } -- Gitblit v1.9.1