diff --git a/cxxm/src/main/java/com/ruoyi/cxxm/controller/TaskCheckController.java b/cxxm/src/main/java/com/ruoyi/cxxm/controller/TaskCheckController.java index b47fbbf6..932d4066 100644 --- a/cxxm/src/main/java/com/ruoyi/cxxm/controller/TaskCheckController.java +++ b/cxxm/src/main/java/com/ruoyi/cxxm/controller/TaskCheckController.java @@ -16,11 +16,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.cxxm.domain.*; import com.ruoyi.cxxm.domain.dto.TaskCheckSubmit; import com.ruoyi.cxxm.domain.vo.TaskCheckSubmitVo; import com.ruoyi.cxxm.domain.vo.app.AppTaskCheckListItem; +import com.ruoyi.cxxm.mapper.TaskCheckMapper; import com.ruoyi.cxxm.service.*; import org.springframework.beans.BeanUtils; import org.springframework.security.access.prepost.PreAuthorize; @@ -52,6 +54,8 @@ public class TaskCheckController extends BaseController { private ITbxxService tbxxService; @Autowired private ITaskCheckAuditService taskCheckAuditService; + @Autowired + private TaskCheckMapper taskCheckMapper; /** * 查询任务巡查记录列表 @@ -140,7 +144,7 @@ public class TaskCheckController extends BaseController { /** * 查询用户提交的填报记录列表 * - * @param taskCheck 包含查询条件的任务检查实体 + * @param taskCheck 包含查询条件的任务检查实体 * @param pageDomain 分页参数 * @return TableDataInfo 包含分页数据的表格信息 */ @@ -149,13 +153,21 @@ public class TaskCheckController extends BaseController { public TableDataInfo submittedList(TaskCheck taskCheck, PageDomain pageDomain) { // 初始化分页信息 Page page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize()); - // 构建查询条件,查询当前用户提交的记录,并按记录ID倒序排列 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(TaskCheck::getXcryId, SecurityUtils.getUserId()); - queryWrapper.orderByDesc(TaskCheck::getId); - // 执行查询 - Page taskCheckPage = taskCheckService.page(page, queryWrapper); + // 构建查询条件,查询当前用户提交的记录,并按记录ID倒序排列 +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(TaskCheck::getXcryId, SecurityUtils.getUserId()); +// queryWrapper.orderByDesc(TaskCheck::getId); + // 联表查询task表添加rwlx条件 + MPJLambdaWrapper tcMPJQueryWrapper = new MPJLambdaWrapper() + .selectAll(TaskCheck.class) + .select(Task::getRwlx) + .leftJoin(Task.class, Task::getId,TaskCheck::getTaskId) + .eq(TaskCheck::getXcryId, SecurityUtils.getUserId()) + .eq(Objects.nonNull(taskCheck.getRwlx()), Task::getRwlx, taskCheck.getRwlx()); + // 执行查询 + // Page taskCheckPage = taskCheckService.page(page, queryWrapper); + Page taskCheckPage = taskCheckMapper.selectJoinPage(page, TaskCheck.class, tcMPJQueryWrapper); // 遍历查询结果,转换为前端需要的格式 ArrayList tcList = new ArrayList<>(); for (TaskCheck item : taskCheckPage.getRecords()) { @@ -188,7 +200,7 @@ public class TaskCheckController extends BaseController { } // 返回处理后的分页数据 - return getDataTableByPageNewList(taskCheckPage,tcList); + return getDataTableByPageNewList(taskCheckPage, tcList); } } diff --git a/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppTypeController.java b/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppTypeController.java index 515bb4fa..1a46009c 100644 --- a/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppTypeController.java +++ b/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppTypeController.java @@ -5,6 +5,7 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.cxxm.domain.vo.app.AppTypeVo; import com.ruoyi.cxxm.mapper.AppTypeMapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; + @RestController @RequestMapping("/cxxm/app/type") public class AppTypeController extends BaseController { @@ -30,6 +32,7 @@ public class AppTypeController extends BaseController { // 构建查询条件,查询字典类型为"task_lx"的任务类型信息 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(AppTypeVo::getDictType,"task_lx"); + queryWrapper.orderByAsc(AppTypeVo::getSort); // 根据查询条件查询任务类型列表 List appTypeVos = appTypeMapper.selectList(queryWrapper); // 将查询结果转换为数据表格格式返回 diff --git a/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppVersionController.java b/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppVersionController.java index 1adbc7c7..43989b6d 100644 --- a/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppVersionController.java +++ b/cxxm/src/main/java/com/ruoyi/cxxm/controller/app/AppVersionController.java @@ -1,22 +1,25 @@ package com.ruoyi.cxxm.controller.app; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; -import com.ruoyi.common.core.page.PageDomain; -import com.ruoyi.common.core.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.poi.ExcelUtil; + +import com.ruoyi.common.core.text.StrFormatter; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.cxxm.domain.AppVersion; import com.ruoyi.cxxm.service.IAppVersionService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.util.List; +import java.net.UnknownHostException; /** * app版本Controller @@ -24,45 +27,93 @@ import java.util.List; * @author jian * @date 2024-04-11 */ +@Slf4j @RestController @RequestMapping("/cxxm/version") -public class AppVersionController extends BaseController -{ +public class AppVersionController extends BaseController { + @Autowired private IAppVersionService appVersionService; + @Autowired + private Environment environment; -/** - * 检查是否有新版本可用 - * - * @param currentVersion 当前应用的版本号,格式为X.Y.Z(数字表示) - * @return 返回新版本的信息或错误消息。如果成功查询到新版本,则返回新版本的信息;如果查询不到新版本或出现错误,则返回错误消息。 - */ -@GetMapping("/check") -public AjaxResult check(String currentVersion) { - // 验证传入的当前版本号是否为空或格式不正确 - if (currentVersion == null || currentVersion.isEmpty() || !currentVersion.matches("\\d+\\.\\d+\\.\\d+")) { - return AjaxResult.error("当前版本格式不正确或不能为空"); + /** + * 检查是否有新版本可用 + * + * @param currentVersion 当前应用的版本号,格式为X.Y.Z(数字表示) + * @return 返回新版本的信息或错误消息。如果成功查询到新版本,则返回新版本的信息;如果查询不到新版本或出现错误,则返回错误消息。 + */ + @GetMapping("/check") + public AjaxResult check(String currentVersion) { + // 验证传入的当前版本号是否为空或格式不正确 + if (currentVersion == null || currentVersion.isEmpty() || !currentVersion.matches("\\d+\\.\\d+\\.\\d+")) { + return AjaxResult.error("当前版本格式不正确或不能为空"); + } + // 构建查询条件,查询比当前版本号大的且标记为需要更新的最新版本 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.gt(AppVersion::getNewVersion, currentVersion); + queryWrapper.eq(AppVersion::getIsUpdate, "Y"); + queryWrapper.orderByDesc(AppVersion::getId); + queryWrapper.last("limit 1"); + try { + AppVersion appVersion = appVersionService.getOne(queryWrapper); + // 判断是否查询到新版本,若查询到则返回新版本信息,否则返回当前已是最新版本的消息 + if (appVersion != null) { + return AjaxResult.success(appVersion); + } else { + return AjaxResult.success("当前已经是最新版本"); + } + } catch (Exception e) { + // 捕获查询过程中的异常,返回查询失败的消息 + return AjaxResult.error("查询最新版本信息失败,请稍后重试"); + } } - // 构建查询条件,查询比当前版本号大的且标记为需要更新的最新版本 - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.gt(AppVersion::getNewVersion, currentVersion); - queryWrapper.eq(AppVersion::getIsUpdate, "Y"); - queryWrapper.orderByDesc(AppVersion::getId); - queryWrapper.last("limit 1"); - try { + + @GetMapping("/checkLastVersion") + public String checkLastVersion() throws UnknownHostException { + // 构建查询条件,查询比当前版本号大的且标记为需要更新的最新版本 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AppVersion::getIsUpdate, "Y"); + queryWrapper.orderByDesc(AppVersion::getId); + queryWrapper.last("limit 1"); AppVersion appVersion = appVersionService.getOne(queryWrapper); // 判断是否查询到新版本,若查询到则返回新版本信息,否则返回当前已是最新版本的消息 - if (appVersion != null) { - return AjaxResult.success(appVersion); - } else { - return AjaxResult.success("当前已经是最新版本"); - } - } catch (Exception e) { - // 捕获查询过程中的异常,返回查询失败的消息 - return AjaxResult.error("查询最新版本信息失败,请稍后重试"); + return StrFormatter.format("http://116.63.157.3:8069/prod-api{}", appVersion.getApkUrl()); } -} + @GetMapping("/checkLastVersion2") + public void checkLastVersion2(HttpServletRequest request, HttpServletResponse response) throws Exception { + // 构建查询条件,查询比当前版本号大的且标记为需要更新的最新版本 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AppVersion::getIsUpdate, "Y"); + queryWrapper.orderByDesc(AppVersion::getId); + queryWrapper.last("limit 1"); + AppVersion appVersion = appVersionService.getOne(queryWrapper); + resourceDownload(appVersion.getApkUrl(), request, response); + } + + public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) + throws Exception { + try { + if (!FileUtils.checkAllowDownload(resource)) { + throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource)); + } + // 本地资源路径 + String localPath = RuoYiConfig.getProfile(); + // 数据库资源地址 + String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX); + // 下载名称 + String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); + response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); + FileUtils.setAttachmentResponseHeader(response, downloadName); + FileUtils.writeBytes(downloadPath, response.getOutputStream()); + } catch (Exception e) { + log.error("下载文件失败", e); + } + } } + + + diff --git a/cxxm/src/main/java/com/ruoyi/cxxm/domain/TaskCheck.java b/cxxm/src/main/java/com/ruoyi/cxxm/domain/TaskCheck.java index b09e0e69..117ec55c 100644 --- a/cxxm/src/main/java/com/ruoyi/cxxm/domain/TaskCheck.java +++ b/cxxm/src/main/java/com/ruoyi/cxxm/domain/TaskCheck.java @@ -2,7 +2,9 @@ package com.ruoyi.cxxm.domain; import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.ruoyi.common.annotation.Excel; @@ -83,5 +85,11 @@ public class TaskCheck extends BaseEntity { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @Excel(name = "巡查时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date xcsj; + + /** + * 任务类型 + */ + @TableField(exist = false) + private String rwlx; } diff --git a/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskCheckMapper.java b/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskCheckMapper.java index 7307c150..5ddc6ca1 100644 --- a/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskCheckMapper.java +++ b/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskCheckMapper.java @@ -1,6 +1,7 @@ package com.ruoyi.cxxm.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.github.yulichang.base.MPJBaseMapper; import com.ruoyi.cxxm.domain.TaskCheck; /** @@ -9,7 +10,7 @@ import com.ruoyi.cxxm.domain.TaskCheck; * @author ruoyi * @date 2024-03-28 */ -public interface TaskCheckMapper extends BaseMapper { +public interface TaskCheckMapper extends MPJBaseMapper { } diff --git a/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskMapper.java b/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskMapper.java index c12503ba..c98eb9bf 100644 --- a/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskMapper.java +++ b/cxxm/src/main/java/com/ruoyi/cxxm/mapper/TaskMapper.java @@ -2,6 +2,7 @@ package com.ruoyi.cxxm.mapper; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.github.yulichang.base.MPJBaseMapper; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.cxxm.domain.Task; import org.apache.ibatis.annotations.Param; @@ -15,7 +16,7 @@ import java.util.List; * @author ruoyi * @date 2024-03-28 */ -public interface TaskMapper extends BaseMapper { +public interface TaskMapper extends MPJBaseMapper { /** * 查询任务列表--保留数据权限 * @param queryWrapper diff --git a/cxxm/src/main/java/com/ruoyi/cxxm/service/impl/TaskCheckServiceImpl.java b/cxxm/src/main/java/com/ruoyi/cxxm/service/impl/TaskCheckServiceImpl.java index 22fc360c..e5c05009 100644 --- a/cxxm/src/main/java/com/ruoyi/cxxm/service/impl/TaskCheckServiceImpl.java +++ b/cxxm/src/main/java/com/ruoyi/cxxm/service/impl/TaskCheckServiceImpl.java @@ -340,6 +340,9 @@ public class TaskCheckServiceImpl extends ServiceImpl().eq(TaskCheckAudit::getTcId, tcId)); + if (Objects.nonNull(tcCheckAudit)) { + if (Objects.equals(tcCheckAudit.getShjg(), SHJG.TRUE.getValue()) || Objects.equals(tcCheckAudit.getShjg(), SHJG.FALSE.getValue())) { + throw new RuntimeException("该任务已审核,无法取消上报!"); + } } // 更新任务检查信息为已上报 taskCheck.setId(tcId); @@ -581,7 +585,6 @@ public class TaskCheckServiceImpl extends ServiceImpl -

{{ title }}

+
-

{{ title }}

+
@@ -78,7 +78,7 @@ export default { color: #fff; font-weight: 600; line-height: 50px; - font-size: 14px; + font-size: 15px; font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif; vertical-align: middle; } diff --git a/ruoyi-ui/src/views/cxxm/task/check/detail.vue b/ruoyi-ui/src/views/cxxm/task/check/detail.vue index b6214e67..3f3415e9 100644 --- a/ruoyi-ui/src/views/cxxm/task/check/detail.vue +++ b/ruoyi-ui/src/views/cxxm/task/check/detail.vue @@ -27,10 +27,10 @@ {{ form.taskCheckStatistics.wzgcs }}次 - + {{ form.taskCheckStatistics.wzgdwcs }}次 - + {{ form.taskCheckStatistics.yzgcs }}次 diff --git a/ruoyi-ui/src/views/cxxm/task/check/index.vue b/ruoyi-ui/src/views/cxxm/task/check/index.vue index 76f13fe9..7e145ef7 100644 --- a/ruoyi-ui/src/views/cxxm/task/check/index.vue +++ b/ruoyi-ui/src/views/cxxm/task/check/index.vue @@ -76,16 +76,16 @@ - + - - - - + + + + - +