Commit a19ff945f64143d7c630fd775d061e10774e4d9b

Authored by guzijian
1 parent 62e6c99d

feat: 修改应用更新逻辑,维护两个应用版本

ruoyi-admin/src/main/java/com/ruoyi/controller/ApplicationUpdateController.java
@@ -33,8 +33,8 @@ public class ApplicationUpdateController { @@ -33,8 +33,8 @@ public class ApplicationUpdateController {
33 */ 33 */
34 @GetMapping("/version/check/{currentVersion}") 34 @GetMapping("/version/check/{currentVersion}")
35 @ApiOperation("校验版本号") 35 @ApiOperation("校验版本号")
36 - public AjaxResult checkVersionNum(@PathVariable("currentVersion") Integer currentVersion) {  
37 - return AjaxResult.success(appService.checkVersionNum(currentVersion)); 36 + public AjaxResult checkVersionNum(@PathVariable("currentVersion") Integer currentVersion, @RequestParam(value = "deviceId", required = false) String deviceId) {
  37 + return AjaxResult.success(appService.checkVersionNum(currentVersion,deviceId));
38 } 38 }
39 39
40 /** 40 /**
@@ -61,6 +61,18 @@ public class ApplicationUpdateController { @@ -61,6 +61,18 @@ public class ApplicationUpdateController {
61 } 61 }
62 } 62 }
63 63
  64 +
  65 + @PostMapping("/uploadApk/other")
  66 + @ApiOperation("上传apk文件")
  67 + public AjaxResult uploadApkOther(MultipartFile file) {
  68 + try {
  69 + return appService.uploadApkOther(file);
  70 + } catch (Exception e) {
  71 + return AjaxResult.error("上传失败,请重试,再次失败请联系管理员,失败原因:" + e.getMessage());
  72 + }
  73 + }
  74 +
  75 +
64 @GetMapping("/checkDeviceHeart") 76 @GetMapping("/checkDeviceHeart")
65 @ApiOperation("设备心跳检测") 77 @ApiOperation("设备心跳检测")
66 public Result<?> checkAppHeart(@Validated @ApiParam @ModelAttribute HeartPackageVo vo) { 78 public Result<?> checkAppHeart(@Validated @ApiParam @ModelAttribute HeartPackageVo vo) {
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
@@ -357,7 +357,7 @@ public class DriverServiceImpl implements IDriverService { @@ -357,7 +357,7 @@ public class DriverServiceImpl implements IDriverService {
357 return vos; 357 return vos;
358 } 358 }
359 359
360 - private boolean doCheckDevice(String deviceId) { 360 + public static boolean doCheckDevice(String deviceId) {
361 if (StringUtil.isEmpty(deviceId)){ 361 if (StringUtil.isEmpty(deviceId)){
362 return true; 362 return true;
363 } 363 }
ruoyi-admin/src/main/java/com/ruoyi/in/controller/SignInController.java
@@ -77,16 +77,16 @@ public class SignInController extends BaseController { @@ -77,16 +77,16 @@ public class SignInController extends BaseController {
77 return success(signInService.selectSignInById(id)); 77 return success(signInService.selectSignInById(id));
78 } 78 }
79 79
80 -// /**  
81 -// * 新增签到  
82 -// */  
83 -//// @PreAuthorize("@ss.hasPermi('in:in:add')")  
84 -// @Log(title = "签到", businessType = BusinessType.INSERT)  
85 -// @PostMapping  
86 -// @ApiOperation("新增签到(通过后台管理页面)")  
87 -// public AjaxResult add(@ApiParam @RequestBody SignIn signIn) {  
88 -// return signInService.insertSignIn(signIn);  
89 -// } 80 + /**
  81 + * 补签
  82 + */
  83 +// @PreAuthorize("@ss.hasPermi('in:in:add')")
  84 + @Log(title = "补签", businessType = BusinessType.INSERT)
  85 + @PutMapping("/supplementarySignature")
  86 + @ApiOperation("补签(通过后台管理页面)")
  87 + public AjaxResult supplementarySignature(@ApiParam @RequestBody SignIn signIn) {
  88 + return signInService.supplementarySignature(signIn);
  89 + }
90 90
91 91
92 /** 92 /**
ruoyi-admin/src/main/java/com/ruoyi/in/service/ISignInService.java
@@ -68,4 +68,6 @@ public interface ISignInService @@ -68,4 +68,6 @@ public interface ISignInService
68 String repairSignRecord(HttpServletRequest request); 68 String repairSignRecord(HttpServletRequest request);
69 69
70 String repairAllSignRecord(HttpServletRequest request,String date); 70 String repairAllSignRecord(HttpServletRequest request,String date);
  71 +
  72 + AjaxResult supplementarySignature(SignIn signIn);
71 } 73 }
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
@@ -19,12 +19,14 @@ import com.ruoyi.common.constant.Constants; @@ -19,12 +19,14 @@ import com.ruoyi.common.constant.Constants;
19 import com.ruoyi.common.core.domain.AjaxResult; 19 import com.ruoyi.common.core.domain.AjaxResult;
20 import com.ruoyi.common.core.redis.RedisCache; 20 import com.ruoyi.common.core.redis.RedisCache;
21 import com.ruoyi.common.utils.DateUtils; 21 import com.ruoyi.common.utils.DateUtils;
  22 +import com.ruoyi.common.utils.SecurityUtils;
22 import com.ruoyi.common.utils.StringUtils; 23 import com.ruoyi.common.utils.StringUtils;
23 import com.ruoyi.common.utils.ip.IpUtils; 24 import com.ruoyi.common.utils.ip.IpUtils;
24 import com.ruoyi.common.utils.uuid.Seq; 25 import com.ruoyi.common.utils.uuid.Seq;
25 import com.ruoyi.common.utils.uuid.UUID; 26 import com.ruoyi.common.utils.uuid.UUID;
26 import com.ruoyi.driver.domain.Driver; 27 import com.ruoyi.driver.domain.Driver;
27 import com.ruoyi.driver.mapper.DriverMapper; 28 import com.ruoyi.driver.mapper.DriverMapper;
  29 +import com.ruoyi.driver.mapper.DriverSchedulingMapper;
28 import com.ruoyi.equipment.domain.Equipment; 30 import com.ruoyi.equipment.domain.Equipment;
29 import com.ruoyi.equipment.mapper.EquipmentMapper; 31 import com.ruoyi.equipment.mapper.EquipmentMapper;
30 import com.ruoyi.errorScheduling.service.IErrorJobcodeService; 32 import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
@@ -72,6 +74,9 @@ public class SignInServiceImpl implements ISignInService { @@ -72,6 +74,9 @@ public class SignInServiceImpl implements ISignInService {
72 @Autowired 74 @Autowired
73 private IErrorJobcodeService errorJobcodeService; 75 private IErrorJobcodeService errorJobcodeService;
74 76
  77 + @Autowired
  78 + private DriverSchedulingMapper schedulingMapper;
  79 +
75 @Resource 80 @Resource
76 private SchedulingCache schedulingCache; 81 private SchedulingCache schedulingCache;
77 @Autowired 82 @Autowired
@@ -161,17 +166,7 @@ public class SignInServiceImpl implements ISignInService { @@ -161,17 +166,7 @@ public class SignInServiceImpl implements ISignInService {
161 GlobalIndex globalIndex = new GlobalIndex(); 166 GlobalIndex globalIndex = new GlobalIndex();
162 long now = signIn.getCreateTime().getTime(); 167 long now = signIn.getCreateTime().getTime();
163 List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now); 168 List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
164 - // 签到检查  
165 - if (checkSignIn(now, dto, globalIndex, signIn, driver)) {  
166 - signIn.setStatus(SIGN_IN_SUCCESS);  
167 - signIn.setExType(SIGN_NO_EX_NUM);  
168 - signIn.setRemark("正常");  
169 - } else {  
170 - signIn.setStatus(SIGN_IN_FAIL);  
171 - signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。"));  
172 - }  
173 - // base64转图片  
174 - signIn.setIp(IpUtils.getIpAddr()); 169 + handleSignBody(signIn, driver, globalIndex, now, dto);
175 170
176 uploadImage(signIn, vo); 171 uploadImage(signIn, vo);
177 signInMapper.insertSignIn(signIn); 172 signInMapper.insertSignIn(signIn);
@@ -185,6 +180,20 @@ public class SignInServiceImpl implements ISignInService { @@ -185,6 +180,20 @@ public class SignInServiceImpl implements ISignInService {
185 return handleAjaxResult(signIn, driver, vo); 180 return handleAjaxResult(signIn, driver, vo);
186 } 181 }
187 182
  183 + private void handleSignBody(SignIn signIn, Driver driver, GlobalIndex globalIndex, long now, List<DriverScheduling> dto) {
  184 + // 签到检查
  185 + if (checkSignIn(now, dto, globalIndex, signIn, driver)) {
  186 + signIn.setStatus(SIGN_IN_SUCCESS);
  187 + signIn.setExType(SIGN_NO_EX_NUM);
  188 + signIn.setRemark("正常");
  189 + } else {
  190 + signIn.setStatus(SIGN_IN_FAIL);
  191 + signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。"));
  192 + }
  193 + // base64转图片
  194 + signIn.setIp(IpUtils.getIpAddr());
  195 + }
  196 +
188 private AjaxResult handleAjaxResult(SignIn signIn, Driver driver, SignInResponseVo vo) { 197 private AjaxResult handleAjaxResult(SignIn signIn, Driver driver, SignInResponseVo vo) {
189 if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) { 198 if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) {
190 AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo); 199 AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo);
@@ -250,6 +259,31 @@ public class SignInServiceImpl implements ISignInService { @@ -250,6 +259,31 @@ public class SignInServiceImpl implements ISignInService {
250 return null; 259 return null;
251 } 260 }
252 261
  262 + @Override
  263 + public AjaxResult supplementarySignature(SignIn signIn) {
  264 + signIn.setRemark("");
  265 + Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode());
  266 + if (Objects.isNull(driver)) return AjaxResult.warn("这个工号的员工不存在!");
  267 + GlobalIndex globalIndex = new GlobalIndex();
  268 + long now = signIn.getCreateTime().getTime();
  269 + List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
  270 + handleSignBody(signIn, driver, globalIndex, now, dto);
  271 + signIn.setUpdateBy(SecurityUtils.getUsername());
  272 +
  273 + signInMapper.insertSignIn(signIn);
  274 + // 更新考勤
  275 + if (CollectionUtil.isNotEmpty(dto)) {
  276 + schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType(), signIn.getCreateTime(), signIn.getRemark(), signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
  277 + // 更新缓存
  278 + nowSchedulingCache.updateCacheByJobCode(ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn);
  279 + }
  280 +
  281 + // 异常保存到异常异常中
  282 + threadJobService.asyncInsertExceptionRecord(signIn, driver, dto, globalIndex);
  283 +
  284 + return AjaxResult.success("补签成功");
  285 + }
  286 +
253 private String handleDate(String dateString) { 287 private String handleDate(String dateString) {
254 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); 288 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
255 // 解析字符串日期为 LocalDate 对象 289 // 解析字符串日期为 LocalDate 对象
@@ -490,19 +524,19 @@ public class SignInServiceImpl implements ISignInService { @@ -490,19 +524,19 @@ public class SignInServiceImpl implements ISignInService {
490 // 给出签到范围 524 // 给出签到范围
491 // 上一次无记|签到,type:签退 当前时间小于最近签到时间 -> 超时签退 525 // 上一次无记|签到,type:签退 当前时间小于最近签到时间 -> 超时签退
492 if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getBcType().equals(BC_TYPE_IN)) { 526 if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getBcType().equals(BC_TYPE_IN)) {
493 - signIn.setRemark(SIGN_OUT_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm",new Date(lastClosestTimestamp.getTimestamps())) + "前后一小时内打卡。"); 527 + signIn.setRemark(SIGN_OUT_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm", new Date(lastClosestTimestamp.getTimestamps())) + "前后一小时内打卡。");
494 globalIndex.setIndex(lastClosestTimestamp.getIndex()); 528 globalIndex.setIndex(lastClosestTimestamp.getIndex());
495 result = false; 529 result = false;
496 } 530 }
497 // 上一次无记无|签到,type:签退 当前时间小于最近签到时间 -> 超时签退 531 // 上一次无记无|签到,type:签退 当前时间小于最近签到时间 -> 超时签退
498 else if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getIndex().equals(currentScheduling.getIndex())) { 532 else if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getIndex().equals(currentScheduling.getIndex())) {
499 - signIn.setRemark(SIGN_IN_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm",new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。"); 533 + signIn.setRemark(SIGN_IN_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm", new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。");
500 globalIndex.setIndex(currentScheduling.getIndex()); 534 globalIndex.setIndex(currentScheduling.getIndex());
501 result = false; 535 result = false;
502 } 536 }
503 // 当前最近无记录|签到,type:签到|签退 -> 签到超时给上 537 // 当前最近无记录|签到,type:签到|签退 -> 签到超时给上
504 else { 538 else {
505 - signIn.setRemark(SIGN_IN_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm",new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。"); 539 + signIn.setRemark(SIGN_IN_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm", new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。");
506 globalIndex.setIndex(currentScheduling.getIndex()); 540 globalIndex.setIndex(currentScheduling.getIndex());
507 result = false; 541 result = false;
508 } 542 }
@@ -512,20 +546,20 @@ public class SignInServiceImpl implements ISignInService { @@ -512,20 +546,20 @@ public class SignInServiceImpl implements ISignInService {
512 DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1); 546 DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1);
513 // 上一次无记|签退,type:签到 当前时间小于最近签退时间 -> 签到异常 547 // 上一次无记|签退,type:签到 当前时间小于最近签退时间 -> 签到异常
514 if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_IN)) { 548 if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_IN)) {
515 - signIn.setRemark(SIGN_IN_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm",new Date(lastClosestTimestamp.getTimestamps())) + "前后一小时内打卡。"); 549 + signIn.setRemark(SIGN_IN_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm", new Date(lastClosestTimestamp.getTimestamps())) + "前后一小时内打卡。");
516 globalIndex.setIndex(lastClosestTimestamp.getIndex()); 550 globalIndex.setIndex(lastClosestTimestamp.getIndex());
517 result = false; 551 result = false;
518 } 552 }
519 // 当前无记|签退 , type:签退|签到 ——> 签退异常 553 // 当前无记|签退 , type:签退|签到 ——> 签退异常
520 else { 554 else {
521 - signIn.setRemark(SIGN_OUT_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm",new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。"); 555 + signIn.setRemark(SIGN_OUT_TIMEOUT + "请在" + ConstDateUtil.formatDate("HH:mm", new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。");
522 globalIndex.setIndex(currentScheduling.getIndex()); 556 globalIndex.setIndex(currentScheduling.getIndex());
523 result = false; 557 result = false;
524 } 558 }
525 } 559 }
526 // 签退|签到 当前有记录 560 // 签退|签到 当前有记录
527 if (!Objects.isNull(currentScheduling.getSignInId())) { 561 if (!Objects.isNull(currentScheduling.getSignInId())) {
528 - String prompt = "请在" + ConstDateUtil.formatDate("HH:mm",new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。"; 562 + String prompt = "请在" + ConstDateUtil.formatDate("HH:mm", new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。";
529 signIn.setRemark((currentScheduling.getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT) + prompt); 563 signIn.setRemark((currentScheduling.getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT) + prompt);
530 globalIndex.setIndex(currentScheduling.getIndex()); 564 globalIndex.setIndex(currentScheduling.getIndex());
531 result = false; 565 result = false;
ruoyi-admin/src/main/java/com/ruoyi/service/AppService.java
@@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult; @@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
5 import com.ruoyi.common.utils.StringUtils; 5 import com.ruoyi.common.utils.StringUtils;
6 import com.ruoyi.common.utils.file.FileUploadUtils; 6 import com.ruoyi.common.utils.file.FileUploadUtils;
7 import com.ruoyi.common.utils.file.FileUtils; 7 import com.ruoyi.common.utils.file.FileUtils;
  8 +import com.ruoyi.driver.service.impl.DriverServiceImpl;
8 import com.ruoyi.equipment.domain.Equipment; 9 import com.ruoyi.equipment.domain.Equipment;
9 import com.ruoyi.equipment.mapper.EquipmentMapper; 10 import com.ruoyi.equipment.mapper.EquipmentMapper;
10 import com.ruoyi.framework.config.ServerConfig; 11 import com.ruoyi.framework.config.ServerConfig;
@@ -24,8 +25,6 @@ import java.nio.file.Paths; @@ -24,8 +25,6 @@ import java.nio.file.Paths;
24 import java.util.Date; 25 import java.util.Date;
25 import java.util.Objects; 26 import java.util.Objects;
26 27
27 -import static com.ruoyi.common.ConstEquipmentProperties.DEVICE_ONLINE;  
28 -  
29 /** 28 /**
30 * 应用service 29 * 应用service
31 */ 30 */
@@ -43,15 +42,35 @@ public class AppService { @@ -43,15 +42,35 @@ public class AppService {
43 @Autowired 42 @Autowired
44 private VersionUpgradeMapper versionUpgradeMapper; 43 private VersionUpgradeMapper versionUpgradeMapper;
45 44
46 - public ApplicationResponseVo checkVersionNum(Integer versionNum) { 45 + public ApplicationResponseVo checkVersionNum(Integer versionNum, String deviceId) {
  46 + boolean result = DriverServiceImpl.doCheckDevice(deviceId);
  47 + if (result) {
  48 + return getApplicationResponseVoByDeviceId(versionNum);
  49 + } else {
  50 + return getApplicationResponseVo(versionNum);
  51 + }
  52 + }
  53 +
  54 + private ApplicationResponseVo getApplicationResponseVoByDeviceId(Integer versionNum) {
  55 + // 比对版本 需要更新 判断是否需要强制更新
  56 + VersionUpgrade vu = versionUpgradeMapper.queryLatestVersionNum(1);
  57 + // 无需更新
  58 + if (!Objects.isNull(vu) && vu.getVersionCode().equals(versionNum)) {
  59 + return ApplicationResponseVo.ApplicationResponseVoBuild().appNoUpdate(versionNum);
  60 + }
  61 + // 更新判断
  62 + return ApplicationResponseVo.ApplicationResponseVoBuild().appForceUpdate(vu.getVersionCode(), vu.getApkUrl());
  63 + }
  64 +
  65 + private ApplicationResponseVo getApplicationResponseVo(Integer versionNum) {
47 // 比对版本 需要更新 判断是否需要强制更新 66 // 比对版本 需要更新 判断是否需要强制更新
48 - VersionUpgrade vu = versionUpgradeMapper.queryLatestVersionNum(); 67 + VersionUpgrade vu = versionUpgradeMapper.queryLatestVersionNum(2);
49 // 无需更新 68 // 无需更新
50 - if (!Objects.isNull(vu) && vu.getVersionCode().equals(versionNum)){ 69 + if (!Objects.isNull(vu) && vu.getVersionCode().equals(versionNum)) {
51 return ApplicationResponseVo.ApplicationResponseVoBuild().appNoUpdate(versionNum); 70 return ApplicationResponseVo.ApplicationResponseVoBuild().appNoUpdate(versionNum);
52 } 71 }
53 // 更新判断 72 // 更新判断
54 - return ApplicationResponseVo.ApplicationResponseVoBuild().appForceUpdate(vu.getVersionCode(),vu.getApkUrl()); 73 + return ApplicationResponseVo.ApplicationResponseVoBuild().appForceUpdate(vu.getVersionCode(), vu.getApkUrl());
55 } 74 }
56 75
57 public void downloadApk(String url, HttpServletResponse response) throws IOException { 76 public void downloadApk(String url, HttpServletResponse response) throws IOException {
@@ -86,7 +105,7 @@ public class AppService { @@ -86,7 +105,7 @@ public class AppService {
86 105
87 private void checkFile(MultipartFile file) { 106 private void checkFile(MultipartFile file) {
88 107
89 - if (StringUtils.isEmpty(file.getOriginalFilename()) ){ 108 + if (StringUtils.isEmpty(file.getOriginalFilename())) {
90 throw new RuntimeException("不是apk文件请重新上传"); 109 throw new RuntimeException("不是apk文件请重新上传");
91 } 110 }
92 if (!file.getOriginalFilename().endsWith(".apk")) { 111 if (!file.getOriginalFilename().endsWith(".apk")) {
@@ -101,4 +120,26 @@ public class AppService { @@ -101,4 +120,26 @@ public class AppService {
101 equipment.setRemark("版本号:" + vo.getVersionNum()); 120 equipment.setRemark("版本号:" + vo.getVersionNum());
102 equipmentMapper.updateEquipmentByDeviceId(equipment); 121 equipmentMapper.updateEquipmentByDeviceId(equipment);
103 } 122 }
  123 +
  124 + public AjaxResult uploadApkOther(MultipartFile file) throws IOException {
  125 + // 校验文件
  126 + checkFile(file);
  127 + // 上传文件路径
  128 + String filePath = RuoYiConfig.getUploadPath() + apkPath + "/other";
  129 + // 上传并返回新文件名称
  130 + String fileName = "app.apk";
  131 + // 获取相对路径
  132 + String absPath = FileUploadUtils.getAbsoluteFile(filePath, fileName).getAbsolutePath();
  133 + // 上传文件
  134 + file.transferTo(Paths.get(absPath));
  135 + fileName = FileUploadUtils.getPathFileName(filePath, fileName);
  136 + // 返回url
  137 + String url = serverConfig.getUrl() + fileName;
  138 + AjaxResult ajax = AjaxResult.success();
  139 + ajax.put("url", url);
  140 + ajax.put("fileName", fileName);
  141 + ajax.put("newFileName", FileUtils.getName(fileName));
  142 + ajax.put("originalFilename", file.getOriginalFilename());
  143 + return ajax;
  144 + }
104 } 145 }
ruoyi-admin/src/main/java/com/ruoyi/upgrade/mapper/VersionUpgradeMapper.java
@@ -2,6 +2,7 @@ package com.ruoyi.upgrade.mapper; @@ -2,6 +2,7 @@ package com.ruoyi.upgrade.mapper;
2 2
3 import java.util.List; 3 import java.util.List;
4 import com.ruoyi.upgrade.domain.VersionUpgrade; 4 import com.ruoyi.upgrade.domain.VersionUpgrade;
  5 +import org.apache.ibatis.annotations.Param;
5 6
6 /** 7 /**
7 * upgradeMapper接口 8 * upgradeMapper接口
@@ -59,5 +60,10 @@ public interface VersionUpgradeMapper @@ -59,5 +60,10 @@ public interface VersionUpgradeMapper
59 */ 60 */
60 public int deleteVersionUpgradeByIds(String[] ids); 61 public int deleteVersionUpgradeByIds(String[] ids);
61 62
62 - VersionUpgrade queryLatestVersionNum(); 63 + /**
  64 + * 获取appurl
  65 + * @param appType
  66 + * @return
  67 + */
  68 + VersionUpgrade queryLatestVersionNum(@Param("appType") Integer appType);
63 } 69 }
ruoyi-admin/src/main/resources/mapper/upgrade/VersionUpgradeMapper.xml
@@ -42,6 +42,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -42,6 +42,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
42 </select> 42 </select>
43 <select id="queryLatestVersionNum" resultType="com.ruoyi.upgrade.domain.VersionUpgrade"> 43 <select id="queryLatestVersionNum" resultType="com.ruoyi.upgrade.domain.VersionUpgrade">
44 <include refid="selectVersionUpgradeVo"></include> 44 <include refid="selectVersionUpgradeVo"></include>
  45 + where app_id = #{appType}
45 order by version_code desc 46 order by version_code desc
46 limit 1 47 limit 1
47 </select> 48 </select>