Browse Source

修改流程

zyh
zhanyunjiu 3 years ago
parent
commit
18928deb2e
  1. 1
      zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java
  2. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/TestController.java
  3. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/event/EventController.java
  4. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java
  5. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java
  6. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java
  7. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java
  8. 62
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
  9. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java
  10. 6
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java
  11. 86
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
  12. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskService.java
  13. 18
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java
  14. 5
      zsw-farm/zsw-farm-impl/src/test/java/cn/iocoder/yudao/module/farm/service/event/EventServiceImplTest.java

1
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 EXECUTE_TIME_IS_BEFORE_TODAY = new ErrorCode(100000729, "执行时间不能在今天之前,操作失败");
ErrorCode GROW_SEED_TIME_IS_BEFORE_TODAY = new ErrorCode(100000730, "项目育苗时间不能在今天之前");
} }

2
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(){ public void toErpMaterial(){
IntoStockMaterialDTO intoStock = IntoStockMaterialDTO.builder() IntoStockMaterialDTO intoStock = IntoStockMaterialDTO.builder()
.wareHouseId("1546738475384201217") .wareHouseId("1546738475384201217")
.materialId("1544629335014780930") .materialId("1552190579234119681")
.num(new BigDecimal(100)) .num(new BigDecimal(100))
.price(BigDecimal.ZERO) .price(BigDecimal.ZERO)
.build(); .build();

2
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 org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import javax.validation.constraints.*;
import javax.validation.*; import javax.validation.*;
import javax.servlet.http.*; import javax.servlet.http.*;
import java.awt.*;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;

2
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 String unit;
private Integer number; private Double number;
@ApiModelProperty("是否占用") @ApiModelProperty("是否占用")
private Boolean occupied; private Boolean occupied;

2
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 String unit;
private Integer number; private Double number;
@ExcelProperty("是否占用") @ExcelProperty("是否占用")
private Boolean occupied; private Boolean occupied;

2
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 String unit;
private Integer number; private Double number;
@ApiModelProperty("是否占用") @ApiModelProperty("是否占用")
private Boolean occupied; private Boolean occupied;

2
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 String unit;
private Integer number; private Double number;
@ApiModelProperty("是否占用") @ApiModelProperty("是否占用")
private Boolean occupied; private Boolean occupied;

62
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; package cn.iocoder.yudao.module.farm.controller.admin.task;
import cn.hutool.core.bean.BeanUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.hutool.core.util.NumberUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; 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.FarmMsg;
import cn.iocoder.yudao.module.farm.annotation.FarmMsgTypeEnum; 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 com.zsw.base.R;
import org.springframework.web.bind.annotation.*; import io.swagger.annotations.Api;
import javax.annotation.Resource; import io.swagger.annotations.ApiImplicitParam;
import org.springframework.validation.annotation.Validated; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; 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.annotation.Resource;
import javax.validation.*; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.*; import javax.validation.Valid;
import java.util.*;
import java.io.IOException; 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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
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;
@Api(tags = "管理后台 - 任务管理") @Api(tags = "管理后台 - 任务管理")
@RestController @RestController
@ -95,9 +94,7 @@ public class TaskController {
@PreAuthorize("@ss.hasPermission('farm:task:query')") @PreAuthorize("@ss.hasPermission('farm:task:query')")
public CommonResult<PageResult<TaskAssemblyDTO>> getTaskPage(@Valid TaskPageReqVO pageVO) { public CommonResult<PageResult<TaskAssemblyDTO>> getTaskPage(@Valid TaskPageReqVO pageVO) {
PageResult<TaskAssemblyDTO> pageResult = taskService.getTaskPage(pageVO); PageResult<TaskAssemblyDTO> pageResult = taskService.getTaskPage(pageVO);
// PageResult<TaskRespVO> rs = TaskConvert.INSTANCE.convertPage(pageResult); return success(pageResult);
CommonResult<PageResult<TaskAssemblyDTO>> s1 = success(pageResult);
return s1;
} }
@GetMapping("/apiPage") @GetMapping("/apiPage")
@ -120,7 +117,6 @@ public class TaskController {
ExcelUtils.write(response, "农场项目.xls", "数据", TaskExcelVO.class, datas); ExcelUtils.write(response, "农场项目.xls", "数据", TaskExcelVO.class, datas);
} }
@GetMapping("/appGet") @GetMapping("/appGet")
@ApiOperation("APP查看农场任务详情") @ApiOperation("APP查看农场任务详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@ -129,14 +125,6 @@ public class TaskController {
return taskService.appGetTask(id); return taskService.appGetTask(id);
} }
@PostMapping("/apiPage")
@ApiOperation("获得农场项目分页")
@PreAuthorize("@ss.hasPermission('farm:task:query')")
public R<PageVO<TaskDetailDTO>> apiGetTaskPage(@RequestBody TaskPageDTO pageDTO) {
return taskService.apiGetTaskPage(pageDTO);
}
@GetMapping("/taskSummary") @GetMapping("/taskSummary")
@ApiOperation("任务汇总") @ApiOperation("任务汇总")
@PreAuthorize("@ss.hasPermission('farm:task:query')") @PreAuthorize("@ss.hasPermission('farm:task:query')")
@ -144,8 +132,6 @@ public class TaskController {
return R.success(taskService.taskSummary()); return R.success(taskService.taskSummary());
} }
@GetMapping("/whatDayHaveTask") @GetMapping("/whatDayHaveTask")
@ApiOperation("有任务的日期") @ApiOperation("有任务的日期")
public R<List<Map<String, String>>> whatDayHaveTask(@RequestParam(value = "projectId", required = false) Long projectId){ public R<List<Map<String, String>>> whatDayHaveTask(@RequestParam(value = "projectId", required = false) Long projectId){

2
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; private String unit;
@ApiModelProperty("数量") @ApiModelProperty("数量")
private Integer number; private Double number;
@ApiModelProperty("是否占用") @ApiModelProperty("是否占用")
private Boolean occupied; private Boolean occupied;

6
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 org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; 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 java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -152,7 +155,6 @@ public class AreaServiceImpl implements AreaService {
updateList.forEach(update ->{ updateList.forEach(update ->{
areaMapper.updateById(update); areaMapper.updateById(update);
}); });
} }
/** /**

86
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.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; 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.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.vo.*; 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 com.zsw.base.R;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -76,10 +79,10 @@ public class ProjectServiceImpl implements ProjectService {
public Long createProject(ProjectCreateReqVO createReqVO) { public Long createProject(ProjectCreateReqVO createReqVO) {
// 插入 // 插入
ProjectDO project = ProjectConvert.INSTANCE.convert(createReqVO); ProjectDO project = ProjectConvert.INSTANCE.convert(createReqVO);
//设置项目状态 //根据育苗时间设置项目状态
this.checkStateByTime(project); this.checkStateByTime(project);
//检查项目新增、修改时的区域 是否能够使用 //检查项目新增、修改时的区域 是否能够使用
this.checkProjectAreas(BeanUtil.copyProperties(createReqVO, ProjectDO.class)); this.checkProjectAreas(project);
project.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId()); project.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId());
projectMapper.insert(project); projectMapper.insert(project);
// 返回 // 返回
@ -91,18 +94,18 @@ public class ProjectServiceImpl implements ProjectService {
public void updateProject(ProjectUpdateReqVO updateReqVO) { public void updateProject(ProjectUpdateReqVO updateReqVO) {
// 校验存在 // 校验存在
this.validateProjectExists(updateReqVO.getId()); this.validateProjectExists(updateReqVO.getId());
//检查项目状态 ProjectDO updateObj = ProjectConvert.INSTANCE.convert(updateReqVO);
this.checkProjectStatus(updateReqVO); //根据育苗时间设置项目状态
this.checkStateByTime(updateObj);
//检查项目对应状态下 信息能否修改
this.checkProjectStatus(updateObj);
//检查项目新增、修改时的区域 是否能够使用 //检查项目新增、修改时的区域 是否能够使用
this.checkProjectAreas(BeanUtil.copyProperties(updateReqVO, ProjectDO.class)); this.checkProjectAreas(updateObj);
//项目修改完成时,,项目下有一个以上任务未完成,改项就不能更改为完成 //项目修改完成时,,项目下有一个以上任务未完成,改项就不能更改为完成
//如果项目可以更改成完成状态 释放占用区域 //如果项目可以更改成完成状态 释放占用区域
if (updateReqVO.getState().equals(ProjectStateEnum.FINISH)){ if (updateObj.getState().equals(ProjectStateEnum.FINISH)){
this.checkProjectTaskFinish(updateReqVO); this.checkProjectTaskFinish(updateObj);
} }
// 更新
ProjectDO updateObj = ProjectConvert.INSTANCE.convert(updateReqVO);
projectMapper.updateById(updateObj); projectMapper.updateById(updateObj);
} }
@ -180,7 +183,7 @@ public class ProjectServiceImpl implements ProjectService {
LambdaQueryWrapperX<ProjectDO> queryWrapperX = this.miniProjectListQuery(pageDTO); LambdaQueryWrapperX<ProjectDO> queryWrapperX = this.miniProjectListQuery(pageDTO);
List<ProjectDO> list = projectMapper.selectPage(pageDTO, queryWrapperX).getList(); List<ProjectDO> list = projectMapper.selectPage(pageDTO, queryWrapperX).getList();
if (ObjectUtil.isEmpty(list)){ if (ObjectUtil.isEmpty(list)){
return R.success(new PageVO<ProjectListDTO>()); return R.success(new PageVO<ProjectListDTO>().setList(new ArrayList<>()));
} }
//小程序项目列表数据展示信息组装 //小程序项目列表数据展示信息组装
PageVO<ProjectListDTO> returnList = this.miniProjectListAssemble(list); PageVO<ProjectListDTO> returnList = this.miniProjectListAssemble(list);
@ -192,6 +195,17 @@ public class ProjectServiceImpl implements ProjectService {
*/ */
private LambdaQueryWrapperX<ProjectDO> miniProjectListQuery(ProjectPageDTO pageDTO){ private LambdaQueryWrapperX<ProjectDO> miniProjectListQuery(ProjectPageDTO pageDTO){
LambdaQueryWrapperX<ProjectDO> queryWrapperX = new LambdaQueryWrapperX<>(); LambdaQueryWrapperX<ProjectDO> queryWrapperX = new LambdaQueryWrapperX<>();
//根据作物名查找
if (ObjectUtil.isNotEmpty(pageDTO.getCropName())){
List<CropDO> cropList = cropMapper.selectList(Wrappers.<CropDO>lambdaQuery().like(CropDO::getName, pageDTO.getCropName()));
if (cropList.size() != 0){
List<Long> 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.eqIfPresent(ProjectDO::getState, pageDTO.getState());
queryWrapperX.likeIfPresent(ProjectDO::getName, pageDTO.getProjectName()); queryWrapperX.likeIfPresent(ProjectDO::getName, pageDTO.getProjectName());
queryWrapperX.eq(ProjectDO::getPretendDelete, false); queryWrapperX.eq(ProjectDO::getPretendDelete, false);
@ -212,13 +226,7 @@ public class ProjectServiceImpl implements ProjectService {
queryWrapperX.apply(" ((JSON_CONTAINS(members, '"+ user.getId()+"') or creator = " + getLoginUserId() +"))"); queryWrapperX.apply(" ((JSON_CONTAINS(members, '"+ user.getId()+"') or creator = " + getLoginUserId() +"))");
} }
} }
if (ObjectUtil.isNotEmpty(pageDTO.getCropName())){
List<CropDO> cropList = cropMapper.selectList(Wrappers.<CropDO>lambdaQuery().like(CropDO::getName, pageDTO.getCropName()));
if (cropList.size() != 0){
List<Long> cropIdList = cropList.stream().map(CropDO::getId).collect(Collectors.toList());
queryWrapperX.in(ProjectDO::getCropId, cropIdList);
}
}
//根据区域id展示 //根据区域id展示
if (ObjectUtil.isNotEmpty(pageDTO.getAreaId())){ if (ObjectUtil.isNotEmpty(pageDTO.getAreaId())){
List<AreaDO> allAreaList = areaService.getAreaAndSubArea(pageDTO.getAreaId()); List<AreaDO> 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<TaskDO> taskList = taskMapper.selectList(Wrappers.<TaskDO>lambdaQuery() List<TaskDO> taskList = taskMapper.selectList(Wrappers.<TaskDO>lambdaQuery()
.eq(TaskDO::getProjectId, updateReqVO.getId()) .eq(TaskDO::getProjectId, updateObj.getId())
.eq(TaskDO::getPretendDelete, false) .eq(TaskDO::getPretendDelete, false)
.eq(TaskDO::getDraft, false) .eq(TaskDO::getDraft, false)
.ne(TaskDO::getStatus, TaskStatus.COMPLETE) .ne(TaskDO::getStatus, TaskStatus.COMPLETE)
@ -309,12 +317,11 @@ public class ProjectServiceImpl implements ProjectService {
} }
//释放区域占用 //释放区域占用
List<AreaDO> areaList = areaService.getAreaList(updateReqVO.getAreas()); List<AreaDO> areaList = areaService.getAreaList(updateObj.getAreas());
areaList.forEach(item -> { areaList.forEach(item -> {
item.setOccupied(false); item.setOccupied(false);
areaMapper.updateById(item); areaMapper.updateById(item);
} });
);
//检查区域占用状态 比如二级区域全部占用 对应一级区域变成占用 //检查区域占用状态 比如二级区域全部占用 对应一级区域变成占用
areaService.checkAreaOccupied(); areaService.checkAreaOccupied();
} }
@ -340,18 +347,18 @@ public class ProjectServiceImpl implements ProjectService {
throw exception(PROJECT_AREA_HAS_OCCUPIED); throw exception(PROJECT_AREA_HAS_OCCUPIED);
} }
areaList.forEach(item ->{ areaList.forEach(item -> {
item.setOccupied(true); item.setOccupied(true);
areaMapper.updateById(item); areaMapper.updateById(item);
}); });
//检查区域占用状态 比如二级区域全部占用 对应一级区域变成占用 //检查区域占用状态 比如二级区域全部占用 对应一级区域变成占用
areaService.checkAreaOccupied(); areaService.checkAreaOccupied();
} }
} }
public void checkProjectStatus(ProjectUpdateReqVO updateProject){ public void checkProjectStatus(ProjectDO updateProject){
ProjectDO project = projectMapper.selectById(updateProject.getId()); ProjectDO project = projectMapper.selectById(updateProject.getId());
//如果项目状态没改,改了其他信息
if (updateProject.getState().equals(project.getState())){ if (updateProject.getState().equals(project.getState())){
if (project.getState().equals(ProjectStateEnum.STARTING)){ if (project.getState().equals(ProjectStateEnum.STARTING)){
if (project.getCropId() != updateProject.getCropId()){ if (project.getCropId() != updateProject.getCropId()){
@ -392,6 +399,9 @@ public class ProjectServiceImpl implements ProjectService {
* 3草稿没填 > 项目计划中 * 3草稿没填 > 项目计划中
*/ */
public void checkStateByTime(ProjectDO projectDO){ public void checkStateByTime(ProjectDO projectDO){
if (projectDO.getState() != null && projectDO.getState().equals(ProjectStateEnum.FINISH)){
return;
}
if (ObjectUtil.isNotEmpty(projectDO.getGrowSeedTime())){ if (ObjectUtil.isNotEmpty(projectDO.getGrowSeedTime())){
FarmTimeEnum timeEnum = FarmTimeUtil.checkingDate(projectDO.getGrowSeedTime()); FarmTimeEnum timeEnum = FarmTimeUtil.checkingDate(projectDO.getGrowSeedTime());
if (timeEnum.equals(FarmTimeEnum.IS_TODAY)){ if (timeEnum.equals(FarmTimeEnum.IS_TODAY)){
@ -399,11 +409,29 @@ public class ProjectServiceImpl implements ProjectService {
}else if (timeEnum.equals(FarmTimeEnum.AFTER_TODAY)){ }else if (timeEnum.equals(FarmTimeEnum.AFTER_TODAY)){
projectDO.setState(ProjectStateEnum.PLAN); projectDO.setState(ProjectStateEnum.PLAN);
}else if (timeEnum.equals(FarmTimeEnum.BEFORE_TODAY)){ }else if (timeEnum.equals(FarmTimeEnum.BEFORE_TODAY)){
throw exception(GROW_SEED_TIME_IS_BEFORE_TODAY); projectDO.setState(ProjectStateEnum.STARTING);
} }
}else{ }else{
//没填育苗时间 默认 计划中 //没填育苗时间 默认 计划中
projectDO.setState(ProjectStateEnum.PLAN); 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<ProjectDO> list = projectMapper.selectList(Wrappers.<ProjectDO>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);
}
}
} }

7
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; 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.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.TaskAssemblyDTO;
import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskDetailDTO; 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.dto.TaskSummaryDTO;
import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskCreateReqVO; 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.TaskExportReqVO;
@ -86,11 +84,6 @@ public interface TaskService {
**/ **/
R<TaskDetailDTO> appGetTask(Long id); R<TaskDetailDTO> appGetTask(Long id);
/**
* APP 获取任务列表
**/
R<PageVO<TaskDetailDTO>> apiGetTaskPage(TaskPageDTO pageDTO);
/** /**
* 根据任务列表 返回每条任务的具体信息 * 根据任务列表 返回每条任务的具体信息
**/ **/

18
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.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; 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.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; 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.ResourceDTO;
import cn.iocoder.yudao.module.farm.controller.admin.resource.dto.ResourceMsgDTO; 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.TaskCreateReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskExportReqVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskExportReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskPageReqVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskPageReqVO;
@ -167,13 +168,16 @@ public class TaskServiceImpl implements TaskService {
LambdaQueryWrapperX<TaskDO> queryWrapperX = new LambdaQueryWrapperX<>(); LambdaQueryWrapperX<TaskDO> queryWrapperX = new LambdaQueryWrapperX<>();
if (ObjectUtil.isNotEmpty(pageReqVO.getMyTask()) && pageReqVO.getMyTask()){ if (ObjectUtil.isNotEmpty(pageReqVO.getMyTask()) && pageReqVO.getMyTask()){
if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.CREATE)){ if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.CREATE)){
//我创建
queryWrapperX.eqIfPresent(TaskDO::getCreator, getLoginUserId()); queryWrapperX.eqIfPresent(TaskDO::getCreator, getLoginUserId());
}else { }else {
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId()); AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId());
CpUserDO cpUserDO = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId()); CpUserDO cpUserDO = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId());
if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.RESPONSIBLE)){ if (pageReqVO.getMemberEnum().equals(TaskMemberEnum.RESPONSIBLE)){
//我负责
queryWrapperX.eq(TaskDO::getMainPerson, cpUserDO.getId()); queryWrapperX.eq(TaskDO::getMainPerson, cpUserDO.getId());
}else{ }else{
//我参与
queryWrapperX.apply(("JSON_CONTAINS(executor_person, '"+ cpUserDO.getId()+"')")); queryWrapperX.apply(("JSON_CONTAINS(executor_person, '"+ cpUserDO.getId()+"')"));
} }
} }
@ -279,14 +283,6 @@ public class TaskServiceImpl implements TaskService {
return R.success(taskMsg); return R.success(taskMsg);
} }
public R<PageVO<TaskDetailDTO>> apiGetTaskPage(TaskPageDTO pageDTO){
PageUtil.startPage(pageDTO);
List<TaskDO> taskDOList = taskMapper.selectList(TaskDO::getPretendDelete, false);
List<TaskDetailDTO> taskList = BeanUtil.copyToList(taskDOList, TaskDetailDTO.class);
PageVO<TaskDetailDTO> pageVO = PageUtil.convertPageInfo(taskList);
return R.success(pageVO);
}
/** /**
* 任务里面信息预查询(查出所有需要的) * 任务里面信息预查询(查出所有需要的)
**/ **/

5
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.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource; 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.module.farm.dal.mysql.event.EventMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import java.util.*; import java.util.*;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*; 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.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; 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.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/** /**
* {@link EventServiceImpl} 的单元测试类 * {@link EventServiceImpl} 的单元测试类

Loading…
Cancel
Save