Browse Source

流程优化

zyh
zhanyunjiu 3 years ago
parent
commit
6b2c8ec70c
  1. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java
  2. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExportReqVO.java
  3. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussPageReqVO.java
  4. 8
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussRespVO.java
  5. 9
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java
  6. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java
  7. 19
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java
  8. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
  9. 34
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

7
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; private Boolean pretendDelete;
@ApiModelProperty("工时") @ApiModelProperty("工时")
private Integer workingHours; private Double workingHours;
private List<Long> joinPerson; private List<Long> joinPerson;
@ApiModelProperty("参与人数")
private Integer joinNumber;
@ApiModelProperty("采收数量") @ApiModelProperty("采收数量")
private Double recoveryNumber; private Double recoveryNumber;
@ApiModelProperty("执行时间") @ApiModelProperty("执行时间")
private Date executeTime; private Date executeTime;
private JSONArray resources;
} }

2
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; private Boolean pretendDelete;
@ApiModelProperty("工时") @ApiModelProperty("工时")
private Integer workingHours; private Double workingHours;
private List<Long> joinPerson; private List<Long> joinPerson;

7
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; private Boolean pretendDelete = false;
@ApiModelProperty("工时") @ApiModelProperty("工时")
private Integer workingHours; private Double workingHours;
private List<Long> joinPerson; private List<Long> joinPerson;
@ApiModelProperty("参与人数")
private Integer joinNumber;
@ApiModelProperty("采收数量") @ApiModelProperty("采收数量")
private Double recoveryNumber; private Double recoveryNumber;
@ApiModelProperty("执行时间") @ApiModelProperty("执行时间")
private Date executeTime; private Date executeTime;
private JSONArray resources;
} }

8
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; package cn.iocoder.yudao.module.farm.controller.admin.discuss.vo;
import com.alibaba.fastjson.JSONArray;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -22,13 +23,18 @@ public class DiscussRespVO extends DiscussBaseVO {
private Date createTime; private Date createTime;
@ApiModelProperty("工时") @ApiModelProperty("工时")
private Integer workingHours; private Double workingHours;
private List<Long> joinPerson; private List<Long> joinPerson;
@ApiModelProperty("参与人数")
private Integer joinNumber;
@ApiModelProperty("采收数量") @ApiModelProperty("采收数量")
private Double recoveryNumber; private Double recoveryNumber;
@ApiModelProperty("执行时间") @ApiModelProperty("执行时间")
private Date executeTime; private Date executeTime;
private JSONArray resources;
} }

9
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; private Boolean pretendDelete;
@ApiModelProperty("工时") @ApiModelProperty("工时")
private Integer workingHours; private Double workingHours;
@ApiModelProperty("参与人") @ApiModelProperty("参与人")
@TableField(typeHandler = ListIntToListLongTypeHandler.class) @TableField(typeHandler = ListIntToListLongTypeHandler.class)
private List<Long> joinPerson; private List<Long> joinPerson;
@ApiModelProperty("参与人数")
private Integer joinNumber;
@ApiModelProperty("采收数量") @ApiModelProperty("采收数量")
private Double recoveryNumber; private Double recoveryNumber;
@ApiModelProperty("执行时间") @ApiModelProperty("执行时间")
private Date executeTime; private Date executeTime;
@ApiModelProperty("资源")
@TableField(typeHandler = JacksonTypeHandler.class)
private JSONArray resources;
} }

2
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<String> findAreaName(List<AreaDO> areaList, List<Long> areaArray){ public List<String> findAreaName(List<AreaDO> areaList, List<Long> areaArray){
List<String> areaNameList = new ArrayList<>(); List<String> areaNameList = new ArrayList<>();

19
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 lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
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;
@ -95,6 +96,7 @@ public class DiscussServiceImpl implements DiscussService {
private OpenErpService openErpService; private OpenErpService openErpService;
@Override @Override
@Transactional(rollbackFor = Exception.class)
public Long createDiscuss(DiscussCreateReqVO createReqVO) { public Long createDiscuss(DiscussCreateReqVO createReqVO) {
//只有所属任务进行中才可以添加活动 //只有所属任务进行中才可以添加活动
this.canDiscussCreated(BeanUtil.copyProperties(createReqVO, DiscussDO.class)); this.canDiscussCreated(BeanUtil.copyProperties(createReqVO, DiscussDO.class));
@ -120,7 +122,7 @@ public class DiscussServiceImpl implements DiscussService {
// 校验存在 // 校验存在
this.validateDiscussExists(updateReqVO.getId()); this.validateDiscussExists(updateReqVO.getId());
//只有所属任务进行中才可以修改活动 //只有所属任务进行中才可以修改活动
this.canDiscussCreated(BeanUtil.copyProperties(updateReqVO, DiscussDO.class)); // this.canDiscussCreated(BeanUtil.copyProperties(updateReqVO, DiscussDO.class));
// 更新 // 更新
DiscussDO updateObj = DiscussConvert.INSTANCE.convert(updateReqVO); DiscussDO updateObj = DiscussConvert.INSTANCE.convert(updateReqVO);
discussMapper.updateById(updateObj); discussMapper.updateById(updateObj);
@ -217,8 +219,8 @@ public class DiscussServiceImpl implements DiscussService {
} }
discussDTO.setWorkList(workUserMsgList); discussDTO.setWorkList(workUserMsgList);
List<String> areaNameList = areaService.findAreaName(areaList, discussDTO.getAreas()); // List<String> areaNameList = areaService.findAreaName(areaList, discussDTO.getAreas());
discussDTO.setAreaNameList(areaNameList); // discussDTO.setAreaNameList(areaNameList);
} }
PageVO<DiscussDTO> returnList = PageUtil.convertPageInfo(discussDTOList); PageVO<DiscussDTO> returnList = PageUtil.convertPageInfo(discussDTOList);
return R.success(returnList); return R.success(returnList);
@ -292,8 +294,8 @@ public class DiscussServiceImpl implements DiscussService {
CropRecordDO cropRecordDO = CropRecordDO.builder() CropRecordDO cropRecordDO = CropRecordDO.builder()
.cropId(taskDO.getCropId()) .cropId(taskDO.getCropId())
.type(true) .type(true)
.stock(reqVO.getCropNum().intValue()) .stock(reqVO.getRecoveryNumber().intValue())
.afterStock(reqVO.getCropNum().intValue() + afterStock) .afterStock(reqVO.getRecoveryNumber().intValue() + afterStock)
.build(); .build();
cropRecordMapper.insert(cropRecordDO); cropRecordMapper.insert(cropRecordDO);
@ -303,12 +305,10 @@ public class DiscussServiceImpl implements DiscussService {
.wareHouseId("1546738475384201217") .wareHouseId("1546738475384201217")
.price(BigDecimal.ZERO) .price(BigDecimal.ZERO)
.materialId(cropDO.getMaterialId().toString()) .materialId(cropDO.getMaterialId().toString())
.num(new BigDecimal(reqVO.getCropNum())) .num(new BigDecimal(reqVO.getRecoveryNumber()))
.build(); .build();
log.info("同步到ERP,,{}", intoStock); log.info("同步到ERP,,{}", intoStock);
openErpService.intoStock(Arrays.asList(intoStock) ); openErpService.intoStock(Arrays.asList(intoStock) );
} }
} }
@ -322,8 +322,7 @@ public class DiscussServiceImpl implements DiscussService {
taskMapper.updateById(taskDO); taskMapper.updateById(taskDO);
//返还资源 //返还资源
taskService.checkTaskResourceNumber(taskDO); // taskService.checkTaskResourceNumber(taskDO);
} }
} }

2
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()); 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; return;
} }

34
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.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.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.*;
@ -45,10 +46,14 @@ import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zsw.base.R; import com.zsw.base.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; 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.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -63,6 +68,7 @@ import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
*/ */
@Service @Service
@Validated @Validated
@Slf4j
public class TaskServiceImpl implements TaskService { public class TaskServiceImpl implements TaskService {
@Resource @Resource
@ -97,7 +103,7 @@ public class TaskServiceImpl implements TaskService {
//检查任务能否新增 //检查任务能否新增
this.canTheTaskStart(task); this.canTheTaskStart(task);
//检查任务资源数量 //检查任务资源数量
this.checkTaskResourceNumber(task); // this.checkTaskResourceNumber(task);
task.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId()); task.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId());
// 插入 // 插入
taskMapper.insert(task); taskMapper.insert(task);
@ -115,7 +121,7 @@ public class TaskServiceImpl implements TaskService {
// 校验存在 // 校验存在
this.validateTaskExists(updateReqVO.getId()); this.validateTaskExists(updateReqVO.getId());
//检查任务资源数量 //检查任务资源数量
this.checkTaskResourceNumber(task); // this.checkTaskResourceNumber(task);
// 更新 // 更新
taskMapper.updateById(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<TaskDO> taskList = taskMapper.selectList(Wrappers.<TaskDO>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);
}
}
} }

Loading…
Cancel
Save