From 9c0566b86975f112a7f0cf044bab322b7ffe4f0a Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期四, 11 五月 2023 18:29:24 +0800 Subject: [PATCH] 超省后台BUG修改 --- management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java | 71 ++++++++++++++++++++++++++++------- 1 files changed, 56 insertions(+), 15 deletions(-) diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java index f139140..73b0ab4 100644 --- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java +++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java @@ -1,45 +1,52 @@ package com.stylefeng.guns.modular.system.controller.general; -import cn.hutool.core.util.CreditCodeUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.stylefeng.guns.core.base.controller.BaseController; import com.stylefeng.guns.core.base.tips.SuccessTip; +import com.stylefeng.guns.core.log.LogObjectHolder; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.shiro.ShiroUser; import com.stylefeng.guns.modular.system.controller.resp.TDriverCommissionResp; import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; -import com.stylefeng.guns.modular.system.controller.util.*; +import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; +import com.stylefeng.guns.modular.system.controller.util.HttpUtils; +import com.stylefeng.guns.modular.system.controller.util.TokenUtils; +import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; import com.stylefeng.guns.modular.system.enums.UserTypeEnum; -import com.stylefeng.guns.modular.system.model.*; +import com.stylefeng.guns.modular.system.model.TDriver; +import com.stylefeng.guns.modular.system.model.TDriverWork; +import com.stylefeng.guns.modular.system.model.TRechargeRecord; +import com.stylefeng.guns.modular.system.model.TRegion; import com.stylefeng.guns.modular.system.service.*; +import com.stylefeng.guns.modular.system.util.RedisUtil; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; -import org.apache.logging.log4j.core.util.UuidUtil; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.shiro.subject.Subject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.ui.Model; +import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.beans.factory.annotation.Autowired; -import com.stylefeng.guns.core.log.LogObjectHolder; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.IOException; import java.io.OutputStream; import java.math.BigDecimal; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Objects; @@ -75,7 +82,13 @@ @Autowired private TokenUtils tokenUtils; @Autowired + private ITDriverWorkService tDriverWorkService; + @Autowired + private RedisUtil redisUtil; + @Autowired private ITRechargeRecordService tRechargeRecordService; + + private Logger log = LoggerFactory.getLogger(this.getClass()); /** * 跳转到首页 @@ -184,8 +197,7 @@ * @return */ @RequestMapping("/auditPage") - public String auditPage( Integer id, - Model model) { + public String auditPage( Integer id,Model model) { tDriverService.auditPage(id,model); return PREFIX + "tDriverAudit.html"; } @@ -363,7 +375,7 @@ */ @RequestMapping(value = "/ocr") @ResponseBody - public Object ocr(String imgUrl) { + public JSONObject ocr(MultipartFile multipartFile) { /*String accessToken = redisTemplate.opsForValue().get(TokenUtils.ACCESS_TOKEN_CACHE_KEY); if (!StringUtils.hasLength(accessToken)) { accessToken = tokenUtils.getSimpleAccessToken(); @@ -374,7 +386,19 @@ JSONObject jsonObject = JSONObject.parseObject(result); System.err.println(jsonObject); return jsonObject;*/ - return tDriverService.ocr(imgUrl); + String originalFilename = multipartFile.getOriginalFilename(); + String[] filename = originalFilename.split("\\."); + log.info("tupian::"+filename[0]+"//"+filename[1]); + File file= null; + try { + file = File.createTempFile(filename[0], "."+filename[1]); + multipartFile.transferTo(file); + file.deleteOnExit(); + log.info("file:"+file.getName()); + } catch (IOException e) { + log.error("ocr识别失败:{}",e.getMessage()); + } + return tDriverService.ocr(file); } /** @@ -411,6 +435,8 @@ return o; } // 默认值板块 + tDriver.setName(tDriver.getName().replace(" ","")); + tDriver.setEmergencyContact(tDriver.getEmergencyContact().replace(" ","")); tDriver.setCode(UUIDUtil.getNumberRandom(16)); tDriver.setBalance(BigDecimal.ZERO); tDriver.setBackgroundBalance(BigDecimal.ZERO); @@ -439,6 +465,19 @@ TDriver tDriver = tDriverService.selectById(id); if(1 == status){ tDriver.setStatus(2); + String value = redisUtil.getValue("DRIVER_" + tDriver.getPhone()); + redisUtil.remove(value); + redisUtil.remove("DRIVER_" + tDriver.getPhone()); + TDriverWork tDriverWork = tDriverWorkService.selectOne(new EntityWrapper<TDriverWork>() + .eq("driverId", tDriver.getId()) + .eq("status", 1) + .orderBy("workTime", false) + .last("LIMIT 1")); + if(Objects.nonNull(tDriverWork)){ + tDriverWork.setStatus(2); + tDriverWork.setOffWorkTime(new Date()); + tDriverWorkService.updateById(tDriverWork); + } } if(2 == status){ tDriver.setStatus(1); @@ -492,6 +531,8 @@ if(Objects.nonNull(o)){ return o; } + tDriver.setName(tDriver.getName().replace(" ","")); + tDriver.setEmergencyContact(tDriver.getEmergencyContact().replace(" ","")); tDriverService.updateById(tDriver); return SUCCESS_TIP; } -- Gitblit v1.7.1