无关风月
2025-06-26 e6fac7e481db2795e46685446968b7b6a36eece8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TTemplateController.java
@@ -58,6 +58,11 @@
    public R<PageInfo<TemplateListVO>> pageList(@RequestBody TemplateListQuery query) {
        return R.ok(templateService.pageList(query));
    }
    @ApiOperation(value = "任务模板不分页列表")
    @PostMapping(value = "/listAllTemplate")
    public R<List<TTemplate>> listAllTemplate() {
        return R.ok(templateService.list());
    }
    @ApiOperation(value = "点位类型不分页列表")
    @PostMapping(value = "/listAll")
    public R<List<TLocationType>> pageList() {
@@ -98,6 +103,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());
        // 先删除定时任务
@@ -135,30 +144,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();
            JSONObject jsonObject = JSONObject.parseObject(num4);
            JSONArray num5Array = jsonObject.getJSONArray("num5");
            for (Object o : num5Array) {
                JSONObject jsonObject1 = (JSONObject) o;
                String string = jsonObject1.getString("id");
                // 如果res中有这个id,则设置num
                for (Object re : res) {
                    JSONObject jsonObject2 = (JSONObject) re;
            JSONArray num5Array = JSONArray.parseArray(num4);
            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());