Browse Source

soc卡汇总

Zimo 1 ngày trước cách đây
mục cha
commit
8cd8ae1926

+ 94 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/IotSocSummaryController.java

@@ -0,0 +1,94 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummarySaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSummaryDO;
+import cn.iocoder.yudao.module.pms.service.qhse.soc.IotSocSummaryService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+
+@Tag(name = "管理后台 - SOC卡汇总")
+@RestController
+@RequestMapping("/rq/iot-soc-summary")
+@Validated
+public class IotSocSummaryController {
+
+    @Resource
+    private IotSocSummaryService iotSocSummaryService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建SOC卡汇总")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-summary:create')")
+    public CommonResult<Long> createIotSocSummary(@Valid @RequestBody IotSocSummarySaveReqVO createReqVO) {
+        return success(iotSocSummaryService.createIotSocSummary(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新SOC卡汇总")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-summary:update')")
+    public CommonResult<Boolean> updateIotSocSummary(@Valid @RequestBody IotSocSummarySaveReqVO updateReqVO) {
+        iotSocSummaryService.updateIotSocSummary(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除SOC卡汇总")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-summary:delete')")
+    public CommonResult<Boolean> deleteIotSocSummary(@RequestParam("id") Long id) {
+        iotSocSummaryService.deleteIotSocSummary(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得SOC卡汇总")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-summary:query')")
+    public CommonResult<IotSocSummaryRespVO> getIotSocSummary(@RequestParam("id") Long id) {
+        IotSocSummaryDO iotSocSummary = iotSocSummaryService.getIotSocSummary(id);
+        return success(BeanUtils.toBean(iotSocSummary, IotSocSummaryRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得SOC卡汇总分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-summary:query')")
+    public CommonResult<PageResult<IotSocSummaryRespVO>> getIotSocSummaryPage(@Valid IotSocSummaryPageReqVO pageReqVO) {
+        PageResult<IotSocSummaryDO> pageResult = iotSocSummaryService.getIotSocSummaryPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotSocSummaryRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出SOC卡汇总 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-summary:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotSocSummaryExcel(@Valid IotSocSummaryPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotSocSummaryDO> list = iotSocSummaryService.getIotSocSummaryPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "SOC卡汇总.xls", "数据", IotSocSummaryRespVO.class,
+                        BeanUtils.toBean(list, IotSocSummaryRespVO.class));
+    }
+
+}

+ 52 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSummaryPageReqVO.java

@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+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 = "管理后台 - SOC卡汇总分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotSocSummaryPageReqVO extends PageParam {
+
+    @Schema(description = "项目部")
+    private String project;
+
+    @Schema(description = "观察日期")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] observationDate;
+
+    @Schema(description = "soc类型")
+    private Long socClass;
+
+    @Schema(description = "类型名称", example = "赵六")
+    private String className;
+
+    @Schema(description = "姓名", example = "王五")
+    private String userName;
+
+    @Schema(description = "岗位")
+    private String post;
+
+    @Schema(description = "部门id", example = "10738")
+    private Long deptId;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "队伍名称", example = "王五")
+    private String deptName;
+
+}

+ 59 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSummaryRespVO.java

@@ -0,0 +1,59 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - SOC卡汇总 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotSocSummaryRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17158")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "项目部")
+    @ExcelProperty("项目部")
+    private String project;
+
+    @Schema(description = "观察日期", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("观察日期")
+    private LocalDateTime observationDate;
+
+    @Schema(description = "soc类型", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("soc类型")
+    private Long socClass;
+
+    @Schema(description = "类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
+    @ExcelProperty("类型名称")
+    private String className;
+
+    @Schema(description = "姓名", example = "王五")
+    @ExcelProperty("姓名")
+    private String userName;
+
+    @Schema(description = "岗位")
+    @ExcelProperty("岗位")
+    private String post;
+
+    @Schema(description = "部门id", example = "10738")
+    @ExcelProperty("部门id")
+    private Long deptId;
+
+    @Schema(description = "备注", example = "你猜")
+    @ExcelProperty("备注")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "队伍名称", example = "王五")
+    @ExcelProperty("队伍名称")
+    private String deptName;
+
+}

+ 47 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSummarySaveReqVO.java

@@ -0,0 +1,47 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - SOC卡汇总新增/修改 Request VO")
+@Data
+public class IotSocSummarySaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "17158")
+    private Long id;
+
+    @Schema(description = "项目部")
+    private String project;
+
+    @Schema(description = "观察日期", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "观察日期不能为空")
+    private LocalDateTime observationDate;
+
+    @Schema(description = "soc类型", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "soc类型不能为空")
+    private Long socClass;
+
+    @Schema(description = "类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
+    @NotEmpty(message = "类型名称不能为空")
+    private String className;
+
+    @Schema(description = "姓名", example = "王五")
+    private String userName;
+
+    @Schema(description = "岗位")
+    private String post;
+
+    @Schema(description = "部门id", example = "10738")
+    private Long deptId;
+
+    @Schema(description = "备注", example = "你猜")
+    private String remark;
+
+    @Schema(description = "队伍名称", example = "王五")
+    private String deptName;
+
+}

+ 68 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/soc/IotSocSummaryDO.java

@@ -0,0 +1,68 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.time.LocalDateTime;
+
+/**
+ * SOC卡汇总 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_iot_soc_summary")
+@KeySequence("rq_iot_soc_summary_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotSocSummaryDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 项目部
+     */
+    private String project;
+    /**
+     * 观察日期
+     */
+    private LocalDateTime observationDate;
+    /**
+     * soc类型
+     */
+    private Long socClass;
+    /**
+     * 类型名称
+     */
+    private String className;
+    /**
+     * 姓名
+     */
+    private String userName;
+    /**
+     * 岗位
+     */
+    private String post;
+    /**
+     * 部门id
+     */
+    private Long deptId;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 队伍名称
+     */
+    private String deptName;
+
+}

+ 33 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/soc/IotSocSummaryMapper.java

@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryPageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSummaryDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * SOC卡汇总 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface IotSocSummaryMapper extends BaseMapperX<IotSocSummaryDO> {
+
+    default PageResult<IotSocSummaryDO> selectPage(IotSocSummaryPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotSocSummaryDO>()
+                .eqIfPresent(IotSocSummaryDO::getProject, reqVO.getProject())
+                .betweenIfPresent(IotSocSummaryDO::getObservationDate, reqVO.getObservationDate())
+                .eqIfPresent(IotSocSummaryDO::getSocClass, reqVO.getSocClass())
+                .likeIfPresent(IotSocSummaryDO::getClassName, reqVO.getClassName())
+                .likeIfPresent(IotSocSummaryDO::getUserName, reqVO.getUserName())
+                .eqIfPresent(IotSocSummaryDO::getPost, reqVO.getPost())
+                .eqIfPresent(IotSocSummaryDO::getDeptId, reqVO.getDeptId())
+                .eqIfPresent(IotSocSummaryDO::getRemark, reqVO.getRemark())
+                .betweenIfPresent(IotSocSummaryDO::getCreateTime, reqVO.getCreateTime())
+                .likeIfPresent(IotSocSummaryDO::getDeptName, reqVO.getDeptName())
+                .orderByDesc(IotSocSummaryDO::getId));
+    }
+
+}

+ 55 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/soc/IotSocSummaryService.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.pms.service.qhse.soc;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummarySaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSummaryDO;
+
+import javax.validation.Valid;
+
+/**
+ * SOC卡汇总 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface IotSocSummaryService {
+
+    /**
+     * 创建SOC卡汇总
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotSocSummary(@Valid IotSocSummarySaveReqVO createReqVO);
+
+    /**
+     * 更新SOC卡汇总
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotSocSummary(@Valid IotSocSummarySaveReqVO updateReqVO);
+
+    /**
+     * 删除SOC卡汇总
+     *
+     * @param id 编号
+     */
+    void deleteIotSocSummary(Long id);
+
+    /**
+     * 获得SOC卡汇总
+     *
+     * @param id 编号
+     * @return SOC卡汇总
+     */
+    IotSocSummaryDO getIotSocSummary(Long id);
+
+    /**
+     * 获得SOC卡汇总分页
+     *
+     * @param pageReqVO 分页查询
+     * @return SOC卡汇总分页
+     */
+    PageResult<IotSocSummaryDO> getIotSocSummaryPage(IotSocSummaryPageReqVO pageReqVO);
+
+}

+ 99 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/soc/IotSocSummaryServiceImpl.java

@@ -0,0 +1,99 @@
+package cn.iocoder.yudao.module.pms.service.qhse.soc;
+
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryPageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummarySaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSummaryDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc.IotSocSourceMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc.IotSocSummaryMapper;
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import java.util.Objects;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * SOC卡汇总 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class IotSocSummaryServiceImpl implements IotSocSummaryService {
+
+    @Resource
+    private IotSocSummaryMapper iotSocSummaryMapper;
+    @Autowired
+    private DeptApi deptApi;
+    @Autowired
+    private IotSocSourceMapper iotSocSourceMapper;
+
+    @Override
+    public Long createIotSocSummary(IotSocSummarySaveReqVO createReqVO) {
+        // 插入
+        IotSocSummaryDO iotSocSummary = BeanUtils.toBean(createReqVO, IotSocSummaryDO.class);
+        Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
+        String loginUserNickname = SecurityFrameworkUtils.getLoginUserNickname();
+        iotSocSummary.setUserName(loginUserNickname);
+        if (Objects.nonNull(loginUserDeptId)) {
+            iotSocSummary.setDeptId(loginUserDeptId);
+            DeptRespDTO dept = deptApi.getDept(loginUserDeptId);
+            if (Objects.isNull(dept)) {throw new ServiceException(new ErrorCode(3,"不存在"));}
+            iotSocSummary.setDeptName(dept.getName());
+        }
+        if (Objects.nonNull(iotSocSummary.getSocClass())) {
+            IotSocSourceDO iotSocSourceDO = iotSocSourceMapper.selectById(iotSocSummary.getSocClass());
+            if (Objects.isNull(iotSocSourceDO)) {throw new ServiceException(new ErrorCode(2,"不存在类别"));}
+            iotSocSummary.setClassName(iotSocSourceDO.getName());
+        }
+        iotSocSummary.setDeleted(false);
+        iotSocSummaryMapper.insert(iotSocSummary);
+        // 返回
+        return iotSocSummary.getId();
+    }
+
+    @Override
+    public void updateIotSocSummary(IotSocSummarySaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotSocSummaryExists(updateReqVO.getId());
+        // 更新
+        IotSocSummaryDO updateObj = BeanUtils.toBean(updateReqVO, IotSocSummaryDO.class);
+        iotSocSummaryMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotSocSummary(Long id) {
+        // 校验存在
+        validateIotSocSummaryExists(id);
+        // 删除
+        iotSocSummaryMapper.deleteById(id);
+    }
+
+    private void validateIotSocSummaryExists(Long id) {
+        if (iotSocSummaryMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(2,"不存在"));
+        }
+    }
+
+    @Override
+    public IotSocSummaryDO getIotSocSummary(Long id) {
+        return iotSocSummaryMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotSocSummaryDO> getIotSocSummaryPage(IotSocSummaryPageReqVO pageReqVO) {
+        return iotSocSummaryMapper.selectPage(pageReqVO);
+    }
+
+}