From b23c06c4cda5f5feda099c6906176e1311815852 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期四, 03 七月 2025 21:36:44 +0800 Subject: [PATCH] bug修改 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java | 48 +++++++++++++++++++++++++++++++++--------------- 1 files changed, 33 insertions(+), 15 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java index bc9e42e..62b0083 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java @@ -55,12 +55,13 @@ private ISysUserService sysUserService; @Autowired private TTaskCleanService taskCleanService; + @Autowired + private TTemplateCountService templateCountService; // 每一个小时执行一次 // @Scheduled(cron = "0 0 0 * * ?") @Scheduled(fixedRate = 1500000000) - public void dayOfCreateInspection() { try { @@ -80,8 +81,6 @@ } public void createInspection(TTemplate template) { - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - Date date = new Date(); // 查询所有的模板详情 List<TTemplateDetail> list = templateDetailService.list(Wrappers.lambdaQuery(TTemplateDetail.class) .eq(TTemplateDetail::getTemplateId, template.getId())); @@ -118,20 +117,36 @@ // 获取点位类型的占比 String num4 = detail.getNum4(); + SysUser sysUser = sysUsers.get(0); + List<TProjectDept> projectDeptLists = new ArrayList<>(); + if(sysUser.getDeptType() == 1){ + TProjectDept projectDept = projectDeptService.getById(sysUser.getDeptId()); + if("0".equals(projectDept.getParentId())){ + projectDeptLists = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class) + .eq(TProjectDept::getParentId, projectDept.getId())); + }else { + projectDeptLists.add(projectDept); + } + }else { + projectDeptLists = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class) + .ne(TProjectDept::getParentId,0)); + } + List<String> proDeptIds = projectDeptLists.stream().map(TProjectDept::getId).collect(Collectors.toList()); + // 获取项目部在该模板详情中的权重 List<String> projectDeptIds = redisCache.getCacheList(detail.getId() + PROJECT_DEPT_WEIGHT); // 获取项目部列表 List<TProjectDept> projectDeptList; if(CollectionUtils.isEmpty(projectDeptIds)){ - projectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class) - .ne(TProjectDept::getParentId,0)); + projectDeptList = projectDeptLists; }else { projectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class) .ne(TProjectDept::getParentId,0) - .in(TProjectDept::getId, projectDeptIds)); + .in(TProjectDept::getId, proDeptIds) + .notIn(TProjectDept::getId, projectDeptIds)); // 所过所有的项目部都被抽取了,则重新抽取,并且清空项目部权重 if(CollectionUtils.isEmpty(projectDeptList)){ - projectDeptList = projectDeptService.list(Wrappers.lambdaQuery(TProjectDept.class)); + projectDeptList = projectDeptLists; redisCache.deleteObject(detail.getId() + PROJECT_DEPT_WEIGHT); } } @@ -215,8 +230,6 @@ List<TLocation> locationList = locationService.list(Wrappers.lambdaQuery(TLocation.class) .in(TLocation::getLocationCleaner, cleanersIds)); // 查询点位类型 -// List<TLocationType> locationTypes = locationTypeService.list(Wrappers.lambdaQuery(TLocationType.class) -// .orderByDesc(TLocationType::getCreateTime)); JSONArray jsonArray = JSONObject.parseArray(num4); List<TLocation> tLocationList = new ArrayList<>(); for (Object o : jsonArray) { @@ -265,12 +278,9 @@ task.setCleanerId(tCleaner.getId()); }); // 获取巡检员 - if(!CollectionUtils.isEmpty(sysUsers)){ - SysUser sysUser = sysUsers.get(0); - task.setPatrolInspector(sysUser.getUserId().toString()); - task.setPatrolInspectorDept(sysUser.getDeptId()); - task.setUserId(sysUser.getUserId()); - } + task.setPatrolInspector(sysUser.getUserId().toString()); + task.setPatrolInspectorDept(sysUser.getDeptId()); + task.setUserId(sysUser.getUserId()); task.setStatus(1); task.setLocationId(tLocation.getId()); task.setImplementTime(LocalDateTime.now().plusDays(1)); @@ -281,6 +291,14 @@ task.setTaskCode(nameAndCode); tasks.add(task); } + + // 添加应生成任务数量 + TTemplateCount templateCount = new TTemplateCount(); + templateCount.setTemplateId(detail.getId()); + templateCount.setTaskCount(tLocationList.size()* cycle); + templateCount.setUserId(sysUser.getUserId()); + templateCountService.saveOrUpdate(templateCount); + taskCleanService.saveBatch(tasks); template.setTaskCount(tasks.size()); templateService.updateById(template); -- Gitblit v1.7.1