From 4453f13b373cd81c445cee875f4fece197e3e0b5 Mon Sep 17 00:00:00 2001 From: zhanyunjiu <787952492@qq.com> Date: Mon, 11 Jul 2022 18:41:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BD=9C=E7=89=A9=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/taskCate/vo/TaskCateBaseVO.java | 11 +- .../admin/taskCate/vo/TaskCateExcelVO.java | 11 +- .../taskCate/vo/TaskCateExportReqVO.java | 12 ++- .../admin/taskCate/vo/TaskCatePageReqVO.java | 13 ++- .../dal/dataobject/taskCate/TaskCateDO.java | 9 +- .../service/discuss/DiscussServiceImpl.java | 101 ++++++++++++------ 6 files changed, 108 insertions(+), 49 deletions(-) diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateBaseVO.java index 4a390e10..2f24db83 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateBaseVO.java +++ b/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; + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExcelVO.java index a02fac23..19e4111a 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExcelVO.java +++ b/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; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExportReqVO.java index 627d8ea7..3de91aab 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCateExportReqVO.java +++ b/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; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCatePageReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCatePageReqVO.java index 19a94ba7..0d884316 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/taskCate/vo/TaskCatePageReqVO.java +++ b/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; + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/taskCate/TaskCateDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/taskCate/TaskCateDO.java index d92d3fb8..75a0df0d 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/taskCate/TaskCateDO.java +++ b/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; + } 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 0e7e47cd..810b39b2 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 @@ -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 workUserIdList = createReqVO.getWorkHourList().stream().map(WorkHourBaseVO::getUserId).collect(Collectors.toList()); - List userList = cpUserMapper.selectList(Wrappers.lambdaQuery().in(CpUserDO::getId, workUserIdList)); + //添加工时记录 + addWorkHourRecord(createReqVO, discuss); - //传了工时 - List 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 workUserIdList = createReqVO.getWorkHourList().stream().map(WorkHourBaseVO::getUserId).collect(Collectors.toList()); + List userList = cpUserMapper.selectList(Wrappers.lambdaQuery().in(CpUserDO::getId, workUserIdList)); + //传了工时 + List 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 max = cropRecordMapper.selectList(Wrappers.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出入库接口 + } + + } + }