From 18928deb2e6572c37e10db841a7381482c08d54c Mon Sep 17 00:00:00 2001 From: zhanyunjiu <787952492@qq.com> Date: Wed, 27 Jul 2022 19:01:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/farm/enums/ErrorCodeConstants.java | 1 - .../farm/controller/admin/TestController.java | 2 +- .../admin/event/EventController.java | 2 - .../admin/resource/vo/ResourceBaseVO.java | 2 +- .../admin/resource/vo/ResourceExcelVO.java | 2 +- .../resource/vo/ResourceExportReqVO.java | 2 +- .../admin/resource/vo/ResourcePageReqVO.java | 2 +- .../controller/admin/task/TaskController.java | 62 ++++++------- .../dal/dataobject/resource/ResourceDO.java | 2 +- .../farm/service/area/AreaServiceImpl.java | 6 +- .../service/project/ProjectServiceImpl.java | 86 ++++++++++++------- .../module/farm/service/task/TaskService.java | 7 -- .../farm/service/task/TaskServiceImpl.java | 18 ++-- .../service/event/EventServiceImplTest.java | 5 -- 14 files changed, 98 insertions(+), 101 deletions(-) diff --git a/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java index bd8af17f..59f53b4b 100644 --- a/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java +++ b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java @@ -64,7 +64,6 @@ public interface ErrorCodeConstants{ ErrorCode EXECUTE_TIME_IS_BEFORE_TODAY = new ErrorCode(100000729, "执行时间不能在今天之前,操作失败"); - ErrorCode GROW_SEED_TIME_IS_BEFORE_TODAY = new ErrorCode(100000730, "项目育苗时间不能在今天之前"); } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/TestController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/TestController.java index 2ccd567e..91cbfa8b 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/TestController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/TestController.java @@ -55,7 +55,7 @@ public class TestController { public void toErpMaterial(){ IntoStockMaterialDTO intoStock = IntoStockMaterialDTO.builder() .wareHouseId("1546738475384201217") - .materialId("1544629335014780930") + .materialId("1552190579234119681") .num(new BigDecimal(100)) .price(BigDecimal.ZERO) .build(); diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/event/EventController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/event/EventController.java index 339ee002..b7449e4a 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/event/EventController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/event/EventController.java @@ -6,10 +6,8 @@ import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; import io.swagger.annotations.*; -import javax.validation.constraints.*; import javax.validation.*; import javax.servlet.http.*; -import java.awt.*; import java.util.*; import java.io.IOException; import java.util.List; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java index bbe81af5..bfd57367 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java @@ -48,7 +48,7 @@ public class ResourceBaseVO { private String unit; - private Integer number; + private Double number; @ApiModelProperty("是否占用") private Boolean occupied; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java index 15b2b086..33cba134 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java @@ -48,7 +48,7 @@ public class ResourceExcelVO { private String unit; - private Integer number; + private Double number; @ExcelProperty("是否占用") private Boolean occupied; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java index 2c28b73a..c34269b0 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java @@ -60,7 +60,7 @@ public class ResourceExportReqVO { private String unit; - private Integer number; + private Double number; @ApiModelProperty("是否占用") private Boolean occupied; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java index e29b9fd7..72889ce6 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java @@ -65,7 +65,7 @@ public class ResourcePageReqVO extends PageParam { private String unit; - private Integer number; + private Double number; @ApiModelProperty("是否占用") private Boolean occupied; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java index aef21187..9b7821c6 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java @@ -1,38 +1,37 @@ package cn.iocoder.yudao.module.farm.controller.admin.task; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.util.NumberUtil; -import cn.iocoder.yudao.framework.common.page.PageVO; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.farm.annotation.FarmMsg; import cn.iocoder.yudao.module.farm.annotation.FarmMsgTypeEnum; -import cn.iocoder.yudao.module.farm.controller.admin.task.dto.*; +import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskAssemblyDTO; +import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskDetailDTO; +import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskSummaryDTO; +import cn.iocoder.yudao.module.farm.controller.admin.task.vo.*; +import cn.iocoder.yudao.module.farm.convert.task.TaskConvert; +import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; +import cn.iocoder.yudao.module.farm.service.task.TaskService; import com.zsw.base.R; -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.annotations.*; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Map; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - -import cn.iocoder.yudao.module.farm.controller.admin.task.vo.*; -import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; -import cn.iocoder.yudao.module.farm.convert.task.TaskConvert; -import cn.iocoder.yudao.module.farm.service.task.TaskService; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @Api(tags = "管理后台 - 任务管理") @RestController @@ -95,9 +94,7 @@ public class TaskController { @PreAuthorize("@ss.hasPermission('farm:task:query')") public CommonResult> getTaskPage(@Valid TaskPageReqVO pageVO) { PageResult pageResult = taskService.getTaskPage(pageVO); -// PageResult rs = TaskConvert.INSTANCE.convertPage(pageResult); - CommonResult> s1 = success(pageResult); - return s1; + return success(pageResult); } @GetMapping("/apiPage") @@ -120,7 +117,6 @@ public class TaskController { ExcelUtils.write(response, "农场项目.xls", "数据", TaskExcelVO.class, datas); } - @GetMapping("/appGet") @ApiOperation("APP查看农场任务详情") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @@ -129,14 +125,6 @@ public class TaskController { return taskService.appGetTask(id); } - - @PostMapping("/apiPage") - @ApiOperation("获得农场项目分页") - @PreAuthorize("@ss.hasPermission('farm:task:query')") - public R> apiGetTaskPage(@RequestBody TaskPageDTO pageDTO) { - return taskService.apiGetTaskPage(pageDTO); - } - @GetMapping("/taskSummary") @ApiOperation("任务汇总") @PreAuthorize("@ss.hasPermission('farm:task:query')") @@ -144,8 +132,6 @@ public class TaskController { return R.success(taskService.taskSummary()); } - - @GetMapping("/whatDayHaveTask") @ApiOperation("有任务的日期") public R>> whatDayHaveTask(@RequestParam(value = "projectId", required = false) Long projectId){ diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java index 00ac8a99..85893fce 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java @@ -76,7 +76,7 @@ public class ResourceDO extends BaseDO { private String unit; @ApiModelProperty("数量") - private Integer number; + private Double number; @ApiModelProperty("是否占用") private Boolean occupied; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java index b51c2935..dd212e04 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java @@ -16,7 +16,10 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -152,7 +155,6 @@ public class AreaServiceImpl implements AreaService { updateList.forEach(update ->{ areaMapper.updateById(update); }); - } /** diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java index d96b2c29..0b561048 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.page.PageVO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.vo.*; @@ -32,12 +33,14 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zsw.base.R; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -76,10 +79,10 @@ public class ProjectServiceImpl implements ProjectService { public Long createProject(ProjectCreateReqVO createReqVO) { // 插入 ProjectDO project = ProjectConvert.INSTANCE.convert(createReqVO); - //设置项目状态 + //根据育苗时间设置项目状态 this.checkStateByTime(project); //检查项目新增、修改时的区域 是否能够使用 - this.checkProjectAreas(BeanUtil.copyProperties(createReqVO, ProjectDO.class)); + this.checkProjectAreas(project); project.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId()); projectMapper.insert(project); // 返回 @@ -91,18 +94,18 @@ public class ProjectServiceImpl implements ProjectService { public void updateProject(ProjectUpdateReqVO updateReqVO) { // 校验存在 this.validateProjectExists(updateReqVO.getId()); - //检查项目状态 - this.checkProjectStatus(updateReqVO); + ProjectDO updateObj = ProjectConvert.INSTANCE.convert(updateReqVO); + //根据育苗时间设置项目状态 + this.checkStateByTime(updateObj); + //检查项目对应状态下 信息能否修改 + this.checkProjectStatus(updateObj); //检查项目新增、修改时的区域 是否能够使用 - this.checkProjectAreas(BeanUtil.copyProperties(updateReqVO, ProjectDO.class)); + this.checkProjectAreas(updateObj); //项目修改完成时,,项目下有一个以上任务未完成,改项就不能更改为完成 //如果项目可以更改成完成状态 释放占用区域 - if (updateReqVO.getState().equals(ProjectStateEnum.FINISH)){ - this.checkProjectTaskFinish(updateReqVO); + if (updateObj.getState().equals(ProjectStateEnum.FINISH)){ + this.checkProjectTaskFinish(updateObj); } - - // 更新 - ProjectDO updateObj = ProjectConvert.INSTANCE.convert(updateReqVO); projectMapper.updateById(updateObj); } @@ -180,7 +183,7 @@ public class ProjectServiceImpl implements ProjectService { LambdaQueryWrapperX queryWrapperX = this.miniProjectListQuery(pageDTO); List list = projectMapper.selectPage(pageDTO, queryWrapperX).getList(); if (ObjectUtil.isEmpty(list)){ - return R.success(new PageVO()); + return R.success(new PageVO().setList(new ArrayList<>())); } //小程序项目列表数据展示信息组装 PageVO returnList = this.miniProjectListAssemble(list); @@ -192,6 +195,17 @@ public class ProjectServiceImpl implements ProjectService { */ private LambdaQueryWrapperX miniProjectListQuery(ProjectPageDTO pageDTO){ LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); + //根据作物名查找 + if (ObjectUtil.isNotEmpty(pageDTO.getCropName())){ + List cropList = cropMapper.selectList(Wrappers.lambdaQuery().like(CropDO::getName, pageDTO.getCropName())); + if (cropList.size() != 0){ + List cropIdList = cropList.stream().map(CropDO::getId).collect(Collectors.toList()); + queryWrapperX.in(ProjectDO::getCropId, cropIdList); + }else{ + // 作物名查找未找到 给个不可能查到的cropId 直接返回 + return queryWrapperX.eq(ProjectDO::getCropId, 99999L); + } + } queryWrapperX.eqIfPresent(ProjectDO::getState, pageDTO.getState()); queryWrapperX.likeIfPresent(ProjectDO::getName, pageDTO.getProjectName()); queryWrapperX.eq(ProjectDO::getPretendDelete, false); @@ -212,13 +226,7 @@ public class ProjectServiceImpl implements ProjectService { queryWrapperX.apply(" ((JSON_CONTAINS(members, '"+ user.getId()+"') or creator = " + getLoginUserId() +"))"); } } - if (ObjectUtil.isNotEmpty(pageDTO.getCropName())){ - List cropList = cropMapper.selectList(Wrappers.lambdaQuery().like(CropDO::getName, pageDTO.getCropName())); - if (cropList.size() != 0){ - List cropIdList = cropList.stream().map(CropDO::getId).collect(Collectors.toList()); - queryWrapperX.in(ProjectDO::getCropId, cropIdList); - } - } + //根据区域id展示 if (ObjectUtil.isNotEmpty(pageDTO.getAreaId())){ List allAreaList = areaService.getAreaAndSubArea(pageDTO.getAreaId()); @@ -297,9 +305,9 @@ public class ProjectServiceImpl implements ProjectService { /** * 检查项目下所有任务是否完成 */ - public void checkProjectTaskFinish(ProjectUpdateReqVO updateReqVO){ + public void checkProjectTaskFinish(ProjectDO updateObj){ List taskList = taskMapper.selectList(Wrappers.lambdaQuery() - .eq(TaskDO::getProjectId, updateReqVO.getId()) + .eq(TaskDO::getProjectId, updateObj.getId()) .eq(TaskDO::getPretendDelete, false) .eq(TaskDO::getDraft, false) .ne(TaskDO::getStatus, TaskStatus.COMPLETE) @@ -309,12 +317,11 @@ public class ProjectServiceImpl implements ProjectService { } //释放区域占用 - List areaList = areaService.getAreaList(updateReqVO.getAreas()); + List areaList = areaService.getAreaList(updateObj.getAreas()); areaList.forEach(item -> { - item.setOccupied(false); - areaMapper.updateById(item); - } - ); + item.setOccupied(false); + areaMapper.updateById(item); + }); //检查区域占用状态 比如二级区域全部占用 对应一级区域变成占用 areaService.checkAreaOccupied(); } @@ -340,18 +347,18 @@ public class ProjectServiceImpl implements ProjectService { throw exception(PROJECT_AREA_HAS_OCCUPIED); } - areaList.forEach(item ->{ + areaList.forEach(item -> { item.setOccupied(true); areaMapper.updateById(item); }); - //检查区域占用状态 比如二级区域全部占用 对应一级区域变成占用 areaService.checkAreaOccupied(); } } - public void checkProjectStatus(ProjectUpdateReqVO updateProject){ + public void checkProjectStatus(ProjectDO updateProject){ ProjectDO project = projectMapper.selectById(updateProject.getId()); + //如果项目状态没改,改了其他信息 if (updateProject.getState().equals(project.getState())){ if (project.getState().equals(ProjectStateEnum.STARTING)){ if (project.getCropId() != updateProject.getCropId()){ @@ -392,6 +399,9 @@ public class ProjectServiceImpl implements ProjectService { * 3、草稿,没填 ——> 项目计划中 */ public void checkStateByTime(ProjectDO projectDO){ + if (projectDO.getState() != null && projectDO.getState().equals(ProjectStateEnum.FINISH)){ + return; + } if (ObjectUtil.isNotEmpty(projectDO.getGrowSeedTime())){ FarmTimeEnum timeEnum = FarmTimeUtil.checkingDate(projectDO.getGrowSeedTime()); if (timeEnum.equals(FarmTimeEnum.IS_TODAY)){ @@ -399,11 +409,29 @@ public class ProjectServiceImpl implements ProjectService { }else if (timeEnum.equals(FarmTimeEnum.AFTER_TODAY)){ projectDO.setState(ProjectStateEnum.PLAN); }else if (timeEnum.equals(FarmTimeEnum.BEFORE_TODAY)){ - throw exception(GROW_SEED_TIME_IS_BEFORE_TODAY); + projectDO.setState(ProjectStateEnum.STARTING); } }else{ //没填育苗时间 默认 计划中 projectDO.setState(ProjectStateEnum.PLAN); } } + + @Scheduled(cron = "0 0/10 * * * ?") + @Transactional(rollbackFor = Exception.class) + public void timingCheckProjectState(){ + Boolean oldIgnore = TenantContextHolder.isIgnore(); + try { + TenantContextHolder.setIgnore(true); + List list = projectMapper.selectList(Wrappers.lambdaQuery().ne(ProjectDO::getDraft, true).eq(ProjectDO::getPretendDelete, false) + .eq(ProjectDO::getState, ProjectStateEnum.PLAN.getCode()).like(ProjectDO::getGrowSeedTime, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); + list.forEach(item ->{ + item.setState(ProjectStateEnum.STARTING); + this.checkProjectAreas(item); + projectMapper.updateById(item); + }); + }finally { + TenantContextHolder.setIgnore(oldIgnore); + } + } } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java index a78fa6e4..7a133e76 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java @@ -1,10 +1,8 @@ package cn.iocoder.yudao.module.farm.service.task; -import cn.iocoder.yudao.framework.common.page.PageVO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskAssemblyDTO; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskDetailDTO; -import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskPageDTO; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskSummaryDTO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskCreateReqVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskExportReqVO; @@ -86,11 +84,6 @@ public interface TaskService { **/ R appGetTask(Long id); - /** - * APP 获取任务列表 - **/ - R> apiGetTaskPage(TaskPageDTO pageDTO); - /** * 根据任务列表 返回每条任务的具体信息 **/ diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java index ad21de14..6b49ad78 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java @@ -4,15 +4,16 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.page.PageUtil; -import cn.iocoder.yudao.framework.common.page.PageVO; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.module.farm.controller.admin.resource.dto.ResourceDTO; import cn.iocoder.yudao.module.farm.controller.admin.resource.dto.ResourceMsgDTO; -import cn.iocoder.yudao.module.farm.controller.admin.task.dto.*; +import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskAssemblyDTO; +import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskDetailDTO; +import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskPreAssemblyDTO; +import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskSummaryDTO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskCreateReqVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskExportReqVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskPageReqVO; @@ -167,13 +168,16 @@ public class TaskServiceImpl implements TaskService { LambdaQueryWrapperX queryWrapperX = new LambdaQueryWrapperX<>(); if (ObjectUtil.isNotEmpty(pageReqVO.getMyTask()) && pageReqVO.getMyTask()){ if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.CREATE)){ + //我创建 queryWrapperX.eqIfPresent(TaskDO::getCreator, getLoginUserId()); }else { AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId()); CpUserDO cpUserDO = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId()); if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.RESPONSIBLE)){ + //我负责 queryWrapperX.eq(TaskDO::getMainPerson, cpUserDO.getId()); }else{ + //我参与 queryWrapperX.apply(("JSON_CONTAINS(executor_person, '"+ cpUserDO.getId()+"')")); } } @@ -279,14 +283,6 @@ public class TaskServiceImpl implements TaskService { return R.success(taskMsg); } - public R> apiGetTaskPage(TaskPageDTO pageDTO){ - PageUtil.startPage(pageDTO); - List taskDOList = taskMapper.selectList(TaskDO::getPretendDelete, false); - List taskList = BeanUtil.copyToList(taskDOList, TaskDetailDTO.class); - PageVO pageVO = PageUtil.convertPageInfo(taskList); - return R.success(pageVO); - } - /** * 任务里面信息预查询(查出所有需要的) **/ diff --git a/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/event/EventServiceImplTest.java b/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/event/EventServiceImplTest.java index 1ba8184c..cfade735 100644 --- a/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/event/EventServiceImplTest.java +++ b/zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/event/EventServiceImplTest.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.farm.service.event; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; import javax.annotation.Resource; @@ -13,18 +12,14 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.event.EventDO; import cn.iocoder.yudao.module.farm.dal.mysql.event.EventMapper; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import javax.annotation.Resource; import org.springframework.context.annotation.Import; import java.util.*; -import static cn.hutool.core.util.RandomUtil.*; import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; /** * {@link EventServiceImpl} 的单元测试类