Browse Source

活动 新增作物记录

zyh
zhanyunjiu 3 years ago
parent
commit
4453f13b37
  1. 11
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateBaseVO.java
  2. 11
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExcelVO.java
  3. 12
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExportReqVO.java
  4. 13
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCatePageReqVO.java
  5. 9
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/taskCate/TaskCateDO.java
  6. 101
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java

11
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateBaseVO.java

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.farm.controller.admin.taskCate.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* 任务类型 Base VO提供给添加修改详细的子 VO 使用
@ -24,4 +24,7 @@ public class TaskCateBaseVO {
private String unit;
@ApiModelProperty("同步到erp")
private Boolean synchronizeErp;
}

11
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExcelVO.java

@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.farm.controller.admin.taskCate.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 任务类型 Excel VO
@ -26,4 +26,7 @@ public class TaskCateExcelVO {
private Boolean pretendDelete;
private String unit;
@ApiModelProperty("同步到erp")
private Boolean synchronizeErp;
}

12
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExportReqVO.java

@ -1,11 +1,12 @@
package cn.iocoder.yudao.module.farm.controller.admin.taskCate.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel(value = "管理后台 - 任务类型 Excel 导出 Request VO", description = "参数和 TaskCatePageReqVO 是一致的")
@ -29,4 +30,7 @@ public class TaskCateExportReqVO {
private Boolean pretendDelete;
private String unit;
@ApiModelProperty("同步到erp")
private Boolean synchronizeErp;
}

13
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCatePageReqVO.java

@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.farm.controller.admin.taskCate.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 任务类型分页 Request VO")
@ -32,4 +36,7 @@ public class TaskCatePageReqVO extends PageParam {
private String unit;
@ApiModelProperty("同步到erp")
private Boolean synchronizeErp;
}

9
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/taskCate/TaskCateDO.java

@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.taskCate;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 任务类型 DO
@ -40,4 +40,7 @@ public class TaskCateDO extends BaseDO {
@ApiModelProperty("任务单位, 亩,株")
private String unit;
@ApiModelProperty("true 同步到erp ")
private Boolean synchronizeErp;
}

101
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java

@ -18,12 +18,16 @@ import cn.iocoder.yudao.module.farm.controller.admin.workHour.dto.WorkUserMsgDTO
import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.WorkHourBaseVO;
import cn.iocoder.yudao.module.farm.convert.discuss.DiscussConvert;
import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.cropRecord.CropRecordDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.discuss.DiscussDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.taskCate.TaskCateDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO;
import cn.iocoder.yudao.module.farm.dal.mysql.area.AreaMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.cropRecord.CropRecordMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.discuss.DiscussMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.workHour.WorkHourMapper;
import cn.iocoder.yudao.module.farm.enums.TaskStatus;
import cn.iocoder.yudao.module.farm.service.area.AreaService;
@ -69,6 +73,10 @@ public class DiscussServiceImpl implements DiscussService {
private AreaMapper areaMapper;
@Resource
private TaskMapper taskMapper;
@Resource
private CropRecordMapper cropRecordMapper;
@Resource
private TaskCateMapper taskCateMapper;
@Override
public Long createDiscuss(DiscussCreateReqVO createReqVO) {
@ -78,38 +86,11 @@ public class DiscussServiceImpl implements DiscussService {
DiscussDO discuss = DiscussConvert.INSTANCE.convert(createReqVO);
discussMapper.insert(discuss);
if (ObjectUtil.isNotEmpty(createReqVO.getWorkHourList())){
List<Long> workUserIdList = createReqVO.getWorkHourList().stream().map(WorkHourBaseVO::getUserId).collect(Collectors.toList());
List<CpUserDO> userList = cpUserMapper.selectList(Wrappers.<CpUserDO>lambdaQuery().in(CpUserDO::getId, workUserIdList));
//添加工时记录
addWorkHourRecord(createReqVO, discuss);
//传了工时
List<WorkHourDO> workSaveList = new ArrayList<>();
for (WorkHourBaseVO work : createReqVO.getWorkHourList()) {
WorkHourDO workHourDO = WorkHourDO.builder()
.userId(work.getUserId())
.discussId(discuss.getId())
.projectId(work.getProjectId())
.taskId(work.getTaskId())
.hour(work.getHour())
.build();
workSaveList.add(workHourDO);
userList.forEach(user ->{
if (work.getUserId().equals(user.getId())){
user.setWorkHour(user.getWorkHour() + work.getHour());
}
});
}
//插入工时记录
workHourMapper.insertBatch(workSaveList);
//更新员工工时合计
//todo service有问题
// cpUserService.updateBatchById(userList);
userList.stream().forEach(item ->{
cpUserMapper.updateById(item);
});
}
//添加作物入库记录
addCropRecord(createReqVO);
// 返回
return discuss.getId();
@ -244,4 +225,62 @@ public class DiscussServiceImpl implements DiscussService {
}
}
/**
* 添加工时记录
*/
public void addWorkHourRecord(DiscussCreateReqVO createReqVO, DiscussDO discuss){
if (ObjectUtil.isNotEmpty(createReqVO.getWorkHourList())){
List<Long> workUserIdList = createReqVO.getWorkHourList().stream().map(WorkHourBaseVO::getUserId).collect(Collectors.toList());
List<CpUserDO> userList = cpUserMapper.selectList(Wrappers.<CpUserDO>lambdaQuery().in(CpUserDO::getId, workUserIdList));
//传了工时
List<WorkHourDO> workSaveList = new ArrayList<>();
for (WorkHourBaseVO work : createReqVO.getWorkHourList()) {
WorkHourDO workHourDO = WorkHourDO.builder()
.userId(work.getUserId())
.discussId(discuss.getId())
.projectId(work.getProjectId())
.taskId(work.getTaskId())
.hour(work.getHour())
.build();
workSaveList.add(workHourDO);
userList.forEach(user ->{
if (work.getUserId().equals(user.getId())){
user.setWorkHour(user.getWorkHour() + work.getHour());
}
});
}
//插入工时记录
workHourMapper.insertBatch(workSaveList);
//更新员工工时合计
userList.stream().forEach(item ->{
cpUserMapper.updateById(item);
});
}
}
/**
* 添加农作物收入记录
*/
public void addCropRecord(DiscussCreateReqVO reqVO){
TaskDO taskDO = taskMapper.selectById(reqVO.getTaskId());
TaskCateDO cateDO = taskCateMapper.selectById(taskDO.getTaskCateName());
//如果任务内容 是要同步的
if (cateDO.getSynchronizeErp()){
Optional<CropRecordDO> max = cropRecordMapper.selectList(Wrappers.<CropRecordDO>lambdaQuery().eq(CropRecordDO::getCropId, taskDO.getCropId()))
.stream().max(Comparator.comparing(CropRecordDO::getId));
Integer afterStock = max.isPresent() ? max.get().getAfterStock() : 0;
CropRecordDO cropRecordDO = CropRecordDO.builder()
.cropId(taskDO.getCropId())
.type(true)
.stock(reqVO.getCropNum().intValue())
.afterStock(reqVO.getCropNum().intValue() + afterStock)
.build();
cropRecordMapper.insert(cropRecordDO);
//todo 调用ERP出入库接口
}
}
}

Loading…
Cancel
Save