From 25b19e60e004290531f61fdf608d1adb5e531903 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期六, 12 七月 2025 14:40:12 +0800 Subject: [PATCH] 保洁巡检本周代码 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTemplateController.java | 58 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 42 insertions(+), 16 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTemplateController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTemplateController.java index 19ab507..a2ff1c3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTemplateController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTemplateController.java @@ -53,6 +53,7 @@ + @ApiOperation(value = "任务模板分页列表") @PostMapping(value = "/pageList") public R<PageInfo<TemplateListVO>> pageList(@RequestBody TemplateListQuery query) { @@ -103,6 +104,10 @@ templateService.updateById(dto); templateDetailService.remove(new LambdaQueryWrapper<TTemplateDetail>() .eq(TTemplateDetail::getTemplateId, dto.getId())); + for (TTemplateDetail tTemplateDetail : dto.getList()) { + tTemplateDetail.setTemplateId(dto.getId()); + tTemplateDetail.setId(null); + } templateDetailService.saveBatch(dto.getList()); // 先删除定时任务 @@ -131,6 +136,13 @@ templateService.removeBatchByIds(Arrays.asList(split)); return R.ok(); } + @ApiOperation(value = "根据模板id查询角色") + @DeleteMapping(value = "/getRoleByTemplateId") + public R<SysRole> getRoleByTemplateId(@RequestParam String id) { + TTemplate template = templateService.getById(id); + SysRole sysRole = sysRoleService.selectRoleById(template.getRoleId()); + return R.ok(sysRole); + } @ApiOperation(value = "详情任务模板") @GetMapping(value = "/detail") public R<TemplateDetailVO> detail(@RequestParam String id) { @@ -140,29 +152,43 @@ .list(); BeanUtils.copyProperties(byId,templateDetailVO); List<String> collect = tLocationTypeService.list().stream().map(TLocationType::getId).collect(Collectors.toList()); - + JSONArray res = new JSONArray(); + for (String s : collect) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id",s); + jsonObject.put("value",""); + res.add(jsonObject); + } for (TTemplateDetail tTemplateDetail : list) { - JSONArray res = new JSONArray(); - for (String s : collect) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("id",s); - jsonObject.put("value",""); - res.add(jsonObject); - } + JSONArray temp = new JSONArray(); String num4 = tTemplateDetail.getNum4(); JSONArray num5Array = JSONArray.parseArray(num4); - for (Object o : num5Array) { - JSONObject jsonObject1 = (JSONObject) o; - String string = jsonObject1.getString("id"); - // 如果res中有这个id,则设置num - for (Object re : res) { - JSONObject jsonObject2 = (JSONObject) re; + for (Object re : res) { + JSONObject jsonObject2 = (JSONObject) re; + int i = 0; + for (Object o : num5Array) { + JSONObject jsonObject1 = (JSONObject) o; + String string = jsonObject1.getString("id"); + // 如果res中有这个id,则设置num if (jsonObject2.getString("id").equals(string)) { - jsonObject2.put("num", jsonObject1.getString("num")); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id",string); + jsonObject.put("value", jsonObject1.getString("value")); + temp.add(jsonObject); + break; + } + i++; + if (i==num5Array.size()){ + JSONObject jsonObject = new JSONObject(); + jsonObject.put("id",string); + jsonObject.put("value", ""); + temp.add(jsonObject); } } + } - tTemplateDetail.setNum4(res.toJSONString()); + + tTemplateDetail.setNum4(temp.toJSONString()); } if (byId.getRoleId()!=null){ SysRole sysRole = sysRoleService.selectRoleById(byId.getRoleId()); -- Gitblit v1.7.1