diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java index fbe2f23b..d80e1e62 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java @@ -39,13 +39,18 @@ public class DiscussBaseVO { private Boolean pretendDelete; @ApiModelProperty("工时") - private Integer workingHours; + private Double workingHours; private List joinPerson; + @ApiModelProperty("参与人数") + private Integer joinNumber; + @ApiModelProperty("采收数量") private Double recoveryNumber; @ApiModelProperty("执行时间") private Date executeTime; + + private JSONArray resources; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExportReqVO.java index 8c9cfb50..9f3978bc 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExportReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExportReqVO.java @@ -42,7 +42,7 @@ public class DiscussExportReqVO { private Boolean pretendDelete; @ApiModelProperty("工时") - private Integer workingHours; + private Double workingHours; private List joinPerson; diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussPageReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussPageReqVO.java index f946c28e..3fe220d2 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussPageReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussPageReqVO.java @@ -47,14 +47,19 @@ public class DiscussPageReqVO extends PageParam { private Boolean pretendDelete = false; @ApiModelProperty("工时") - private Integer workingHours; + private Double workingHours; private List joinPerson; + @ApiModelProperty("参与人数") + private Integer joinNumber; + @ApiModelProperty("采收数量") private Double recoveryNumber; @ApiModelProperty("执行时间") private Date executeTime; + private JSONArray resources; + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussRespVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussRespVO.java index 1eb6c365..9d7f48eb 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussRespVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.farm.controller.admin.discuss.vo; +import com.alibaba.fastjson.JSONArray; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -22,13 +23,18 @@ public class DiscussRespVO extends DiscussBaseVO { private Date createTime; @ApiModelProperty("工时") - private Integer workingHours; + private Double workingHours; private List joinPerson; + @ApiModelProperty("参与人数") + private Integer joinNumber; + @ApiModelProperty("采收数量") private Double recoveryNumber; @ApiModelProperty("执行时间") private Date executeTime; + + private JSONArray resources; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java index ef71c673..3d2f4775 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java @@ -64,15 +64,22 @@ public class DiscussDO extends BaseDO { private Boolean pretendDelete; @ApiModelProperty("工时") - private Integer workingHours; + private Double workingHours; @ApiModelProperty("参与人") @TableField(typeHandler = ListIntToListLongTypeHandler.class) private List joinPerson; + @ApiModelProperty("参与人数") + private Integer joinNumber; + @ApiModelProperty("采收数量") private Double recoveryNumber; @ApiModelProperty("执行时间") private Date executeTime; + + @ApiModelProperty("资源") + @TableField(typeHandler = JacksonTypeHandler.class) + private JSONArray resources; } 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 b78a9035..b51c2935 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 @@ -92,7 +92,7 @@ public class AreaServiceImpl implements AreaService { /** - * 根据区域 返回区域信息List + * 活动根据区域 返回区域信息List **/ public List findAreaName(List areaList, List areaArray){ List areaNameList = new ArrayList<>(); diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java index 7e0cd2ae..9bee6517 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java @@ -46,6 +46,7 @@ import dubbo.service.OpenErpService; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -95,6 +96,7 @@ public class DiscussServiceImpl implements DiscussService { private OpenErpService openErpService; @Override + @Transactional(rollbackFor = Exception.class) public Long createDiscuss(DiscussCreateReqVO createReqVO) { //只有所属任务进行中才可以添加活动 this.canDiscussCreated(BeanUtil.copyProperties(createReqVO, DiscussDO.class)); @@ -120,7 +122,7 @@ public class DiscussServiceImpl implements DiscussService { // 校验存在 this.validateDiscussExists(updateReqVO.getId()); //只有所属任务进行中才可以修改活动 - this.canDiscussCreated(BeanUtil.copyProperties(updateReqVO, DiscussDO.class)); +// this.canDiscussCreated(BeanUtil.copyProperties(updateReqVO, DiscussDO.class)); // 更新 DiscussDO updateObj = DiscussConvert.INSTANCE.convert(updateReqVO); discussMapper.updateById(updateObj); @@ -217,8 +219,8 @@ public class DiscussServiceImpl implements DiscussService { } discussDTO.setWorkList(workUserMsgList); - List areaNameList = areaService.findAreaName(areaList, discussDTO.getAreas()); - discussDTO.setAreaNameList(areaNameList); +// List areaNameList = areaService.findAreaName(areaList, discussDTO.getAreas()); +// discussDTO.setAreaNameList(areaNameList); } PageVO returnList = PageUtil.convertPageInfo(discussDTOList); return R.success(returnList); @@ -292,8 +294,8 @@ public class DiscussServiceImpl implements DiscussService { CropRecordDO cropRecordDO = CropRecordDO.builder() .cropId(taskDO.getCropId()) .type(true) - .stock(reqVO.getCropNum().intValue()) - .afterStock(reqVO.getCropNum().intValue() + afterStock) + .stock(reqVO.getRecoveryNumber().intValue()) + .afterStock(reqVO.getRecoveryNumber().intValue() + afterStock) .build(); cropRecordMapper.insert(cropRecordDO); @@ -303,12 +305,10 @@ public class DiscussServiceImpl implements DiscussService { .wareHouseId("1546738475384201217") .price(BigDecimal.ZERO) .materialId(cropDO.getMaterialId().toString()) - .num(new BigDecimal(reqVO.getCropNum())) + .num(new BigDecimal(reqVO.getRecoveryNumber())) .build(); log.info("同步到ERP,,{}", intoStock); openErpService.intoStock(Arrays.asList(intoStock) ); - - } } @@ -322,8 +322,7 @@ public class DiscussServiceImpl implements DiscussService { taskMapper.updateById(taskDO); //返还资源 - taskService.checkTaskResourceNumber(taskDO); - +// taskService.checkTaskResourceNumber(taskDO); } } 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 6cc8729d..d5601588 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 @@ -299,7 +299,7 @@ public class ProjectServiceImpl implements ProjectService { ProjectDO old = projectMapper.selectById(projectDO.getId()); //区域没修改 跳过下面的检查 - if (CollectionUtils.isEqualCollection(projectDO.getAreas(), old.getAreas())){ + if (old != null && old.getAreas() != null && CollectionUtils.isEqualCollection(projectDO.getAreas(), old.getAreas())){ return; } 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 93eb3e53..f63033ab 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 @@ -9,6 +9,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.resource.dto.ResourceDTO; import cn.iocoder.yudao.module.farm.controller.admin.resource.dto.ResourceMsgDTO; import cn.iocoder.yudao.module.farm.controller.admin.task.dto.*; @@ -45,10 +46,14 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zsw.base.R; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; 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; @@ -63,6 +68,7 @@ import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*; */ @Service @Validated +@Slf4j public class TaskServiceImpl implements TaskService { @Resource @@ -97,7 +103,7 @@ public class TaskServiceImpl implements TaskService { //检查任务能否新增 this.canTheTaskStart(task); //检查任务资源数量 - this.checkTaskResourceNumber(task); +// this.checkTaskResourceNumber(task); task.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId()); // 插入 taskMapper.insert(task); @@ -115,7 +121,7 @@ public class TaskServiceImpl implements TaskService { // 校验存在 this.validateTaskExists(updateReqVO.getId()); //检查任务资源数量 - this.checkTaskResourceNumber(task); +// this.checkTaskResourceNumber(task); // 更新 taskMapper.updateById(task); } @@ -556,4 +562,28 @@ public class TaskServiceImpl implements TaskService { } } + /** + * 定时任务:检查任务状态 计划中、准备中的到了执行时间变成已开始 + */ + @Scheduled(cron = "* 0/10 * * * ?") + public void timingCheckTaskStatus(){ + Boolean oldIgnore = TenantContextHolder.isIgnore(); + try { + TenantContextHolder.setIgnore(true); + List taskList = taskMapper.selectList(Wrappers.lambdaQuery().ne(TaskDO::getDraft, true).eq(TaskDO::getPretendDelete, false) + .in(TaskDO::getStatus, TaskStatus.PLAN.getCode(), TaskStatus.READY.getCode()) + .like(TaskDO::getPlanStartTime, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); + if (taskList.size() != 0){ + log.info("检查任务状态,更改 {} 个", taskList.size()); + taskList.forEach(item ->{ + item.setStatus(TaskStatus.STARTED); + taskMapper.updateById(item); + }); + } + } finally { + TenantContextHolder.setIgnore(oldIgnore); + } + + } + }