ソースを参照

计量器具台账

lipenghui 1 週間 前
コミット
b439ac526f

+ 98 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/IotMeasureBookController.java

@@ -0,0 +1,98 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.measure;
+
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
+import cn.iocoder.yudao.module.pms.service.qhse.measure.IotMeasureBookService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import java.util.*;
+import java.io.IOException;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
+
+
+@Tag(name = "管理后台 - 计量器具台账")
+@RestController
+@RequestMapping("/rq/iot-measure-book")
+@Validated
+public class IotMeasureBookController {
+
+    @Resource
+    private IotMeasureBookService iotMeasureBookService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建计量器具台账")
+    @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:create')")
+    public CommonResult<Long> createIotMeasureBook(@Valid @RequestBody IotMeasureBookSaveReqVO createReqVO) {
+        return success(iotMeasureBookService.createIotMeasureBook(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新计量器具台账")
+    @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:update')")
+    public CommonResult<Boolean> updateIotMeasureBook(@Valid @RequestBody IotMeasureBookSaveReqVO updateReqVO) {
+        iotMeasureBookService.updateIotMeasureBook(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除计量器具台账")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:delete')")
+    public CommonResult<Boolean> deleteIotMeasureBook(@RequestParam("id") Long id) {
+        iotMeasureBookService.deleteIotMeasureBook(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得计量器具台账")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:query')")
+    public CommonResult<IotMeasureBookRespVO> getIotMeasureBook(@RequestParam("id") Long id) {
+        IotMeasureBookDO iotMeasureBook = iotMeasureBookService.getIotMeasureBook(id);
+        return success(BeanUtils.toBean(iotMeasureBook, IotMeasureBookRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得计量器具台账分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:query')")
+    public CommonResult<PageResult<IotMeasureBookRespVO>> getIotMeasureBookPage(@Valid IotMeasureBookPageReqVO pageReqVO) {
+        PageResult<IotMeasureBookDO> pageResult = iotMeasureBookService.getIotMeasureBookPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotMeasureBookRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出计量器具台账 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:iot-measure-book:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotMeasureBookExcel(@Valid IotMeasureBookPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotMeasureBookDO> list = iotMeasureBookService.getIotMeasureBookPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "计量器具台账.xls", "数据", IotMeasureBookRespVO.class,
+                        BeanUtils.toBean(list, IotMeasureBookRespVO.class));
+    }
+
+}

+ 66 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/vo/IotMeasureBookPageReqVO.java

@@ -0,0 +1,66 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 计量器具台账分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotMeasureBookPageReqVO extends PageParam {
+
+    @Schema(description = "计量器具编码")
+    private String measureCode;
+
+    @Schema(description = "计量器具名称", example = "王五")
+    private String measureName;
+
+    @Schema(description = "分类")
+    private String classify;
+
+    @Schema(description = "责任人")
+    private String dutyPerson;
+
+    @Schema(description = "采购日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private String[] buyDate;
+
+    @Schema(description = "品牌")
+    private String brand;
+
+    @Schema(description = "规格型号", example = "芋艿")
+    private String modelName;
+
+    @Schema(description = "有效期")
+    private LocalDateTime validity;
+
+    @Schema(description = "上次检验/校准日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private String[] lastTime;
+
+    @Schema(description = "单位")
+    private String measureUnit;
+
+    @Schema(description = "价格", example = "7760")
+    private Double measurePrice;
+
+    @Schema(description = "图片")
+    private String measurePic;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "部门id", example = "26945")
+    private Long deptId;
+
+}

+ 79 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/vo/IotMeasureBookRespVO.java

@@ -0,0 +1,79 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 计量器具台账 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotMeasureBookRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31994")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "计量器具编码", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("计量器具编码")
+    private String measureCode;
+
+    @Schema(description = "计量器具名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
+    @ExcelProperty("计量器具名称")
+    private String measureName;
+
+    @Schema(description = "分类", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("分类")
+    private String classify;
+
+    @Schema(description = "责任人", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("责任人")
+    private String dutyPerson;
+
+    @Schema(description = "采购日期")
+    @ExcelProperty("采购日期")
+    private String buyDate;
+
+    @Schema(description = "品牌")
+    @ExcelProperty("品牌")
+    private String brand;
+
+    @Schema(description = "规格型号", example = "芋艿")
+    @ExcelProperty("规格型号")
+    private String modelName;
+
+    @Schema(description = "有效期")
+    @ExcelProperty("有效期")
+    private LocalDateTime validity;
+
+    @Schema(description = "上次检验/校准日期")
+    @ExcelProperty("上次检验/校准日期")
+    private String lastTime;
+
+    @Schema(description = "单位")
+    @ExcelProperty("单位")
+    private String measureUnit;
+
+    @Schema(description = "价格", example = "7760")
+    @ExcelProperty("价格")
+    private Double measurePrice;
+
+    @Schema(description = "图片")
+    @ExcelProperty("图片")
+    private String measurePic;
+
+    @Schema(description = "备注", example = "你猜")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "部门id", example = "26945")
+    @ExcelProperty("部门id")
+    private Long deptId;
+
+}

+ 64 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/vo/IotMeasureBookSaveReqVO.java

@@ -0,0 +1,64 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import javax.validation.constraints.NotEmpty;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 计量器具台账新增/修改 Request VO")
+@Data
+public class IotMeasureBookSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31994")
+    private Long id;
+
+    @Schema(description = "计量器具编码", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "计量器具编码不能为空")
+    private String measureCode;
+
+    @Schema(description = "计量器具名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
+    @NotEmpty(message = "计量器具名称不能为空")
+    private String measureName;
+
+    @Schema(description = "分类", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "分类不能为空")
+    private String classify;
+
+    @Schema(description = "责任人", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "责任人不能为空")
+    private String dutyPerson;
+
+    @Schema(description = "采购日期")
+    private String buyDate;
+
+    @Schema(description = "品牌")
+    private String brand;
+
+    @Schema(description = "规格型号", example = "芋艿")
+    private String modelName;
+
+    @Schema(description = "有效期")
+    private LocalDateTime validity;
+
+    @Schema(description = "上次检验/校准日期")
+    private String lastTime;
+
+    @Schema(description = "单位")
+    private String measureUnit;
+
+    @Schema(description = "价格", example = "7760")
+    private Double measurePrice;
+
+    @Schema(description = "图片")
+    private String measurePic;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+    @Schema(description = "部门id", example = "26945")
+    private Long deptId;
+
+}

+ 88 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/measure/IotMeasureBookDO.java

@@ -0,0 +1,88 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure;
+
+import lombok.*;
+import java.util.*;
+import java.time.LocalDateTime;
+import java.time.LocalDateTime;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 计量器具台账 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_iot_measure_book")
+@KeySequence("rq_iot_measure_book_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotMeasureBookDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 计量器具编码
+     */
+    private String measureCode;
+    /**
+     * 计量器具名称
+     */
+    private String measureName;
+    /**
+     * 分类
+     */
+    private String classify;
+    /**
+     * 责任人
+     */
+    private String dutyPerson;
+    /**
+     * 采购日期
+     */
+    private String buyDate;
+    /**
+     * 品牌
+     */
+    private String brand;
+    /**
+     * 规格型号
+     */
+    private String modelName;
+    /**
+     * 有效期
+     */
+    private LocalDateTime validity;
+    /**
+     * 上次检验/校准日期
+     */
+    private String lastTime;
+    /**
+     * 单位
+     */
+    private String measureUnit;
+    /**
+     * 价格
+     */
+    private Double measurePrice;
+    /**
+     * 图片
+     */
+    private String measurePic;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 部门id
+     */
+    private Long deptId;
+
+}

+ 40 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/measure/IotMeasureBookMapper.java

@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.qhse.measure;
+
+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.pms.controller.admin.qhse.measure.vo.IotMeasureBookPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 计量器具台账 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface IotMeasureBookMapper extends BaseMapperX<IotMeasureBookDO> {
+
+    default PageResult<IotMeasureBookDO> selectPage(IotMeasureBookPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotMeasureBookDO>()
+                .eqIfPresent(IotMeasureBookDO::getMeasureCode, reqVO.getMeasureCode())
+                .likeIfPresent(IotMeasureBookDO::getMeasureName, reqVO.getMeasureName())
+                .eqIfPresent(IotMeasureBookDO::getClassify, reqVO.getClassify())
+                .eqIfPresent(IotMeasureBookDO::getDutyPerson, reqVO.getDutyPerson())
+                .betweenIfPresent(IotMeasureBookDO::getBuyDate, reqVO.getBuyDate())
+                .eqIfPresent(IotMeasureBookDO::getBrand, reqVO.getBrand())
+                .likeIfPresent(IotMeasureBookDO::getModelName, reqVO.getModelName())
+                .eqIfPresent(IotMeasureBookDO::getValidity, reqVO.getValidity())
+                .betweenIfPresent(IotMeasureBookDO::getLastTime, reqVO.getLastTime())
+                .eqIfPresent(IotMeasureBookDO::getMeasureUnit, reqVO.getMeasureUnit())
+                .eqIfPresent(IotMeasureBookDO::getMeasurePrice, reqVO.getMeasurePrice())
+                .eqIfPresent(IotMeasureBookDO::getMeasurePic, reqVO.getMeasurePic())
+                .eqIfPresent(IotMeasureBookDO::getRemark, reqVO.getRemark())
+                .betweenIfPresent(IotMeasureBookDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(IotMeasureBookDO::getDeptId, reqVO.getDeptId())
+                .orderByDesc(IotMeasureBookDO::getId));
+    }
+
+}

+ 57 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/measure/IotMeasureBookService.java

@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.module.pms.service.qhse.measure;
+
+import java.util.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
+
+import javax.validation.Valid;
+
+/**
+ * 计量器具台账 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface IotMeasureBookService {
+
+    /**
+     * 创建计量器具台账
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotMeasureBook(@Valid IotMeasureBookSaveReqVO createReqVO);
+
+    /**
+     * 更新计量器具台账
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotMeasureBook(@Valid IotMeasureBookSaveReqVO updateReqVO);
+
+    /**
+     * 删除计量器具台账
+     *
+     * @param id 编号
+     */
+    void deleteIotMeasureBook(Long id);
+
+    /**
+     * 获得计量器具台账
+     *
+     * @param id 编号
+     * @return 计量器具台账
+     */
+    IotMeasureBookDO getIotMeasureBook(Long id);
+
+    /**
+     * 获得计量器具台账分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 计量器具台账分页
+     */
+    PageResult<IotMeasureBookDO> getIotMeasureBookPage(IotMeasureBookPageReqVO pageReqVO);
+
+}

+ 79 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/measure/IotMeasureBookServiceImpl.java

@@ -0,0 +1,79 @@
+package cn.iocoder.yudao.module.pms.service.qhse.measure;
+
+import cn.hutool.core.date.DateUtil;
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo.IotMeasureBookSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.measure.IotMeasureBookMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * 计量器具台账 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class IotMeasureBookServiceImpl implements IotMeasureBookService {
+
+    @Resource
+    private IotMeasureBookMapper iotMeasureBookMapper;
+
+    @Override
+    public Long createIotMeasureBook(IotMeasureBookSaveReqVO createReqVO) {
+        // 插入
+        IotMeasureBookDO iotMeasureBook = BeanUtils.toBean(createReqVO, IotMeasureBookDO.class);
+        iotMeasureBook.setMeasureCode("JLQJ"+ DateUtil.format(new Date(), "yyyyMMddHHmmss"));
+        iotMeasureBook.setDeleted(false);
+        iotMeasureBookMapper.insert(iotMeasureBook);
+        // 返回
+        return iotMeasureBook.getId();
+    }
+
+    @Override
+    public void updateIotMeasureBook(IotMeasureBookSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotMeasureBookExists(updateReqVO.getId());
+        // 更新
+        IotMeasureBookDO updateObj = BeanUtils.toBean(updateReqVO, IotMeasureBookDO.class);
+        iotMeasureBookMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotMeasureBook(Long id) {
+        // 校验存在
+        validateIotMeasureBookExists(id);
+        // 删除
+        iotMeasureBookMapper.deleteById(id);
+    }
+
+    private void validateIotMeasureBookExists(Long id) {
+        if (iotMeasureBookMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(111,"计量器具台账"));
+        }
+    }
+
+    @Override
+    public IotMeasureBookDO getIotMeasureBook(Long id) {
+        return iotMeasureBookMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotMeasureBookDO> getIotMeasureBookPage(IotMeasureBookPageReqVO pageReqVO) {
+        return iotMeasureBookMapper.selectPage(pageReqVO);
+    }
+
+}