|
@@ -0,0 +1,147 @@
|
|
|
|
|
+package com.zd.airbottle.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.zd.airbottle.domain.DbBottle;
|
|
|
|
|
+import com.zd.airbottle.domain.DbInOutRecord;
|
|
|
|
|
+import com.zd.airbottle.domain.DbStock;
|
|
|
|
|
+import com.zd.airbottle.domain.bo.DbInOutRecordBo;
|
|
|
|
|
+import com.zd.airbottle.domain.bo.DbInOutRecordParam;
|
|
|
|
|
+import com.zd.airbottle.service.DbBottleService;
|
|
|
|
|
+import com.zd.airbottle.service.DbInOutRecordService;
|
|
|
|
|
+import com.zd.airbottle.service.DbStockService;
|
|
|
|
|
+import com.zd.airbottle.utils.PageUtil;
|
|
|
|
|
+import com.zd.common.core.utils.StringUtils;
|
|
|
|
|
+import com.zd.common.core.web.controller.AbstractController;
|
|
|
|
|
+import com.zd.model.domain.ResultData;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @Description 东北大学入库出库记录控制类
|
|
|
|
|
+ * @Author hzw
|
|
|
|
|
+ * @Date 2023/10/16 17:47
|
|
|
|
|
+ * @Version 2.0
|
|
|
|
|
+ */
|
|
|
|
|
+@Api(tags = "东北大学入库出库记录控制类")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/inOutRecord")
|
|
|
|
|
+public class DbInOutRecordController extends AbstractController {
|
|
|
|
|
+
|
|
|
|
|
+// @Autowired
|
|
|
|
|
+// private DbBottleService dbBottleService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DbStockService dbStockService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DbInOutRecordService dbInOutRecordService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 气瓶入库
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dbInOutRecordBo
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperation(value = "气瓶入库", tags = "参数说明:gasName 气体名称,level 级别,size 规格,bottleCode 气瓶编号 ")
|
|
|
|
|
+ @PostMapping(value = "/enter")
|
|
|
|
|
+ public ResultData in(@RequestBody DbInOutRecordBo dbInOutRecordBo) {
|
|
|
|
|
+ //参数检查
|
|
|
|
|
+ paramCheck.notNull(dbInOutRecordBo).notNull(dbInOutRecordBo.getType()).strNotEmpty(dbInOutRecordBo.getGasName()).notNull(dbInOutRecordBo.getBottleCode()).notNull(dbInOutRecordBo.getBeaconTag()).notNull(dbInOutRecordBo.getSubjectId());
|
|
|
|
|
+ //检查气瓶编号是否被占用
|
|
|
|
|
+// long count = dbBottleService.count(new LambdaQueryWrapper<DbBottle>().eq(DbBottle::getBottleCode, dbInOutRecordBo.getBottleCode()));
|
|
|
|
|
+// if (count == 0) {
|
|
|
|
|
+// return ResultData.success("此气瓶码不存在,请扫描已录入气瓶码!");
|
|
|
|
|
+// }
|
|
|
|
|
+ long count1 = dbStockService.count(new LambdaQueryWrapper<DbStock>().eq(DbStock::getBottleCode, dbInOutRecordBo.getBottleCode()));
|
|
|
|
|
+ if (count1 > 0) {
|
|
|
|
|
+ return ResultData.success("此气瓶码已经绑定!");
|
|
|
|
|
+ }
|
|
|
|
|
+ //验证信标
|
|
|
|
|
+ long count2 = dbStockService.count(new LambdaQueryWrapper<DbStock>().eq(DbStock::getBeaconTag, dbInOutRecordBo.getBeaconTag()));
|
|
|
|
|
+ if (count2 > 0) {
|
|
|
|
|
+ return ResultData.success("当前信标已绑定!");
|
|
|
|
|
+ }
|
|
|
|
|
+ DbInOutRecord dbInOutRecord = new DbInOutRecord();
|
|
|
|
|
+ BeanUtils.copyProperties(dbInOutRecordBo, dbInOutRecord);
|
|
|
|
|
+ boolean a = dbInOutRecordService.save(dbInOutRecord);
|
|
|
|
|
+
|
|
|
|
|
+ DbStock dbStock = new DbStock();
|
|
|
|
|
+ BeanUtils.copyProperties(dbInOutRecordBo, dbStock);
|
|
|
|
|
+ boolean b = dbStockService.save(dbStock);
|
|
|
|
|
+ if (a && b) {
|
|
|
|
|
+ return ResultData.success("操作成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultData.fail("操作失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 气瓶出库
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dbInOutRecordBo
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperation(value = "气瓶出库", tags = "参数说明:gasName 气体名称,level 级别,size 规格,bottleCode 气瓶编号 ")
|
|
|
|
|
+ @PostMapping(value = "/out")
|
|
|
|
|
+ public ResultData out(@RequestBody DbInOutRecordBo dbInOutRecordBo) {
|
|
|
|
|
+ //参数检查
|
|
|
|
|
+ paramCheck.notNull(dbInOutRecordBo).notNull(dbInOutRecordBo.getStockId()).notNull(dbInOutRecordBo.getType());
|
|
|
|
|
+ DbStock stock = dbStockService.getById(dbInOutRecordBo.getStockId());
|
|
|
|
|
+ DbInOutRecord dbInOutRecord = new DbInOutRecord();
|
|
|
|
|
+ BeanUtils.copyProperties(stock, dbInOutRecord);
|
|
|
|
|
+ dbInOutRecord.setType(2);
|
|
|
|
|
+ boolean a = dbInOutRecordService.save(dbInOutRecord);
|
|
|
|
|
+ boolean b = dbStockService.removeById(dbInOutRecord.getId());
|
|
|
|
|
+ if (a && b) {
|
|
|
|
|
+ return ResultData.success("出库成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultData.fail("出库失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 通过ID获取出入库详情
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperation(value = "通过ID获取出入库详情", tags = "参数说明:id 必填")
|
|
|
|
|
+ @GetMapping(value = "/findById")
|
|
|
|
|
+ public ResultData find(@RequestParam("id") Long id) {
|
|
|
|
|
+ paramCheck.notNull(id);
|
|
|
|
|
+ DbInOutRecord dbInOutRecord = dbInOutRecordService.getById(id);
|
|
|
|
|
+ return ResultData.success(dbInOutRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取出入库list
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dbInOutRecordParam
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @ApiOperation(value = "获取出入库list", tags = "参数说明:searchValue 关键字")
|
|
|
|
|
+ @PostMapping(value = "/list")
|
|
|
|
|
+ public ResultData list(@RequestBody DbInOutRecordParam dbInOutRecordParam) {
|
|
|
|
|
+ //查询条件
|
|
|
|
|
+ LambdaQueryWrapper<DbInOutRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ //操作人 联系电话 气瓶编号 气瓶名称
|
|
|
|
|
+ if (StringUtils.isNotBlank(dbInOutRecordParam.getSearchValue())) {
|
|
|
|
|
+ queryWrapper.like(DbInOutRecord::getGasName, dbInOutRecordParam.getSearchValue()).or().like(DbInOutRecord::getOperator, dbInOutRecordParam.getSearchValue()).or().like(DbInOutRecord::getPhone, dbInOutRecordParam.getSearchValue()).or().like(DbInOutRecord::getBottleCode, dbInOutRecordParam.getSearchValue());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (Objects.nonNull(dbInOutRecordParam.getCollegeId())) {
|
|
|
|
|
+ queryWrapper.eq(DbInOutRecord::getCollegeId, dbInOutRecordParam.getCollegeId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Objects.nonNull(dbInOutRecordParam.getStartTime()) && Objects.nonNull(dbInOutRecordParam.getEndTime())) {
|
|
|
|
|
+ queryWrapper.between(DbInOutRecord::getCreateTime, dbInOutRecordParam.getStartTime(), dbInOutRecordParam.getEndTime());
|
|
|
|
|
+ }
|
|
|
|
|
+ //倒叙
|
|
|
|
|
+ queryWrapper.orderByDesc(DbInOutRecord::getId);
|
|
|
|
|
+ IPage<DbInOutRecord> result = dbInOutRecordService.page(PageUtil.getQuery(dbInOutRecordParam.getPageNum(), dbInOutRecordParam.getPageSize()), queryWrapper);
|
|
|
|
|
+ return ResultData.success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|