Browse Source

新增:作物、作物出入记录

zyh
小久哥 3 years ago
parent
commit
d18ce96c45
  1. 4
      zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java
  2. 100
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/CropController.java
  3. 26
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropBaseVO.java
  4. 14
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropCreateReqVO.java
  5. 32
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropExcelVO.java
  6. 32
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropExportReqVO.java
  7. 34
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropPageReqVO.java
  8. 19
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropRespVO.java
  9. 18
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropUpdateReqVO.java
  10. 100
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/CropRecordController.java
  11. 30
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordBaseVO.java
  12. 14
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordCreateReqVO.java
  13. 35
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordExcelVO.java
  14. 35
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordExportReqVO.java
  15. 37
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordPageReqVO.java
  16. 19
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordRespVO.java
  17. 18
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordUpdateReqVO.java
  18. 34
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/crop/CropConvert.java
  19. 34
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/cropRecord/CropRecordConvert.java
  20. 40
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/crop/CropDO.java
  21. 44
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/cropRecord/CropRecordDO.java
  22. 38
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/crop/CropMapper.java
  23. 40
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/cropRecord/CropRecordMapper.java
  24. 70
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/crop/CropService.java
  25. 82
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/crop/CropServiceImpl.java
  26. 70
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/cropRecord/CropRecordService.java
  27. 82
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/cropRecord/CropRecordServiceImpl.java
  28. 12
      zsw-farm/zsw-farm-impl/src/main/resources/mapper/crop/CropMapper.xml
  29. 12
      zsw-farm/zsw-farm-impl/src/main/resources/mapper/cropRecord/CropRecordMapper.xml

4
zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java

@ -19,6 +19,10 @@ public interface ErrorCodeConstants{
ErrorCode AREA_NOT_EXISTS = new ErrorCode(1000007007, "农村工作区域不存在");
ErrorCode CROP_NOT_EXISTS = new ErrorCode(1000007008, "农场作物区域不存在");
ErrorCode CROP_RECORD_NOT_EXISTS = new ErrorCode(1000007009, "农场作物出入记录不存在");

100
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/CropController.java

@ -0,0 +1,100 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.farm.controller.admin.crop.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.crop.CropDO;
import cn.iocoder.yudao.module.farm.convert.crop.CropConvert;
import cn.iocoder.yudao.module.farm.service.crop.CropService;
@Api(tags = "管理后台 - ")
@RestController
@RequestMapping("/farm/crop")
@Validated
public class CropController {
@Resource
private CropService cropService;
@PostMapping("/create")
@ApiOperation("创建")
@PreAuthorize("@ss.hasPermission('farm:crop:create')")
public CommonResult<Long> createCrop(@Valid @RequestBody CropCreateReqVO createReqVO) {
return success(cropService.createCrop(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新")
@PreAuthorize("@ss.hasPermission('farm:crop:update')")
public CommonResult<Boolean> updateCrop(@Valid @RequestBody CropUpdateReqVO updateReqVO) {
cropService.updateCrop(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('farm:crop:delete')")
public CommonResult<Boolean> deleteCrop(@RequestParam("id") Long id) {
cropService.deleteCrop(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('farm:crop:query')")
public CommonResult<CropRespVO> getCrop(@RequestParam("id") Long id) {
CropDO crop = cropService.getCrop(id);
return success(CropConvert.INSTANCE.convert(crop));
}
@GetMapping("/list")
@ApiOperation("获得列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('farm:crop:query')")
public CommonResult<List<CropRespVO>> getCropList(@RequestParam("ids") Collection<Long> ids) {
List<CropDO> list = cropService.getCropList(ids);
return success(CropConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获得分页")
@PreAuthorize("@ss.hasPermission('farm:crop:query')")
public CommonResult<PageResult<CropRespVO>> getCropPage(@Valid CropPageReqVO pageVO) {
PageResult<CropDO> pageResult = cropService.getCropPage(pageVO);
return success(CropConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@ApiOperation("导出 Excel")
@PreAuthorize("@ss.hasPermission('farm:crop:export')")
@OperateLog(type = EXPORT)
public void exportCropExcel(@Valid CropExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<CropDO> list = cropService.getCropList(exportReqVO);
// 导出 Excel
List<CropExcelVO> datas = CropConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, ".xls", "数据", CropExcelVO.class, datas);
}
}

26
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropBaseVO.java

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
/**
* Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class CropBaseVO {
@ApiModelProperty(value = "物料名", required = true)
@NotNull(message = "物料名不能为空")
private String name;
@ApiModelProperty(value = "物料图片")
private String images;
@ApiModelProperty(value = "当前库存", required = true)
@NotNull(message = "当前库存不能为空")
private Integer stock;
}

14
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropCreateReqVO.java

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropCreateReqVO extends CropBaseVO {
}

32
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropExcelVO.java

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* Excel VO
*
* @author 系统管理员
*/
@Data
public class CropExcelVO {
@ExcelProperty("物料id")
private Long id;
@ExcelProperty("物料名")
private String name;
@ExcelProperty("物料图片")
private String images;
@ExcelProperty("当前库存")
private Integer stock;
@ExcelProperty("")
private Date createTime;
}

32
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropExportReqVO.java

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel(value = "管理后台 - Excel 导出 Request VO", description = "参数和 CropPageReqVO 是一致的")
@Data
public class CropExportReqVO {
@ApiModelProperty(value = "物料名")
private String name;
@ApiModelProperty(value = "物料图片")
private String images;
@ApiModelProperty(value = "当前库存")
private Integer stock;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private Date endCreateTime;
}

34
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropPageReqVO.java

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropPageReqVO extends PageParam {
@ApiModelProperty(value = "物料名")
private String name;
@ApiModelProperty(value = "物料图片")
private String images;
@ApiModelProperty(value = "当前库存")
private Integer stock;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private Date endCreateTime;
}

19
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropRespVO.java

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
@ApiModel("管理后台 - Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropRespVO extends CropBaseVO {
@ApiModelProperty(value = "物料id", required = true)
private Long id;
@ApiModelProperty(value = "")
private Date createTime;
}

18
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/crop/vo/CropUpdateReqVO.java

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.farm.controller.admin.crop.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropUpdateReqVO extends CropBaseVO {
@ApiModelProperty(value = "物料id", required = true)
@NotNull(message = "物料id不能为空")
private Long id;
}

100
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/CropRecordController.java

@ -0,0 +1,100 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.cropRecord.CropRecordDO;
import cn.iocoder.yudao.module.farm.convert.cropRecord.CropRecordConvert;
import cn.iocoder.yudao.module.farm.service.cropRecord.CropRecordService;
@Api(tags = "管理后台 - ")
@RestController
@RequestMapping("/farm/crop-record")
@Validated
public class CropRecordController {
@Resource
private CropRecordService cropRecordService;
@PostMapping("/create")
@ApiOperation("创建")
@PreAuthorize("@ss.hasPermission('farm:crop-record:create')")
public CommonResult<Long> createCropRecord(@Valid @RequestBody CropRecordCreateReqVO createReqVO) {
return success(cropRecordService.createCropRecord(createReqVO));
}
@PutMapping("/update")
@ApiOperation("更新")
@PreAuthorize("@ss.hasPermission('farm:crop-record:update')")
public CommonResult<Boolean> updateCropRecord(@Valid @RequestBody CropRecordUpdateReqVO updateReqVO) {
cropRecordService.updateCropRecord(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@ApiOperation("删除")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('farm:crop-record:delete')")
public CommonResult<Boolean> deleteCropRecord(@RequestParam("id") Long id) {
cropRecordService.deleteCropRecord(id);
return success(true);
}
@GetMapping("/get")
@ApiOperation("获得")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@PreAuthorize("@ss.hasPermission('farm:crop-record:query')")
public CommonResult<CropRecordRespVO> getCropRecord(@RequestParam("id") Long id) {
CropRecordDO cropRecord = cropRecordService.getCropRecord(id);
return success(CropRecordConvert.INSTANCE.convert(cropRecord));
}
@GetMapping("/list")
@ApiOperation("获得列表")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@PreAuthorize("@ss.hasPermission('farm:crop-record:query')")
public CommonResult<List<CropRecordRespVO>> getCropRecordList(@RequestParam("ids") Collection<Long> ids) {
List<CropRecordDO> list = cropRecordService.getCropRecordList(ids);
return success(CropRecordConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@ApiOperation("获得分页")
@PreAuthorize("@ss.hasPermission('farm:crop-record:query')")
public CommonResult<PageResult<CropRecordRespVO>> getCropRecordPage(@Valid CropRecordPageReqVO pageVO) {
PageResult<CropRecordDO> pageResult = cropRecordService.getCropRecordPage(pageVO);
return success(CropRecordConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@ApiOperation("导出 Excel")
@PreAuthorize("@ss.hasPermission('farm:crop-record:export')")
@OperateLog(type = EXPORT)
public void exportCropRecordExcel(@Valid CropRecordExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<CropRecordDO> list = cropRecordService.getCropRecordList(exportReqVO);
// 导出 Excel
List<CropRecordExcelVO> datas = CropRecordConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, ".xls", "数据", CropRecordExcelVO.class, datas);
}
}

30
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordBaseVO.java

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
/**
* Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class CropRecordBaseVO {
@ApiModelProperty(value = "物料id", required = true)
@NotNull(message = "物料id不能为空")
private Long cropId;
@ApiModelProperty(value = "出入库 0出 1入")
private Boolean type;
@ApiModelProperty(value = "操作数量", required = true)
@NotNull(message = "操作数量不能为空")
private Integer stock;
@ApiModelProperty(value = "剩余数量", required = true)
@NotNull(message = "剩余数量不能为空")
private Integer afterStock;
}

14
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordCreateReqVO.java

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropRecordCreateReqVO extends CropRecordBaseVO {
}

35
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordExcelVO.java

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* Excel VO
*
* @author 系统管理员
*/
@Data
public class CropRecordExcelVO {
@ExcelProperty("")
private Long id;
@ExcelProperty("物料id")
private Long cropId;
@ExcelProperty("出入库 0出 1入")
private Boolean type;
@ExcelProperty("操作数量")
private Integer stock;
@ExcelProperty("剩余数量")
private Integer afterStock;
@ExcelProperty("")
private Date createTime;
}

35
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordExportReqVO.java

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel(value = "管理后台 - Excel 导出 Request VO", description = "参数和 CropRecordPageReqVO 是一致的")
@Data
public class CropRecordExportReqVO {
@ApiModelProperty(value = "物料id")
private Long cropId;
@ApiModelProperty(value = "出入库 0出 1入")
private Boolean type;
@ApiModelProperty(value = "操作数量")
private Integer stock;
@ApiModelProperty(value = "剩余数量")
private Integer afterStock;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private Date endCreateTime;
}

37
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordPageReqVO.java

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropRecordPageReqVO extends PageParam {
@ApiModelProperty(value = "物料id")
private Long cropId;
@ApiModelProperty(value = "出入库 0出 1入")
private Boolean type;
@ApiModelProperty(value = "操作数量")
private Integer stock;
@ApiModelProperty(value = "剩余数量")
private Integer afterStock;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束")
private Date endCreateTime;
}

19
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordRespVO.java

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
@ApiModel("管理后台 - Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropRecordRespVO extends CropRecordBaseVO {
@ApiModelProperty(value = "", required = true)
private Long id;
@ApiModelProperty(value = "")
private Date createTime;
}

18
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/cropRecord/vo/CropRecordUpdateReqVO.java

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import javax.validation.constraints.*;
@ApiModel("管理后台 - 更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CropRecordUpdateReqVO extends CropRecordBaseVO {
@ApiModelProperty(value = "", required = true)
@NotNull(message = "不能为空")
private Long id;
}

34
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/crop/CropConvert.java

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.farm.convert.crop;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.farm.controller.admin.crop.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.crop.CropDO;
/**
* Convert
*
* @author 系统管理员
*/
@Mapper
public interface CropConvert {
CropConvert INSTANCE = Mappers.getMapper(CropConvert.class);
CropDO convert(CropCreateReqVO bean);
CropDO convert(CropUpdateReqVO bean);
CropRespVO convert(CropDO bean);
List<CropRespVO> convertList(List<CropDO> list);
PageResult<CropRespVO> convertPage(PageResult<CropDO> page);
List<CropExcelVO> convertList02(List<CropDO> list);
}

34
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/convert/cropRecord/CropRecordConvert.java

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.farm.convert.cropRecord;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.cropRecord.CropRecordDO;
/**
* Convert
*
* @author 系统管理员
*/
@Mapper
public interface CropRecordConvert {
CropRecordConvert INSTANCE = Mappers.getMapper(CropRecordConvert.class);
CropRecordDO convert(CropRecordCreateReqVO bean);
CropRecordDO convert(CropRecordUpdateReqVO bean);
CropRecordRespVO convert(CropRecordDO bean);
List<CropRecordRespVO> convertList(List<CropRecordDO> list);
PageResult<CropRecordRespVO> convertPage(PageResult<CropRecordDO> page);
List<CropRecordExcelVO> convertList02(List<CropRecordDO> list);
}

40
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/crop/CropDO.java

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.crop;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author 系统管理员
*/
@TableName("farm_crop")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CropDO extends BaseDO {
/**
* 物料id
*/
@TableId
private Long id;
/**
* 物料名
*/
private String name;
/**
* 物料图片
*/
private String images;
/**
* 当前库存
*/
private Integer stock;
}

44
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/cropRecord/CropRecordDO.java

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.cropRecord;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author 系统管理员
*/
@TableName("farm_crop_record")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CropRecordDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* 物料id
*/
private Long cropId;
/**
* 出入库 0出 1入
*/
private Boolean type;
/**
* 操作数量
*/
private Integer stock;
/**
* 剩余数量
*/
private Integer afterStock;
}

38
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/crop/CropMapper.java

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.farm.dal.mysql.crop;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.farm.dal.dataobject.crop.CropDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.farm.controller.admin.crop.vo.*;
/**
* Mapper
*
* @author 系统管理员
*/
@Mapper
public interface CropMapper extends BaseMapperX<CropDO> {
default PageResult<CropDO> selectPage(CropPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CropDO>()
.likeIfPresent(CropDO::getName, reqVO.getName())
.eqIfPresent(CropDO::getImages, reqVO.getImages())
.eqIfPresent(CropDO::getStock, reqVO.getStock())
.betweenIfPresent(CropDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(CropDO::getId));
}
default List<CropDO> selectList(CropExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<CropDO>()
.likeIfPresent(CropDO::getName, reqVO.getName())
.eqIfPresent(CropDO::getImages, reqVO.getImages())
.eqIfPresent(CropDO::getStock, reqVO.getStock())
.betweenIfPresent(CropDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(CropDO::getId));
}
}

40
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/mysql/cropRecord/CropRecordMapper.java

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.farm.dal.mysql.cropRecord;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.farm.dal.dataobject.cropRecord.CropRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo.*;
/**
* Mapper
*
* @author 系统管理员
*/
@Mapper
public interface CropRecordMapper extends BaseMapperX<CropRecordDO> {
default PageResult<CropRecordDO> selectPage(CropRecordPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<CropRecordDO>()
.eqIfPresent(CropRecordDO::getCropId, reqVO.getCropId())
.eqIfPresent(CropRecordDO::getType, reqVO.getType())
.eqIfPresent(CropRecordDO::getStock, reqVO.getStock())
.eqIfPresent(CropRecordDO::getAfterStock, reqVO.getAfterStock())
.betweenIfPresent(CropRecordDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(CropRecordDO::getId));
}
default List<CropRecordDO> selectList(CropRecordExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<CropRecordDO>()
.eqIfPresent(CropRecordDO::getCropId, reqVO.getCropId())
.eqIfPresent(CropRecordDO::getType, reqVO.getType())
.eqIfPresent(CropRecordDO::getStock, reqVO.getStock())
.eqIfPresent(CropRecordDO::getAfterStock, reqVO.getAfterStock())
.betweenIfPresent(CropRecordDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.orderByDesc(CropRecordDO::getId));
}
}

70
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/crop/CropService.java

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.farm.service.crop;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.farm.controller.admin.crop.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.crop.CropDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* Service 接口
*
* @author 系统管理员
*/
public interface CropService {
/**
* 创建
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createCrop(@Valid CropCreateReqVO createReqVO);
/**
* 更新
*
* @param updateReqVO 更新信息
*/
void updateCrop(@Valid CropUpdateReqVO updateReqVO);
/**
* 删除
*
* @param id 编号
*/
void deleteCrop(Long id);
/**
* 获得
*
* @param id 编号
* @return
*/
CropDO getCrop(Long id);
/**
* 获得列表
*
* @param ids 编号
* @return 列表
*/
List<CropDO> getCropList(Collection<Long> ids);
/**
* 获得分页
*
* @param pageReqVO 分页查询
* @return 分页
*/
PageResult<CropDO> getCropPage(CropPageReqVO pageReqVO);
/**
* 获得列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 列表
*/
List<CropDO> getCropList(CropExportReqVO exportReqVO);
}

82
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/crop/CropServiceImpl.java

@ -0,0 +1,82 @@
package cn.iocoder.yudao.module.farm.service.crop;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.farm.controller.admin.crop.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.crop.CropDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.farm.convert.crop.CropConvert;
import cn.iocoder.yudao.module.farm.dal.mysql.crop.CropMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
/**
* Service 实现类
*
* @author 系统管理员
*/
@Service
@Validated
public class CropServiceImpl implements CropService {
@Resource
private CropMapper cropMapper;
@Override
public Long createCrop(CropCreateReqVO createReqVO) {
// 插入
CropDO crop = CropConvert.INSTANCE.convert(createReqVO);
cropMapper.insert(crop);
// 返回
return crop.getId();
}
@Override
public void updateCrop(CropUpdateReqVO updateReqVO) {
// 校验存在
this.validateCropExists(updateReqVO.getId());
// 更新
CropDO updateObj = CropConvert.INSTANCE.convert(updateReqVO);
cropMapper.updateById(updateObj);
}
@Override
public void deleteCrop(Long id) {
// 校验存在
this.validateCropExists(id);
// 删除
cropMapper.deleteById(id);
}
private void validateCropExists(Long id) {
if (cropMapper.selectById(id) == null) {
throw exception(CROP_NOT_EXISTS);
}
}
@Override
public CropDO getCrop(Long id) {
return cropMapper.selectById(id);
}
@Override
public List<CropDO> getCropList(Collection<Long> ids) {
return cropMapper.selectBatchIds(ids);
}
@Override
public PageResult<CropDO> getCropPage(CropPageReqVO pageReqVO) {
return cropMapper.selectPage(pageReqVO);
}
@Override
public List<CropDO> getCropList(CropExportReqVO exportReqVO) {
return cropMapper.selectList(exportReqVO);
}
}

70
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/cropRecord/CropRecordService.java

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.farm.service.cropRecord;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.cropRecord.CropRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* Service 接口
*
* @author 系统管理员
*/
public interface CropRecordService {
/**
* 创建
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createCropRecord(@Valid CropRecordCreateReqVO createReqVO);
/**
* 更新
*
* @param updateReqVO 更新信息
*/
void updateCropRecord(@Valid CropRecordUpdateReqVO updateReqVO);
/**
* 删除
*
* @param id 编号
*/
void deleteCropRecord(Long id);
/**
* 获得
*
* @param id 编号
* @return
*/
CropRecordDO getCropRecord(Long id);
/**
* 获得列表
*
* @param ids 编号
* @return 列表
*/
List<CropRecordDO> getCropRecordList(Collection<Long> ids);
/**
* 获得分页
*
* @param pageReqVO 分页查询
* @return 分页
*/
PageResult<CropRecordDO> getCropRecordPage(CropRecordPageReqVO pageReqVO);
/**
* 获得列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 列表
*/
List<CropRecordDO> getCropRecordList(CropRecordExportReqVO exportReqVO);
}

82
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/cropRecord/CropRecordServiceImpl.java

@ -0,0 +1,82 @@
package cn.iocoder.yudao.module.farm.service.cropRecord;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.farm.controller.admin.cropRecord.vo.*;
import cn.iocoder.yudao.module.farm.dal.dataobject.cropRecord.CropRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.farm.convert.cropRecord.CropRecordConvert;
import cn.iocoder.yudao.module.farm.dal.mysql.cropRecord.CropRecordMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.*;
/**
* Service 实现类
*
* @author 系统管理员
*/
@Service
@Validated
public class CropRecordServiceImpl implements CropRecordService {
@Resource
private CropRecordMapper cropRecordMapper;
@Override
public Long createCropRecord(CropRecordCreateReqVO createReqVO) {
// 插入
CropRecordDO cropRecord = CropRecordConvert.INSTANCE.convert(createReqVO);
cropRecordMapper.insert(cropRecord);
// 返回
return cropRecord.getId();
}
@Override
public void updateCropRecord(CropRecordUpdateReqVO updateReqVO) {
// 校验存在
this.validateCropRecordExists(updateReqVO.getId());
// 更新
CropRecordDO updateObj = CropRecordConvert.INSTANCE.convert(updateReqVO);
cropRecordMapper.updateById(updateObj);
}
@Override
public void deleteCropRecord(Long id) {
// 校验存在
this.validateCropRecordExists(id);
// 删除
cropRecordMapper.deleteById(id);
}
private void validateCropRecordExists(Long id) {
if (cropRecordMapper.selectById(id) == null) {
throw exception(CROP_RECORD_NOT_EXISTS);
}
}
@Override
public CropRecordDO getCropRecord(Long id) {
return cropRecordMapper.selectById(id);
}
@Override
public List<CropRecordDO> getCropRecordList(Collection<Long> ids) {
return cropRecordMapper.selectBatchIds(ids);
}
@Override
public PageResult<CropRecordDO> getCropRecordPage(CropRecordPageReqVO pageReqVO) {
return cropRecordMapper.selectPage(pageReqVO);
}
@Override
public List<CropRecordDO> getCropRecordList(CropRecordExportReqVO exportReqVO) {
return cropRecordMapper.selectList(exportReqVO);
}
}

12
zsw-farm/zsw-farm-impl/src/main/resources/mapper/crop/CropMapper.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.farm.dal.mysql.crop.CropMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

12
zsw-farm/zsw-farm-impl/src/main/resources/mapper/cropRecord/CropRecordMapper.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.farm.dal.mysql.cropRecord.CropRecordMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
Loading…
Cancel
Save