diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java index d8af6c65..51a92ffe 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.farm.annotation; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.farm.annotation.FarmMsg; import cn.iocoder.yudao.module.farm.controller.admin.project.vo.ProjectCreateReqVO; @@ -122,14 +123,20 @@ public class FarmMsgAspect { for (Object object : objects) { if (farmMsg.type().equals("项目")){ ProjectUpdateReqVO projectDO = (ProjectUpdateReqVO) object; - title = projectDO.getName(); + if (ObjectUtil.isNotEmpty(projectDO.getName())){ + title = projectDO.getName(); + } } if (farmMsg.type().equals("任务")){ TaskUpdateReqVO taskDO = (TaskUpdateReqVO) object; ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId()); - title = project.getName(); + if (ObjectUtil.isNotEmpty(project)){ + title = project.getName(); + } TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId()); - msg = taskCate.getName(); + if (ObjectUtil.isNotEmpty(taskCate)){ + msg = taskCate.getName(); + } } } } @@ -138,14 +145,20 @@ public class FarmMsgAspect { for (Object object : objects){ if (farmMsg.type().equals("项目")){ ProjectCreateReqVO projectDO = (ProjectCreateReqVO) object; - title = projectDO.getName(); + if (ObjectUtil.isNotEmpty(projectDO.getName())){ + title = projectDO.getName(); + } } if (farmMsg.type().equals("任务")){ TaskCreateReqVO taskDO = (TaskCreateReqVO) object; ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId()); - title = project.getName(); + if (ObjectUtil.isNotEmpty(project)){ + title = project.getName(); + } TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId()); - msg = taskCate.getName(); + if (ObjectUtil.isNotEmpty(taskCate)){ + msg = taskCate.getName(); + } } } } 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 ebb3a71c..2e8935da 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,5 +1,6 @@ package cn.iocoder.yudao.module.farm.controller.admin.task; +import cn.hutool.core.util.NumberUtil; import cn.iocoder.yudao.framework.common.page.PageVO; import cn.iocoder.yudao.module.farm.annotation.FarmMsg; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.TaskAssemblyDTO; @@ -92,7 +93,9 @@ public class TaskController { @PreAuthorize("@ss.hasPermission('farm:task:query')") public CommonResult> getTaskPage(@Valid TaskPageReqVO pageVO) { PageResult pageResult = taskService.getTaskPage(pageVO); - return success(TaskConvert.INSTANCE.convertPage(pageResult)); + PageResult rs = TaskConvert.INSTANCE.convertPage(pageResult); + CommonResult> s1 = success(rs); + return s1; } @GetMapping("/apiPage") diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/dto/TaskDetailDTO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/dto/TaskDetailDTO.java index d5524866..77c446a8 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/dto/TaskDetailDTO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/dto/TaskDetailDTO.java @@ -4,6 +4,7 @@ import cn.hutool.system.oshi.CpuInfo; import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO; import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO; +import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -19,8 +20,11 @@ public class TaskDetailDTO extends TaskDO { //项目名 String apiProjectName; - //区域 - List apiArea; + //已选择的一级区域 + List firstAreaList; + + //已选择的二级区域 + List secondAreaList; //执行人 List apiExecutor; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java index bd591843..ce732b49 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.farm.controller.admin.task.vo; import com.alibaba.fastjson.JSONArray; import cn.iocoder.yudao.module.farm.enums.TaskStatus; +import com.fasterxml.jackson.annotation.JsonManagedReference; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import lombok.*; import java.util.*; import io.swagger.annotations.*; @@ -25,7 +27,9 @@ public class TaskBaseVO { @ApiModelProperty(value = "") private JSONArray resources; - private JSONArray areas; + + @ApiModelProperty("子区域列表") + private List areas; private Long mainPerson; private JSONArray executorPerson; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java index 37d569bf..6263066c 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExcelVO.java @@ -30,7 +30,9 @@ public class TaskExcelVO { @ExcelProperty("") private JSONArray resources; - private JSONArray areas; + @ApiModelProperty("子区域列表") + private List areas; + private Long mainPerson; private JSONArray executorPerson; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java index 156072f3..e2add38b 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskExportReqVO.java @@ -22,7 +22,7 @@ public class TaskExportReqVO { @ApiModelProperty(value = "") private JSONArray resources; - private JSONArray areas; + private List areas; private Long mainPerson; private JSONArray executorPerson; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java index 4135b9d8..ceab434f 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageReqVO.java @@ -24,7 +24,7 @@ public class TaskPageReqVO extends PageParam { @ApiModelProperty(value = "") private JSONArray resources; - private JSONArray areas; + private List areas; private Long mainPerson; private JSONArray executorPerson; @@ -61,7 +61,7 @@ public class TaskPageReqVO extends PageParam { private Date endCreateTime; @ApiModelProperty("草稿") - private Boolean draft; + private Boolean draft = false; private Boolean pretendDelete = false; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java index 6bc64e61..69b19c16 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskPageSearchReqVO.java @@ -11,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; import java.util.Date; +import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -29,7 +30,9 @@ public class TaskPageSearchReqVO extends PageParam { @ApiModelProperty(value = "") private JSONArray resources; - private JSONArray areas; + @ApiModelProperty("子区域列表") + private List areas; + private Long mainPerson; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskRespVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskRespVO.java index f17944e5..1f4271bd 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskRespVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskRespVO.java @@ -1,6 +1,10 @@ package cn.iocoder.yudao.module.farm.controller.admin.task.vo; +import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO; +import com.alibaba.ttl.threadpool.agent.internal.javassist.SerialVersionUID; import lombok.*; + +import java.io.Serializable; import java.util.*; import io.swagger.annotations.*; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java index b1c11474..947a897c 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.farm.dal.dataobject.task; import com.alibaba.fastjson.JSONArray; +import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import io.swagger.annotations.ApiModelProperty; import cn.iocoder.yudao.module.farm.enums.TaskStatus; @@ -51,9 +52,9 @@ public class TaskDO extends BaseDO { @ApiModelProperty("资源") @TableField(typeHandler = JacksonTypeHandler.class) private JSONArray resources; - @ApiModelProperty("区域及子区域") + @ApiModelProperty("子区域") @TableField(typeHandler = JacksonTypeHandler.class) - private JSONArray areas; + private List areas; @ApiModelProperty("任务图片") @TableField(typeHandler = JacksonTypeHandler.class) 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 acd32e9c..75ef21b4 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 @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.farm.service.task; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.text.StrBuilder; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.page.PageUtil; import cn.iocoder.yudao.framework.common.page.PageVO; @@ -186,7 +187,12 @@ public class TaskServiceImpl implements TaskService { //任务活动的累计数量 List discussDOList = discussMapper.selectList(DiscussDO::getTaskId, id); taskMsg.setCumulativeQuantity(ObjectUtil.isEmpty(discussDOList) ? 0 : discussDOList.stream().mapToInt(DiscussDO::getCropNum).sum()); - + //已选择的二级区域 + List secondAreaList = areaMapper.selectList(AreaDO::getId, taskDO.getAreas()); + taskMsg.setSecondAreaList(secondAreaList); + List parendIdList = secondAreaList.stream().map(AreaDO::getParentId).collect(Collectors.toList()); + List firstAreaList = areaMapper.selectList(AreaDO::getId, parendIdList); + taskMsg.setFirstAreaList(firstAreaList); return R.success(taskMsg); } @@ -214,9 +220,7 @@ public class TaskServiceImpl implements TaskService { for (TaskDO taskDO : taskDOList) { if (ObjectUtil.isNotEmpty(taskDO.getAreas())){ - for (Object area : taskDO.getAreas()) { - areaIdList.addAll(JSONArray.parseArray(area.toString(), Long.class)); - } + areaIdList.addAll(taskDO.getAreas()); } if (ObjectUtil.isNotEmpty(taskDO.getExecutorPerson())){ executorIdList.addAll(taskDO.getExecutorPerson().toJavaList(Long.class)); @@ -344,17 +348,13 @@ public class TaskServiceImpl implements TaskService { //区域名 List areaNameList = new ArrayList<>(); if (ObjectUtil.isNotEmpty(taskDO.getAreas())) { - for (Object obj : taskDO.getAreas()) { - List areaList = JSONArray.parseArray(obj.toString(), Long.class); - StrBuilder areaName = new StrBuilder(); - areaList.forEach( one ->{ - preAssemblyDTO.getAreaDOList().stream().filter(item -> item.getId().equals(one)).findFirst() - .ifPresent(sonArea ->{ - areaName.append(sonArea.getName()); - }); - }); - areaNameList.add(areaName.toString()); - } + List areaList = JSONArray.parseArray(taskDO.getAreas().toString(), Long.class); + areaList.forEach( one ->{ + preAssemblyDTO.getAreaDOList().stream().filter(item -> item.getId().equals(one.longValue())).findFirst() + .ifPresent(sonArea ->{ + areaNameList.add(sonArea.getName()); + }); + }); } dto.setAreaNameList(areaNameList);