| | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.google.common.collect.ImmutableMap; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | |
| | | import com.ruoyi.system.model.TTemplateDetail; |
| | | import com.ruoyi.system.query.TemplateListQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.task.base.QuartzManager; |
| | | import com.ruoyi.system.task.base.TimeJobType; |
| | | import com.ruoyi.system.task.jobs.CreateInspectionJob; |
| | | import com.ruoyi.system.vo.system.TemplateDetailVO; |
| | | import com.ruoyi.system.vo.system.TemplateListVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "任务模板分页列表") |
| | | @PostMapping(value = "/pageList") |
| | | 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") |
| | |
| | | tTemplateDetail.setTemplateId(dto.getId()); |
| | | } |
| | | templateDetailService.saveBatch(list); |
| | | |
| | | // 计算定时任务时间周期 |
| | | |
| | | // 添加定时任务 |
| | | // Map<String, ? extends Object> maps = |
| | | // new ImmutableMap.Builder<String, String>(). |
| | | // put("id", dto.getId()) |
| | | // .build(); |
| | | // QuartzManager.addJob( |
| | | // CreateInspectionJob.class, |
| | | // (CreateInspectionJob.name+dto.getId()).toUpperCase(), |
| | | // TimeJobType.CREATE_INSPECTION, |
| | | // new Date(new Date().getTime()+48*60*60*1000L), |
| | | // maps |
| | | // ); |
| | | |
| | | return R.ok(); |
| | | } |
| | | @Log(title = "编辑任务模板", businessType = BusinessType.UPDATE) |
| | |
| | | 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()); |
| | | |
| | | // 先删除定时任务 |
| | | // QuartzManager.removeJob((CreateInspectionJob.name+dto.getId()).toUpperCase(),TimeJobType.CREATE_INSPECTION); |
| | | |
| | | // 添加定时任务 |
| | | // Map<String, ? extends Object> maps = |
| | | // new ImmutableMap.Builder<String, String>(). |
| | | // put("id", dto.getId()) |
| | | // .build(); |
| | | // QuartzManager.addJob( |
| | | // CreateInspectionJob.class, |
| | | // (CreateInspectionJob.name+dto.getId()).toUpperCase(), |
| | | // TimeJobType.CREATE_INSPECTION, |
| | | // new Date(new Date().getTime()+48*60*60*1000L), |
| | | // maps |
| | | // ); |
| | | |
| | | return R.ok(); |
| | | } |
| | | @Log(title = "批量删除任务模板", businessType = BusinessType.DELETE) |
| | |
| | | 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) { |
| | |
| | | .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()); |