feat: 从长辉移植新高缺失的六个业务模块(安全生产/能耗/数采/备件/质检台账/售后问题回访)
## 移植范围(199 个 java 文件 + 建表脚本)
| 模块 | 文件数 | 说明 |
|---|---|---|
| 安全生产 safety | 100 | 安全档案、隐患整改、风险监测、巡检、培训、作业许可、证件 |
| 数采 collect | 37 | MQTT 设备数据采集、实时数据、报警、周期、技术参数 |
| 能耗 energy | 19 | 能耗记录、报警、统计分析 |
| 设备备件 spare | 10 | 备件台账、出入库流水 |
| 质检台账 ledger | 7 | 检验台账汇总 |
| 售后问题 problem | 8 | 问题记录全生命周期 |
| 售后回访 visit | 8 | 回访登记、满意度、复发跟踪 |
| 公司配置/数据库备份 | 10 | 系统级辅助功能 |
## 前置依赖补齐
1. 新增 HrmEmployeeApi + HrmEmployeeSimpleDTO + HrmEmployeeApiImpl
(安全生产的特种作业证需关联员工档案,新高原本没有这个跨模块 API)
2. mes/pom.xml 新增 yudao-module-hrm-api 依赖
3. yudao-dependencies 与 mes/pom.xml 新增 paho MQTT 客户端(数采连接设备网关)
## 既有类增量补齐
- MesDvMachineryDO:新增 collectDeviceCode / collectEnabled 字段
- MesDvMachineryMapper:新增 selectByCollectDeviceCode / selectListWithCollectDeviceCode
- MesProTaskMapper:新增 selectRunningTaskByWorkstationId(数采定位当前任务)
- MesDvRepairMapper:新增 lockForSpare(备件出库加行锁)
- AfterSaleTicketDO:新增 visitStatus / lastVisitTime / lastVisitSatisfied / lastVisitRecurred / problemId / problemNo
- AfterSaleNoRedisDAO:新增 PROBLEM_NO_PREFIX
- mes ErrorCodeConstants:新增 COLLECT_ALARM_*
- aftersales ErrorCodeConstants:新增 PROBLEM_* / VISIT_*
- aftersales enums:新增 AfterSaleProblemStatusEnum / AfterSaleVisitStatusEnum
## 数据库变更(已在新高生产执行,事前全库备份)
- 新建 12 张 safety_* 表
- 新建 mes_energy_record、7 张 mes_collect_* 表、2 张 mes_dv_spare_* 表
- mes_dv_machinery 补 2 列
- after_sale_ticket 补 6 列
- 新建 after_sale_problem、after_sale_visit 表
## 验证
全项目 mvn compile 通过(EXIT=0),打包成功。待部署后做接口实测。
| | |
| | | <version>${vertx.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- MQTTï¼MES æ°é客æ·ç«¯ä½¿ç¨ paho --> |
| | | <dependency> |
| | | <groupId>org.eclipse.paho</groupId> |
| | | <artifactId>org.eclipse.paho.client.mqttv3</artifactId> |
| | | <version>${mqtt.version}</version> |
| | | </dependency> |
| | | |
| | | <!-- MQTT --> |
| | | <dependency> |
| | | <groupId>org.eclipse.paho</groupId> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.problem; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo.AfterSaleProblemPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo.AfterSaleProblemRespVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo.AfterSaleProblemSaveReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.problem.AfterSaleProblemDO; |
| | | import cn.iocoder.yudao.module.aftersales.service.problem.AfterSaleProblemService; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | |
| | | @Tag(name = "管çåå° - å®åé®é¢åº") |
| | | @RestController |
| | | @RequestMapping("/aftersales/problem") |
| | | @Validated |
| | | public class AfterSaleProblemController { |
| | | |
| | | @Resource |
| | | private AfterSaleProblemService problemService; |
| | | |
| | | @Resource |
| | | private CrmCustomerApi customerApi; |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "å建å®åé®é¢") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:create')") |
| | | public CommonResult<Long> createProblem(@Valid @RequestBody AfterSaleProblemSaveReqVO createReqVO) { |
| | | return success(problemService.createProblem(createReqVO, getLoginUserId())); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "æ´æ°å®åé®é¢") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:update')") |
| | | public CommonResult<Boolean> updateProblem(@Valid @RequestBody AfterSaleProblemSaveReqVO updateReqVO) { |
| | | problemService.updateProblem(updateReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤å®åé®é¢") |
| | | @Parameter(name = "id", description = "é®é¢ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:delete')") |
| | | public CommonResult<Boolean> deleteProblem(@RequestParam("id") Long id) { |
| | | problemService.deleteProblem(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾å®åé®é¢") |
| | | @Parameter(name = "id", description = "é®é¢ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:query')") |
| | | public CommonResult<AfterSaleProblemRespVO> getProblem(@RequestParam("id") Long id) { |
| | | AfterSaleProblemDO problemDO = problemService.getProblem(id); |
| | | AfterSaleProblemRespVO respVO = buildProblemDetailList(List.of(problemDO)).get(0); |
| | | respVO.setAttachmentList(storageAttachmentApi.listAttachments("aftersales_after_sale_problem", id)); |
| | | return success(respVO); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾å®åé®é¢å页") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:query')") |
| | | public CommonResult<PageResult<AfterSaleProblemRespVO>> getProblemPage(@Valid AfterSaleProblemPageReqVO pageReqVO) { |
| | | PageResult<AfterSaleProblemDO> pageResult = problemService.getProblemPage(pageReqVO); |
| | | return success(new PageResult<>(buildProblemDetailList(pageResult.getList()), pageResult.getTotal())); |
| | | } |
| | | |
| | | @PutMapping("/publish") |
| | | @Operation(summary = "åå¸å®åé®é¢") |
| | | @Parameter(name = "id", description = "é®é¢ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:publish')") |
| | | public CommonResult<Boolean> publishProblem(@RequestParam("id") Long id) { |
| | | problemService.publishProblem(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/disable") |
| | | @Operation(summary = "åç¨å®åé®é¢") |
| | | @Parameter(name = "id", description = "é®é¢ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:disable')") |
| | | public CommonResult<Boolean> disableProblem(@RequestParam("id") Long id) { |
| | | problemService.disableProblem(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/reference") |
| | | @Operation(summary = "æ°å·¥ååçåèæ£ç´¢(å·²åå¸é®é¢)") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:problem:query')") |
| | | public CommonResult<List<AfterSaleProblemRespVO>> getReferenceList(@Valid AfterSaleProblemPageReqVO pageReqVO) { |
| | | return success(buildProblemDetailList(problemService.getReferenceList(pageReqVO))); |
| | | } |
| | | |
| | | // ========== å
鍿¹æ³ï¼æ¹éæ¼è£
å
³èåç§° ========== |
| | | |
| | | private List<AfterSaleProblemRespVO> buildProblemDetailList(List<AfterSaleProblemDO> problemList) { |
| | | if (CollUtil.isEmpty(problemList)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // 1. æ¹éå 载客æ·åç§° |
| | | Set<Long> customerIds = convertSet(problemList, AfterSaleProblemDO::getCustomerId); |
| | | Map<Long, CrmCustomerRespDTO> customerMap = customerApi.getCustomerMap(customerIds); |
| | | // 2. æ¹éå è½½æ²æ·äººåç§° |
| | | Set<Long> userIds = convertSet(problemList, AfterSaleProblemDO::getOwnerUserId); |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |
| | | // 3. æ¼è£
åç§°åæ®µ |
| | | return BeanUtils.toBean(problemList, AfterSaleProblemRespVO.class, vo -> { |
| | | CrmCustomerRespDTO customer = customerMap.get(vo.getCustomerId()); |
| | | if (customer != null) { |
| | | vo.setCustomerName(customer.getName()); |
| | | } |
| | | AdminUserRespDTO ownerUser = userMap.get(vo.getOwnerUserId()); |
| | | if (ownerUser != null) { |
| | | vo.setOwnerUserName(ownerUser.getNickname()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.problem.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; |
| | | |
| | | /** |
| | | * å®åé®é¢åº - å页æ¥è¯¢ Request VO |
| | | */ |
| | | @Schema(description = "å®åé®é¢åº - å页æ¥è¯¢ Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class AfterSaleProblemPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "é®é¢åå·", example = "AP20260813000001") |
| | | private String no; |
| | | |
| | | @Schema(description = "å
³é®å(åå·/æ é¢/æè¿°/è§£å³æ¹æ¡)", example = "ä¼ æå¨") |
| | | private String keyword; |
| | | |
| | | @Schema(description = "æ¥æºå·¥åç¼å·", example = "1") |
| | | private Long sourceTicketId; |
| | | |
| | | @Schema(description = "ç©æç¼å·", example = "1") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "ç©æç¼ç (模ç³)", example = "MAT-001") |
| | | private String itemCode; |
| | | |
| | | @Schema(description = "é®é¢åç±»", example = "åè½æ
é") |
| | | private String issueCategory; |
| | | |
| | | @Schema(description = "é®é¢ç±»å", example = "1") |
| | | private Integer issueType; |
| | | |
| | | @Schema(description = "æ ¹å åç±»", example = "3") |
| | | private Integer rootCauseCategory; |
| | | |
| | | @Schema(description = "ç¶æ: 0-è稿 1-å·²åå¸ 2-å·²åç¨", example = "1") |
| | | private Integer status; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo; |
| | | |
| | | import cn.iocoder.yudao.module.system.api.storage.dto.StorageBlobRespDTO; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®åé®é¢åº - ååº VO |
| | | */ |
| | | @Schema(description = "å®åé®é¢åº - ååº VO") |
| | | @Data |
| | | public class AfterSaleProblemRespVO { |
| | | |
| | | @Schema(description = "é®é¢ç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "é®é¢åå·", example = "AP20260813000001") |
| | | private String no; |
| | | |
| | | @Schema(description = "é®é¢æ é¢", example = "æåæºä¼ æå¨æ è¾åº") |
| | | private String title; |
| | | |
| | | @Schema(description = "æ¥æºå·¥åç¼å·", example = "1") |
| | | private Long sourceTicketId; |
| | | |
| | | @Schema(description = "æ¥æºå·¥ååå·(åä½)", example = "AS20260813000001") |
| | | private String sourceTicketNo; |
| | | |
| | | @Schema(description = "客æ·ç¼å·", example = "1") |
| | | private Long customerId; |
| | | |
| | | @Schema(description = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @Schema(description = "ç©æç¼å·", example = "1") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "ç©æç¼ç ", example = "MAT-001") |
| | | private String itemCode; |
| | | |
| | | @Schema(description = "ç©æåç§°", example = "çµåå
å¨ä»¶") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "çäº§æ¹æ¬¡ç¼å·", example = "1") |
| | | private Long batchId; |
| | | |
| | | @Schema(description = "çäº§æ¹æ¬¡å·", example = "BATCH-2024-001") |
| | | private String batchCode; |
| | | |
| | | @Schema(description = "é®é¢ç±»å", example = "1") |
| | | private Integer issueType; |
| | | |
| | | @Schema(description = "é®é¢åç±»", example = "åè½æ
é") |
| | | private String issueCategory; |
| | | |
| | | @Schema(description = "严éç¨åº¦", example = "2") |
| | | private Integer severityLevel; |
| | | |
| | | @Schema(description = "é®é¢æè¿°") |
| | | private String description; |
| | | |
| | | @Schema(description = "æ ¹å åç±»", example = "3") |
| | | private Integer rootCauseCategory; |
| | | |
| | | @Schema(description = "æ ¹å åæ") |
| | | private String rootCause; |
| | | |
| | | @Schema(description = "è§£å³æ¹æ¡") |
| | | private String solution; |
| | | |
| | | @Schema(description = "ç¶æ: 0-è稿 1-å·²åå¸ 2-å·²åç¨", example = "1") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "æ²æ·äººç¨æ·ç¼å·", example = "1") |
| | | private Long ownerUserId; |
| | | |
| | | @Schema(description = "æ²æ·äººåç§°") |
| | | private String ownerUserName; |
| | | |
| | | @Schema(description = "å叿¶é´") |
| | | private LocalDateTime publishTime; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "å建è
") |
| | | private String creator; |
| | | |
| | | @Schema(description = "å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Schema(description = "æ´æ°è
") |
| | | private String updater; |
| | | |
| | | @Schema(description = "æ´æ°æ¶é´") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @Schema(description = "éä»¶å表") |
| | | private List<StorageBlobRespDTO> attachmentList; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®åé®é¢åº - ä¿å Request VO |
| | | */ |
| | | @Schema(description = "å®åé®é¢åº - ä¿å Request VO") |
| | | @Data |
| | | public class AfterSaleProblemSaveReqVO { |
| | | |
| | | @Schema(description = "é®é¢ç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "é®é¢æ é¢", requiredMode = Schema.RequiredMode.REQUIRED, example = "æåæºä¼ æå¨æ è¾åº") |
| | | @NotEmpty(message = "é®é¢æ é¢ä¸è½ä¸ºç©º") |
| | | private String title; |
| | | |
| | | @Schema(description = "æ¥æºå·¥åç¼å·(å¯éï¼ä¾¿äºè¿½æº¯)", example = "1") |
| | | private Long sourceTicketId; |
| | | |
| | | @Schema(description = "客æ·ç¼å·", example = "1") |
| | | private Long customerId; |
| | | |
| | | @Schema(description = "ç©æç¼å·", example = "1") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "ç©æç¼ç ", example = "MAT-001") |
| | | private String itemCode; |
| | | |
| | | @Schema(description = "ç©æåç§°", example = "çµåå
å¨ä»¶") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "çäº§æ¹æ¬¡ç¼å·", example = "1") |
| | | private Long batchId; |
| | | |
| | | @Schema(description = "çäº§æ¹æ¬¡å·", example = "BATCH-2024-001") |
| | | private String batchCode; |
| | | |
| | | @Schema(description = "é®é¢ç±»å: 0-æªå¤å® 1-ä¸è¬é®é¢ 2-ç»´ä¿®é®é¢ 3-éè´§é®é¢", example = "1") |
| | | private Integer issueType; |
| | | |
| | | @Schema(description = "é®é¢åç±»", example = "åè½æ
é") |
| | | private String issueCategory; |
| | | |
| | | @Schema(description = "严éç¨åº¦: 0-轻微 1-ä¸è¬ 2-严é 3-è´å½", example = "2") |
| | | private Integer severityLevel; |
| | | |
| | | @Schema(description = "é®é¢æè¿°") |
| | | private String description; |
| | | |
| | | @Schema(description = "æ ¹å åç±»: 1-设计 2-ç©æ 3-å·¥èº 4-è£
é
5-è¿è¾ 6-å
è£
7-ä½¿ç¨ 8-软件 9-å
¶ä»", example = "3") |
| | | private Integer rootCauseCategory; |
| | | |
| | | @Schema(description = "æ ¹å åæ") |
| | | private String rootCause; |
| | | |
| | | @Schema(description = "è§£å³æ¹æ¡") |
| | | private String solution; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "éä»¶ blobId å表") |
| | | private List<Long> blobIds; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.visit; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo.AfterSaleVisitCreateReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo.AfterSaleVisitPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo.AfterSaleVisitRespVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.visit.AfterSaleVisitDO; |
| | | import cn.iocoder.yudao.module.aftersales.service.visit.AfterSaleVisitService; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | |
| | | @Tag(name = "管çåå° - å®åå访记å½") |
| | | @RestController |
| | | @RequestMapping("/aftersales/visit") |
| | | @Validated |
| | | public class AfterSaleVisitController { |
| | | |
| | | @Resource |
| | | private AfterSaleVisitService visitService; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "ç»è®°å®åå访") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:visit:create')") |
| | | public CommonResult<Long> createVisit(@Valid @RequestBody AfterSaleVisitCreateReqVO createReqVO) { |
| | | return success(visitService.createVisit(createReqVO, getLoginUserId())); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾å®åå访记å½") |
| | | @Parameter(name = "id", description = "å访记å½ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:visit:query')") |
| | | public CommonResult<AfterSaleVisitRespVO> getVisit(@RequestParam("id") Long id) { |
| | | AfterSaleVisitDO visitDO = visitService.getVisit(id); |
| | | AfterSaleVisitRespVO respVO = buildVisitDetailList(List.of(visitDO)).get(0); |
| | | respVO.setAttachmentList(storageAttachmentApi.listAttachments("aftersales_after_sale_visit", id)); |
| | | return success(respVO); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @Operation(summary = "è·å¾æå·¥åçå访记å½å表") |
| | | @Parameter(name = "ticketId", description = "å·¥åç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:visit:query')") |
| | | public CommonResult<List<AfterSaleVisitRespVO>> getVisitListByTicketId(@RequestParam("ticketId") Long ticketId) { |
| | | List<AfterSaleVisitDO> visitList = visitService.getVisitListByTicketId(ticketId); |
| | | return success(buildVisitDetailList(visitList)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾å®åå访记å½å页") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:visit:query')") |
| | | public CommonResult<PageResult<AfterSaleVisitRespVO>> getVisitPage(@Valid AfterSaleVisitPageReqVO pageReqVO) { |
| | | PageResult<AfterSaleVisitDO> pageResult = visitService.getVisitPage(pageReqVO); |
| | | return success(new PageResult<>(buildVisitDetailList(pageResult.getList()), pageResult.getTotal())); |
| | | } |
| | | |
| | | // ========== å
鍿¹æ³ï¼æ¹éæ¼è£
å
³èåç§° ========== |
| | | |
| | | private List<AfterSaleVisitRespVO> buildVisitDetailList(List<AfterSaleVisitDO> visitList) { |
| | | if (CollUtil.isEmpty(visitList)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¹éå è½½å访人åç§° |
| | | Set<Long> userIds = convertSet(visitList, AfterSaleVisitDO::getVisitorUserId); |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |
| | | return BeanUtils.toBean(visitList, AfterSaleVisitRespVO.class, vo -> { |
| | | AdminUserRespDTO visitorUser = userMap.get(vo.getVisitorUserId()); |
| | | if (visitorUser != null) { |
| | | vo.setVisitorUserName(visitorUser.getNickname()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®ååè®¿è®°å½ - ç»è®° Request VO |
| | | */ |
| | | @Schema(description = "å®ååè®¿è®°å½ - ç»è®° Request VO") |
| | | @Data |
| | | public class AfterSaleVisitCreateReqVO { |
| | | |
| | | @Schema(description = "å·¥åç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "å·¥åä¸è½ä¸ºç©º") |
| | | private Long ticketId; |
| | | |
| | | @Schema(description = "å访æ¹å¼: 0-çµè¯ 1-ä¸é¨ 2-è¿ç¨ 3-å
¶ä»", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| | | @NotNull(message = "å访æ¹å¼ä¸è½ä¸ºç©º") |
| | | private Integer visitType; |
| | | |
| | | @Schema(description = "å访å
容", example = "客æ·åé¦å·²æ£å¸¸ä½¿ç¨") |
| | | private String content; |
| | | |
| | | @Schema(description = "æ¯å¦æ»¡æ", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") |
| | | @NotNull(message = "æ¯å¦æ»¡æä¸è½ä¸ºç©º") |
| | | private Boolean satisfied; |
| | | |
| | | @Schema(description = "é®é¢æ¯å¦å¤å", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| | | @NotNull(message = "é®é¢æ¯å¦å¤åä¸è½ä¸ºç©º") |
| | | private Boolean recurred; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "éä»¶ blobId å表") |
| | | private List<Long> blobIds; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.visit.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; |
| | | |
| | | /** |
| | | * å®ååè®¿è®°å½ - å页æ¥è¯¢ Request VO |
| | | */ |
| | | @Schema(description = "å®ååè®¿è®°å½ - å页æ¥è¯¢ Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class AfterSaleVisitPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "å·¥åç¼å·", example = "1") |
| | | private Long ticketId; |
| | | |
| | | @Schema(description = "å访æ¹å¼", example = "0") |
| | | private Integer visitType; |
| | | |
| | | @Schema(description = "æ¯å¦æ»¡æ", example = "true") |
| | | private Boolean satisfied; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo; |
| | | |
| | | import cn.iocoder.yudao.module.system.api.storage.dto.StorageBlobRespDTO; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®ååè®¿è®°å½ - ååº VO |
| | | */ |
| | | @Schema(description = "å®ååè®¿è®°å½ - ååº VO") |
| | | @Data |
| | | public class AfterSaleVisitRespVO { |
| | | |
| | | @Schema(description = "å访记å½ç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "å·¥åç¼å·", example = "1") |
| | | private Long ticketId; |
| | | |
| | | @Schema(description = "å访æ¹å¼: 0-çµè¯ 1-ä¸é¨ 2-è¿ç¨ 3-å
¶ä»", example = "0") |
| | | private Integer visitType; |
| | | |
| | | @Schema(description = "åè®¿äººç¨æ·ç¼å·", example = "1") |
| | | private Long visitorUserId; |
| | | |
| | | @Schema(description = "å访人åç§°") |
| | | private String visitorUserName; |
| | | |
| | | @Schema(description = "å访å
容") |
| | | private String content; |
| | | |
| | | @Schema(description = "æ¯å¦æ»¡æ", example = "true") |
| | | private Boolean satisfied; |
| | | |
| | | @Schema(description = "é®é¢æ¯å¦å¤å", example = "false") |
| | | private Boolean recurred; |
| | | |
| | | @Schema(description = "å访æ¶é´") |
| | | private LocalDateTime visitTime; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "å建è
") |
| | | private String creator; |
| | | |
| | | @Schema(description = "å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | @Schema(description = "éä»¶å表") |
| | | private List<StorageBlobRespDTO> attachmentList; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.dal.dataobject.problem; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleProblemStatusEnum; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®åé®é¢åº DO |
| | | * <p> |
| | | * ç¬ç«çç¥è¯æ²æ·å®ä½ï¼å·¥å彿¡£æ¶æå·¥åå¿«ç
§èªå¨çæè稿ï¼äººå·¥è¡¥å
æ ¹å /æ¹æ¡ååå¸ï¼ |
| | | * æ°å·¥ååçæ¶å¯æç©æ/åç±»/å
³é®åå½ä¸å·²åå¸é®é¢ä½åèã |
| | | */ |
| | | @TableName("after_sale_problem") |
| | | @KeySequence("after_sale_problem_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class AfterSaleProblemDO extends BaseDO { |
| | | |
| | | /** |
| | | * é®é¢ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | /** |
| | | * é®é¢åå·ï¼æ ¼å¼ AP+yyyyMMdd+6ä½ |
| | | */ |
| | | private String no; |
| | | /** |
| | | * é®é¢æ é¢ |
| | | */ |
| | | private String title; |
| | | /** |
| | | * æ¥æºå·¥åç¼å·ï¼å
³è after_sale_ticket.id |
| | | */ |
| | | private Long sourceTicketId; |
| | | /** |
| | | * æ¥æºå·¥ååå·(åä½) |
| | | */ |
| | | private String sourceTicketNo; |
| | | /** |
| | | * 客æ·ç¼å·(æ¥æºå·¥å带å
¥) |
| | | */ |
| | | private Long customerId; |
| | | /** |
| | | * ç©æç¼å·(é»è®¤åæ¥æºå·¥å馿¡æç») |
| | | */ |
| | | private Long itemId; |
| | | /** |
| | | * ç©æç¼ç (åä½) |
| | | */ |
| | | private String itemCode; |
| | | /** |
| | | * ç©æåç§°(åä½) |
| | | */ |
| | | private String itemName; |
| | | /** |
| | | * çäº§æ¹æ¬¡ç¼å·(å¯é) |
| | | */ |
| | | private Long batchId; |
| | | /** |
| | | * çäº§æ¹æ¬¡å·(å¯é) |
| | | */ |
| | | private String batchCode; |
| | | /** |
| | | * é®é¢ç±»åï¼æä¸¾ {@link cn.iocoder.yudao.module.aftersales.enums.AfterSaleIssueTypeEnum} |
| | | */ |
| | | private Integer issueType; |
| | | /** |
| | | * é®é¢åç±» |
| | | */ |
| | | private String issueCategory; |
| | | /** |
| | | * 严éç¨åº¦: 0-轻微 1-ä¸è¬ 2-严é 3-è´å½ |
| | | */ |
| | | private Integer severityLevel; |
| | | /** |
| | | * é®é¢æè¿° |
| | | */ |
| | | private String description; |
| | | /** |
| | | * æ ¹å åç±»ï¼æä¸¾ {@link cn.iocoder.yudao.module.aftersales.enums.AfterSaleRootCauseCategoryEnum} |
| | | */ |
| | | private Integer rootCauseCategory; |
| | | /** |
| | | * æ ¹å åæ |
| | | */ |
| | | private String rootCause; |
| | | /** |
| | | * è§£å³æ¹æ¡ |
| | | */ |
| | | private String solution; |
| | | /** |
| | | * ç¶æï¼æä¸¾ {@link AfterSaleProblemStatusEnum} |
| | | */ |
| | | private Integer status; |
| | | /** |
| | | * æ²æ·äººç¨æ·ç¼å· |
| | | */ |
| | | private Long ownerUserId; |
| | | /** |
| | | * å叿¶é´ |
| | | */ |
| | | private LocalDateTime publishTime; |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| | |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | /** |
| | | * åè®¿ç¶æ |
| | | * |
| | | * æä¸¾ {@link cn.iocoder.yudao.module.aftersales.enums.AfterSaleVisitStatusEnum} |
| | | */ |
| | | private Integer visitStatus; |
| | | /** |
| | | * æåå访æ¶é´ |
| | | */ |
| | | private LocalDateTime lastVisitTime; |
| | | /** |
| | | * æåå访æ¯å¦æ»¡æ |
| | | */ |
| | | private Boolean lastVisitSatisfied; |
| | | /** |
| | | * æåå访æ¯å¦å¤å |
| | | */ |
| | | private Boolean lastVisitRecurred; |
| | | /** |
| | | * å
³èé®é¢è®°å½ç¼å· |
| | | * |
| | | * å
³è {@link cn.iocoder.yudao.module.aftersales.dal.dataobject.problem.AfterSaleProblemDO#getId()} |
| | | */ |
| | | private Long problemId; |
| | | /** |
| | | * å
³èé®é¢åå· |
| | | */ |
| | | private String problemNo; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.dal.dataobject.visit; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®ååè®¿è®°å½ DO |
| | | * <p> |
| | | * æå¨å®åå·¥åä¸çå访åè®°å½ï¼å¯å¤æ¡ï¼ç»è®°å访æ¶åæ¥æ¨è¿å·¥ååè®¿ç¶æã |
| | | */ |
| | | @TableName("after_sale_visit") |
| | | @KeySequence("after_sale_visit_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class AfterSaleVisitDO extends BaseDO { |
| | | |
| | | /** |
| | | * å访记å½ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | /** |
| | | * å·¥åç¼å·ï¼å
³è after_sale_ticket.id |
| | | */ |
| | | private Long ticketId; |
| | | /** |
| | | * å访æ¹å¼: 0-çµè¯ 1-ä¸é¨ 2-è¿ç¨ 3-å
¶ä» |
| | | */ |
| | | private Integer visitType; |
| | | /** |
| | | * åè®¿äººç¨æ·ç¼å· |
| | | */ |
| | | private Long visitorUserId; |
| | | /** |
| | | * å访å
容 |
| | | */ |
| | | private String content; |
| | | /** |
| | | * æ¯å¦æ»¡æ: 0-å¦ 1-æ¯ |
| | | */ |
| | | @TableField("is_satisfied") |
| | | private Boolean satisfied; |
| | | /** |
| | | * é®é¢æ¯å¦å¤å: 0-å¦ 1-æ¯ |
| | | */ |
| | | @TableField("is_recurred") |
| | | private Boolean recurred; |
| | | /** |
| | | * å访æ¶é´(ç»è®°å³å½æ¶) |
| | | */ |
| | | private LocalDateTime visitTime; |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.dal.mysql.problem; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | 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.aftersales.dal.dataobject.problem.AfterSaleProblemDO; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleProblemStatusEnum; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®åé®é¢åº Mapper |
| | | */ |
| | | @Mapper |
| | | public interface AfterSaleProblemMapper extends BaseMapperX<AfterSaleProblemDO> { |
| | | |
| | | default AfterSaleProblemDO selectByNo(String no) { |
| | | return selectOne(AfterSaleProblemDO::getNo, no); |
| | | } |
| | | |
| | | default AfterSaleProblemDO selectBySourceTicketId(Long sourceTicketId) { |
| | | return selectOne(AfterSaleProblemDO::getSourceTicketId, sourceTicketId); |
| | | } |
| | | |
| | | default PageResult<AfterSaleProblemDO> selectPage(PageParam pageParam, String no, String keyword, |
| | | Long sourceTicketId, Long itemId, String itemCode, |
| | | String issueCategory, |
| | | Integer issueType, Integer rootCauseCategory, Integer status) { |
| | | LambdaQueryWrapperX<AfterSaleProblemDO> query = new LambdaQueryWrapperX<AfterSaleProblemDO>() |
| | | .eqIfPresent(AfterSaleProblemDO::getNo, no) |
| | | .eqIfPresent(AfterSaleProblemDO::getSourceTicketId, sourceTicketId) |
| | | .eqIfPresent(AfterSaleProblemDO::getItemId, itemId) |
| | | .likeIfPresent(AfterSaleProblemDO::getItemCode, itemCode) |
| | | .eqIfPresent(AfterSaleProblemDO::getIssueCategory, issueCategory) |
| | | .eqIfPresent(AfterSaleProblemDO::getIssueType, issueType) |
| | | .eqIfPresent(AfterSaleProblemDO::getRootCauseCategory, rootCauseCategory) |
| | | .eqIfPresent(AfterSaleProblemDO::getStatus, status); |
| | | // å
³é®åæ£ç´¢ï¼åå·/æ é¢/æè¿°/è§£å³æ¹æ¡ |
| | | if (StrUtil.isNotBlank(keyword)) { |
| | | query.and(w -> w.like(AfterSaleProblemDO::getNo, keyword) |
| | | .or().like(AfterSaleProblemDO::getTitle, keyword) |
| | | .or().like(AfterSaleProblemDO::getDescription, keyword) |
| | | .or().like(AfterSaleProblemDO::getSolution, keyword)); |
| | | } |
| | | query.orderByDesc(AfterSaleProblemDO::getUpdateTime); |
| | | return selectPage(pageParam, query); |
| | | } |
| | | |
| | | /** |
| | | * æ°å·¥ååçåèæ£ç´¢ï¼åªè¿åå·²åå¸ï¼æç©æ/åç±»/å
³é®åå½ä¸ï¼åæè¿æ´æ° 10 æ¡ |
| | | */ |
| | | default List<AfterSaleProblemDO> selectReferenceList(Long itemId, String issueCategory, Integer issueType, |
| | | Integer rootCauseCategory, String keyword) { |
| | | LambdaQueryWrapperX<AfterSaleProblemDO> query = new LambdaQueryWrapperX<AfterSaleProblemDO>() |
| | | .eq(AfterSaleProblemDO::getStatus, AfterSaleProblemStatusEnum.PUBLISHED.getStatus()); |
| | | query.and(w -> { |
| | | boolean hasCond = false; |
| | | if (itemId != null) { |
| | | w.eq(AfterSaleProblemDO::getItemId, itemId); |
| | | hasCond = true; |
| | | } |
| | | if (StrUtil.isNotBlank(issueCategory)) { |
| | | if (hasCond) { |
| | | w.or(); |
| | | } |
| | | w.eq(AfterSaleProblemDO::getIssueCategory, issueCategory); |
| | | hasCond = true; |
| | | } |
| | | if (issueType != null) { |
| | | if (hasCond) { |
| | | w.or(); |
| | | } |
| | | w.eq(AfterSaleProblemDO::getIssueType, issueType); |
| | | hasCond = true; |
| | | } |
| | | if (rootCauseCategory != null) { |
| | | if (hasCond) { |
| | | w.or(); |
| | | } |
| | | w.eq(AfterSaleProblemDO::getRootCauseCategory, rootCauseCategory); |
| | | hasCond = true; |
| | | } |
| | | if (StrUtil.isNotBlank(keyword)) { |
| | | if (hasCond) { |
| | | w.or(); |
| | | } |
| | | w.like(AfterSaleProblemDO::getTitle, keyword); |
| | | hasCond = true; |
| | | } |
| | | if (!hasCond) { |
| | | w.eq(AfterSaleProblemDO::getId, -1L); // æ æ¡ä»¶æ¶è¿å空ï¼é¿å
å
¨è¡¨æå |
| | | } |
| | | }); |
| | | query.orderByDesc(AfterSaleProblemDO::getUpdateTime).last("LIMIT 10"); |
| | | return selectList(query); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.dal.mysql.visit; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | 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.aftersales.dal.dataobject.visit.AfterSaleVisitDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®ååè®¿è®°å½ Mapper |
| | | */ |
| | | @Mapper |
| | | public interface AfterSaleVisitMapper extends BaseMapperX<AfterSaleVisitDO> { |
| | | |
| | | default List<AfterSaleVisitDO> selectListByTicketId(Long ticketId) { |
| | | return selectList(new LambdaQueryWrapperX<AfterSaleVisitDO>() |
| | | .eq(AfterSaleVisitDO::getTicketId, ticketId) |
| | | .orderByDesc(AfterSaleVisitDO::getVisitTime)); |
| | | } |
| | | |
| | | default PageResult<AfterSaleVisitDO> selectPage(PageParam pageParam, Long ticketId, Integer visitType, |
| | | Boolean satisfied) { |
| | | return selectPage(pageParam, new LambdaQueryWrapperX<AfterSaleVisitDO>() |
| | | .eqIfPresent(AfterSaleVisitDO::getTicketId, ticketId) |
| | | .eqIfPresent(AfterSaleVisitDO::getVisitType, visitType) |
| | | .eqIfPresent(AfterSaleVisitDO::getSatisfied, satisfied) |
| | | .orderByDesc(AfterSaleVisitDO::getVisitTime)); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | public static final String RETURN_NO_PREFIX = "RT"; |
| | | |
| | | /** |
| | | * é®é¢è®°å½ç¼å·åç¼ |
| | | */ |
| | | public static final String PROBLEM_NO_PREFIX = "AP"; |
| | | |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.enums; |
| | | |
| | | import cn.iocoder.yudao.framework.common.core.ArrayValuable; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * å®åé®é¢åºç¶ææä¸¾ |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum AfterSaleProblemStatusEnum implements ArrayValuable<Integer> { |
| | | |
| | | DRAFT(0, "è稿"), |
| | | PUBLISHED(1, "å·²åå¸"), |
| | | DISABLED(2, "å·²åç¨"); |
| | | |
| | | public static final Integer[] ARRAYS = Arrays.stream(values()).map(AfterSaleProblemStatusEnum::getStatus).toArray(Integer[]::new); |
| | | |
| | | /** |
| | | * é®é¢ç¶æ |
| | | */ |
| | | private final Integer status; |
| | | /** |
| | | * é®é¢ç¶æåç§° |
| | | */ |
| | | private final String name; |
| | | |
| | | @Override |
| | | public Integer[] array() { |
| | | return ARRAYS; |
| | | } |
| | | |
| | | public static String getNameByStatus(Integer status) { |
| | | return Arrays.stream(values()) |
| | | .filter(item -> item.getStatus().equals(status)) |
| | | .map(AfterSaleProblemStatusEnum::getName) |
| | | .findFirst().orElse(null); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.enums; |
| | | |
| | | import cn.iocoder.yudao.framework.common.core.ArrayValuable; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * å®åå·¥ååè®¿ç¶ææä¸¾ |
| | | * <p> |
| | | * å·¥åå®ç»(COMPLETED)åè¿å
¥ãå¾
å访ãï¼ç»è®°ã满æä¸æªå¤åãçå访å置为ãå·²å访éè¿ãï¼æ¹å¯å½æ¡£ã |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum AfterSaleVisitStatusEnum implements ArrayValuable<Integer> { |
| | | |
| | | WAITING(0, "å¾
å访"), |
| | | PASSED(1, "å·²å访éè¿"); |
| | | |
| | | public static final Integer[] ARRAYS = Arrays.stream(values()).map(AfterSaleVisitStatusEnum::getStatus).toArray(Integer[]::new); |
| | | |
| | | /** |
| | | * åè®¿ç¶æ |
| | | */ |
| | | private final Integer status; |
| | | /** |
| | | * åè®¿ç¶æåç§° |
| | | */ |
| | | private final String name; |
| | | |
| | | @Override |
| | | public Integer[] array() { |
| | | return ARRAYS; |
| | | } |
| | | |
| | | public static String getNameByStatus(Integer status) { |
| | | return Arrays.stream(values()) |
| | | .filter(item -> item.getStatus().equals(status)) |
| | | .map(AfterSaleVisitStatusEnum::getName) |
| | | .findFirst().orElse(null); |
| | | } |
| | | |
| | | } |
| | |
| | | ErrorCode COMPENSATION_AUDIT_REJECT_REASON_REQUIRED = new ErrorCode(1_022_004_006, "å®¡æ ¸ä¸éè¿æ¶å¿
须填åä¸éè¿åå "); |
| | | ErrorCode COMPENSATION_UPDATE_FAIL_NOT_EDITABLE = new ErrorCode(1_022_004_007, "åªææªæäº¤æå®¡æ ¸ä¸éè¿ç¶æçèµä»åæè½ä¿®æ¹"); |
| | | |
| | | // ========== å®åæå¡-é®é¢è®°å½ï¼1-022-005-000ï¼ ========== |
| | | ErrorCode PROBLEM_NOT_EXISTS = new ErrorCode(1_022_005_000, "é®é¢è®°å½ä¸åå¨"); |
| | | ErrorCode PROBLEM_NO_EXISTS = new ErrorCode(1_022_005_001, "é®é¢åå·éå¤ï¼è¯·éè¯"); |
| | | ErrorCode PROBLEM_UPDATE_FAIL_STATUS = new ErrorCode(1_022_005_002, "é®é¢ä¿®æ¹å¤±è´¥ï¼åå ï¼ä»
èç¨¿ç¶æå¯ç¼è¾"); |
| | | ErrorCode PROBLEM_DELETE_FAIL_STATUS = new ErrorCode(1_022_005_003, "é®é¢å é¤å¤±è´¥ï¼åå ï¼ä»
èç¨¿ç¶æå¯å é¤"); |
| | | ErrorCode PROBLEM_PUBLISH_FAIL_STATUS = new ErrorCode(1_022_005_004, "é®é¢åå¸å¤±è´¥ï¼åå ï¼å½åç¶æä¸å¯åå¸"); |
| | | ErrorCode PROBLEM_DISABLE_FAIL_STATUS = new ErrorCode(1_022_005_005, "é®é¢åç¨å¤±è´¥ï¼åå ï¼å½åç¶æä¸å¯åç¨"); |
| | | |
| | | // ========== å®åæå¡-å访ï¼1-022-006-000ï¼ ========== |
| | | ErrorCode VISIT_NOT_EXISTS = new ErrorCode(1_022_006_000, "å访记å½ä¸åå¨"); |
| | | ErrorCode VISIT_CREATE_FAIL_STATUS = new ErrorCode(1_022_006_001, "ç»è®°å访失败ï¼åå ï¼å·¥å䏿¯å·²å®ç»(å¾
å访)ç¶æ"); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.service.problem; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo.AfterSaleProblemPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo.AfterSaleProblemSaveReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.problem.AfterSaleProblemDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.ticket.AfterSaleTicketDO; |
| | | import jakarta.validation.Valid; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®åé®é¢åº Service æ¥å£ |
| | | */ |
| | | public interface AfterSaleProblemService { |
| | | |
| | | /** |
| | | * å建é®é¢(人工建档)ï¼åå§ç¶æè稿 |
| | | * |
| | | * @param createReqVO åå»ºä¿¡æ¯ |
| | | * @param userId å½åç¨æ·ç¼å·(æ²æ·äºº) |
| | | * @return é®é¢ç¼å· |
| | | */ |
| | | Long createProblem(@Valid AfterSaleProblemSaveReqVO createReqVO, Long userId); |
| | | |
| | | /** |
| | | * æ´æ°é®é¢ |
| | | * |
| | | * @param updateReqVO æ´æ°ä¿¡æ¯ |
| | | */ |
| | | void updateProblem(@Valid AfterSaleProblemSaveReqVO updateReqVO); |
| | | |
| | | /** |
| | | * å é¤é®é¢(ä»
è稿) |
| | | * |
| | | * @param id é®é¢ç¼å· |
| | | */ |
| | | void deleteProblem(Long id); |
| | | |
| | | /** |
| | | * è·å¾é®é¢ |
| | | * |
| | | * @param id é®é¢ç¼å· |
| | | * @return é®é¢ |
| | | */ |
| | | AfterSaleProblemDO getProblem(Long id); |
| | | |
| | | /** |
| | | * è·å¾é®é¢å表 |
| | | * |
| | | * @param ids ç¼å·å表 |
| | | * @return é®é¢å表 |
| | | */ |
| | | List<AfterSaleProblemDO> getProblemList(Collection<Long> ids); |
| | | |
| | | /** |
| | | * è·å¾é®é¢å页 |
| | | * |
| | | * @param pageReqVO å页æ¥è¯¢ |
| | | * @return é®é¢å页 |
| | | */ |
| | | PageResult<AfterSaleProblemDO> getProblemPage(AfterSaleProblemPageReqVO pageReqVO); |
| | | |
| | | /** |
| | | * åå¸é®é¢ |
| | | * |
| | | * @param id é®é¢ç¼å· |
| | | */ |
| | | void publishProblem(Long id); |
| | | |
| | | /** |
| | | * åç¨é®é¢ |
| | | * |
| | | * @param id é®é¢ç¼å· |
| | | */ |
| | | void disableProblem(Long id); |
| | | |
| | | /** |
| | | * æ°å·¥ååçåèæ£ç´¢ï¼å½ä¸å·²åå¸åå²é®é¢ |
| | | * |
| | | * @param pageReqVO åèæ£ç´¢æ¡ä»¶(å itemId/issueCategory/issueType/rootCauseCategory/keyword) |
| | | * @return å·²åå¸é®é¢å表(è³å¤10æ¡) |
| | | */ |
| | | List<AfterSaleProblemDO> getReferenceList(AfterSaleProblemPageReqVO pageReqVO); |
| | | |
| | | /** |
| | | * å·¥å彿¡£æ¶èªå¨æ²æ·é®é¢(è稿æ)ï¼åä¸å·¥åä»
æ²æ·ä¸æ¬¡(å¹ç) |
| | | * |
| | | * @param ticket å®åå·¥å |
| | | * @return æ²æ·åºçé®é¢ |
| | | */ |
| | | AfterSaleProblemDO createProblemFromTicket(AfterSaleTicketDO ticket); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.service.problem; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo.AfterSaleProblemPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.problem.vo.AfterSaleProblemSaveReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.problem.AfterSaleProblemDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.ticket.AfterSaleTicketDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.ticket.AfterSaleTicketItemDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.mysql.problem.AfterSaleProblemMapper; |
| | | import cn.iocoder.yudao.module.aftersales.dal.mysql.ticket.AfterSaleTicketItemMapper; |
| | | import cn.iocoder.yudao.module.aftersales.dal.mysql.ticket.AfterSaleTicketMapper; |
| | | import cn.iocoder.yudao.module.aftersales.dal.redis.no.AfterSaleNoRedisDAO; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleProblemStatusEnum; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | import static cn.iocoder.yudao.module.aftersales.enums.ErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®åé®é¢åº Service å®ç°ç±» |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @Slf4j |
| | | public class AfterSaleProblemServiceImpl implements AfterSaleProblemService { |
| | | |
| | | @Resource |
| | | private AfterSaleProblemMapper problemMapper; |
| | | @Resource |
| | | private AfterSaleTicketMapper ticketMapper; |
| | | @Resource |
| | | private AfterSaleTicketItemMapper ticketItemMapper; |
| | | @Resource |
| | | private AfterSaleNoRedisDAO noRedisDAO; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createProblem(AfterSaleProblemSaveReqVO createReqVO, Long userId) { |
| | | AfterSaleProblemDO problem = BeanUtils.toBean(createReqVO, AfterSaleProblemDO.class); |
| | | // æ¥æºå·¥åå卿¶è¡¥å
¨åä½åå·ä¸é»è®¤å®¢æ· |
| | | if (createReqVO.getSourceTicketId() != null) { |
| | | AfterSaleTicketDO ticket = ticketMapper.selectById(createReqVO.getSourceTicketId()); |
| | | if (ticket == null) { |
| | | throw exception(TICKET_NOT_EXISTS); |
| | | } |
| | | problem.setSourceTicketNo(ticket.getNo()); |
| | | if (problem.getCustomerId() == null) { |
| | | problem.setCustomerId(ticket.getCustomerId()); |
| | | } |
| | | } |
| | | problem.setNo(generateNo()) |
| | | .setStatus(AfterSaleProblemStatusEnum.DRAFT.getStatus()) |
| | | .setOwnerUserId(userId); |
| | | problemMapper.insert(problem); |
| | | // ç»å®éä»¶ |
| | | if (CollUtil.isNotEmpty(createReqVO.getBlobIds())) { |
| | | storageAttachmentApi.bindAttachments("file", "aftersales_after_sale_problem", |
| | | problem.getId(), createReqVO.getBlobIds()); |
| | | } |
| | | return problem.getId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateProblem(AfterSaleProblemSaveReqVO updateReqVO) { |
| | | AfterSaleProblemDO problem = validateProblemExists(updateReqVO.getId()); |
| | | if (!AfterSaleProblemStatusEnum.DRAFT.getStatus().equals(problem.getStatus())) { |
| | | throw exception(PROBLEM_UPDATE_FAIL_STATUS); |
| | | } |
| | | AfterSaleProblemDO update = BeanUtils.toBean(updateReqVO, AfterSaleProblemDO.class); |
| | | problemMapper.updateById(update); |
| | | if (CollUtil.isNotEmpty(updateReqVO.getBlobIds())) { |
| | | storageAttachmentApi.updateAttachments("file", "aftersales_after_sale_problem", |
| | | updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteProblem(Long id) { |
| | | AfterSaleProblemDO problem = validateProblemExists(id); |
| | | if (!AfterSaleProblemStatusEnum.DRAFT.getStatus().equals(problem.getStatus())) { |
| | | throw exception(PROBLEM_DELETE_FAIL_STATUS); |
| | | } |
| | | problemMapper.deleteById(id); |
| | | storageAttachmentApi.deleteAttachmentsByRecord("aftersales_after_sale_problem", id); |
| | | // è§£é¤å·¥å对é®é¢çå
³è |
| | | ticketMapper.update(null, new LambdaUpdateWrapper<AfterSaleTicketDO>() |
| | | .eq(AfterSaleTicketDO::getProblemId, id) |
| | | .set(AfterSaleTicketDO::getProblemId, null) |
| | | .set(AfterSaleTicketDO::getProblemNo, null)); |
| | | } |
| | | |
| | | @Override |
| | | public AfterSaleProblemDO getProblem(Long id) { |
| | | return validateProblemExists(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<AfterSaleProblemDO> getProblemList(Collection<Long> ids) { |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return List.of(); |
| | | } |
| | | return problemMapper.selectBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<AfterSaleProblemDO> getProblemPage(AfterSaleProblemPageReqVO pageReqVO) { |
| | | return problemMapper.selectPage(pageReqVO, pageReqVO.getNo(), pageReqVO.getKeyword(), |
| | | pageReqVO.getSourceTicketId(), pageReqVO.getItemId(), pageReqVO.getItemCode(), |
| | | pageReqVO.getIssueCategory(), |
| | | pageReqVO.getIssueType(), pageReqVO.getRootCauseCategory(), pageReqVO.getStatus()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void publishProblem(Long id) { |
| | | AfterSaleProblemDO problem = validateProblemExists(id); |
| | | if (!(AfterSaleProblemStatusEnum.DRAFT.getStatus().equals(problem.getStatus()) |
| | | || AfterSaleProblemStatusEnum.DISABLED.getStatus().equals(problem.getStatus()))) { |
| | | throw exception(PROBLEM_PUBLISH_FAIL_STATUS); |
| | | } |
| | | problemMapper.updateById(new AfterSaleProblemDO().setId(id) |
| | | .setStatus(AfterSaleProblemStatusEnum.PUBLISHED.getStatus()) |
| | | .setPublishTime(LocalDateTime.now())); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void disableProblem(Long id) { |
| | | AfterSaleProblemDO problem = validateProblemExists(id); |
| | | if (!AfterSaleProblemStatusEnum.PUBLISHED.getStatus().equals(problem.getStatus())) { |
| | | throw exception(PROBLEM_DISABLE_FAIL_STATUS); |
| | | } |
| | | problemMapper.updateById(new AfterSaleProblemDO().setId(id) |
| | | .setStatus(AfterSaleProblemStatusEnum.DISABLED.getStatus())); |
| | | } |
| | | |
| | | @Override |
| | | public List<AfterSaleProblemDO> getReferenceList(AfterSaleProblemPageReqVO pageReqVO) { |
| | | return problemMapper.selectReferenceList(pageReqVO.getItemId(), pageReqVO.getIssueCategory(), |
| | | pageReqVO.getIssueType(), pageReqVO.getRootCauseCategory(), pageReqVO.getKeyword()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AfterSaleProblemDO createProblemFromTicket(AfterSaleTicketDO ticket) { |
| | | // å¹çï¼åä¸å·¥åå·²æ²æ·è¿åç´æ¥å¤ç¨ |
| | | AfterSaleProblemDO exist = problemMapper.selectBySourceTicketId(ticket.getId()); |
| | | if (exist != null) { |
| | | return exist; |
| | | } |
| | | AfterSaleProblemDO problem = new AfterSaleProblemDO() |
| | | .setNo(generateNo()) |
| | | .setTitle(ticket.getName()) |
| | | .setSourceTicketId(ticket.getId()) |
| | | .setSourceTicketNo(ticket.getNo()) |
| | | .setCustomerId(ticket.getCustomerId()) |
| | | .setIssueType(ticket.getIssueType()) |
| | | .setIssueCategory(ticket.getIssueCategory()) |
| | | .setSeverityLevel(ticket.getSeverityLevel()) |
| | | .setDescription(ticket.getIssueDescription()) |
| | | .setStatus(AfterSaleProblemStatusEnum.DRAFT.getStatus()) |
| | | .setOwnerUserId(getLoginUserId()); |
| | | // åå·¥å馿¡æç»ä½ä¸ºç©æå¿«ç
§(å
è®¸æ æç»è¡) |
| | | AfterSaleTicketItemDO firstItem = CollUtil.getFirst(ticketItemMapper.selectListByTicketId(ticket.getId())); |
| | | if (firstItem != null) { |
| | | problem.setItemId(firstItem.getItemId()) |
| | | .setItemCode(firstItem.getItemCode()) |
| | | .setItemName(firstItem.getItemName()) |
| | | .setBatchId(firstItem.getBatchId()) |
| | | .setBatchCode(firstItem.getBatchCode()); |
| | | } |
| | | problemMapper.insert(problem); |
| | | return problem; |
| | | } |
| | | |
| | | // ========== å
鍿¹æ³ ========== |
| | | |
| | | private AfterSaleProblemDO validateProblemExists(Long id) { |
| | | AfterSaleProblemDO problem = problemMapper.selectById(id); |
| | | if (problem == null) { |
| | | throw exception(PROBLEM_NOT_EXISTS); |
| | | } |
| | | return problem; |
| | | } |
| | | |
| | | private String generateNo() { |
| | | String no = noRedisDAO.generate(AfterSaleNoRedisDAO.PROBLEM_NO_PREFIX); |
| | | if (problemMapper.selectByNo(no) != null) { |
| | | throw exception(PROBLEM_NO_EXISTS); |
| | | } |
| | | return no; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.service.visit; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo.AfterSaleVisitCreateReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo.AfterSaleVisitPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.visit.AfterSaleVisitDO; |
| | | import jakarta.validation.Valid; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®ååè®¿è®°å½ Service æ¥å£ |
| | | */ |
| | | public interface AfterSaleVisitService { |
| | | |
| | | /** |
| | | * ç»è®°å访 |
| | | * <p> |
| | | * å·¥åé¡»å¤äºå·²å®ç»(å¾
å访)ç¶æãç»è®°æ¶åæ¥æ¨è¿å·¥åï¼ |
| | | * 满æä¸æªå¤å â å·¥åå访éè¿(å¯å½æ¡£)ï¼ä¸æ»¡ææå¤å â å·¥ååéå¤çä¸éæ°å¤çã |
| | | * |
| | | * @param createReqVO ç»è®°ä¿¡æ¯ |
| | | * @param userId å½åç¨æ·ç¼å·(å访人) |
| | | * @return å访记å½ç¼å· |
| | | */ |
| | | Long createVisit(@Valid AfterSaleVisitCreateReqVO createReqVO, Long userId); |
| | | |
| | | /** |
| | | * è·å¾åè®¿è®°å½ |
| | | * |
| | | * @param id ç¼å· |
| | | * @return åè®¿è®°å½ |
| | | */ |
| | | AfterSaleVisitDO getVisit(Long id); |
| | | |
| | | /** |
| | | * è·å¾æå·¥åçå访记å½å表 |
| | | * |
| | | * @param ticketId å·¥åç¼å· |
| | | * @return å访记å½å表 |
| | | */ |
| | | List<AfterSaleVisitDO> getVisitListByTicketId(Long ticketId); |
| | | |
| | | /** |
| | | * è·å¾å访记å½å页 |
| | | * |
| | | * @param pageReqVO å页æ¥è¯¢ |
| | | * @return å访记å½å页 |
| | | */ |
| | | PageResult<AfterSaleVisitDO> getVisitPage(AfterSaleVisitPageReqVO pageReqVO); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.service.visit; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo.AfterSaleVisitCreateReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.visit.vo.AfterSaleVisitPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.ticket.AfterSaleTicketDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.visit.AfterSaleVisitDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.mysql.ticket.AfterSaleTicketMapper; |
| | | import cn.iocoder.yudao.module.aftersales.dal.mysql.visit.AfterSaleVisitMapper; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleTicketStatusEnum; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleVisitStatusEnum; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.aftersales.enums.ErrorCodeConstants.TICKET_NOT_EXISTS; |
| | | import static cn.iocoder.yudao.module.aftersales.enums.ErrorCodeConstants.VISIT_CREATE_FAIL_STATUS; |
| | | import static cn.iocoder.yudao.module.aftersales.enums.ErrorCodeConstants.VISIT_NOT_EXISTS; |
| | | |
| | | /** |
| | | * å®ååè®¿è®°å½ Service å®ç°ç±» |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @Slf4j |
| | | public class AfterSaleVisitServiceImpl implements AfterSaleVisitService { |
| | | |
| | | @Resource |
| | | private AfterSaleVisitMapper visitMapper; |
| | | @Resource |
| | | private AfterSaleTicketMapper ticketMapper; |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createVisit(AfterSaleVisitCreateReqVO createReqVO, Long userId) { |
| | | // 1. æ ¡éªå·¥åï¼å¿
é¡»åå¨ä¸å¤äºå·²å®ç»(å¾
å访)ç¶æ |
| | | AfterSaleTicketDO ticket = ticketMapper.selectById(createReqVO.getTicketId()); |
| | | if (ticket == null) { |
| | | throw exception(TICKET_NOT_EXISTS); |
| | | } |
| | | if (!AfterSaleTicketStatusEnum.COMPLETED.getStatus().equals(ticket.getStatus())) { |
| | | throw exception(VISIT_CREATE_FAIL_STATUS); |
| | | } |
| | | |
| | | // 2. æå
¥åè®¿è®°å½ |
| | | AfterSaleVisitDO visitDO = BeanUtils.toBean(createReqVO, AfterSaleVisitDO.class) |
| | | .setVisitorUserId(userId) |
| | | .setVisitTime(LocalDateTime.now()); |
| | | visitMapper.insert(visitDO); |
| | | |
| | | // 3. ç»å®éä»¶ |
| | | if (CollUtil.isNotEmpty(createReqVO.getBlobIds())) { |
| | | storageAttachmentApi.bindAttachments("file", "aftersales_after_sale_visit", |
| | | visitDO.getId(), createReqVO.getBlobIds()); |
| | | } |
| | | |
| | | // 4. æ¨è¿å·¥ååè®¿ç¶æï¼æ»¡æä¸æªå¤å â éè¿ï¼ä¸æ»¡ææå¤å â åéå¤çä¸éæ°å¤ç |
| | | boolean satisfied = Boolean.TRUE.equals(createReqVO.getSatisfied()); |
| | | boolean recurred = Boolean.TRUE.equals(createReqVO.getRecurred()); |
| | | AfterSaleTicketDO update = new AfterSaleTicketDO().setId(ticket.getId()) |
| | | .setLastVisitTime(visitDO.getVisitTime()) |
| | | .setLastVisitSatisfied(satisfied) |
| | | .setLastVisitRecurred(recurred); |
| | | if (satisfied && !recurred) { |
| | | update.setVisitStatus(AfterSaleVisitStatusEnum.PASSED.getStatus()); |
| | | } else { |
| | | update.setStatus(AfterSaleTicketStatusEnum.PROCESSING.getStatus()) |
| | | .setResolvedTime(null) |
| | | .setVisitStatus(AfterSaleVisitStatusEnum.WAITING.getStatus()); |
| | | } |
| | | ticketMapper.updateById(update); |
| | | return visitDO.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public AfterSaleVisitDO getVisit(Long id) { |
| | | AfterSaleVisitDO visitDO = visitMapper.selectById(id); |
| | | if (visitDO == null) { |
| | | throw exception(VISIT_NOT_EXISTS); |
| | | } |
| | | return visitDO; |
| | | } |
| | | |
| | | @Override |
| | | public List<AfterSaleVisitDO> getVisitListByTicketId(Long ticketId) { |
| | | return visitMapper.selectListByTicketId(ticketId); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<AfterSaleVisitDO> getVisitPage(AfterSaleVisitPageReqVO pageReqVO) { |
| | | return visitMapper.selectPage(pageReqVO, pageReqVO.getTicketId(), |
| | | pageReqVO.getVisitType(), pageReqVO.getSatisfied()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.api.employee; |
| | | |
| | | import cn.iocoder.yudao.module.hrm.api.employee.dto.HrmEmployeeSimpleDTO; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * åå·¥æ¡£æ¡ API æ¥å£ |
| | | * |
| | | * <p>æä¾ç»å
¶ä»æ¨¡åè·¨æ¨¡åæ¥è¯¢å工精ç®ä¿¡æ¯ï¼ |
| | | * ä¾å¦å®å
¨ç产模åçç¹ç§ä½ä¸è¯éè¦å
³èæè¯äººã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | public interface HrmEmployeeApi { |
| | | |
| | | /** |
| | | * è·åå工精ç®ä¿¡æ¯ |
| | | * |
| | | * @param id åå·¥ç¼å· |
| | | * @return å工信æ¯ï¼ä¸åå¨è¿å null |
| | | */ |
| | | HrmEmployeeSimpleDTO getEmployee(Long id); |
| | | |
| | | /** |
| | | * æ¹éè·åå工精ç®ä¿¡æ¯ |
| | | * |
| | | * @param ids åå·¥ç¼å·éå |
| | | * @return å工信æ¯å表 |
| | | */ |
| | | List<HrmEmployeeSimpleDTO> getEmployeeList(Collection<Long> ids); |
| | | |
| | | /** |
| | | * æ ¡éªåå·¥æ¯å¦åå¨ï¼ä¸æªå é¤ï¼ |
| | | * |
| | | * @param id åå·¥ç¼å· |
| | | * @return æ¯å¦åå¨ |
| | | */ |
| | | boolean validateEmployeeExists(Long id); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.api.employee.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å工精ç®ä¿¡æ¯ DTO |
| | | * |
| | | * <p>ä¾å
¶ä»æ¨¡åï¼å¦å®å
¨ç产模åçç¹ç§ä½ä¸è¯ï¼å
³èåå·¥æ¡£æ¡æ¶ä½¿ç¨ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Data |
| | | public class HrmEmployeeSimpleDTO { |
| | | |
| | | /** |
| | | * åå·¥ç¼å· |
| | | */ |
| | | private Long id; |
| | | |
| | | /** |
| | | * å
³èçç³»ç»ç¨æ·ç¼å· |
| | | * |
| | | * å
³è AdminUserDO#getId() |
| | | */ |
| | | private Long userId; |
| | | |
| | | /** |
| | | * åå·¥ç¼å·ï¼å·¥å·ï¼ |
| | | */ |
| | | private String employeeNo; |
| | | |
| | | /** |
| | | * åå·¥å§å |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * é¨é¨ç¼å· |
| | | */ |
| | | private Long deptId; |
| | | |
| | | /** |
| | | * é¨é¨åç§° |
| | | */ |
| | | private String deptName; |
| | | |
| | | /** |
| | | * ææºå·ç |
| | | */ |
| | | private String phone; |
| | | |
| | | /** |
| | | * åå·¥ç¶æï¼1-å¨èï¼2-è¯ç¨ï¼3-离è |
| | | */ |
| | | private Integer employeeStatus; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.api.employee; |
| | | |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.hrm.api.employee.dto.HrmEmployeeSimpleDTO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.employee.HrmEmployeeMapper; |
| | | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| | | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * åå·¥æ¡£æ¡ API å®ç°ç±» |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class HrmEmployeeApiImpl implements HrmEmployeeApi { |
| | | |
| | | @Resource |
| | | private HrmEmployeeMapper employeeMapper; |
| | | @Resource |
| | | private DeptApi deptApi; |
| | | |
| | | @Override |
| | | public HrmEmployeeSimpleDTO getEmployee(Long id) { |
| | | if (id == null) { |
| | | return null; |
| | | } |
| | | HrmEmployeeDO employee = employeeMapper.selectById(id); |
| | | if (employee == null) { |
| | | return null; |
| | | } |
| | | return build(employee, getDeptName(employee.getDeptId())); |
| | | } |
| | | |
| | | @Override |
| | | public List<HrmEmployeeSimpleDTO> getEmployeeList(Collection<Long> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return List.of(); |
| | | } |
| | | List<HrmEmployeeDO> employees = employeeMapper.selectBatchIds(ids); |
| | | if (employees.isEmpty()) { |
| | | return List.of(); |
| | | } |
| | | // æ¹éæ¥é¨é¨ï¼é¿å
N+1 |
| | | List<Long> deptIds = employees.stream().map(HrmEmployeeDO::getDeptId) |
| | | .filter(Objects::nonNull).distinct().toList(); |
| | | // ç¨ new HashMap<>() èé Map.of()ï¼åå·¥ç deptId å
è®¸ä¸ºç©ºï¼ |
| | | // åé¢ deptMap.get(e.getDeptId()) ä¼ get(null)ï¼Map.of() ç get(null) æ NPEã |
| | | Map<Long, DeptRespDTO> deptMap = deptIds.isEmpty() ? new HashMap<>() : deptApi.getDeptMap(deptIds); |
| | | return employees.stream() |
| | | .map(e -> { |
| | | DeptRespDTO dept = deptMap.get(e.getDeptId()); |
| | | return build(e, dept == null ? null : dept.getName()); |
| | | }) |
| | | .toList(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean validateEmployeeExists(Long id) { |
| | | return id != null && employeeMapper.selectById(id) != null; |
| | | } |
| | | |
| | | private String getDeptName(Long deptId) { |
| | | if (deptId == null) { |
| | | return null; |
| | | } |
| | | DeptRespDTO dept = deptApi.getDept(deptId); |
| | | return dept == null ? null : dept.getName(); |
| | | } |
| | | |
| | | private static HrmEmployeeSimpleDTO build(HrmEmployeeDO employee, String deptName) { |
| | | HrmEmployeeSimpleDTO dto = BeanUtils.toBean(employee, HrmEmployeeSimpleDTO.class); |
| | | dto.setDeptName(deptName); |
| | | return dto; |
| | | } |
| | | |
| | | } |
| | |
| | | <version>${revision}</version> |
| | | </dependency> |
| | | |
| | | <!-- HRM 人åèµæº APIï¼å®å
¨ç产模åçç¹ç§ä½ä¸è¯éå
³èåå·¥æ¡£æ¡ --> |
| | | <dependency> |
| | | <groupId>cn.iocoder.boot</groupId> |
| | | <artifactId>yudao-module-hrm-api</artifactId> |
| | | <version>${revision}</version> |
| | | </dependency> |
| | | |
| | | <!-- MDM ä¸»æ°æ®ç®¡ç API --> |
| | | <dependency> |
| | | <groupId>cn.iocoder.boot</groupId> |
| | |
| | | <version>3.3.3</version> |
| | | </dependency> |
| | | |
| | | <!-- MQTT 客æ·ç«¯ï¼MES æ°éï¼collectï¼æ¨¡åè¿æ¥è®¾å¤ç½å
³ --> |
| | | <dependency> |
| | | <groupId>org.eclipse.paho</groupId> |
| | | <artifactId>org.eclipse.paho.client.mqttv3</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- Test æµè¯ç¸å
³ --> |
| | | <dependency> |
| | | <groupId>cn.iocoder.boot</groupId> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.collect.vo.*; |
| | | import cn.iocoder.yudao.module.mes.service.collect.MesCollectQueryService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管çåå° - MES æ°éçæ§") |
| | | @RestController |
| | | @RequestMapping("/mes/collect") |
| | | @Validated |
| | | public class MesCollectController { |
| | | |
| | | @Resource |
| | | private MesCollectQueryService queryService; |
| | | |
| | | @GetMapping("/device/list") |
| | | @Operation(summary = "è·åæ°é设å¤ç¶æå表") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<List<MesCollectDeviceRespVO>> getDeviceList() { |
| | | return success(queryService.getDeviceList()); |
| | | } |
| | | |
| | | @GetMapping("/realtime/get") |
| | | @Operation(summary = "è·åè®¾å¤ææ°å®æ¶ç¶æ") |
| | | @Parameter(name = "deviceCode", description = "æ°é设å¤ç¼å·", required = true, example = "C01") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<MesCollectRealtimeRespVO> getRealtime(@RequestParam("deviceCode") String deviceCode) { |
| | | return success(queryService.getRealtime(deviceCode)); |
| | | } |
| | | |
| | | @GetMapping("/realtime/history-page") |
| | | @Operation(summary = "å页æ¥è¯¢å®æ¶ç¶æåå²") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectRealtimeRespVO>> getRealtimeHistoryPage( |
| | | @Valid MesCollectRealtimeHistoryPageReqVO reqVO) { |
| | | return success(queryService.getRealtimeHistoryPage(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/cycle/page") |
| | | @Operation(summary = "å页æ¥è¯¢å¨æè¿ç¨æ°æ®") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectCycleRespVO>> getCyclePage(@Valid MesCollectCyclePageReqVO reqVO) { |
| | | return success(queryService.getCyclePage(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/cycle/get") |
| | | @Operation(summary = "è·å卿è¿ç¨æ°æ®æç»") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<MesCollectCycleRespVO> getCycle(@RequestParam("id") Long id) { |
| | | return success(queryService.getCycle(id)); |
| | | } |
| | | |
| | | @GetMapping("/tech/get") |
| | | @Operation(summary = "è·åè®¾å¤ææ°å·¥èºåæ°å¿«ç
§") |
| | | @Parameter(name = "deviceCode", description = "æ°é设å¤ç¼å·", required = true, example = "C01") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<MesCollectTechRespVO> getTech(@RequestParam("deviceCode") String deviceCode) { |
| | | return success(queryService.getTech(deviceCode)); |
| | | } |
| | | |
| | | @GetMapping("/operate-log/page") |
| | | @Operation(summary = "å页æ¥è¯¢åæ°åæ´æ¥å¿") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectOperateLogRespVO>> getOperateLogPage( |
| | | @Valid MesCollectOperateLogPageReqVO reqVO) { |
| | | return success(queryService.getOperateLogPage(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/alarm/page") |
| | | @Operation(summary = "å页æ¥è¯¢æ¥è¦è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect:query')") |
| | | public CommonResult<PageResult<MesCollectAlarmRespVO>> getAlarmPage(@Valid MesCollectAlarmPageReqVO reqVO) { |
| | | return success(queryService.getAlarmPage(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/alarm/ack") |
| | | @Operation(summary = "人工确认æ¶é¤æ¥è¦") |
| | | @Parameter(name = "id", description = "æ¥è¦è®°å½ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('mes:collect-alarm:ack')") |
| | | public CommonResult<Boolean> ackAlarm(@RequestParam("id") Long id) { |
| | | queryService.ackAlarm(id); |
| | | return success(true); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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 = "管çåå° - MES æ°éæ¥è¦å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectAlarmPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "ç¶æï¼0æªæ¶é¤ 1å·²æ¶é¤", example = "0") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "æ¥è¦æ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] wmTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éæ¥è¦ Response VO") |
| | | @Data |
| | | public class MesCollectAlarmRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "æ¥è¦æ è¯ï¼2产ç 0æ¶å¤±", example = "2") |
| | | private Integer wmId; |
| | | @Schema(description = "æ¥è¦å
容", example = "å®å
¨é¨æªå
³") |
| | | private String wmMsg; |
| | | @Schema(description = "æ¥è¦æ¶é´") |
| | | private LocalDateTime wmTime; |
| | | @Schema(description = "ç¶æï¼0æªæ¶é¤ 1å·²æ¶é¤", example = "0") |
| | | private Integer status; |
| | | @Schema(description = "ç¶æåç§°", example = "æªæ¶é¤") |
| | | private String statusName; |
| | | @Schema(description = "æ¶é¤æ¶é´") |
| | | private LocalDateTime clearTime; |
| | | @Schema(description = "æ¥æééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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 = "管çåå° - MES æ°é卿è¿ç¨å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectCyclePageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "ééæ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] collectTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é卿è¿ç¨æ°æ® Response VO") |
| | | @Data |
| | | public class MesCollectCycleRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "卿åºå·ï¼CYCNï¼", example = "100") |
| | | private Long cycleNo; |
| | | @Schema(description = "ééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "卿æ¶é´ï¼ECYCTï¼") |
| | | private BigDecimal ecyct; |
| | | @Schema(description = "å°åºèµ·ç¹ï¼EISSï¼") |
| | | private BigDecimal eiss; |
| | | @Schema(description = "æå¤§å°éï¼EIVMï¼") |
| | | private BigDecimal eivm; |
| | | @Schema(description = "æå¤§å°åï¼EIPMï¼") |
| | | private BigDecimal eipm; |
| | | @Schema(description = "转ä¿åæ¶é´ï¼ESIPTï¼") |
| | | private BigDecimal esipt; |
| | | @Schema(description = "转ä¿åååï¼ESIPPï¼") |
| | | private BigDecimal esipp; |
| | | @Schema(description = "转ä¿åä½ç½®ï¼ESIPSï¼") |
| | | private BigDecimal esips; |
| | | @Schema(description = "å°åºæ¶é´ï¼EIPTï¼") |
| | | private BigDecimal eipt; |
| | | @Schema(description = "å°åºç»ç¹ä½ç½®ï¼EIPSEï¼") |
| | | private BigDecimal eipse; |
| | | @Schema(description = "卿æ¶é´ï¼EPLSTï¼") |
| | | private BigDecimal eplst; |
| | | @Schema(description = "卿ç»ç¹ï¼EPLSSEï¼") |
| | | private BigDecimal eplsse; |
| | | @Schema(description = "æå¤§å¨æååï¼EPLSPMï¼") |
| | | private BigDecimal eplspm; |
| | | @Schema(description = "ç产温度 JSONï¼ET1..ETnï¼") |
| | | private String etTemps; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é设å¤ç¶æ Response VO") |
| | | @Data |
| | | public class MesCollectDeviceRespVO { |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "设å¤ç¼ç ", example = "MC_20260818001") |
| | | private String machineryCode; |
| | | @Schema(description = "设å¤åç§°", example = "æ³¨å¡æº 1 å·") |
| | | private String machineryName; |
| | | @Schema(description = "å·¥ä½ç«ç¼å·", example = "1") |
| | | private Long workstationId; |
| | | @Schema(description = "å·¥ä½ç«åç§°", example = "注å¡å·¥ä½ç«") |
| | | private String workstationName; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String collectDeviceCode; |
| | | @Schema(description = "æ¯å¦å¯ç¨æ°é", example = "true") |
| | | private Boolean collectEnabled; |
| | | @Schema(description = "æè¿ééæ¶é´") |
| | | private LocalDateTime lastCollectTime; |
| | | @Schema(description = "æ¯å¦å¨çº¿ï¼5 åéå
ææ°æ®ï¼", example = "true") |
| | | private Boolean online; |
| | | @Schema(description = "è¿è¡ç¶æï¼1å¾
æº 2ç产", example = "2") |
| | | private Integer sts; |
| | | @Schema(description = "è¿è¡ç¶æåç§°", example = "ç产") |
| | | private String stsName; |
| | | @Schema(description = "è¿è¡æ¨¡å¼ï¼0æå¨ 1åèªå¨ 2çµç¼èªå¨ 3æ¶é´èªå¨ 4è°æ¨¡ä½¿ç¨", example = "2") |
| | | private Integer opm; |
| | | @Schema(description = "è¿è¡æ¨¡å¼åç§°", example = "çµç¼èªå¨") |
| | | private String opmName; |
| | | @Schema(description = "油温", example = "26.5") |
| | | private BigDecimal ot; |
| | | @Schema(description = "åæ®µæ¸©åº¦ JSON") |
| | | private String temps; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产任å¡ç¼ç ", example = "PT202610200001") |
| | | private String taskCode; |
| | | @Schema(description = "ç产任å¡åç§°", example = "注å¡ä»»å¡") |
| | | private String taskName; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "ç产工åç¼ç ", example = "PO202610200001") |
| | | private String workOrderCode; |
| | | @Schema(description = "æªæ¶é¤æ¥è¦æ°é", example = "1") |
| | | private Long activeAlarmCount; |
| | | /** |
| | | * æè¿ä¸æ¬¡ééç宿´æ°æ® JSONã |
| | | * |
| | | * <p>设å¤ç½å
³ä¸æ¥çæ¯ä¸æé®çç¬æ¶å¼ï¼å¦ {"计米":268.35,"线é度":0.0}ï¼ï¼ |
| | | * 䏿³¨å¡æºåè®®ç STS/OPM/OT ç»æä¸åï¼ç»æååæ®µï¼sts/opm/ot/tempsï¼ä¼æ¯ç©ºçï¼ |
| | | * å端å±ç¤ºãå½åæ°æ®ãéè¦è¿ä¸ªåå§ JSONã</p> |
| | | */ |
| | | @Schema(description = "æè¿ééæ°æ® JSON", example = "{\"计米\":268.35}") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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 = "管çåå° - MES æ°éåæ°åæ´å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectOperateLogPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "åéç¼ç ", example = "SIPS") |
| | | private String varId; |
| | | |
| | | @Schema(description = "ä¿®æ¹æ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] modifyTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éåæ°åæ´ Response VO") |
| | | @Data |
| | | public class MesCollectOperateLogRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "åéç¼ç ", example = "SIPS") |
| | | private String varId; |
| | | @Schema(description = "ä¿®æ¹åçå¼", example = "37") |
| | | private String oldValue; |
| | | @Schema(description = "ä¿®æ¹åçå¼", example = "37.5") |
| | | private String newValue; |
| | | @Schema(description = "åæ°ä¿®æ¹æ¶é´") |
| | | private LocalDateTime modifyTime; |
| | | @Schema(description = "æ¥æééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.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 = "管çåå° - MES æ°é宿¶åå²å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesCollectRealtimeHistoryPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | |
| | | @Schema(description = "ééæ¶é´") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] collectTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°é宿¶æ°æ® Response VO") |
| | | @Data |
| | | public class MesCollectRealtimeRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "ééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "è¿è¡ç¶æï¼1å¾
æº 2ç产", example = "2") |
| | | private Integer sts; |
| | | @Schema(description = "è¿è¡ç¶æåç§°", example = "ç产") |
| | | private String stsName; |
| | | @Schema(description = "è¿è¡æ¨¡å¼ï¼0æå¨ 1åèªå¨ 2çµç¼èªå¨ 3æ¶é´èªå¨ 4è°æ¨¡ä½¿ç¨", example = "2") |
| | | private Integer opm; |
| | | @Schema(description = "è¿è¡æ¨¡å¼åç§°", example = "çµç¼èªå¨") |
| | | private String opmName; |
| | | @Schema(description = "éå ç¶æ", example = "0") |
| | | private Integer asts; |
| | | @Schema(description = "油温", example = "26.5") |
| | | private BigDecimal ot; |
| | | @Schema(description = "åæ®µæ¸©åº¦ JSON") |
| | | private String temps; |
| | | @Schema(description = "宿´æ°æ® JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.collect.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ°éå·¥èºåæ° Response VO") |
| | | @Data |
| | | public class MesCollectTechRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | @Schema(description = "设å¤å°è´¦ç¼å·", example = "1") |
| | | private Long machineryId; |
| | | @Schema(description = "æ°é设å¤ç¼å·", example = "C01") |
| | | private String deviceCode; |
| | | @Schema(description = "ç产任å¡ç¼å·", example = "1") |
| | | private Long taskId; |
| | | @Schema(description = "ç产工åç¼å·", example = "1") |
| | | private Long workOrderId; |
| | | @Schema(description = "ééæ¶é´") |
| | | private LocalDateTime collectTime; |
| | | @Schema(description = "å·¥èºåæ°å®æ´å¿«ç
§ JSON") |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.dv.spare; |
| | | import cn.iocoder.yudao.framework.common.pojo.*; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.spare.MesDvSparePartDO; |
| | | import cn.iocoder.yudao.module.mes.service.dv.spare.MesDvSpareService; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | @Tag(name="管çåå° - 设å¤å¤ä»¶ç®¡ç") |
| | | @RestController @RequestMapping("/mes/dv/spare") @Validated |
| | | public class MesDvSpareController { |
| | | @Resource private MesDvSpareService service; |
| | | @GetMapping("/page") @PreAuthorize("@ss.hasPermission('mes:dv-spare:query')") |
| | | public CommonResult<PageResult<MesDvSparePartDO>> page(@Valid MesDvSparePageReqVO req) { return success(service.page(req)); } |
| | | @GetMapping("/get") @PreAuthorize("@ss.hasPermission('mes:dv-spare:query')") |
| | | public CommonResult<MesDvSparePartDO> get(@RequestParam Long id) { return success(service.get(id)); } |
| | | @PostMapping("/create") @PreAuthorize("@ss.hasPermission('mes:dv-spare:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody MesDvSparePartSaveReqVO req) { |
| | | req.setId(null); return success(service.create(req,getLoginUserId())); |
| | | } |
| | | @PutMapping("/update") @PreAuthorize("@ss.hasPermission('mes:dv-spare:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody MesDvSparePartSaveReqVO req) { service.update(req); return success(true); } |
| | | @DeleteMapping("/delete") @PreAuthorize("@ss.hasPermission('mes:dv-spare:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam Long id) { service.delete(id); return success(true); } |
| | | @GetMapping("/movement-page") @PreAuthorize("@ss.hasPermission('mes:dv-spare:record')") |
| | | public CommonResult<PageResult<MesDvSpareMovementRespVO>> movements(@Valid MesDvSparePageReqVO req) { return success(service.movements(req)); } |
| | | @PostMapping("/receive") @PreAuthorize("@ss.hasPermission('mes:dv-spare:receive')") |
| | | public CommonResult<Long> receive(@Valid @RequestBody MesDvSpareActionReqVO req) { return success(service.receive(req,getLoginUserId())); } |
| | | @PostMapping("/issue") @PreAuthorize("@ss.hasPermission('mes:dv-spare:issue')") |
| | | public CommonResult<Long> issue(@Valid @RequestBody MesDvSpareActionReqVO req) { return success(service.issue(req,getLoginUserId())); } |
| | | @PostMapping("/return") @PreAuthorize("@ss.hasPermission('mes:dv-spare:return')") |
| | | public CommonResult<Long> returnPart(@Valid @RequestBody MesDvSpareActionReqVO req) { return success(service.returnPart(req,getLoginUserId())); } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | @Data |
| | | public class MesDvSpareActionReqVO { |
| | | @NotBlank @Pattern(regexp="[a-zA-Z0-9-]{16,64}") private String requestKey; |
| | | @Positive private Long sparePartId; |
| | | @Positive private Long repairId; |
| | | @Positive private Long originalId; |
| | | @Positive private Long receiverUserId; |
| | | @NotNull @DecimalMin(value="0",inclusive=false) @Digits(integer=15,fraction=3) private BigDecimal quantity; |
| | | @NotBlank @Size(max=500) private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.spare.MesDvSpareMovementDO; |
| | | import java.math.BigDecimal; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | @Data @EqualsAndHashCode(callSuper=true) |
| | | public class MesDvSpareMovementRespVO extends MesDvSpareMovementDO { |
| | | private BigDecimal returnedQuantity; |
| | | private BigDecimal returnableQuantity; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import jakarta.validation.constraints.*; |
| | | @Data @EqualsAndHashCode(callSuper=true) |
| | | public class MesDvSparePageReqVO extends PageParam { |
| | | private String code; |
| | | private String name; |
| | | private Integer status; |
| | | private Boolean shortageOnly; |
| | | private Long sparePartId; |
| | | private Long repairId; |
| | | private String repairCode; |
| | | @Min(1) @Max(4) private Integer type; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | @Data |
| | | public class MesDvSparePartSaveReqVO { |
| | | private Long id; |
| | | @NotBlank @Size(max=64) private String code; |
| | | @NotBlank @Size(max=128) private String name; |
| | | @Size(max=255) private String specification; |
| | | @NotBlank @Size(max=32) private String unit; |
| | | @Size(max=128) private String location; |
| | | @NotNull @DecimalMin("0") @Digits(integer=15,fraction=3) private BigDecimal initialQuantity; |
| | | @NotNull @DecimalMin("0") @Digits(integer=15,fraction=3) private BigDecimal safetyQuantity; |
| | | @NotNull @Min(0) @Max(1) private Integer status; |
| | | @Size(max=500) private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.*; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.energy.vo.EnergyAlertRuleSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.energy.*; |
| | | import cn.iocoder.yudao.module.mes.service.energy.EnergyAlertService; |
| | | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import jakarta.validation.constraints.*; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @RestController @RequestMapping("/energy/alert") @Validated |
| | | public class EnergyAlertController { |
| | | @Resource private EnergyAlertService energyAlertService; |
| | | @Resource private AdminUserService adminUserService; |
| | | @GetMapping("/page") @PreAuthorize("@ss.hasPermission('energy:alert:query')") |
| | | public CommonResult<PageResult<EnergyAlertRuleDO>> page(@Valid PageParam page) { return success(energyAlertService.page(page)); } |
| | | @GetMapping("/logs") @PreAuthorize("@ss.hasPermission('energy:alert:query')") |
| | | public CommonResult<PageResult<EnergyAlertLogDO>> logs(@Valid PageParam page, |
| | | @RequestParam(required=false) @DateTimeFormat(iso=DateTimeFormat.ISO.DATE) LocalDate date, |
| | | @RequestParam(required=false) @Pattern(regexp="SENT|FAILED") String status) { |
| | | return success(energyAlertService.logs(page, date, status)); |
| | | } |
| | | @GetMapping("/recipients") @PreAuthorize("@ss.hasPermission('energy:alert:query')") |
| | | public CommonResult<List<Map<String, Object>>> recipients() { |
| | | return success(adminUserService.getUserListByStatus(0).stream() |
| | | .map(user -> Map.<String,Object>of("id", user.getId(), "nickname", user.getNickname())).toList()); |
| | | } |
| | | @PostMapping("/create") @PreAuthorize("@ss.hasPermission('energy:alert:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody EnergyAlertRuleSaveReqVO req) { req.setId(null); return success(energyAlertService.save(req)); } |
| | | @PutMapping("/update") @PreAuthorize("@ss.hasPermission('energy:alert:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody EnergyAlertRuleSaveReqVO req) { |
| | | if (req.getId() == null) throw cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception( |
| | | new cn.iocoder.yudao.framework.common.exception.ErrorCode(1_040_951_001, "ä¿®æ¹é¢è¦è§åå¿
é¡»æä¾ç¼å·")); |
| | | energyAlertService.save(req); return success(true); |
| | | } |
| | | @DeleteMapping("/delete") @PreAuthorize("@ss.hasPermission('energy:alert:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam Long id) { energyAlertService.delete(id); return success(true); } |
| | | @PostMapping("/check") @PreAuthorize("@ss.hasPermission('energy:alert:check')") |
| | | public CommonResult<Map<String,Integer>> check(@RequestParam @NotNull @PastOrPresent |
| | | @DateTimeFormat(iso=DateTimeFormat.ISO.DATE) LocalDate date) { return success(energyAlertService.check(date)); } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.energy.vo.*; |
| | | import cn.iocoder.yudao.module.mes.service.energy.EnergyRecordService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管çåå° - ç¬ç«è½è管ç") |
| | | @RestController |
| | | @RequestMapping("/energy/record") |
| | | @Validated |
| | | public class EnergyRecordController { |
| | | @Resource private cn.iocoder.yudao.module.mes.service.energy.EnergyExportService energyExportService; |
| | | @Resource(name = "energyRecordService") |
| | | private EnergyRecordService energyRecordService; |
| | | |
| | | @GetMapping("/export-excel") |
| | | @PreAuthorize("@ss.hasPermission('energy:record:export')") |
| | | public void export(@Valid EnergyRecordPageReqVO req, jakarta.servlet.http.HttpServletResponse response) throws java.io.IOException { |
| | | energyExportService.records(req, response); |
| | | } |
| | | @GetMapping("/analysis-export") |
| | | @PreAuthorize("@ss.hasPermission('energy:analysis:export')") |
| | | public void exportAnalysis(@Valid EnergyAnalysisReqVO req, jakarta.servlet.http.HttpServletResponse response) throws java.io.IOException { |
| | | energyExportService.analysis(req, response); |
| | | } |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "æå¨æ°å¢è½èè®°å½") |
| | | @PreAuthorize("@ss.hasPermission('energy:record:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody EnergyRecordSaveReqVO req) { |
| | | return success(energyRecordService.create(req)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹è½èè®°å½") |
| | | @PreAuthorize("@ss.hasPermission('energy:record:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody EnergyRecordSaveReqVO req) { |
| | | energyRecordService.update(req); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤è½èè®°å½") |
| | | @PreAuthorize("@ss.hasPermission('energy:record:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") Long id) { |
| | | energyRecordService.delete(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "æ¥çè½èè®°å½") |
| | | @PreAuthorize("@ss.hasPermission('energy:record:query')") |
| | | public CommonResult<EnergyRecordRespVO> get(@RequestParam("id") Long id) { |
| | | return success(BeanUtils.toBean(energyRecordService.get(id), EnergyRecordRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "å页æ¥è¯¢è½èè®°å½") |
| | | @PreAuthorize("@ss.hasPermission('energy:record:query')") |
| | | public CommonResult<PageResult<EnergyRecordRespVO>> page(@Valid EnergyRecordPageReqVO req) { |
| | | return success(BeanUtils.toBean(energyRecordService.page(req), EnergyRecordRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/analysis") |
| | | @Operation(summary = "è½èæ°æ®åæï¼æè½æºå嫿±æ»ç¨éï¼") |
| | | @PreAuthorize("@ss.hasPermission('energy:analysis:query')") |
| | | public CommonResult<EnergyAnalysisRespVO> analysis(@Valid EnergyAnalysisReqVO req) { |
| | | return success(energyRecordService.analysis(req)); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy.vo; |
| | | |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class EnergyAlertRuleSaveReqVO { |
| | | private Long id; |
| | | @NotBlank @Size(max = 100) private String name; |
| | | @NotNull @Pattern(regexp = "WATER|ELECTRICITY|STEAM") private String energyType; |
| | | @Size(max = 100) private String usageArea; |
| | | @Size(max = 50) private String productCategory; |
| | | @NotNull @Pattern(regexp = "QUANTITY|AMOUNT|MONTH_QUANTITY|MONTH_AMOUNT") private String metric; |
| | | @NotNull @DecimalMin(value = "0", inclusive = false) @Digits(integer = 26, fraction = 3) |
| | | private BigDecimal threshold; |
| | | @NotNull private Boolean enabled; |
| | | @NotEmpty @Size(max = 50) private List<@NotNull @Positive Long> recipientIds; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy.vo; |
| | | |
| | | import jakarta.validation.constraints.AssertTrue; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Pattern; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | public class EnergyAnalysisReqVO { |
| | | @NotNull |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate startDate; |
| | | @NotNull |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate endDate; |
| | | @Pattern(regexp = "WATER|ELECTRICITY|STEAM") |
| | | private String energyType; |
| | | private String usageArea; |
| | | private String productCategory; |
| | | @NotNull |
| | | @Pattern(regexp = "DAY|MONTH") |
| | | private String groupBy = "DAY"; |
| | | |
| | | @AssertTrue(message = "ç»è®¡æ¥æèå´å¿
é¡»å¨ä¸¤å¹´ä»¥å
ï¼ä¸å¼å§æ¥æä¸è½æäºç»ææ¥æ") |
| | | public boolean isDateRangeValid() { |
| | | return startDate == null || endDate == null |
| | | || (!startDate.isAfter(endDate) && !endDate.isAfter(startDate.plusYears(2))); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy.vo; |
| | | |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class EnergyAnalysisRespVO { |
| | | private BigDecimal totalAmount = BigDecimal.ZERO; |
| | | private long recordCount; |
| | | private List<Summary> summary = new ArrayList<>(); |
| | | private List<Bucket> trend = new ArrayList<>(); |
| | | private List<Bucket> areas = new ArrayList<>(); |
| | | |
| | | @Data |
| | | public static class Summary { |
| | | private String energyType; |
| | | private BigDecimal quantity = BigDecimal.ZERO; |
| | | private BigDecimal amount = BigDecimal.ZERO; |
| | | private long recordCount; |
| | | } |
| | | |
| | | @Data |
| | | public static class Bucket extends Summary { |
| | | /** è¶å¿ä¸ºæ¥æ/æï¼åºååå¸ä¸ºåºååç§°ã */ |
| | | private String label; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy.vo; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import jakarta.validation.constraints.AssertTrue; |
| | | import jakarta.validation.constraints.Pattern; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class EnergyRecordPageReqVO extends PageParam { |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate startDate; |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate endDate; |
| | | @Pattern(regexp = "WATER|ELECTRICITY|STEAM") |
| | | private String energyType; |
| | | private String usageArea; |
| | | private String productCategory; |
| | | |
| | | @AssertTrue(message = "å¼å§æ¥æä¸è½æäºç»ææ¥æ") |
| | | public boolean isDateRangeValid() { |
| | | return startDate == null || endDate == null || !startDate.isAfter(endDate); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy.vo; |
| | | |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class EnergyRecordRespVO { |
| | | private Long id; |
| | | private LocalDate recordDate; |
| | | private String energyType; |
| | | private String usageArea; |
| | | private String productCategory; |
| | | private String usagePurpose; |
| | | private BigDecimal quantity; |
| | | private BigDecimal unitPrice; |
| | | private BigDecimal amount; |
| | | private String recorder; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.energy.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | @Data |
| | | @Schema(description = "管çåå° - è½èè®°å½æ°å¢/ä¿®æ¹") |
| | | public class EnergyRecordSaveReqVO { |
| | | @Positive |
| | | private Long id; |
| | | @NotNull(message = "ç»è®¡æ¥æä¸è½ä¸ºç©º") |
| | | @PastOrPresent(message = "ç»è®¡æ¥æä¸è½æäºä»å¤©") |
| | | private LocalDate recordDate; |
| | | @NotBlank |
| | | @Pattern(regexp = "WATER|ELECTRICITY|STEAM", message = "è½æºç±»ååªè½ä¸ºæ°´ãçµãè¸æ±½") |
| | | private String energyType; |
| | | @NotBlank(message = "使ç¨åºåä¸è½ä¸ºç©º") |
| | | @Size(max = 100) |
| | | private String usageArea; |
| | | @NotBlank(message = "产åç±»å«ä¸è½ä¸ºç©º") |
| | | @Size(max = 50) |
| | | private String productCategory; |
| | | @NotBlank(message = "ç¨éä¸è½ä¸ºç©º") |
| | | @Size(max = 100) |
| | | private String usagePurpose; |
| | | @NotNull |
| | | @DecimalMin(value = "0", inclusive = false, message = "ç¨éå¿
须大äºé¶") |
| | | @Digits(integer = 15, fraction = 3, message = "ç¨éæå¤15使´æ°ã3ä½å°æ°") |
| | | private BigDecimal quantity; |
| | | @NotNull |
| | | @DecimalMin(value = "0", message = "åä»·ä¸è½ä¸ºè´æ°") |
| | | @Digits(integer = 8, fraction = 4, message = "åä»·æå¤8使´æ°ã4ä½å°æ°") |
| | | private BigDecimal unitPrice; |
| | | @NotBlank(message = "å½å
¥äººä¸è½ä¸ºç©º") |
| | | @Size(max = 50) |
| | | private String recorder; |
| | | @Size(max = 500) |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.ledger; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | 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.dict.core.DictFrameworkUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerExportVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcQualityExportVO; |
| | | import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; |
| | | import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; |
| | | import cn.iocoder.yudao.module.mes.service.qc.ledger.MesQcInspectionLedgerService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管çåå° - MES æ£æµç»æå°è´¦") |
| | | @RestController |
| | | @RequestMapping("/mes/qc/inspection-ledger") |
| | | @Validated |
| | | public class MesQcInspectionLedgerController { |
| | | |
| | | @Resource |
| | | private MesQcInspectionLedgerService ledgerService; |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾æ£æµç»æå°è´¦å页ï¼åç±»æ£éªåç»ä¸æ¥è¯¢ï¼") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-inspection-ledger:query')") |
| | | public CommonResult<PageResult<MesQcInspectionLedgerRespVO>> getInspectionLedgerPage( |
| | | @Valid MesQcInspectionLedgerPageReqVO pageReqVO) { |
| | | return success(ledgerService.getInspectionLedgerPage(pageReqVO)); |
| | | } |
| | | |
| | | @GetMapping("/export-excel") |
| | | @Operation(summary = "å¯¼åºæ£æµç»æå°è´¦ Excel") |
| | | @PreAuthorize("@ss.hasPermission('mes:qc-inspection-ledger:export')") |
| | | @ApiAccessLog(operateType = EXPORT) |
| | | public void exportInspectionLedgerExcel(@Valid MesQcInspectionLedgerPageReqVO pageReqVO, |
| | | HttpServletResponse response) throws IOException { |
| | | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| | | List<MesQcInspectionLedgerRespVO> list = ledgerService.getInspectionLedgerPage(pageReqVO).getList(); |
| | | ExcelUtils.write(response, "æ£æµç»æå°è´¦.xls", "æ£æµç»æå°è´¦", |
| | | MesQcInspectionLedgerExportVO.class, buildExportList(list)); |
| | | } |
| | | |
| | | private List<MesQcInspectionLedgerExportVO> buildExportList(List<MesQcInspectionLedgerRespVO> list) { |
| | | if (CollUtil.isEmpty(list)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<MesQcInspectionLedgerExportVO> exportList = new ArrayList<>(list.size()); |
| | | for (MesQcInspectionLedgerRespVO vo : list) { |
| | | MesQcInspectionLedgerExportVO export = new MesQcInspectionLedgerExportVO(); |
| | | export.setQcTypeName(qcTypeName(vo.getQcType())); |
| | | export.setCode(vo.getCode()); |
| | | export.setName(vo.getName()); |
| | | export.setItemCode(vo.getItemCode()); |
| | | export.setItemName(vo.getItemName()); |
| | | export.setItemSpecification(vo.getItemSpecification()); |
| | | export.setBatchNo(vo.getBatchNo()); |
| | | export.setIndicatorName(vo.getIndicatorName()); |
| | | export.setIndicatorValue(vo.getIndicatorValue()); |
| | | export.setJudgementBasis(vo.getJudgementBasis()); |
| | | export.setCheckResultText(parseDictLabel(DictTypeConstants.MES_QC_CHECK_RESULT, vo.getCheckResult())); |
| | | export.setCheckQuantity(MesQcQualityExportVO.formatDecimal(vo.getCheckQuantity())); |
| | | export.setQualifiedQuantity(MesQcQualityExportVO.formatDecimal(vo.getQualifiedQuantity())); |
| | | export.setUnqualifiedQuantity(MesQcQualityExportVO.formatDecimal(vo.getUnqualifiedQuantity())); |
| | | export.setInspectorName(vo.getInspectorName()); |
| | | export.setInspectDate(MesQcQualityExportVO.formatDateTime(vo.getInspectDate())); |
| | | export.setStatusText(parseDictLabel(DictTypeConstants.MES_ORDER_STATUS, vo.getStatus())); |
| | | export.setRemark(vo.getRemark()); |
| | | exportList.add(export); |
| | | } |
| | | return exportList; |
| | | } |
| | | |
| | | private static String qcTypeName(Integer qcType) { |
| | | for (MesQcTypeEnum e : MesQcTypeEnum.values()) { |
| | | if (Objects.equals(e.getType(), qcType)) { |
| | | return e.getName(); |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | private static String parseDictLabel(String dictType, Integer value) { |
| | | if (value == null) { |
| | | return ""; |
| | | } |
| | | String label = DictFrameworkUtils.parseDictDataLabel(dictType, String.valueOf(value)); |
| | | return StrUtil.nullToEmpty(label); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo; |
| | | |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * MES æ£æµç»æå°è´¦å¯¼åº Excel VO |
| | | * |
| | | * <p>ä¸è¡ = ä¸ä¸ªæ£æµé¡¹ç»æï¼æ£éªåæªå½å
¥æ£æµé¡¹æ¶è¯¥åå ä¸è¡ï¼æ£æµé¡¹ç¸å
³å为空ï¼ï¼ç¨äºæ¥è¯¢ãæå°ä¸åæ¡£ã |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Data |
| | | public class MesQcInspectionLedgerExportVO { |
| | | |
| | | @ExcelProperty("åç±»") |
| | | private String qcTypeName; |
| | | |
| | | @ExcelProperty("æ£éªåç¼å·") |
| | | private String code; |
| | | |
| | | @ExcelProperty("æ£éªååç§°") |
| | | private String name; |
| | | |
| | | @ExcelProperty("ç©æç¼ç ") |
| | | private String itemCode; |
| | | |
| | | @ExcelProperty("ç©æåç§°") |
| | | private String itemName; |
| | | |
| | | @ExcelProperty("è§æ ¼åå·") |
| | | private String itemSpecification; |
| | | |
| | | @ExcelProperty("æ¹æ¬¡å·") |
| | | private String batchNo; |
| | | |
| | | @ExcelProperty("æ£æµé¡¹") |
| | | private String indicatorName; |
| | | |
| | | @ExcelProperty("æ£æµå¼") |
| | | private String indicatorValue; |
| | | |
| | | @ExcelProperty("å¤å®ä¾æ®") |
| | | private String judgementBasis; |
| | | |
| | | @ExcelProperty("æ£æµç»æ") |
| | | private String checkResultText; |
| | | |
| | | @ExcelProperty("æ£æµæ°é") |
| | | private String checkQuantity; |
| | | |
| | | @ExcelProperty("åæ ¼æ°é") |
| | | private String qualifiedQuantity; |
| | | |
| | | @ExcelProperty("ä¸åæ ¼æ°é") |
| | | private String unqualifiedQuantity; |
| | | |
| | | @ExcelProperty("æ£æµäººå") |
| | | private String inspectorName; |
| | | |
| | | @ExcelProperty("æ£æµæ¥æ") |
| | | private String inspectDate; |
| | | |
| | | @ExcelProperty("åæ®ç¶æ") |
| | | private String statusText; |
| | | |
| | | @ExcelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | 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 = "管çåå° - MES æ£æµç»æå°è´¦å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class MesQcInspectionLedgerPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "åç±»ï¼æ£éªç±»åï¼ï¼1 æ¥ææ£éª / 2 è¿ç¨æ£éª / 3 åºè´§æ£éª / 4 éè´§æ£éªï¼ä¸ä¼ 为å
¨é¨", example = "1") |
| | | private Integer qcType; |
| | | |
| | | @Schema(description = "æ£æµæ¥æåºé´ï¼ä¼ [å¼å§æ¶é´, ç»ææ¶é´]", |
| | | example = "[\"2026-01-01 00:00:00\", \"2026-12-31 23:59:59\"]") |
| | | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| | | private LocalDateTime[] inspectDate; |
| | | |
| | | @Schema(description = "æ£éªåç¼å·ï¼æ¨¡ç³å¹é
ï¼", example = "IQC1787563511197") |
| | | private String code; |
| | | |
| | | @Schema(description = "ç©æç¼å·", example = "28") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "æ¹æ¬¡å·ï¼æ¨¡ç³å¹é
ï¼æ¥ææ£éªåä¾åºåæ¹æ¬¡å·ï¼åºè´§/éè´§æ£éªåæ¹æ¬¡å·ï¼", example = "20260920a") |
| | | private String batchNo; |
| | | |
| | | @Schema(description = "æ£æµç»æ", example = "1") |
| | | private Integer checkResult; |
| | | |
| | | @Schema(description = "æ£æµäººåç¼å·", example = "1") |
| | | private Long inspectorUserId; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES æ£æµç»æå°è´¦ Response VO") |
| | | @Data |
| | | public class MesQcInspectionLedgerRespVO { |
| | | |
| | | // ========== æ£éªå ========== |
| | | |
| | | @Schema(description = "åç±»ï¼æ£éªç±»åï¼ï¼1 æ¥ææ£éª / 2 è¿ç¨æ£éª / 3 åºè´§æ£éª / 4 éè´§æ£éªï¼åå
¸ mes_qc_type", example = "1") |
| | | private Integer qcType; |
| | | |
| | | @Schema(description = "æ£éªå ID", example = "1") |
| | | private Long qcId; |
| | | |
| | | @Schema(description = "æ£éªåç¼å·", example = "IQC1787563511197") |
| | | private String code; |
| | | |
| | | @Schema(description = "æ£éªååç§°", example = "AN1787563511157-ç©ææ£éª") |
| | | private String name; |
| | | |
| | | @Schema(description = "åæ®ç¶æï¼åå
¸ mes_order_status", example = "4") |
| | | private Integer status; |
| | | |
| | | // ========== ç©æ ========== |
| | | |
| | | @Schema(description = "ç©æç¼å·", example = "28") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "ç©æç¼ç ", example = "WL0001") |
| | | private String itemCode; |
| | | |
| | | @Schema(description = "ç©æåç§°", example = "ç©æA") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "è§æ ¼åå·", example = "100mm*50mm") |
| | | private String itemSpecification; |
| | | |
| | | @Schema(description = "计éåä½åç§°", example = "个") |
| | | private String unitName; |
| | | |
| | | @Schema(description = "æ¹æ¬¡å·", example = "20260920a") |
| | | private String batchNo; |
| | | |
| | | // ========== æ°éä¸ç»æ ========== |
| | | |
| | | @Schema(description = "æ£æµæ°é", example = "100.00") |
| | | private BigDecimal checkQuantity; |
| | | |
| | | @Schema(description = "åæ ¼æ°é", example = "99.00") |
| | | private BigDecimal qualifiedQuantity; |
| | | |
| | | @Schema(description = "ä¸åæ ¼æ°é", example = "1.00") |
| | | private BigDecimal unqualifiedQuantity; |
| | | |
| | | @Schema(description = "æ£æµç»æï¼åå
¸ mes_qc_check_result", example = "1") |
| | | private Integer checkResult; |
| | | |
| | | @Schema(description = "æ£æµæ¥æ") |
| | | private LocalDateTime inspectDate; |
| | | |
| | | @Schema(description = "æ£æµäººåç¼å·", example = "1") |
| | | private Long inspectorUserId; |
| | | |
| | | @Schema(description = "æ£æµäººåæµç§°", example = "å¼ ä¸") |
| | | private String inspectorName; |
| | | |
| | | // ========== æ£æµé¡¹ç»æï¼ä¸æ¡æç»ä¸è¡ï¼æ£éªåæªå½å
¥æ£æµé¡¹æ¶è¯¥ç»åæ®µä¸ºç©ºï¼ ========== |
| | | |
| | | @Schema(description = "æ£æµé¡¹ç¼å·", example = "2") |
| | | private Long indicatorId; |
| | | |
| | | @Schema(description = "æ£æµé¡¹åç§°", example = "é¿åº¦") |
| | | private String indicatorName; |
| | | |
| | | @Schema(description = "æ£æµå¼", example = "15") |
| | | private String indicatorValue; |
| | | |
| | | @Schema(description = "æ£æµé¡¹å¤æ³¨", example = "æ½æ£") |
| | | private String indicatorRemark; |
| | | |
| | | @Schema(description = "å¤å®ä¾æ®ï¼ç±æ£æµé¡¹æ åå¼/误差ä¸ä¸éæ¼è£
", example = "10~20") |
| | | private String judgementBasis; |
| | | |
| | | @Schema(description = "æ£æµé¡¹æ åå¼ï¼å¤å®ä¾æ®åå§å¼ï¼å端å±ç¤ºç¨ judgementBasis å³å¯ï¼", example = "15") |
| | | private BigDecimal standardValue; |
| | | |
| | | @Schema(description = "æ£æµé¡¹è¯¯å·®ä¸éï¼å¤å®ä¾æ®åå§å¼ï¼", example = "10") |
| | | private BigDecimal minThreshold; |
| | | |
| | | @Schema(description = "æ£æµé¡¹è¯¯å·®ä¸éï¼å¤å®ä¾æ®åå§å¼ï¼", example = "20") |
| | | private BigDecimal maxThreshold; |
| | | |
| | | @Schema(description = "æ£éªå夿³¨") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Builder; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 管çåå° - è´¨æ£å导å
¥ Response VOï¼IQC / IPQC / OQC å
±ç¨ï¼ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - è´¨æ£å导å
¥ Response VO") |
| | | @Data |
| | | @Builder |
| | | public class MesQcImportRespVO { |
| | | |
| | | @Schema(description = "导å
¥æåçæ£éªåç¼å·æ°ç»", example = "IQC20260101000001") |
| | | private List<String> createList; |
| | | |
| | | @Schema(description = "导å
¥å¤±è´¥éåï¼key ä¸ºè¡æ è¯ï¼æ£éªåç¼å·æç¬¬ N è¡ï¼ï¼value 为失败åå ") |
| | | private Map<String, String> failureList; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.qc.vo; |
| | | |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | /** |
| | | * MES è´¨æ£æ£éªåå¯¼åº Excel VOï¼IQC/IPQC/OQC/RQC å
±ç¨ï¼ |
| | | * |
| | | * <p>导åºåï¼æ£éªååç§° / ç©æåç§° / æ¹å· / æ£æµæ¥æ / æ£éªææ / å¤å®ä¾æ® / æ£éªç»æ / æ£éªäºº / å®¡æ ¸äºº / 夿³¨ã |
| | | * æ£éªææ ãå¤å®ä¾æ®åèªæ£éªåè¡æç»ï¼å®¡æ ¸äººææ æ°æ®æ¥æºï¼å¯¼åºä¸ºç©ºåã |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Data |
| | | public class MesQcQualityExportVO { |
| | | |
| | | @ExcelProperty("æ£éªååç§°") |
| | | private String docName; |
| | | |
| | | @ExcelProperty("ç©æåç§°") |
| | | private String itemName; |
| | | |
| | | @ExcelProperty("æ¹å·") |
| | | private String batchNo; |
| | | |
| | | @ExcelProperty("æ£æµæ¥æ") |
| | | private String inspectDate; |
| | | |
| | | @ExcelProperty("æ£éªææ ") |
| | | private String indicatorNames; |
| | | |
| | | @ExcelProperty("å¤å®ä¾æ®") |
| | | private String judgementBasis; |
| | | |
| | | @ExcelProperty("æ£éªç»æ") |
| | | private String checkResultText; |
| | | |
| | | @ExcelProperty("æ£éªäºº") |
| | | private String inspectorName; |
| | | |
| | | @ExcelProperty("å®¡æ ¸äºº") |
| | | private String auditorName; |
| | | |
| | | @ExcelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | /** |
| | | * æ ¼å¼åæ£æµæ¥æï¼ä»
æ¥æï¼ï¼null è¿å空串 |
| | | */ |
| | | public static String formatDateTime(LocalDateTime dateTime) { |
| | | if (dateTime == null) { |
| | | return ""; |
| | | } |
| | | return dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | } |
| | | |
| | | /** |
| | | * 廿æ°å¼å°¾é¨æ æä¹ç 0ï¼å¦ 35.000000 -> 35ã2.500000 -> 2.5 |
| | | */ |
| | | public static String formatDecimal(BigDecimal value) { |
| | | if (value == null) { |
| | | return ""; |
| | | } |
| | | return value.stripTrailingZeros().toPlainString(); |
| | | } |
| | | |
| | | /** |
| | | * ç»è£
åä¸ªæ£æµé¡¹çå¤å®ä¾æ®ææ¬ï¼ |
| | | * ä¸ä¸éåæ -> "ä¸é~ä¸é"ï¼ä»
æä¸é -> "â¤ä¸é"ï¼ä»
æä¸é -> "â¥ä¸é"ï¼ |
| | | * åæ ä½ç»äºæ åå¼ -> "æ åå¼ æ åå¼"ï¼å¦åè¿å空串ã |
| | | */ |
| | | public static String buildRangeText(BigDecimal standardValue, BigDecimal minThreshold, BigDecimal maxThreshold) { |
| | | if (maxThreshold != null && minThreshold != null) { |
| | | return formatDecimal(minThreshold) + "~" + formatDecimal(maxThreshold); |
| | | } |
| | | if (maxThreshold != null) { |
| | | return "â¤" + formatDecimal(maxThreshold); |
| | | } |
| | | if (minThreshold != null) { |
| | | return "â¥" + formatDecimal(minThreshold); |
| | | } |
| | | if (standardValue != null) { |
| | | return "æ åå¼ " + formatDecimal(standardValue); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert.SafetyCertificatePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert.SafetyCertificateRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert.SafetyCertificateSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyCertificateService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯å°è´¦ï¼å«å°æèªå¨é¢è¦ï¼ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-ç¹ç§ä½ä¸è¯") |
| | | @RestController |
| | | @RequestMapping("/safety/certificate") |
| | | @Validated |
| | | public class SafetyCertificateController { |
| | | |
| | | @Resource |
| | | private SafetyCertificateService certificateService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "æ°å¢ç¹ç§ä½ä¸è¯") |
| | | @PreAuthorize("@ss.hasPermission('safety:cert:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody SafetyCertificateSaveReqVO reqVO) { |
| | | return success(certificateService.createCertificate(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹ç¹ç§ä½ä¸è¯") |
| | | @PreAuthorize("@ss.hasPermission('safety:cert:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody SafetyCertificateSaveReqVO reqVO) { |
| | | certificateService.updateCertificate(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤ç¹ç§ä½ä¸è¯") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:cert:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") Long id) { |
| | | certificateService.deleteCertificate(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾ç¹ç§ä½ä¸è¯") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:cert:query')") |
| | | public CommonResult<SafetyCertificateRespVO> get(@RequestParam("id") Long id) { |
| | | var cert = certificateService.getCertificate(id); |
| | | var resp = BeanUtils.toBean(cert, SafetyCertificateRespVO.class); |
| | | certificateService.fillDisplayFields(cert, resp); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾ç¹ç§ä½ä¸è¯å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:cert:query')") |
| | | public CommonResult<PageResult<SafetyCertificateRespVO>> page(@Valid SafetyCertificatePageReqVO reqVO) { |
| | | var page = certificateService.getCertificatePage(reqVO); |
| | | // æ¹éè¡¥å
¨æè¯äººææ°æ¡£æ¡ï¼å§å/å·¥å·/é¨é¨ï¼ï¼ä¸æ¬¡æ§æ¥å¥½é¿å
N+1 |
| | | certificateService.fillEmployeeInfo(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyCertificateRespVO.class); |
| | | certificateService.fillDisplayFieldsBatch(page.getList(), result.getList()); |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/expiring-list") |
| | | @Operation(summary = "è·å¾å³å°å°æ/å·²è¿æçç¹ç§ä½ä¸è¯ï¼å°æèªå¨é¢è¦ï¼") |
| | | @Parameter(name = "days", description = "æåé¢è¦å¤©æ°ï¼é»è®¤ 30 天") |
| | | @PreAuthorize("@ss.hasPermission('safety:cert:query')") |
| | | public CommonResult<List<SafetyCertificateRespVO>> expiringList( |
| | | @RequestParam(value = "days", required = false) Integer days) { |
| | | List<cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyCertificateDO> certs = |
| | | certificateService.getExpiringCertificates(days); |
| | | certificateService.fillEmployeeInfo(certs); |
| | | var resps = BeanUtils.toBean(certs, SafetyCertificateRespVO.class); |
| | | certificateService.fillDisplayFieldsBatch(certs, resps); |
| | | return success(resps); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyFileService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç§»å¨ç«¯ç°åºæç
§ä¸ä¼ |
| | | * |
| | | * <p>å·¡æ£ã鿣䏿¥ãä½ä¸ç¥¨ãæ¼ç»çç¯èçç
§çç»ä¸èµ°æ¤æ¥å£ï¼ |
| | | * è¿åå¯è®¿é® URLï¼åç«¯æ¼æéå·ä¸²åå
¥ä¸å¡è¡¨ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-éä»¶ä¸ä¼ ") |
| | | @RestController |
| | | @RequestMapping("/safety/file") |
| | | @Validated |
| | | public class SafetyFileController { |
| | | |
| | | @Resource |
| | | private SafetyFileService fileService; |
| | | |
| | | @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | @Operation(summary = "ä¸ä¼ å个éä»¶ï¼ç§»å¨ç«¯æç
§ï¼") |
| | | @Parameter(name = "file", description = "æä»¶", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:file:upload')") |
| | | public CommonResult<String> upload(@RequestPart("file") MultipartFile file, |
| | | @RequestParam(value = "bizType", required = false) String bizType) { |
| | | return success(fileService.upload(file, bizType)); |
| | | } |
| | | |
| | | @PostMapping(value = "/upload-batch", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | @Operation(summary = "æ¹éä¸ä¼ éä»¶ï¼ç§»å¨ç«¯ä¸æ¬¡å¤å¼ ï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:file:upload')") |
| | | public CommonResult<List<String>> uploadBatch(@RequestPart("files") List<MultipartFile> files, |
| | | @RequestParam(value = "bizType", required = false) String bizType) { |
| | | return success(fileService.uploadBatch(files, bizType)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard.*; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyHazardService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣䏿¥ä¸éç¯ï¼ä¸æ¥-åæ´¾-æ´æ¹-夿¥ï¼ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-鿣éç¯") |
| | | @RestController |
| | | @RequestMapping("/safety/hazard") |
| | | @Validated |
| | | public class SafetyHazardController { |
| | | |
| | | @Resource |
| | | private SafetyHazardService hazardService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "鿣䏿¥ï¼æ¯æç§»å¨ç«¯æç
§ä¸ä¼ ç photoUrlsï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody SafetyHazardSaveReqVO reqVO) { |
| | | return success(hazardService.createHazard(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹éæ£åºç¡ä¿¡æ¯") |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody SafetyHazardSaveReqVO reqVO) { |
| | | hazardService.updateHazard(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤éæ£") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") Long id) { |
| | | hazardService.deleteHazard(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾éæ£") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:query')") |
| | | public CommonResult<SafetyHazardRespVO> get(@RequestParam("id") Long id) { |
| | | var hazard = hazardService.getHazard(id); |
| | | hazardService.fillPersonNames(java.util.List.of(hazard)); |
| | | var resp = BeanUtils.toBean(hazard, SafetyHazardRespVO.class); |
| | | SafetyHazardService.fillHazardDisplay(hazard, resp); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾éæ£å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:query')") |
| | | public CommonResult<PageResult<SafetyHazardRespVO>> page(@Valid SafetyHazardPageReqVO reqVO) { |
| | | var page = hazardService.getHazardPage(reqVO); |
| | | hazardService.fillPersonNames(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyHazardRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyHazardService.fillHazardDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | @PutMapping("/assign") |
| | | @Operation(summary = "åæ´¾éæ£æ´æ¹è´£ä»»äºº") |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:assign')") |
| | | public CommonResult<Boolean> assign(@Valid @RequestBody SafetyHazardAssignReqVO reqVO) { |
| | | hazardService.assignHazard(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/rectify") |
| | | @Operation(summary = "æäº¤éæ£æ´æ¹ç»æ") |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:rectify')") |
| | | public CommonResult<Boolean> rectify(@Valid @RequestBody SafetyHazardRectifyReqVO reqVO) { |
| | | hazardService.rectifyHazard(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/recheck") |
| | | @Operation(summary = "鿣夿¥ï¼éè¿åéç¯ï¼ä¸éè¿éåæ´æ¹ï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:hazard:recheck')") |
| | | public CommonResult<Boolean> recheck(@Valid @RequestBody SafetyHazardRecheckReqVO reqVO) { |
| | | hazardService.recheckHazard(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection.*; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyInspectionService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½ä¸å·¡æ£è®°å½ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-å®å
¨å·¡æ£") |
| | | @RestController |
| | | @RequestMapping("/safety/inspection") |
| | | @Validated |
| | | public class SafetyInspectionController { |
| | | |
| | | @Resource |
| | | private SafetyInspectionService inspectionService; |
| | | |
| | | // ==================== å·¡æ£ç¹ä½ ==================== |
| | | |
| | | @PostMapping("/point/create") |
| | | @Operation(summary = "æ°å¢å·¡æ£ç¹ä½") |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection-point:create')") |
| | | public CommonResult<Long> createPoint(@Valid @RequestBody SafetyInspectionPointSaveReqVO reqVO) { |
| | | return success(inspectionService.createPoint(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/point/update") |
| | | @Operation(summary = "ä¿®æ¹å·¡æ£ç¹ä½") |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection-point:update')") |
| | | public CommonResult<Boolean> updatePoint(@Valid @RequestBody SafetyInspectionPointSaveReqVO reqVO) { |
| | | inspectionService.updatePoint(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/point/delete") |
| | | @Operation(summary = "å é¤å·¡æ£ç¹ä½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection-point:delete')") |
| | | public CommonResult<Boolean> deletePoint(@RequestParam("id") Long id) { |
| | | inspectionService.deletePoint(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/point/get") |
| | | @Operation(summary = "è·å¾å·¡æ£ç¹ä½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection-point:query')") |
| | | public CommonResult<SafetyInspectionPointRespVO> getPoint(@RequestParam("id") Long id) { |
| | | var point = inspectionService.getPoint(id); |
| | | // åæ¡æ¥è¯¢ä¹è¦åå¡«ä¸»æ°æ®ææ°å¼ï¼ä¸è½åªè¿åå¿«ç
§ |
| | | inspectionService.fillPointRefs(java.util.List.of(point)); |
| | | var resp = BeanUtils.toBean(point, SafetyInspectionPointRespVO.class); |
| | | SafetyInspectionService.fillPointDisplay(point, resp); |
| | | resp.setLastInspectTime(inspectionService.getLastInspectTime(id)); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/point/page") |
| | | @Operation(summary = "è·å¾å·¡æ£ç¹ä½å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection-point:query')") |
| | | public CommonResult<PageResult<SafetyInspectionPointRespVO>> getPointPage( |
| | | @Valid SafetyInspectionPointPageReqVO reqVO) { |
| | | var page = inspectionService.getPointPage(reqVO); |
| | | inspectionService.fillPointRefs(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyInspectionPointRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyInspectionService.fillPointDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/point/simple-list") |
| | | @Operation(summary = "è·å¾å¯ç¨ä¸çå·¡æ£ç¹ä½ç²¾ç®å表ï¼ç§»å¨ç«¯å·¡æ£éæ©ï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection-point:query')") |
| | | public CommonResult<List<SafetyInspectionPointRespVO>> getPointSimpleList() { |
| | | var points = inspectionService.getEnabledPointList(); |
| | | inspectionService.fillPointRefs(points); |
| | | List<SafetyInspectionPointRespVO> list = points.stream() |
| | | .map(point -> { |
| | | var resp = BeanUtils.toBean(point, SafetyInspectionPointRespVO.class); |
| | | SafetyInspectionService.fillPointDisplay(point, resp); |
| | | return resp; |
| | | }).toList(); |
| | | return success(list); |
| | | } |
| | | |
| | | // ==================== å·¡æ£è®°å½ ==================== |
| | | |
| | | @PostMapping("/record/create") |
| | | @Operation(summary = "æ°å¢å·¡æ£è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection:create')") |
| | | public CommonResult<Long> createRecord(@Valid @RequestBody SafetyInspectionSaveReqVO reqVO) { |
| | | return success(inspectionService.createInspection(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/record/update") |
| | | @Operation(summary = "ä¿®æ¹å·¡æ£è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection:update')") |
| | | public CommonResult<Boolean> updateRecord(@Valid @RequestBody SafetyInspectionSaveReqVO reqVO) { |
| | | inspectionService.updateInspection(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/record/delete") |
| | | @Operation(summary = "å é¤å·¡æ£è®°å½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection:delete')") |
| | | public CommonResult<Boolean> deleteRecord(@RequestParam("id") Long id) { |
| | | inspectionService.deleteInspection(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/record/get") |
| | | @Operation(summary = "è·å¾å·¡æ£è®°å½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection:query')") |
| | | public CommonResult<SafetyInspectionRespVO> getRecord(@RequestParam("id") Long id) { |
| | | var record = inspectionService.getInspection(id); |
| | | inspectionService.fillInspectorNames(java.util.List.of(record)); |
| | | var resp = BeanUtils.toBean(record, SafetyInspectionRespVO.class); |
| | | resp.setPointTypeName(cn.iocoder.yudao.module.mes.enums.safety.SafetyInspectionPointTypeEnum |
| | | .getNameByType(record.getPointType())); |
| | | resp.setResultName("NORMAL".equals(record.getResult()) ? "æ£å¸¸" : "å¼å¸¸"); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/record/page") |
| | | @Operation(summary = "è·å¾å·¡æ£è®°å½å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:inspection:query')") |
| | | public CommonResult<PageResult<SafetyInspectionRespVO>> getRecordPage( |
| | | @Valid SafetyInspectionPageReqVO reqVO) { |
| | | var page = inspectionService.getInspectionPage(reqVO); |
| | | inspectionService.fillInspectorNames(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyInspectionRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | var record = page.getList().get(i); |
| | | var resp = result.getList().get(i); |
| | | resp.setPointTypeName(cn.iocoder.yudao.module.mes.enums.safety.SafetyInspectionPointTypeEnum |
| | | .getNameByType(record.getPointType())); |
| | | resp.setResultName("NORMAL".equals(record.getResult()) ? "æ£å¸¸" : "å¼å¸¸"); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.ledger.SafetyLedgerExportReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.ledger.SafetyOverviewRespVO; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyLedgerExportService; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyOverviewService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ»è§ç»è®¡ä¸æ ååå°è´¦å¯¼åº |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-å°è´¦ä¸ç»è®¡") |
| | | @RestController |
| | | @RequestMapping("/safety/ledger") |
| | | @Validated |
| | | public class SafetyLedgerController { |
| | | |
| | | @Resource |
| | | private SafetyOverviewService overviewService; |
| | | @Resource |
| | | private SafetyLedgerExportService ledgerExportService; |
| | | |
| | | @GetMapping("/overview") |
| | | @Operation(summary = "è·å¾å®å
¨ç产æ»è§ç»è®¡") |
| | | @PreAuthorize("@ss.hasPermission('safety:ledger:query')") |
| | | public CommonResult<SafetyOverviewRespVO> overview() { |
| | | return success(overviewService.getOverview()); |
| | | } |
| | | |
| | | @GetMapping("/export") |
| | | @Operation(summary = "导åºçµåè¡ä¸å®å
¨æ ååå°è´¦ï¼å
¨å¥æå¤éå
¶ä¸ï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:ledger:export')") |
| | | public void export(@Valid SafetyLedgerExportReqVO reqVO, HttpServletResponse response) throws IOException { |
| | | ledgerExportService.export(reqVO, response); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material.*; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyMaterialService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - åºæ¥ç©èµå°è´¦ä¸åºå
¥åºï¼ç»ç¼ç¨å
· / å±åå / æ¶é²ç©èµï¼ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-åºæ¥ç©èµ") |
| | | @RestController |
| | | @RequestMapping("/safety/material") |
| | | @Validated |
| | | public class SafetyMaterialController { |
| | | |
| | | @Resource |
| | | private SafetyMaterialService materialService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "æ°å¢ç©èµ") |
| | | @PreAuthorize("@ss.hasPermission('safety:material:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody SafetyMaterialSaveReqVO reqVO) { |
| | | return success(materialService.createMaterial(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹ç©èµï¼åºåæ°éåªè½éè¿åºå
¥åºåå¨ï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:material:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody SafetyMaterialSaveReqVO reqVO) { |
| | | materialService.updateMaterial(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤ç©èµ") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:material:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") Long id) { |
| | | materialService.deleteMaterial(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾ç©èµ") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:material:query')") |
| | | public CommonResult<SafetyMaterialRespVO> get(@RequestParam("id") Long id) { |
| | | var material = materialService.getMaterial(id); |
| | | materialService.fillManagers(java.util.List.of(material)); |
| | | var resp = BeanUtils.toBean(material, SafetyMaterialRespVO.class); |
| | | SafetyMaterialService.fillMaterialDisplay(material, resp); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾ç©èµå页") |
| | | @PreAuthorize("@ss.hasPermission('safety:material:query')") |
| | | public CommonResult<PageResult<SafetyMaterialRespVO>> page(@Valid SafetyMaterialPageReqVO reqVO) { |
| | | var page = materialService.getMaterialPage(reqVO); |
| | | materialService.fillManagers(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyMaterialRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyMaterialService.fillMaterialDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | @GetMapping("/below-safe-stock") |
| | | @Operation(summary = "è·å¾ä½äºå®å
¨åºåçç©èµå表ï¼é¢è¦ï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:material:query')") |
| | | public CommonResult<List<SafetyMaterialRespVO>> belowSafeStock() { |
| | | var materials = materialService.getBelowSafeStockList(); |
| | | materialService.fillManagers(materials); |
| | | List<SafetyMaterialRespVO> list = materials.stream() |
| | | .map(material -> { |
| | | var resp = BeanUtils.toBean(material, SafetyMaterialRespVO.class); |
| | | SafetyMaterialService.fillMaterialDisplay(material, resp); |
| | | return resp; |
| | | }).toList(); |
| | | return success(list); |
| | | } |
| | | |
| | | @GetMapping("/expiring-list") |
| | | @Operation(summary = "è·å¾å³å°å°æçç©èµå表ï¼é¢è¦ï¼") |
| | | @Parameter(name = "days", description = "æåé¢è¦å¤©æ°ï¼é»è®¤ 30 天") |
| | | @PreAuthorize("@ss.hasPermission('safety:material:query')") |
| | | public CommonResult<List<SafetyMaterialRespVO>> expiringList( |
| | | @RequestParam(value = "days", required = false) Integer days) { |
| | | var materials = materialService.getExpiringList(days); |
| | | materialService.fillManagers(materials); |
| | | List<SafetyMaterialRespVO> list = materials.stream() |
| | | .map(material -> { |
| | | var resp = BeanUtils.toBean(material, SafetyMaterialRespVO.class); |
| | | SafetyMaterialService.fillMaterialDisplay(material, resp); |
| | | return resp; |
| | | }).toList(); |
| | | return success(list); |
| | | } |
| | | |
| | | // ==================== åºå
¥åº ==================== |
| | | |
| | | @PostMapping("/stock/create") |
| | | @Operation(summary = "åºå
¥åºç»è®°ï¼èªå¨æ´æ°åºåï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:material-stock:in') or @ss.hasPermission('safety:material-stock:out')") |
| | | public CommonResult<Long> createStock(@Valid @RequestBody SafetyMaterialStockSaveReqVO reqVO) { |
| | | return success(materialService.createStock(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/stock/page") |
| | | @Operation(summary = "è·å¾åºå
¥åºæµæ°´å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:material-stock:query')") |
| | | public CommonResult<PageResult<SafetyMaterialStockRespVO>> stockPage( |
| | | @Valid SafetyMaterialStockPageReqVO reqVO) { |
| | | var page = materialService.getStockPage(reqVO); |
| | | var result = BeanUtils.toBean(page, SafetyMaterialStockRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyMaterialService.fillStockDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.org.SafetyOrgRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.org.SafetyOrgSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyOrgService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å®å
¨ç»ç»æ¶æ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-ç»ç»æ¶æ") |
| | | @RestController |
| | | @RequestMapping("/safety/org") |
| | | @Validated |
| | | public class SafetyOrgController { |
| | | |
| | | @Resource |
| | | private SafetyOrgService orgService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "æ°å¢å®å
¨ç»ç»") |
| | | @PreAuthorize("@ss.hasPermission('safety:org:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody SafetyOrgSaveReqVO reqVO) { |
| | | return success(orgService.createOrg(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹å®å
¨ç»ç»") |
| | | @PreAuthorize("@ss.hasPermission('safety:org:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody SafetyOrgSaveReqVO reqVO) { |
| | | orgService.updateOrg(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤å®å
¨ç»ç»") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:org:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") Long id) { |
| | | orgService.deleteOrg(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾å®å
¨ç»ç»") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:org:query')") |
| | | public CommonResult<SafetyOrgRespVO> get(@RequestParam("id") Long id) { |
| | | var org = orgService.getOrg(id); |
| | | var resp = new SafetyOrgRespVO(); |
| | | org2resp(org, resp); |
| | | // è´è´£äººç¨åå·¥æ¡£æ¡ææ°å§åè¦çå¿«ç
§ |
| | | if (org.getLeaderId() != null) { |
| | | var employee = orgService.getLeader(org.getLeaderId()); |
| | | if (employee != null) { |
| | | resp.setLeaderName(employee.getName()); |
| | | resp.setLeaderPhone(employee.getPhone()); |
| | | } |
| | | } |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/tree") |
| | | @Operation(summary = "è·å¾å®å
¨ç»ç»æ ") |
| | | @PreAuthorize("@ss.hasPermission('safety:org:query')") |
| | | public CommonResult<List<SafetyOrgRespVO>> tree() { |
| | | return success(orgService.getOrgTree()); |
| | | } |
| | | |
| | | private static void org2resp(cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyOrgDO org, |
| | | SafetyOrgRespVO resp) { |
| | | resp.setId(org.getId()); |
| | | resp.setParentId(org.getParentId()); |
| | | resp.setName(org.getName()); |
| | | resp.setLeaderName(org.getLeaderName()); |
| | | resp.setLeaderPhone(org.getLeaderPhone()); |
| | | resp.setMemberNames(org.getMemberNames()); |
| | | resp.setDuty(org.getDuty()); |
| | | resp.setSort(org.getSort()); |
| | | resp.setStatus(org.getStatus()); |
| | | resp.setRemark(org.getRemark()); |
| | | resp.setCreateTime(org.getCreateTime()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train.*; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyTrainingService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å¹è®ãæ¼ç»ãäºæ
ç»è®°çµåå彿¡£ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-å¹è®ä¸äºæ
") |
| | | @RestController |
| | | @RequestMapping("/safety/training") |
| | | @Validated |
| | | public class SafetyTrainingController { |
| | | |
| | | @Resource |
| | | private SafetyTrainingService trainingService; |
| | | |
| | | // ==================== å¹è® ==================== |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "æ°å¢å®å
¨å¹è®è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('safety:training:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody SafetyTrainingSaveReqVO reqVO) { |
| | | return success(trainingService.createTraining(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹å®å
¨å¹è®è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('safety:training:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody SafetyTrainingSaveReqVO reqVO) { |
| | | trainingService.updateTraining(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤å®å
¨å¹è®è®°å½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:training:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") Long id) { |
| | | trainingService.deleteTraining(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾å®å
¨å¹è®è®°å½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:training:query')") |
| | | public CommonResult<SafetyTrainingRespVO> get(@RequestParam("id") Long id) { |
| | | var training = trainingService.getTraining(id); |
| | | trainingService.fillTrainers(java.util.List.of(training)); |
| | | var resp = BeanUtils.toBean(training, SafetyTrainingRespVO.class); |
| | | SafetyTrainingService.fillTrainingDisplay(training, resp); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾å®å
¨å¹è®è®°å½å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:training:query')") |
| | | public CommonResult<PageResult<SafetyTrainingRespVO>> page(@Valid SafetyTrainingPageReqVO reqVO) { |
| | | var page = trainingService.getTrainingPage(reqVO); |
| | | trainingService.fillTrainers(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyTrainingRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyTrainingService.fillTrainingDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | // ==================== æ¼ç» ==================== |
| | | |
| | | @PostMapping("/drill/create") |
| | | @Operation(summary = "æ°å¢æ¶é²æ¼ç»è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('safety:drill:create')") |
| | | public CommonResult<Long> createDrill(@Valid @RequestBody SafetyDrillSaveReqVO reqVO) { |
| | | return success(trainingService.createDrill(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/drill/update") |
| | | @Operation(summary = "ä¿®æ¹æ¶é²æ¼ç»è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('safety:drill:update')") |
| | | public CommonResult<Boolean> updateDrill(@Valid @RequestBody SafetyDrillSaveReqVO reqVO) { |
| | | trainingService.updateDrill(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/drill/delete") |
| | | @Operation(summary = "å 餿¶é²æ¼ç»è®°å½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:drill:delete')") |
| | | public CommonResult<Boolean> deleteDrill(@RequestParam("id") Long id) { |
| | | trainingService.deleteDrill(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/drill/get") |
| | | @Operation(summary = "è·å¾æ¶é²æ¼ç»è®°å½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:drill:query')") |
| | | public CommonResult<SafetyDrillRespVO> getDrill(@RequestParam("id") Long id) { |
| | | var drill = trainingService.getDrill(id); |
| | | trainingService.fillOrganizers(java.util.List.of(drill)); |
| | | var resp = BeanUtils.toBean(drill, SafetyDrillRespVO.class); |
| | | SafetyTrainingService.fillDrillDisplay(drill, resp); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/drill/page") |
| | | @Operation(summary = "è·å¾æ¶é²æ¼ç»è®°å½å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:drill:query')") |
| | | public CommonResult<PageResult<SafetyDrillRespVO>> drillPage(@Valid SafetyDrillPageReqVO reqVO) { |
| | | var page = trainingService.getDrillPage(reqVO); |
| | | trainingService.fillOrganizers(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyDrillRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyTrainingService.fillDrillDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | // ==================== äºæ
==================== |
| | | |
| | | @PostMapping("/accident/create") |
| | | @Operation(summary = "æ°å¢äºæ
ç»è®°") |
| | | @PreAuthorize("@ss.hasPermission('safety:accident:create')") |
| | | public CommonResult<Long> createAccident(@Valid @RequestBody SafetyAccidentSaveReqVO reqVO) { |
| | | return success(trainingService.createAccident(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/accident/update") |
| | | @Operation(summary = "ä¿®æ¹äºæ
ç»è®°") |
| | | @PreAuthorize("@ss.hasPermission('safety:accident:update')") |
| | | public CommonResult<Boolean> updateAccident(@Valid @RequestBody SafetyAccidentSaveReqVO reqVO) { |
| | | trainingService.updateAccident(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/accident/delete") |
| | | @Operation(summary = "å é¤äºæ
ç»è®°") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:accident:delete')") |
| | | public CommonResult<Boolean> deleteAccident(@RequestParam("id") Long id) { |
| | | trainingService.deleteAccident(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/accident/get") |
| | | @Operation(summary = "è·å¾äºæ
ç»è®°") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:accident:query')") |
| | | public CommonResult<SafetyAccidentRespVO> getAccident(@RequestParam("id") Long id) { |
| | | var accident = trainingService.getAccident(id); |
| | | trainingService.fillAccidentRefs(java.util.List.of(accident)); |
| | | var resp = BeanUtils.toBean(accident, SafetyAccidentRespVO.class); |
| | | SafetyTrainingService.fillAccidentDisplay(accident, resp); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/accident/page") |
| | | @Operation(summary = "è·å¾äºæ
ç»è®°å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:accident:query')") |
| | | public CommonResult<PageResult<SafetyAccidentRespVO>> accidentPage( |
| | | @Valid SafetyAccidentPageReqVO reqVO) { |
| | | var page = trainingService.getAccidentPage(reqVO); |
| | | trainingService.fillAccidentRefs(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyAccidentRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyTrainingService.fillAccidentDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit.*; |
| | | import cn.iocoder.yudao.module.mes.service.safety.SafetyWorkPermitService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ï¼å¨ç« / é«åå¸¦çµ / æé空é´çï¼å®¡æ¹ä¸çµåçå |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Tag(name = "管çåå° - å®å
¨ç产-é«å±ä½ä¸ç¥¨") |
| | | @RestController |
| | | @RequestMapping("/safety/permit") |
| | | @Validated |
| | | public class SafetyWorkPermitController { |
| | | |
| | | @Resource |
| | | private SafetyWorkPermitService permitService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "æäº¤é«å±ä½ä¸ç³è¯·") |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:create')") |
| | | public CommonResult<Long> create(@Valid @RequestBody SafetyWorkPermitSaveReqVO reqVO) { |
| | | return success(permitService.createPermit(reqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "ä¿®æ¹ä½ä¸ç¥¨") |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:update')") |
| | | public CommonResult<Boolean> update(@Valid @RequestBody SafetyWorkPermitSaveReqVO reqVO) { |
| | | permitService.updatePermit(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤ä½ä¸ç¥¨ï¼è¿åçæ¤è®°å½ï¼") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:delete')") |
| | | public CommonResult<Boolean> delete(@RequestParam("id") Long id) { |
| | | permitService.deletePermit(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾ä½ä¸ç¥¨") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:query')") |
| | | public CommonResult<SafetyWorkPermitRespVO> get(@RequestParam("id") Long id) { |
| | | var permit = permitService.getPermit(id); |
| | | permitService.fillPermitRefs(java.util.List.of(permit)); |
| | | var resp = BeanUtils.toBean(permit, SafetyWorkPermitRespVO.class); |
| | | SafetyWorkPermitService.fillPermitDisplay(permit, resp); |
| | | return success(resp); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾ä½ä¸ç¥¨å页") |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:query')") |
| | | public CommonResult<PageResult<SafetyWorkPermitRespVO>> page(@Valid SafetyWorkPermitPageReqVO reqVO) { |
| | | var page = permitService.getPermitPage(reqVO); |
| | | permitService.fillPermitRefs(page.getList()); |
| | | var result = BeanUtils.toBean(page, SafetyWorkPermitRespVO.class); |
| | | for (int i = 0; i < page.getList().size(); i++) { |
| | | SafetyWorkPermitService.fillPermitDisplay(page.getList().get(i), result.getList().get(i)); |
| | | } |
| | | return success(result); |
| | | } |
| | | |
| | | @PutMapping("/approve") |
| | | @Operation(summary = "审æ¹ä½ä¸ç¥¨ï¼éè¿/驳åï¼") |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:approve')") |
| | | public CommonResult<Boolean> approve(@Valid @RequestBody SafetyWorkPermitApproveReqVO reqVO) { |
| | | permitService.approvePermit(reqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/start") |
| | | @Operation(summary = "å¼å§ä½ä¸") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:update')") |
| | | public CommonResult<Boolean> start(@RequestParam("id") Long id) { |
| | | permitService.startPermit(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/close") |
| | | @Operation(summary = "ç»æä½ä¸å¹¶å½æ¡£") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:update')") |
| | | public CommonResult<Boolean> close(@RequestParam("id") Long id) { |
| | | permitService.closePermit(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/cancel") |
| | | @Operation(summary = "ä½åºä½ä¸ç¥¨") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:update')") |
| | | public CommonResult<Boolean> cancel(@RequestParam("id") Long id) { |
| | | permitService.cancelPermit(id); |
| | | return success(true); |
| | | } |
| | | |
| | | // ==================== çæ¤è®°å½ ==================== |
| | | |
| | | @GetMapping("/monitor/list") |
| | | @Operation(summary = "è·å¾ä½ä¸çæ¤è®°å½å表") |
| | | @Parameter(name = "permitId", description = "ä½ä¸ç¥¨ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:query')") |
| | | public CommonResult<List<SafetyWorkPermitMonitorRespVO>> monitorList(@RequestParam("permitId") Long permitId) { |
| | | var monitors = permitService.getMonitorList(permitId); |
| | | permitService.fillMonitorGuardians(monitors); |
| | | return success(BeanUtils.toBean(monitors, SafetyWorkPermitMonitorRespVO.class)); |
| | | } |
| | | |
| | | @PostMapping("/monitor/create") |
| | | @Operation(summary = "æ°å¢ä½ä¸çæ¤è®°å½") |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:update')") |
| | | public CommonResult<Long> createMonitor(@Valid @RequestBody SafetyWorkPermitMonitorSaveReqVO reqVO) { |
| | | return success(permitService.createMonitor(reqVO)); |
| | | } |
| | | |
| | | @DeleteMapping("/monitor/delete") |
| | | @Operation(summary = "å é¤ä½ä¸çæ¤è®°å½") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('safety:permit:update')") |
| | | public CommonResult<Boolean> deleteMonitor(@RequestParam("id") Long id) { |
| | | permitService.deleteMonitor(id); |
| | | return success(true); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç¹ç§ä½ä¸è¯å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyCertificatePageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æè¯äººï¼åå·¥ç¼å·ï¼") |
| | | private Long employeeId; |
| | | |
| | | @Schema(description = "æè¯äººå§åï¼æ¨¡ç³å¹é
ï¼") |
| | | private String employeeName; |
| | | |
| | | @Schema(description = "å·¥å·") |
| | | private String employeeNo; |
| | | |
| | | @Schema(description = "æå±é¨é¨") |
| | | private String deptName; |
| | | |
| | | @Schema(description = "è¯ä»¶ç±»å") |
| | | private String certType; |
| | | |
| | | @Schema(description = "è¯ä»¶ç¼å·") |
| | | private String certNo; |
| | | |
| | | @Schema(description = "ç¶æ") |
| | | private String status; |
| | | |
| | | @Schema(description = "æææå¼å§") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate expireDateStart; |
| | | |
| | | @Schema(description = "ææææªæ¢") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate expireDateEnd; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç¹ç§ä½ä¸è¯ Response VO") |
| | | @Data |
| | | public class SafetyCertificateRespVO { |
| | | |
| | | private Long id; |
| | | @Schema(description = "æè¯äººï¼åå·¥ç¼å·ï¼") |
| | | private Long employeeId; |
| | | @Schema(description = "æè¯äººå
³èçç³»ç»ç¨æ·ç¼å·") |
| | | private Long userId; |
| | | private String employeeName; |
| | | private String employeeNo; |
| | | private String deptName; |
| | | private String phone; |
| | | private String certType; |
| | | @Schema(description = "è¯ä»¶ç±»ååç§°") |
| | | private String certTypeName; |
| | | private String certNo; |
| | | private String issuer; |
| | | private LocalDate issueDate; |
| | | private LocalDate expireDate; |
| | | private LocalDate reviewDate; |
| | | private Integer warnDays; |
| | | private String status; |
| | | @Schema(description = "ç¶æåç§°") |
| | | private String statusName; |
| | | @Schema(description = "è·å°æå¤©æ°ï¼è´æ°è¡¨ç¤ºå·²è¿æ") |
| | | private Long remainingDays; |
| | | private String attachment; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * <p>æè¯äººéè¿ employeeId å
³èå工档æ¡ï¼å§åä¸é¨é¨ç±åç«¯ä»æ¡£æ¡å¸¦åºï¼ |
| | | * å端åªéé人ï¼ä¸æå·¥å¡«åï¼é¿å
ä¸äººåèµæºæ°æ®ä¸ä¸è´ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç¹ç§ä½ä¸è¯æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyCertificateSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "æè¯äººï¼åå·¥ç¼å·ï¼", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "è¯·éæ©æè¯äºº") |
| | | private Long employeeId; |
| | | |
| | | @Schema(description = "è¯ä»¶ç±»å", requiredMode = Schema.RequiredMode.REQUIRED, example = "HIGH_VOLTAGE_OPERATION") |
| | | @NotBlank(message = "è¯ä»¶ç±»åä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "LOW_VOLTAGE_ELECTRICIAN|HIGH_VOLTAGE_OPERATION|WELDING|HOIST|HEIGHT_WORK|LIMITED_SPACE|FORKLIFT|BOILER|OTHER", |
| | | message = "è¯ä»¶ç±»åä¸åæ³") |
| | | private String certType; |
| | | |
| | | @Schema(description = "è¯ä»¶ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "T330102199001011234") |
| | | @NotBlank(message = "è¯ä»¶ç¼å·ä¸è½ä¸ºç©º") |
| | | @Size(max = 64) |
| | | private String certNo; |
| | | |
| | | @Schema(description = "åè¯æºå
³") |
| | | @Size(max = 100) |
| | | private String issuer; |
| | | |
| | | @Schema(description = "åè¯æ¥æ") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate issueDate; |
| | | |
| | | @Schema(description = "æææè³", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "æææä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate expireDate; |
| | | |
| | | @Schema(description = "䏿¬¡å¤å®¡æ¥æ") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate reviewDate; |
| | | |
| | | @Schema(description = "å°æé¢è¦æå天æ°", example = "30") |
| | | @Min(value = 0, message = "é¢è¦å¤©æ°ä¸è½ä¸ºè´æ°") |
| | | @Max(value = 365, message = "é¢è¦å¤©æ°ä¸è½è¶
è¿ 365 天") |
| | | private Integer warnDays; |
| | | |
| | | @Schema(description = "ç¶æ", example = "VALID") |
| | | @Pattern(regexp = "VALID|EXPIRING|EXPIRED|REVOKED", message = "ç¶æä¸åæ³") |
| | | private String status; |
| | | |
| | | @Schema(description = "è¯ä»¶æ«æä»¶ URLï¼éå·åé") |
| | | @Size(max = 500) |
| | | private String attachment; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣忴¾ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - 鿣忴¾ Request VO") |
| | | @Data |
| | | public class SafetyHazardAssignReqVO { |
| | | |
| | | @Schema(description = "鿣ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "鿣ç¼å·ä¸è½ä¸ºç©º") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ´æ¹è´£ä»»äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¯·éæ©æ´æ¹è´£ä»»äºº") |
| | | private Long assigneeId; |
| | | |
| | | @Schema(description = "æ´æ¹æé") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate rectifyDeadline; |
| | | |
| | | @Schema(description = "åæ´¾è¯´æ") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - 鿣å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyHazardPageReqVO extends PageParam { |
| | | |
| | | private String code; |
| | | private String title; |
| | | private String level; |
| | | private String source; |
| | | private String status; |
| | | private String assignee; |
| | | private String location; |
| | | |
| | | @Schema(description = "䏿¥æ¶é´èå´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime[] reportTime; |
| | | |
| | | @Schema(description = "䏿¥æ¶é´å¼å§ï¼å
é¨ä½¿ç¨ï¼", hidden = true) |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime reportTimeStart; |
| | | |
| | | @Schema(description = "䏿¥æ¶é´ç»æï¼å
é¨ä½¿ç¨ï¼", hidden = true) |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime reportTimeEnd; |
| | | |
| | | public void normalizeTimeRange() { |
| | | if (reportTime != null && reportTime.length == 2) { |
| | | this.reportTimeStart = reportTime[0]; |
| | | this.reportTimeEnd = reportTime[1]; |
| | | } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Pattern; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣夿¥ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - 鿣夿¥ Request VO") |
| | | @Data |
| | | public class SafetyHazardRecheckReqVO { |
| | | |
| | | @Schema(description = "鿣ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "鿣ç¼å·ä¸è½ä¸ºç©º") |
| | | private Long id; |
| | | |
| | | @Schema(description = "夿¥äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¯·éæ©å¤æ¥äºº") |
| | | private Long recheckerId; |
| | | |
| | | @Schema(description = "夿¥ç»è®ºï¼PASSED-éè¿ï¼REJECTED-ä¸éè¿", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "夿¥ç»è®ºä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "PASSED|REJECTED", message = "夿¥ç»è®ºåªè½ä¸ºéè¿æä¸éè¿") |
| | | private String recheckResult; |
| | | |
| | | @Schema(description = "夿¥æè§") |
| | | @Size(max = 500) |
| | | private String recheckRemark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - éæ£æ´æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - éæ£æ´æ¹ Request VO") |
| | | @Data |
| | | public class SafetyHazardRectifyReqVO { |
| | | |
| | | @Schema(description = "鿣ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "鿣ç¼å·ä¸è½ä¸ºç©º") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ´æ¹æªæ½ä¸ç»æ", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "æ´æ¹æªæ½ä¸ç»æä¸è½ä¸ºç©º") |
| | | @Size(max = 2000) |
| | | private String rectifyDesc; |
| | | |
| | | @Schema(description = "æ´æ¹åç
§ç URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String rectifyPhotoUrls; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣 Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - 鿣 Response VO") |
| | | @Data |
| | | public class SafetyHazardRespVO { |
| | | |
| | | private Long id; |
| | | private String code; |
| | | private String title; |
| | | private String level; |
| | | @Schema(description = "鿣ç级åç§°") |
| | | private String levelName; |
| | | private String source; |
| | | @Schema(description = "æ¥æºåç§°") |
| | | private String sourceName; |
| | | private Long inspectionId; |
| | | private Long pointId; |
| | | private String pointName; |
| | | private String location; |
| | | private String description; |
| | | private String photoUrls; |
| | | @Schema(description = "䏿¥äººç¼å·") |
| | | private Long reporterId; |
| | | private String reporter; |
| | | private LocalDateTime reportTime; |
| | | @Schema(description = "æ´æ¹è´£ä»»äººç¼å·") |
| | | private Long assigneeId; |
| | | private String assignee; |
| | | private LocalDateTime assignTime; |
| | | private LocalDate rectifyDeadline; |
| | | @Schema(description = "æ¯å¦å·²è¶
æ") |
| | | private Boolean overdue; |
| | | private String rectifyDesc; |
| | | private String rectifyPhotoUrls; |
| | | private LocalDateTime rectifyTime; |
| | | @Schema(description = "夿¥äººç¼å·") |
| | | private Long recheckerId; |
| | | private String rechecker; |
| | | private LocalDateTime recheckTime; |
| | | private String recheckResult; |
| | | @Schema(description = "夿¥ç»è®ºåç§°") |
| | | private String recheckResultName; |
| | | private String recheckRemark; |
| | | private String status; |
| | | @Schema(description = "ç¶æåç§°") |
| | | private String statusName; |
| | | private LocalDateTime closeTime; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣䏿¥/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - 鿣䏿¥/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyHazardSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "鿣æ é¢", requiredMode = Schema.RequiredMode.REQUIRED, example = "é
çµå®¤é¨æªä¸é") |
| | | @NotBlank(message = "鿣æ é¢ä¸è½ä¸ºç©º") |
| | | @Size(max = 200) |
| | | private String title; |
| | | |
| | | @Schema(description = "鿣ç级", example = "GENERAL") |
| | | @Pattern(regexp = "GENERAL|MAJOR", message = "鿣ç级ä¸åæ³") |
| | | private String level; |
| | | |
| | | @Schema(description = "æ¥æº", example = "INSPECTION") |
| | | @Pattern(regexp = "INSPECTION|SELF_CHECK|REPORT|EXTERNAL", message = "éæ£æ¥æºä¸åæ³") |
| | | private String source; |
| | | |
| | | @Schema(description = "å
³èå·¡æ£è®°å½ç¼å·") |
| | | private Long inspectionId; |
| | | |
| | | @Schema(description = "å
³èå·¡æ£ç¹ä½ç¼å·") |
| | | private Long pointId; |
| | | |
| | | @Schema(description = "ç¹ä½åç§°") |
| | | @Size(max = 100) |
| | | private String pointName; |
| | | |
| | | @Schema(description = "鿣ä½ç½®") |
| | | @Size(max = 200) |
| | | private String location; |
| | | |
| | | @Schema(description = "鿣æè¿°") |
| | | @Size(max = 2000) |
| | | private String description; |
| | | |
| | | @Schema(description = "ç°åºç
§ç URLï¼éå·åéï¼ç§»å¨ç«¯æç
§ä¸ä¼ ï¼") |
| | | @Size(max = 2000) |
| | | private String photoUrls; |
| | | |
| | | @Schema(description = "䏿¥äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¯·éæ©ä¸æ¥äºº") |
| | | private Long reporterId; |
| | | |
| | | @Schema(description = "䏿¥æ¶é´") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime reportTime; |
| | | |
| | | @Schema(description = "æ´æ¹æé") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate rectifyDeadline; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£è®°å½å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å·¡æ£è®°å½å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyInspectionPageReqVO extends PageParam { |
| | | |
| | | private Long pointId; |
| | | private String pointType; |
| | | private String inspector; |
| | | private String result; |
| | | |
| | | @Schema(description = "å·¡æ£æ¶é´èå´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime[] inspectTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å·¡æ£ç¹ä½å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyInspectionPointPageReqVO extends PageParam { |
| | | |
| | | private String code; |
| | | private String name; |
| | | private String pointType; |
| | | private String workshopName; |
| | | private Integer status; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å·¡æ£ç¹ä½ Response VO") |
| | | @Data |
| | | public class SafetyInspectionPointRespVO { |
| | | |
| | | private Long id; |
| | | private String code; |
| | | private String name; |
| | | private String pointType; |
| | | @Schema(description = "ç¹ä½ç±»ååç§°") |
| | | private String pointTypeName; |
| | | @Schema(description = "æå±è½¦é´ç¼å·") |
| | | private Long workshopId; |
| | | private String workshopName; |
| | | private String location; |
| | | private String inspectItems; |
| | | private String inspectCycle; |
| | | @Schema(description = "å·¡æ£å¨æåç§°") |
| | | private String inspectCycleName; |
| | | @Schema(description = "责任人ç¼å·") |
| | | private Long ownerId; |
| | | private String ownerName; |
| | | private Integer status; |
| | | @Schema(description = "æè¿ä¸æ¬¡å·¡æ£æ¶é´") |
| | | private LocalDateTime lastInspectTime; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å·¡æ£ç¹ä½æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyInspectionPointSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "ç¹ä½ç¼ç ", requiredMode = Schema.RequiredMode.REQUIRED, example = "PD-001") |
| | | @NotBlank(message = "ç¹ä½ç¼ç ä¸è½ä¸ºç©º") |
| | | @Size(max = 64) |
| | | private String code; |
| | | |
| | | @Schema(description = "ç¹ä½åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "1#é«åé
çµå®¤") |
| | | @NotBlank(message = "ç¹ä½åç§°ä¸è½ä¸ºç©º") |
| | | @Size(max = 100) |
| | | private String name; |
| | | |
| | | @Schema(description = "ç¹ä½ç±»å", requiredMode = Schema.RequiredMode.REQUIRED, example = "HIGH_VOLTAGE_ROOM") |
| | | @NotBlank(message = "ç¹ä½ç±»åä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "HIGH_VOLTAGE_ROOM|UNIT_AREA|DANGER_CHEMICAL|FIRE_AREA|WORKSHOP|OTHER", message = "ç¹ä½ç±»åä¸åæ³") |
| | | private String pointType; |
| | | |
| | | @Schema(description = "æå±è½¦é´ï¼å
³è mes_md_workshopï¼") |
| | | private Long workshopId; |
| | | |
| | | @Schema(description = "å
·ä½ä½ç½®") |
| | | @Size(max = 200) |
| | | private String location; |
| | | |
| | | @Schema(description = "å·¡æ£é¡¹ç®æ¸
åï¼æè¡åé") |
| | | @Size(max = 2000) |
| | | private String inspectItems; |
| | | |
| | | @Schema(description = "å·¡æ£å¨æ", example = "DAILY") |
| | | @Pattern(regexp = "SHIFT|DAILY|WEEKLY|MONTHLY", message = "å·¡æ£å¨æä¸åæ³") |
| | | private String inspectCycle; |
| | | |
| | | @Schema(description = "责任人ï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼") |
| | | private Long ownerId; |
| | | |
| | | @Schema(description = "ç¶æï¼0-å¯ç¨ï¼1-åç¨", example = "0") |
| | | @NotNull(message = "ç¶æä¸è½ä¸ºç©º") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£è®°å½ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å·¡æ£è®°å½ Response VO") |
| | | @Data |
| | | public class SafetyInspectionRespVO { |
| | | |
| | | private Long id; |
| | | private Long pointId; |
| | | private String pointName; |
| | | private String pointType; |
| | | @Schema(description = "ç¹ä½ç±»ååç§°") |
| | | private String pointTypeName; |
| | | private LocalDateTime inspectTime; |
| | | @Schema(description = "å·¡æ£äººç¼å·") |
| | | private Long inspectorId; |
| | | private String inspector; |
| | | private String result; |
| | | @Schema(description = "å·¡æ£ç»æåç§°") |
| | | private String resultName; |
| | | private String content; |
| | | private String photoUrls; |
| | | private Integer hazardCount; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£è®°å½æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å·¡æ£è®°å½æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyInspectionSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "å·¡æ£ç¹ä½ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "å·¡æ£ç¹ä½ä¸è½ä¸ºç©º") |
| | | private Long pointId; |
| | | |
| | | @Schema(description = "å·¡æ£æ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "å·¡æ£æ¶é´ä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime inspectTime; |
| | | |
| | | @Schema(description = "å·¡æ£äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¯·éæ©å·¡æ£äºº") |
| | | private Long inspectorId; |
| | | |
| | | @Schema(description = "å·¡æ£ç»æ", example = "NORMAL") |
| | | @Pattern(regexp = "NORMAL|ABNORMAL", message = "å·¡æ£ç»æåªè½ä¸ºæ£å¸¸æå¼å¸¸") |
| | | private String result; |
| | | |
| | | @Schema(description = "å·¡æ£å
容䏿
åµ") |
| | | @Size(max = 2000) |
| | | private String content; |
| | | |
| | | @Schema(description = "ç°åºç
§ç URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String photoUrls; |
| | | |
| | | @Schema(description = "æ¬æ¬¡åç°ç鿣æ°", example = "0") |
| | | @Min(value = 0, message = "鿣æ°ä¸è½ä¸ºè´æ°") |
| | | private Integer hazardCount; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.ledger; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.Pattern; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ ååå°è´¦å¯¼åº Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - æ ååå°è´¦å¯¼åº Request VO") |
| | | @Data |
| | | public class SafetyLedgerExportReqVO { |
| | | |
| | | @Schema(description = "å°è´¦ç±»åï¼ALL-å
¨å¥ï¼CERT-ç¹ç§ä½ä¸è¯ï¼HAZARD-鿣ï¼PERMIT-ä½ä¸ç¥¨ï¼MATERIAL-ç©èµï¼TRAINING-å¹è®ï¼DRILL-æ¼ç»ï¼ACCIDENT-äºæ
ï¼INSPECTION-å·¡æ£", |
| | | example = "ALL") |
| | | @Pattern(regexp = "ALL|CERT|HAZARD|PERMIT|MATERIAL|TRAINING|DRILL|ACCIDENT|INSPECTION", message = "å°è´¦ç±»åä¸åæ³") |
| | | private String type; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate endDate; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.ledger; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ»è§ç»è®¡ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å®å
¨ç产æ»è§ç»è®¡ Response VO") |
| | | @Data |
| | | public class SafetyOverviewRespVO { |
| | | |
| | | @Schema(description = "ç¹ç§ä½ä¸è¯æ»æ°") |
| | | private Long certTotal; |
| | | @Schema(description = "å³å°å°æè¯ä»¶æ°") |
| | | private Long certExpiring; |
| | | @Schema(description = "å·²è¿æè¯ä»¶æ°") |
| | | private Long certExpired; |
| | | @Schema(description = "éæ£æ»æ°") |
| | | private Long hazardTotal; |
| | | @Schema(description = "æªéç¯éæ£æ°") |
| | | private Long hazardOpen; |
| | | @Schema(description = "å·²è¶
ææªéç¯éæ£æ°") |
| | | private Long hazardOverdue; |
| | | @Schema(description = "鿣éç¯çï¼0-100ï¼") |
| | | private Integer hazardCloseRate; |
| | | @Schema(description = "å¾
审æ¹ä½ä¸ç¥¨æ°") |
| | | private Long permitPending; |
| | | @Schema(description = "è¿è¡ä¸ä½ä¸ç¥¨æ°") |
| | | private Long permitInProgress; |
| | | @Schema(description = "ç©èµä½äºå®å
¨åºåæ°") |
| | | private Long materialBelowSafeStock; |
| | | @Schema(description = "ç©èµä¸´è¿ææææ°") |
| | | private Long materialExpiring; |
| | | @Schema(description = "æ¬æå¹è®åºæ¬¡") |
| | | private Long trainingThisMonth; |
| | | @Schema(description = "æ¬ææ¼ç»åºæ¬¡") |
| | | private Long drillThisMonth; |
| | | @Schema(description = "æ¬æäºæ
æ°") |
| | | private Long accidentThisMonth; |
| | | |
| | | @Schema(description = "鿣è¶å¿ï¼è¿ 6 个æï¼ææï¼") |
| | | private List<MonthlyCount> hazardTrend; |
| | | @Schema(description = "äºæ
è¶å¿ï¼è¿ 6 个æï¼ææï¼") |
| | | private List<MonthlyCount> accidentTrend; |
| | | |
| | | /** |
| | | * ææè®¡æ° |
| | | */ |
| | | @Data |
| | | public static class MonthlyCount { |
| | | @Schema(description = "æä»½ï¼æ ¼å¼ yyyy-MM", example = "2026-10") |
| | | private String month; |
| | | @Schema(description = "æ°é") |
| | | private Long count; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµå°è´¦å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç©èµå°è´¦å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyMaterialPageReqVO extends PageParam { |
| | | |
| | | private String code; |
| | | private String name; |
| | | private String category; |
| | | private String storageLocation; |
| | | private Integer status; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµå°è´¦ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç©èµå°è´¦ Response VO") |
| | | @Data |
| | | public class SafetyMaterialRespVO { |
| | | |
| | | private Long id; |
| | | private String code; |
| | | private String name; |
| | | private String category; |
| | | @Schema(description = "ç±»å«åç§°") |
| | | private String categoryName; |
| | | private String spec; |
| | | private String unit; |
| | | private BigDecimal stockQty; |
| | | private BigDecimal safeStock; |
| | | @Schema(description = "æ¯å¦ä½äºå®å
¨åºå") |
| | | private Boolean belowSafeStock; |
| | | private String storageLocation; |
| | | private LocalDate expireDate; |
| | | @Schema(description = "è·æææå¤©æ°ï¼è´æ°è¡¨ç¤ºå·²è¿æ") |
| | | private Long expireRemainingDays; |
| | | private Integer validityMonths; |
| | | @Schema(description = "ä¿ç®¡äººç¼å·") |
| | | private Long managerId; |
| | | private String manager; |
| | | private Integer status; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµå°è´¦æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç©èµå°è´¦æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyMaterialSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "ç©èµç¼ç ", requiredMode = Schema.RequiredMode.REQUIRED, example = "PM-001") |
| | | @NotBlank(message = "ç©èµç¼ç ä¸è½ä¸ºç©º") |
| | | @Size(max = 64) |
| | | private String code; |
| | | |
| | | @Schema(description = "ç©èµåç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "10kV ç»ç¼æå¥") |
| | | @NotBlank(message = "ç©èµåç§°ä¸è½ä¸ºç©º") |
| | | @Size(max = 100) |
| | | private String name; |
| | | |
| | | @Schema(description = "ç±»å«", requiredMode = Schema.RequiredMode.REQUIRED, example = "INSULATING") |
| | | @NotBlank(message = "ç©èµç±»å«ä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "INSULATING|HAZARD_CHEMICAL|FIRE|PPE|OTHER", message = "ç©èµç±»å«ä¸åæ³") |
| | | private String category; |
| | | |
| | | @Schema(description = "è§æ ¼åå·") |
| | | @Size(max = 100) |
| | | private String spec; |
| | | |
| | | @Schema(description = "计éåä½", example = "å") |
| | | @Size(max = 20) |
| | | private String unit; |
| | | |
| | | @Schema(description = "å½ååºåæ°é") |
| | | @DecimalMin(value = "0", message = "åºåæ°éä¸è½ä¸ºè´æ°") |
| | | private BigDecimal stockQty; |
| | | |
| | | @Schema(description = "å®å
¨åºå") |
| | | @DecimalMin(value = "0", message = "å®å
¨åºåä¸è½ä¸ºè´æ°") |
| | | private BigDecimal safeStock; |
| | | |
| | | @Schema(description = "åæ¾ä½ç½®") |
| | | @Size(max = 100) |
| | | private String storageLocation; |
| | | |
| | | @Schema(description = "æææè³") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate expireDate; |
| | | |
| | | @Schema(description = "æææææ°") |
| | | @Min(value = 0, message = "æææææ°ä¸è½ä¸ºè´æ°") |
| | | private Integer validityMonths; |
| | | |
| | | @Schema(description = "ä¿ç®¡äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼") |
| | | private Long managerId; |
| | | |
| | | @Schema(description = "ç¶æï¼0-å¯ç¨ï¼1-åç¨", example = "0") |
| | | @NotNull(message = "ç¶æä¸è½ä¸ºç©º") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµåºå
¥åºæµæ°´å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç©èµåºå
¥åºæµæ°´å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyMaterialStockPageReqVO extends PageParam { |
| | | |
| | | private Long materialId; |
| | | private String materialName; |
| | | private String category; |
| | | private String bizType; |
| | | |
| | | @Schema(description = "ä¸å¡æ¥æèå´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate[] bizDate; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµåºå
¥åºæµæ°´ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç©èµåºå
¥åºæµæ°´ Response VO") |
| | | @Data |
| | | public class SafetyMaterialStockRespVO { |
| | | |
| | | private Long id; |
| | | private Long materialId; |
| | | private String materialName; |
| | | private String category; |
| | | @Schema(description = "ç±»å«åç§°") |
| | | private String categoryName; |
| | | private String bizType; |
| | | @Schema(description = "ä¸å¡ç±»ååç§°") |
| | | private String bizTypeName; |
| | | private BigDecimal quantity; |
| | | private BigDecimal stockBefore; |
| | | private BigDecimal stockAfter; |
| | | private LocalDate bizDate; |
| | | private String operator; |
| | | private String receiver; |
| | | private String purpose; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµåºå
¥åºç»è®° Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ç©èµåºå
¥åºç»è®° Request VO") |
| | | @Data |
| | | public class SafetyMaterialStockSaveReqVO { |
| | | |
| | | @Schema(description = "ç©èµç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "ç©èµä¸è½ä¸ºç©º") |
| | | private Long materialId; |
| | | |
| | | @Schema(description = "ä¸å¡ç±»åï¼IN-å
¥åºï¼OUT-åºåº", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "ä¸å¡ç±»åä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "IN|OUT", message = "ä¸å¡ç±»ååªè½ä¸ºå
¥åºæåºåº") |
| | | private String bizType; |
| | | |
| | | @Schema(description = "æ°é", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") |
| | | @NotNull(message = "æ°éä¸è½ä¸ºç©º") |
| | | @DecimalMin(value = "0", inclusive = false, message = "æ°éå¿
须大äºé¶") |
| | | @Digits(integer = 15, fraction = 3) |
| | | private BigDecimal quantity; |
| | | |
| | | @Schema(description = "ä¸å¡æ¥æ") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate bizDate; |
| | | |
| | | @Schema(description = "ç»å人", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "ç»å人ä¸è½ä¸ºç©º") |
| | | @Size(max = 50) |
| | | private String operator; |
| | | |
| | | @Schema(description = "é¢ç¨äººï¼åºåºå¡«åï¼") |
| | | @Size(max = 50) |
| | | private String receiver; |
| | | |
| | | @Schema(description = "ç¨é/å»å") |
| | | @Size(max = 200) |
| | | private String purpose; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.org; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å®å
¨ç»ç» Response VOï¼æ å½¢ï¼ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å®å
¨ç»ç» Response VO") |
| | | @Data |
| | | public class SafetyOrgRespVO { |
| | | |
| | | private Long id; |
| | | private Long parentId; |
| | | private String name; |
| | | @Schema(description = "è´è´£äººï¼åå·¥ç¼å·ï¼") |
| | | private Long leaderId; |
| | | @Schema(description = "è´è´£äººå§åï¼å¿«ç
§ï¼") |
| | | private String leaderName; |
| | | private String leaderPhone; |
| | | private String memberNames; |
| | | private String duty; |
| | | private Integer sort; |
| | | private Integer status; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | @Schema(description = "åç»ç»") |
| | | private List<SafetyOrgRespVO> children; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.org; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å®å
¨ç»ç»æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å®å
¨ç»ç»æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyOrgSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "ç¶çº§ç¼å·ï¼0 为顶级", example = "0") |
| | | private Long parentId; |
| | | |
| | | @Schema(description = "ç»ç»åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "å®å
¨ç产å§åä¼") |
| | | @NotBlank(message = "ç»ç»åç§°ä¸è½ä¸ºç©º") |
| | | @Size(max = 100, message = "ç»ç»åç§°é¿åº¦ä¸è½è¶
è¿ 100 å") |
| | | private String name; |
| | | |
| | | @Schema(description = "è´è´£äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼") |
| | | private Long leaderId; |
| | | |
| | | @Schema(description = "æåå§åï¼éå·åé") |
| | | @Size(max = 500) |
| | | private String memberNames; |
| | | |
| | | @Schema(description = "å®å
¨èè´£") |
| | | @Size(max = 500) |
| | | private String duty; |
| | | |
| | | @Schema(description = "æ¾ç¤ºé¡ºåº", example = "1") |
| | | @NotNull(message = "æ¾ç¤ºé¡ºåºä¸è½ä¸ºç©º") |
| | | private Integer sort; |
| | | |
| | | @Schema(description = "ç¶æï¼0-å¯ç¨ï¼1-åç¨", example = "0") |
| | | @NotNull(message = "ç¶æä¸è½ä¸ºç©º") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Pattern; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨å®¡æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - é«å±ä½ä¸ç¥¨å®¡æ¹ Request VO") |
| | | @Data |
| | | public class SafetyWorkPermitApproveReqVO { |
| | | |
| | | @Schema(description = "ä½ä¸ç¥¨ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "ä½ä¸ç¥¨ç¼å·ä¸è½ä¸ºç©º") |
| | | private Long id; |
| | | |
| | | @Schema(description = "审æ¹äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¯·éæ©å®¡æ¹äºº") |
| | | private Long approverId; |
| | | |
| | | @Schema(description = "审æ¹ç»è®ºï¼APPROVED-éè¿ï¼REJECTED-驳å", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotBlank(message = "审æ¹ç»è®ºä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "APPROVED|REJECTED", message = "审æ¹ç»è®ºåªè½ä¸ºéè¿æé©³å") |
| | | private String decision; |
| | | |
| | | @Schema(description = "å®¡æ¹æè§") |
| | | @Size(max = 500) |
| | | private String approveComment; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ä½ä¸çæ¤è®°å½ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ä½ä¸çæ¤è®°å½ Response VO") |
| | | @Data |
| | | public class SafetyWorkPermitMonitorRespVO { |
| | | |
| | | private Long id; |
| | | private Long permitId; |
| | | private LocalDateTime monitorTime; |
| | | @Schema(description = "çæ¤äººç¼å·") |
| | | private Long guardianId; |
| | | private String guardian; |
| | | private String monitorContent; |
| | | private String abnormal; |
| | | private String photoUrls; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ä½ä¸çæ¤è®°å½æ°å¢ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - ä½ä¸çæ¤è®°å½æ°å¢ Request VO") |
| | | @Data |
| | | public class SafetyWorkPermitMonitorSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "ä½ä¸ç¥¨ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "ä½ä¸ç¥¨ç¼å·ä¸è½ä¸ºç©º") |
| | | private Long permitId; |
| | | |
| | | @Schema(description = "çæ¤æ¶é´") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime monitorTime; |
| | | |
| | | @Schema(description = "çæ¤äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¯·éæ©çæ¤äºº") |
| | | private Long guardianId; |
| | | |
| | | @Schema(description = "çæ¤å
容䏿
åµ") |
| | | @Size(max = 1000) |
| | | private String monitorContent; |
| | | |
| | | @Schema(description = "å¼å¸¸æ
åµä¸å¤ç½®") |
| | | @Size(max = 500) |
| | | private String abnormal; |
| | | |
| | | @Schema(description = "ç°åºç
§ç URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String photoUrls; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - é«å±ä½ä¸ç¥¨å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyWorkPermitPageReqVO extends PageParam { |
| | | |
| | | private String code; |
| | | private String title; |
| | | private String permitType; |
| | | private String status; |
| | | private String riskLevel; |
| | | private String applicant; |
| | | private String workshopName; |
| | | |
| | | @Schema(description = "计åå¼å§æ¶é´èå´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime[] planStartTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - é«å±ä½ä¸ç¥¨ Response VO") |
| | | @Data |
| | | public class SafetyWorkPermitRespVO { |
| | | |
| | | private Long id; |
| | | private String code; |
| | | private String permitType; |
| | | @Schema(description = "ä½ä¸ç±»ååç§°") |
| | | private String permitTypeName; |
| | | private String title; |
| | | @Schema(description = "ä½ä¸è½¦é´ç¼å·") |
| | | private Long workshopId; |
| | | private String workshopName; |
| | | private String location; |
| | | private String workContent; |
| | | @Schema(description = "ç³è¯·äººç¼å·") |
| | | private Long applicantId; |
| | | private String applicant; |
| | | private LocalDateTime applyTime; |
| | | private LocalDateTime planStartTime; |
| | | private LocalDateTime planEndTime; |
| | | private LocalDateTime actualStartTime; |
| | | private LocalDateTime actualEndTime; |
| | | private String riskLevel; |
| | | @Schema(description = "é£é©ç级åç§°") |
| | | private String riskLevelName; |
| | | private String safetyMeasures; |
| | | @Schema(description = "审æ¹äººç¼å·") |
| | | private Long approverId; |
| | | private String approver; |
| | | private LocalDateTime approveTime; |
| | | private String approveComment; |
| | | @Schema(description = "çæ¤äººç¼å·") |
| | | private Long guardianId; |
| | | private String guardian; |
| | | private String status; |
| | | @Schema(description = "ç¶æåç§°") |
| | | private String statusName; |
| | | private String attachment; |
| | | private String photoUrls; |
| | | @Schema(description = "çæ¤äººæ¯å¦å¿
å¡«ï¼å¨ç«/é«å带çµ/æé空é´ï¼") |
| | | private Boolean guardianRequired; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ç³è¯·/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - é«å±ä½ä¸ç¥¨ç³è¯·/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyWorkPermitSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "ä½ä¸ç±»å", requiredMode = Schema.RequiredMode.REQUIRED, example = "HOT_WORK") |
| | | @NotBlank(message = "ä½ä¸ç±»åä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "HOT_WORK|LIVE_HIGH_VOLTAGE|LIMITED_SPACE|WORK_AT_HEIGHT|LIFTING|TEMP_ELECTRIC|OTHER", |
| | | message = "ä½ä¸ç±»åä¸åæ³") |
| | | private String permitType; |
| | | |
| | | @Schema(description = "ä½ä¸åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "2#ä¸»åæ£ä¿®å¨ç«") |
| | | @NotBlank(message = "ä½ä¸åç§°ä¸è½ä¸ºç©º") |
| | | @Size(max = 200) |
| | | private String title; |
| | | |
| | | @Schema(description = "ä½ä¸è½¦é´ï¼å
³è mes_md_workshopï¼") |
| | | private Long workshopId; |
| | | |
| | | @Schema(description = "ä½ä¸å°ç¹") |
| | | @Size(max = 200) |
| | | private String location; |
| | | |
| | | @Schema(description = "ä½ä¸å
容ä¸èå´") |
| | | @Size(max = 2000) |
| | | private String workContent; |
| | | |
| | | @Schema(description = "ç³è¯·äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "è¯·éæ©ç³è¯·äºº") |
| | | private Long applicantId; |
| | | |
| | | @Schema(description = "ç³è¯·æ¶é´") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime applyTime; |
| | | |
| | | @Schema(description = "计åå¼å§æ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "计åå¼å§æ¶é´ä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime planStartTime; |
| | | |
| | | @Schema(description = "计åç»ææ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "计åç»ææ¶é´ä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime planEndTime; |
| | | |
| | | @Schema(description = "é£é©ç级", example = "HIGH") |
| | | @Pattern(regexp = "LOW|NORMAL|HIGH|VERY_HIGH", message = "é£é©ç级ä¸åæ³") |
| | | private String riskLevel; |
| | | |
| | | @Schema(description = "å®å
¨æªæ½") |
| | | @Size(max = 2000) |
| | | private String safetyMeasures; |
| | | |
| | | @Schema(description = "çæ¤äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼") |
| | | private Long guardianId; |
| | | |
| | | @Schema(description = "ä½ä¸ç¥¨éä»¶ URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String attachment; |
| | | |
| | | @Schema(description = "ç°åºç
§ç URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String photoUrls; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
ç»è®°å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - äºæ
ç»è®°å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyAccidentPageReqVO extends PageParam { |
| | | |
| | | private String code; |
| | | private String title; |
| | | private String accidentType; |
| | | private String level; |
| | | private String status; |
| | | |
| | | @Schema(description = "åçæ¶é´èå´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime[] occurTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
ç»è®° Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - äºæ
ç»è®° Response VO") |
| | | @Data |
| | | public class SafetyAccidentRespVO { |
| | | |
| | | private Long id; |
| | | private String code; |
| | | private String title; |
| | | private String accidentType; |
| | | @Schema(description = "äºæ
ç±»ååç§°") |
| | | private String accidentTypeName; |
| | | private String level; |
| | | @Schema(description = "äºæ
ç级åç§°") |
| | | private String levelName; |
| | | private LocalDateTime occurTime; |
| | | private String location; |
| | | @Schema(description = "æå±è½¦é´ç¼å·") |
| | | private Long workshopId; |
| | | private String workshopName; |
| | | private String casualtyDesc; |
| | | private BigDecimal economicLoss; |
| | | private String involvedPersons; |
| | | private String description; |
| | | private String causeAnalysis; |
| | | private String measures; |
| | | @Schema(description = "ç»è®°äººç¼å·") |
| | | private Long reporterId; |
| | | private String reporter; |
| | | private LocalDateTime reportTime; |
| | | private String status; |
| | | @Schema(description = "ç¶æåç§°") |
| | | private String statusName; |
| | | private String attachment; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
ç»è®°æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - äºæ
ç»è®°æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyAccidentSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "äºæ
åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "10kV å¼å
³æè¯¯æä½è§¦çµ") |
| | | @NotBlank(message = "äºæ
åç§°ä¸è½ä¸ºç©º") |
| | | @Size(max = 200) |
| | | private String title; |
| | | |
| | | @Schema(description = "äºæ
ç±»å", requiredMode = Schema.RequiredMode.REQUIRED, example = "ELECTRIC_SHOCK") |
| | | @NotBlank(message = "äºæ
ç±»åä¸è½ä¸ºç©º") |
| | | @Pattern(regexp = "ELECTRIC_SHOCK|FIRE|FALL|OBJECT_STRIKE|MECHANICAL|CHEMICAL|VEHICLE|OTHER", message = "äºæ
ç±»åä¸åæ³") |
| | | private String accidentType; |
| | | |
| | | @Schema(description = "äºæ
ç级", example = "GENERAL") |
| | | @Pattern(regexp = "SLIGHT|GENERAL|SEVERE|MAJOR", message = "äºæ
ç级ä¸åæ³") |
| | | private String level; |
| | | |
| | | @Schema(description = "åçæ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "åçæ¶é´ä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime occurTime; |
| | | |
| | | @Schema(description = "åçå°ç¹") |
| | | @Size(max = 200) |
| | | private String location; |
| | | |
| | | @Schema(description = "æå±è½¦é´ï¼å
³è mes_md_workshopï¼") |
| | | private Long workshopId; |
| | | |
| | | @Schema(description = "伤亡æ
åµ") |
| | | @Size(max = 500) |
| | | private String casualtyDesc; |
| | | |
| | | @Schema(description = "ç´æ¥ç»æµæå¤±ï¼å
ï¼") |
| | | @DecimalMin(value = "0", message = "ç»æµæå¤±ä¸è½ä¸ºè´æ°") |
| | | private BigDecimal economicLoss; |
| | | |
| | | @Schema(description = "æ¶äºäººåå§åï¼éå·åé") |
| | | @Size(max = 500) |
| | | private String involvedPersons; |
| | | |
| | | @Schema(description = "äºæ
ç»è¿") |
| | | @Size(max = 2000) |
| | | private String description; |
| | | |
| | | @Schema(description = "åå åæ") |
| | | @Size(max = 2000) |
| | | private String causeAnalysis; |
| | | |
| | | @Schema(description = "å¤çæªæ½ä¸æ´æ¹è¦æ±") |
| | | @Size(max = 2000) |
| | | private String measures; |
| | | |
| | | @Schema(description = "ç»è®°äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼") |
| | | private Long reporterId; |
| | | |
| | | @Schema(description = "ç»è®°æ¶é´") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| | | private LocalDateTime reportTime; |
| | | |
| | | @Schema(description = "ç¶æ", example = "REPORTED") |
| | | @Pattern(regexp = "REPORTED|INVESTIGATING|HANDLED|CLOSED", message = "ç¶æä¸åæ³") |
| | | private String status; |
| | | |
| | | @Schema(description = "ç°åºç
§ç/è°æ¥æ¥å URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String attachment; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ¼ç»è®°å½å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - æ¼ç»è®°å½å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyDrillPageReqVO extends PageParam { |
| | | |
| | | private String title; |
| | | private String drillType; |
| | | private String organizer; |
| | | |
| | | @Schema(description = "æ¼ç»æ¥æèå´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate[] drillDate; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ¼ç»è®°å½ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - æ¼ç»è®°å½ Response VO") |
| | | @Data |
| | | public class SafetyDrillRespVO { |
| | | |
| | | private Long id; |
| | | private String title; |
| | | private String drillType; |
| | | @Schema(description = "æ¼ç»ç±»ååç§°") |
| | | private String drillTypeName; |
| | | private LocalDate drillDate; |
| | | private String location; |
| | | @Schema(description = "ç»ç»äººç¼å·") |
| | | private Long organizerId; |
| | | private String organizer; |
| | | private String participants; |
| | | private Integer participantCount; |
| | | private String planDesc; |
| | | private String processDesc; |
| | | private String summary; |
| | | private Integer durationMinutes; |
| | | private String attachment; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ¶é²æ¼ç»è®°å½æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - æ¶é²æ¼ç»è®°å½æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyDrillSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¼ç»åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026 年度æ¶é²çæ£æ¼ç»") |
| | | @NotBlank(message = "æ¼ç»åç§°ä¸è½ä¸ºç©º") |
| | | @Size(max = 200) |
| | | private String title; |
| | | |
| | | @Schema(description = "æ¼ç»ç±»å", example = "FIRE") |
| | | @Pattern(regexp = "FIRE|EMERGENCY_EVAC|ELECTRIC_ACCIDENT|CHEMICAL_LEAK|OTHER", message = "æ¼ç»ç±»åä¸åæ³") |
| | | private String drillType; |
| | | |
| | | @Schema(description = "æ¼ç»æ¥æ", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "æ¼ç»æ¥æä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate drillDate; |
| | | |
| | | @Schema(description = "æ¼ç»å°ç¹") |
| | | @Size(max = 200) |
| | | private String location; |
| | | |
| | | @Schema(description = "ç»ç»äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼") |
| | | private Long organizerId; |
| | | |
| | | @Schema(description = "åå 人åå§åï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String participants; |
| | | |
| | | @Schema(description = "åå 人æ°") |
| | | @Min(value = 0, message = "åå 人æ°ä¸è½ä¸ºè´æ°") |
| | | private Integer participantCount; |
| | | |
| | | @Schema(description = "æ¼ç»æ¹æ¡") |
| | | @Size(max = 2000) |
| | | private String planDesc; |
| | | |
| | | @Schema(description = "æ¼ç»è¿ç¨è®°å½") |
| | | @Size(max = 2000) |
| | | private String processDesc; |
| | | |
| | | @Schema(description = "æ¼ç»æ»ç»ä¸æ¹è¿") |
| | | @Size(max = 2000) |
| | | private String summary; |
| | | |
| | | @Schema(description = "æ¼ç»æ¶é¿ï¼åéï¼") |
| | | @Min(value = 0, message = "æ¼ç»æ¶é¿ä¸è½ä¸ºè´æ°") |
| | | private Integer durationMinutes; |
| | | |
| | | @Schema(description = "æ¼ç»ç
§ç/è®°å½è¡¨ URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String attachment; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å¹è®è®°å½å页 Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å¹è®è®°å½å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyTrainingPageReqVO extends PageParam { |
| | | |
| | | private String title; |
| | | private String trainingType; |
| | | private String trainer; |
| | | |
| | | @Schema(description = "å¹è®æ¥æèå´") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate[] trainDate; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å¹è®è®°å½ Response VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å¹è®è®°å½ Response VO") |
| | | @Data |
| | | public class SafetyTrainingRespVO { |
| | | |
| | | private Long id; |
| | | private String title; |
| | | private String trainingType; |
| | | @Schema(description = "å¹è®ç±»ååç§°") |
| | | private String trainingTypeName; |
| | | private LocalDate trainDate; |
| | | private BigDecimal durationHours; |
| | | @Schema(description = "讲å¸/ç»ç»äººç¼å·") |
| | | private Long trainerId; |
| | | private String trainer; |
| | | private String location; |
| | | private String participants; |
| | | private Integer participantCount; |
| | | private String content; |
| | | private String examResult; |
| | | private String attachment; |
| | | private String remark; |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.*; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å¹è®è®°å½æ°å¢/ä¿®æ¹ Request VO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "管çåå° - å¹è®è®°å½æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class SafetyTrainingSaveReqVO { |
| | | |
| | | private Long id; |
| | | |
| | | @Schema(description = "å¹è®ä¸»é¢", requiredMode = Schema.RequiredMode.REQUIRED, example = "年度å®å
¨è§ç¨å¹è®") |
| | | @NotBlank(message = "å¹è®ä¸»é¢ä¸è½ä¸ºç©º") |
| | | @Size(max = 200) |
| | | private String title; |
| | | |
| | | @Schema(description = "å¹è®ç±»å", example = "SAFETY") |
| | | @Pattern(regexp = "SAFETY|SKILL|LAW|EMERGENCY|INDUCTION|OTHER", message = "å¹è®ç±»åä¸åæ³") |
| | | private String trainingType; |
| | | |
| | | @Schema(description = "å¹è®æ¥æ", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @NotNull(message = "å¹è®æ¥æä¸è½ä¸ºç©º") |
| | | @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) |
| | | private LocalDate trainDate; |
| | | |
| | | @Schema(description = "å¹è®å¦æ¶", example = "2.0") |
| | | @DecimalMin(value = "0", message = "å¹è®å¦æ¶ä¸è½ä¸ºè´æ°") |
| | | private BigDecimal durationHours; |
| | | |
| | | @Schema(description = "讲å¸/ç»ç»äººï¼åå·¥ç¼å·ï¼å
³è hrm_employeeï¼") |
| | | private Long trainerId; |
| | | |
| | | @Schema(description = "å¹è®å°ç¹") |
| | | @Size(max = 200) |
| | | private String location; |
| | | |
| | | @Schema(description = "åå 人åå§åï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String participants; |
| | | |
| | | @Schema(description = "åå 人æ°") |
| | | @Min(value = 0, message = "åå 人æ°ä¸è½ä¸ºè´æ°") |
| | | private Integer participantCount; |
| | | |
| | | @Schema(description = "å¹è®å
容") |
| | | @Size(max = 2000) |
| | | private String content; |
| | | |
| | | @Schema(description = "èæ ¸æ
åµ") |
| | | @Size(max = 2000) |
| | | private String examResult; |
| | | |
| | | @Schema(description = "ç¾å°è¡¨/课件/ç
§ç URLï¼éå·åé") |
| | | @Size(max = 2000) |
| | | private String attachment; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @Size(max = 500) |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-æ¥è¦è®°å½ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_alarm") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectAlarmDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private Integer wmId; |
| | | private String wmMsg; |
| | | private LocalDateTime wmTime; |
| | | private Integer status; |
| | | private LocalDateTime clearTime; |
| | | private LocalDateTime collectTime; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-卿è¿ç¨æ°æ® DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_cycle") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectCycleDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private Long cycleNo; |
| | | private LocalDateTime collectTime; |
| | | private BigDecimal ecyct; |
| | | private BigDecimal eiss; |
| | | private BigDecimal eivm; |
| | | private BigDecimal eipm; |
| | | private BigDecimal esipt; |
| | | private BigDecimal esipp; |
| | | private BigDecimal esips; |
| | | private BigDecimal eipt; |
| | | private BigDecimal eipse; |
| | | private BigDecimal eplst; |
| | | private BigDecimal eplsse; |
| | | private BigDecimal eplspm; |
| | | private String etTemps; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-åå§æ¥æ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_message") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectMessageDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private String mqttTopic; |
| | | private String msgType; |
| | | private LocalDateTime eventTime; |
| | | private String rawPayload; |
| | | private Integer processStatus; |
| | | private String errorMsg; |
| | | private LocalDateTime receiveTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-åæ°åæ´æ¥å¿ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_operate_log") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectOperateLogDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private String varId; |
| | | private String oldValue; |
| | | private String newValue; |
| | | private LocalDateTime modifyTime; |
| | | private LocalDateTime collectTime; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-设å¤å®æ¶ç¶æ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_realtime") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectRealtimeDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private LocalDateTime collectTime; |
| | | private Integer sts; |
| | | private Integer opm; |
| | | private Integer asts; |
| | | private BigDecimal ot; |
| | | private String temps; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-宿¶ç¶æåå² DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_realtime_history") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectRealtimeHistoryDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private LocalDateTime collectTime; |
| | | private Integer sts; |
| | | private Integer opm; |
| | | private Integer asts; |
| | | private BigDecimal ot; |
| | | private String temps; |
| | | private String dataJson; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-å·¥èºåæ°å¿«ç
§ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("mes_collect_tech") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesCollectTechDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long machineryId; |
| | | private String deviceCode; |
| | | private Long taskId; |
| | | private Long workOrderId; |
| | | private LocalDateTime collectTime; |
| | | private String dataJson; |
| | | |
| | | } |
| | |
| | | * 设å¤å建æ¶èªå¨å建对åºç©æï¼å¹¶ä»¥æ¤å
³è设å¤ä»åºå |
| | | */ |
| | | private Long itemId; |
| | | /** |
| | | * æ°é设å¤ç¼å·ï¼MQTT devIdï¼å¦ C01ï¼ |
| | | */ |
| | | private String collectDeviceCode; |
| | | /** |
| | | * æ¯å¦å¯ç¨æ°é |
| | | */ |
| | | private Boolean collectEnabled; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.dv.spare; |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.*; |
| | | import java.math.BigDecimal; |
| | | @TableName("mes_dv_spare_movement") |
| | | @KeySequence("mes_dv_spare_movement_seq") |
| | | @Data @EqualsAndHashCode(callSuper = true) |
| | | public class MesDvSpareMovementDO extends BaseDO { |
| | | @TableId private Long id; |
| | | private String requestKey; |
| | | private Long sparePartId; |
| | | private String sparePartCode; |
| | | private String sparePartName; |
| | | private String specification; |
| | | private String unit; |
| | | /** 1 åå§åºåï¼2 å
¥åºï¼3 ç»´ä¿®é¢ç¨ï¼4 éå */ |
| | | private Integer type; |
| | | private BigDecimal quantity; |
| | | private BigDecimal beforeQuantity; |
| | | private BigDecimal afterQuantity; |
| | | private Long repairId; |
| | | private String repairCode; |
| | | private Long machineryId; |
| | | private String machineryName; |
| | | private Long originalId; |
| | | private Long receiverUserId; |
| | | private String receiverName; |
| | | private Long operatorUserId; |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.dv.spare; |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.*; |
| | | import java.math.BigDecimal; |
| | | @TableName("mes_dv_spare_part") |
| | | @KeySequence("mes_dv_spare_part_seq") |
| | | @Data @EqualsAndHashCode(callSuper = true) |
| | | public class MesDvSparePartDO extends BaseDO { |
| | | @TableId private Long id; |
| | | private String code; |
| | | private String name; |
| | | private String specification; |
| | | private String unit; |
| | | private String location; |
| | | private BigDecimal stockQuantity; |
| | | private BigDecimal safetyQuantity; |
| | | private Integer status; |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.*; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | @TableName("mes_energy_alert_log") @Data @EqualsAndHashCode(callSuper = true) |
| | | public class EnergyAlertLogDO extends TenantBaseDO { |
| | | @TableId private Long id; |
| | | private Long ruleId; |
| | | private String ruleName; |
| | | private LocalDate recordDate; |
| | | private String periodType; |
| | | private String energyType; |
| | | private String scope; |
| | | private String metric; |
| | | private BigDecimal actualValue; |
| | | private BigDecimal threshold; |
| | | private Long recipientId; |
| | | private String recipientName; |
| | | private Long messageId; |
| | | private String status; |
| | | private String errorMessage; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.*; |
| | | import java.math.BigDecimal; |
| | | |
| | | @TableName("mes_energy_alert_rule") @Data @EqualsAndHashCode(callSuper = true) |
| | | public class EnergyAlertRuleDO extends TenantBaseDO { |
| | | @TableId private Long id; |
| | | private String name; |
| | | private String energyType; |
| | | private String usageArea; |
| | | private String productCategory; |
| | | private String metric; |
| | | private BigDecimal threshold; |
| | | private Boolean enabled; |
| | | /** Comma-separated validated administrator IDs, at most 50. */ |
| | | private String recipientIds; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | /** ç¬ç«è½èå°è´¦ï¼ä¸å
³è设å¤ãå·¥åã产åæé¨é¨ä¸»æ°æ®ã */ |
| | | @TableName("mes_energy_record") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class EnergyRecordDO extends TenantBaseDO { |
| | | @TableId |
| | | private Long id; |
| | | private LocalDate recordDate; |
| | | /** WATER / ELECTRICITY / STEAMï¼åä½åå«ä¸º m³ / kWh / tã */ |
| | | private String energyType; |
| | | private String usageArea; |
| | | private String productCategory; |
| | | private String usagePurpose; |
| | | private BigDecimal quantity; |
| | | private BigDecimal unitPrice; |
| | | private BigDecimal amount; |
| | | private String recorder; |
| | | private String remark; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
ç»è®° DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_accident") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyAccidentDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** äºæ
ç¼å· */ |
| | | private String code; |
| | | /** äºæ
åç§° */ |
| | | private String title; |
| | | /** äºæ
ç±»åï¼è§ SafetyAccidentTypeEnum */ |
| | | private String accidentType; |
| | | /** äºæ
ç级ï¼è§ SafetyAccidentLevelEnum */ |
| | | private String level; |
| | | /** åçæ¶é´ */ |
| | | private LocalDateTime occurTime; |
| | | /** åçå°ç¹ */ |
| | | private String location; |
| | | /** æå±è½¦é´ï¼å
³è mes_md_workshop.idï¼ */ |
| | | private Long workshopId; |
| | | /** æå±è½¦é´åç§°ï¼å¿«ç
§ï¼ç±è½¦é´ä¸»æ°æ®å¸¦åºï¼ */ |
| | | private String workshopName; |
| | | /** 伤亡æ
åµ */ |
| | | private String casualtyDesc; |
| | | /** ç´æ¥ç»æµæå¤±ï¼å
ï¼ */ |
| | | private BigDecimal economicLoss; |
| | | /** æ¶äºäººåå§åï¼éå·åé */ |
| | | private String involvedPersons; |
| | | /** äºæ
ç»è¿ */ |
| | | private String description; |
| | | /** åå åæ */ |
| | | private String causeAnalysis; |
| | | /** å¤çæªæ½ä¸æ´æ¹è¦æ± */ |
| | | private String measures; |
| | | /** ç»è®°äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long reporterId; |
| | | /** ç»è®°äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String reporter; |
| | | /** ç»è®°æ¶é´ */ |
| | | private LocalDateTime reportTime; |
| | | /** ç¶æï¼è§ SafetyAccidentStatusEnum */ |
| | | private String status; |
| | | /** ç°åºç
§ç/è°æ¥æ¥å URLï¼éå·åé */ |
| | | private String attachment; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯å°è´¦ DO |
| | | * |
| | | * <p>è¦ççµå·¥è¯ãé«åæä½è¯çç¹ç§ä½ä¸èµæ ¼è¯ä»¶ï¼ææææèªå¨å¤æç¶æå¹¶é¢è¦ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_certificate") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyCertificateDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** |
| | | * æè¯äººï¼åå·¥ç¼å·ï¼ |
| | | * |
| | | * å
³è HrmEmployeeDO#getId()ï¼å§å/å·¥å·/é¨é¨åç±æ¤å
³èå¸¦åº |
| | | */ |
| | | private Long employeeId; |
| | | /** æè¯äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ç¨äºå工档æ¡åæ´å追溯å¼è¯æ¶ä¿¡æ¯ï¼ */ |
| | | private String employeeName; |
| | | /** å·¥å·ï¼å¿«ç
§ï¼ */ |
| | | private String employeeNo; |
| | | /** æå±é¨é¨ï¼å¿«ç
§ï¼ */ |
| | | private String deptName; |
| | | /** è¯ä»¶ç±»åï¼è§ SafetyCertificateTypeEnum */ |
| | | private String certType; |
| | | /** è¯ä»¶ç¼å· */ |
| | | private String certNo; |
| | | /** åè¯æºå
³ */ |
| | | private String issuer; |
| | | /** åè¯æ¥æ */ |
| | | private LocalDate issueDate; |
| | | /** æææè³ */ |
| | | private LocalDate expireDate; |
| | | /** 䏿¬¡å¤å®¡æ¥æ */ |
| | | private LocalDate reviewDate; |
| | | /** å°æé¢è¦æåå¤©æ° */ |
| | | private Integer warnDays; |
| | | /** ç¶æï¼è§ SafetyCertificateStatusEnum */ |
| | | private String status; |
| | | /** è¯ä»¶æ«æä»¶ URLï¼éå·åé */ |
| | | private String attachment; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ¶é²æ¼ç»è®°å½ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_drill") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyDrillDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** æ¼ç»åç§° */ |
| | | private String title; |
| | | /** æ¼ç»ç±»åï¼è§ SafetyDrillTypeEnum */ |
| | | private String drillType; |
| | | /** æ¼ç»æ¥æ */ |
| | | private LocalDate drillDate; |
| | | /** æ¼ç»å°ç¹ */ |
| | | private String location; |
| | | /** ç»ç»äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long organizerId; |
| | | /** ç»ç»äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String organizer; |
| | | /** åå 人åå§åï¼éå·åé */ |
| | | private String participants; |
| | | /** åå äººæ° */ |
| | | private Integer participantCount; |
| | | /** æ¼ç»æ¹æ¡ */ |
| | | private String planDesc; |
| | | /** æ¼ç»è¿ç¨è®°å½ */ |
| | | private String processDesc; |
| | | /** æ¼ç»æ»ç»ä¸æ¹è¿ */ |
| | | private String summary; |
| | | /** æ¼ç»æ¶é¿ï¼åéï¼ */ |
| | | private Integer durationMinutes; |
| | | /** æ¼ç»ç
§ç/è®°å½è¡¨ URLï¼éå·åé */ |
| | | private String attachment; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣ç»è®°ä¸éç¯ DO |
| | | * |
| | | * <p>宿´éç¯ï¼ä¸æ¥ â åæ´¾ â æ´æ¹ â 夿¥ï¼éè¿åéç¯ï¼ä¸éè¿éåæ´æ¹ï¼ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_hazard") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyHazardDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** 鿣ç¼å· */ |
| | | private String code; |
| | | /** 鿣æ é¢ */ |
| | | private String title; |
| | | /** 鿣ç级ï¼è§ SafetyHazardLevelEnum */ |
| | | private String level; |
| | | /** æ¥æºï¼è§ SafetyHazardSourceEnum */ |
| | | private String source; |
| | | /** å
³èå·¡æ£è®°å½ç¼å· */ |
| | | private Long inspectionId; |
| | | /** å
³èå·¡æ£ç¹ä½ç¼å· */ |
| | | private Long pointId; |
| | | /** ç¹ä½åç§° */ |
| | | private String pointName; |
| | | /** 鿣ä½ç½® */ |
| | | private String location; |
| | | /** 鿣æè¿° */ |
| | | private String description; |
| | | /** ç°åºç
§ç URLï¼éå·åéï¼ç§»å¨ç«¯æç
§ä¸ä¼ ï¼ */ |
| | | private String photoUrls; |
| | | /** 䏿¥äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long reporterId; |
| | | /** 䏿¥äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String reporter; |
| | | /** 䏿¥æ¶é´ */ |
| | | private LocalDateTime reportTime; |
| | | /** æ´æ¹è´£ä»»äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long assigneeId; |
| | | /** æ´æ¹è´£ä»»äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String assignee; |
| | | /** åæ´¾æ¶é´ */ |
| | | private LocalDateTime assignTime; |
| | | /** æ´æ¹æé */ |
| | | private LocalDate rectifyDeadline; |
| | | /** æ´æ¹æªæ½ä¸ç»æ */ |
| | | private String rectifyDesc; |
| | | /** æ´æ¹åç
§ç URLï¼éå·åé */ |
| | | private String rectifyPhotoUrls; |
| | | /** æ´æ¹å®ææ¶é´ */ |
| | | private LocalDateTime rectifyTime; |
| | | /** 夿¥äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long recheckerId; |
| | | /** 夿¥äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String rechecker; |
| | | /** 夿¥æ¶é´ */ |
| | | private LocalDateTime recheckTime; |
| | | /** 夿¥ç»è®ºï¼PASSED-éè¿ï¼REJECTED-ä¸éè¿ */ |
| | | private String recheckResult; |
| | | /** 夿¥æè§ */ |
| | | private String recheckRemark; |
| | | /** ç¶æï¼è§ SafetyHazardStatusEnum */ |
| | | private String status; |
| | | /** éç¯æ¶é´ */ |
| | | private LocalDateTime closeTime; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£è®°å½ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_inspection") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyInspectionDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** å·¡æ£ç¹ä½ç¼å· */ |
| | | private Long pointId; |
| | | /** ç¹ä½åç§°ï¼å¿«ç
§ï¼ */ |
| | | private String pointName; |
| | | /** ç¹ä½ç±»åï¼å¿«ç
§ï¼ */ |
| | | private String pointType; |
| | | /** å·¡æ£æ¶é´ */ |
| | | private LocalDateTime inspectTime; |
| | | /** å·¡æ£äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long inspectorId; |
| | | /** å·¡æ£äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String inspector; |
| | | /** å·¡æ£ç»æï¼NORMAL-æ£å¸¸ï¼ABNORMAL-å¼å¸¸ */ |
| | | private String result; |
| | | /** å·¡æ£å
容䏿
åµ */ |
| | | private String content; |
| | | /** ç°åºç
§ç URLï¼éå·åé */ |
| | | private String photoUrls; |
| | | /** æ¬æ¬¡åç°çéæ£æ° */ |
| | | private Integer hazardCount; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½ DO |
| | | * |
| | | * <p>é«åé
çµå®¤ãæºç»åºçæ¥å¸¸å®å
¨å·¡æ£ç¹ä½ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_inspection_point") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyInspectionPointDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** ç¹ä½ç¼ç */ |
| | | private String code; |
| | | /** ç¹ä½åç§° */ |
| | | private String name; |
| | | /** ç¹ä½ç±»åï¼è§ SafetyInspectionPointTypeEnum */ |
| | | private String pointType; |
| | | /** æå±è½¦é´ï¼å
³è mes_md_workshop.idï¼ */ |
| | | private Long workshopId; |
| | | /** æå±è½¦é´åç§°ï¼å¿«ç
§ï¼ç±è½¦é´ä¸»æ°æ®å¸¦åºï¼ */ |
| | | private String workshopName; |
| | | /** å
·ä½ä½ç½® */ |
| | | private String location; |
| | | /** å·¡æ£é¡¹ç®æ¸
åï¼æè¡åé */ |
| | | private String inspectItems; |
| | | /** å·¡æ£å¨æï¼è§ SafetyInspectCycleEnum */ |
| | | private String inspectCycle; |
| | | /** 责任人ï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long ownerId; |
| | | /** 责任人å§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String ownerName; |
| | | /** ç¶æï¼0-å¯ç¨ï¼1-åç¨ */ |
| | | private Integer status; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - åºæ¥/å®å
¨ç©èµå°è´¦ DO |
| | | * |
| | | * <p>çµåç»ç¼ç¨å
·ãå±ååãæ¶é²ç©èµçã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_material") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyMaterialDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** ç©èµç¼ç */ |
| | | private String code; |
| | | /** ç©èµåç§° */ |
| | | private String name; |
| | | /** ç±»å«ï¼è§ SafetyMaterialCategoryEnum */ |
| | | private String category; |
| | | /** è§æ ¼åå· */ |
| | | private String spec; |
| | | /** 计éåä½ */ |
| | | private String unit; |
| | | /** å½ååºåæ°é */ |
| | | private BigDecimal stockQty; |
| | | /** å®å
¨åºåï¼ä½äºåé¢è¦ï¼ */ |
| | | private BigDecimal safeStock; |
| | | /** åæ¾ä½ç½® */ |
| | | private String storageLocation; |
| | | /** æææè³ï¼ç»ç¼/å±ååå¿
å¡«ï¼ */ |
| | | private LocalDate expireDate; |
| | | /** æææææ° */ |
| | | private Integer validityMonths; |
| | | /** ä¿ç®¡äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long managerId; |
| | | /** ä¿ç®¡äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String manager; |
| | | /** ç¶æï¼0-å¯ç¨ï¼1-åç¨ */ |
| | | private Integer status; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµåºå
¥åºæµæ°´ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_material_stock") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyMaterialStockDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** ç©èµç¼å· */ |
| | | private Long materialId; |
| | | /** ç©èµåç§°ï¼å¿«ç
§ï¼ */ |
| | | private String materialName; |
| | | /** ç©èµç±»å«ï¼å¿«ç
§ï¼ */ |
| | | private String category; |
| | | /** ä¸å¡ç±»åï¼IN-å
¥åºï¼OUT-åºåº */ |
| | | private String bizType; |
| | | /** æ°é */ |
| | | private BigDecimal quantity; |
| | | /** æä½ååºå */ |
| | | private BigDecimal stockBefore; |
| | | /** æä½ååºå */ |
| | | private BigDecimal stockAfter; |
| | | /** ä¸å¡æ¥æ */ |
| | | private LocalDate bizDate; |
| | | /** ç»å人 */ |
| | | private String operator; |
| | | /** é¢ç¨äººï¼åºåºï¼ */ |
| | | private String receiver; |
| | | /** ç¨é/å»å */ |
| | | private String purpose; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å®å
¨ç»ç»æ¶æ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_org") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyOrgDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** ç¶çº§ç¼å·ï¼0 为顶级 */ |
| | | private Long parentId; |
| | | /** ç»ç»åç§°ï¼å¦å®å
¨ç产å§åä¼ãå®å
¨ç®¡çé¨ */ |
| | | private String name; |
| | | /** è´è´£äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long leaderId; |
| | | /** è´è´£äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String leaderName; |
| | | /** è´è´£äººçµè¯ */ |
| | | private String leaderPhone; |
| | | /** æåå§åï¼éå·åé */ |
| | | private String memberNames; |
| | | /** å®å
¨èè´£ */ |
| | | private String duty; |
| | | /** æ¾ç¤ºé¡ºåº */ |
| | | private Integer sort; |
| | | /** ç¶æï¼0-å¯ç¨ï¼1-åç¨ */ |
| | | private Integer status; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å®å
¨å¹è®è®°å½ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_training") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyTrainingDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** å¹è®ä¸»é¢ */ |
| | | private String title; |
| | | /** å¹è®ç±»åï¼è§ SafetyTrainingTypeEnum */ |
| | | private String trainingType; |
| | | /** å¹è®æ¥æ */ |
| | | private LocalDate trainDate; |
| | | /** å¹è®å¦æ¶ */ |
| | | private BigDecimal durationHours; |
| | | /** 讲å¸/ç»ç»äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long trainerId; |
| | | /** 讲å¸/ç»ç»äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String trainer; |
| | | /** å¹è®å°ç¹ */ |
| | | private String location; |
| | | /** åå 人åå§åï¼éå·åé */ |
| | | private String participants; |
| | | /** åå äººæ° */ |
| | | private Integer participantCount; |
| | | /** å¹è®å
容 */ |
| | | private String content; |
| | | /** èæ ¸æ
åµ */ |
| | | private String examResult; |
| | | /** ç¾å°è¡¨/课件/ç
§ç URLï¼éå·åé */ |
| | | private String attachment; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ DO |
| | | * |
| | | * <p>å¨ç«ãé«å带çµãæé空é´çä½ä¸ç线ä¸å®¡æ¹ä¸çµåçåã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_work_permit") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyWorkPermitDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** ä½ä¸ç¥¨ç¼å· */ |
| | | private String code; |
| | | /** ä½ä¸ç±»åï¼è§ SafetyPermitTypeEnum */ |
| | | private String permitType; |
| | | /** ä½ä¸åç§° */ |
| | | private String title; |
| | | /** ä½ä¸è½¦é´ï¼å
³è mes_md_workshop.idï¼ */ |
| | | private Long workshopId; |
| | | /** ä½ä¸è½¦é´åç§°ï¼å¿«ç
§ï¼ç±è½¦é´ä¸»æ°æ®å¸¦åºï¼ */ |
| | | private String workshopName; |
| | | /** ä½ä¸å°ç¹ */ |
| | | private String location; |
| | | /** ä½ä¸å
容ä¸èå´ */ |
| | | private String workContent; |
| | | /** ç³è¯·äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long applicantId; |
| | | /** ç³è¯·äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String applicant; |
| | | /** ç³è¯·æ¶é´ */ |
| | | private LocalDateTime applyTime; |
| | | /** 计åå¼å§æ¶é´ */ |
| | | private LocalDateTime planStartTime; |
| | | /** 计åç»ææ¶é´ */ |
| | | private LocalDateTime planEndTime; |
| | | /** å®é
å¼å§æ¶é´ */ |
| | | private LocalDateTime actualStartTime; |
| | | /** å®é
ç»ææ¶é´ */ |
| | | private LocalDateTime actualEndTime; |
| | | /** é£é©ç级ï¼è§ SafetyRiskLevelEnum */ |
| | | private String riskLevel; |
| | | /** å®å
¨æªæ½ */ |
| | | private String safetyMeasures; |
| | | /** 审æ¹äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long approverId; |
| | | /** 审æ¹äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String approver; |
| | | /** å®¡æ¹æ¶é´ */ |
| | | private LocalDateTime approveTime; |
| | | /** å®¡æ¹æè§ */ |
| | | private String approveComment; |
| | | /** çæ¤äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long guardianId; |
| | | /** çæ¤äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String guardian; |
| | | /** ç¶æï¼è§ SafetyPermitStatusEnum */ |
| | | private String status; |
| | | /** ä½ä¸ç¥¨éä»¶ URLï¼éå·åé */ |
| | | private String attachment; |
| | | /** ç°åºç
§ç URLï¼éå·åé */ |
| | | private String photoUrls; |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ä½ä¸çæ¤è®°å½ DO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("safety_work_permit_monitor") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SafetyWorkPermitMonitorDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | /** ä½ä¸ç¥¨ç¼å· */ |
| | | private Long permitId; |
| | | /** çæ¤æ¶é´ */ |
| | | private LocalDateTime monitorTime; |
| | | /** çæ¤äººï¼åå·¥ç¼å·ï¼å
³è hrm_employee.idï¼ */ |
| | | private Long guardianId; |
| | | /** çæ¤äººå§åï¼å¿«ç
§ï¼ç±å工档æ¡å¸¦åºï¼ */ |
| | | private String guardian; |
| | | /** çæ¤å
容䏿
åµ */ |
| | | private String monitorContent; |
| | | /** å¼å¸¸æ
åµä¸å¤ç½® */ |
| | | private String abnormal; |
| | | /** ç°åºç
§ç URLï¼éå·åé */ |
| | | private String photoUrls; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectAlarmPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectAlarmDO; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-æ¥è¦è®°å½ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectAlarmMapper extends BaseMapperX<MesCollectAlarmDO> { |
| | | |
| | | default PageResult<MesCollectAlarmDO> selectPage(MesCollectAlarmPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectAlarmDO>() |
| | | .eqIfPresent(MesCollectAlarmDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectAlarmDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectAlarmDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .eqIfPresent(MesCollectAlarmDO::getStatus, reqVO.getStatus()) |
| | | .betweenIfPresent(MesCollectAlarmDO::getWmTime, reqVO.getWmTime()) |
| | | .orderByDesc(MesCollectAlarmDO::getWmTime)); |
| | | } |
| | | |
| | | default Long selectActiveCountByDeviceCode(String deviceCode) { |
| | | return selectCount(new LambdaQueryWrapperX<MesCollectAlarmDO>() |
| | | .eq(MesCollectAlarmDO::getDeviceCode, deviceCode) |
| | | .eq(MesCollectAlarmDO::getStatus, 0)); |
| | | } |
| | | |
| | | default int clearActiveByDeviceCode(String deviceCode, LocalDateTime clearTime) { |
| | | return update(null, new LambdaUpdateWrapper<MesCollectAlarmDO>() |
| | | .eq(MesCollectAlarmDO::getDeviceCode, deviceCode) |
| | | .eq(MesCollectAlarmDO::getStatus, 0) |
| | | .set(MesCollectAlarmDO::getStatus, 1) |
| | | .set(MesCollectAlarmDO::getClearTime, clearTime)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectCyclePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectCycleDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-卿è¿ç¨æ°æ® Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectCycleMapper extends BaseMapperX<MesCollectCycleDO> { |
| | | |
| | | default PageResult<MesCollectCycleDO> selectPage(MesCollectCyclePageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectCycleDO>() |
| | | .eqIfPresent(MesCollectCycleDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectCycleDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectCycleDO::getTaskId, reqVO.getTaskId()) |
| | | .eqIfPresent(MesCollectCycleDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .betweenIfPresent(MesCollectCycleDO::getCollectTime, reqVO.getCollectTime()) |
| | | .orderByDesc(MesCollectCycleDO::getCollectTime)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectMessageDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-åå§æ¥æ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectMessageMapper extends BaseMapperX<MesCollectMessageDO> { |
| | | |
| | | default int deleteBefore(LocalDateTime before, int limit) { |
| | | return delete(new LambdaQueryWrapperX<MesCollectMessageDO>() |
| | | .lt(MesCollectMessageDO::getReceiveTime, before) |
| | | .last("LIMIT " + limit)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectOperateLogPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectOperateLogDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-åæ°åæ´æ¥å¿ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectOperateLogMapper extends BaseMapperX<MesCollectOperateLogDO> { |
| | | |
| | | default PageResult<MesCollectOperateLogDO> selectPage(MesCollectOperateLogPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectOperateLogDO>() |
| | | .eqIfPresent(MesCollectOperateLogDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectOperateLogDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectOperateLogDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .eqIfPresent(MesCollectOperateLogDO::getVarId, reqVO.getVarId()) |
| | | .betweenIfPresent(MesCollectOperateLogDO::getModifyTime, reqVO.getModifyTime()) |
| | | .orderByDesc(MesCollectOperateLogDO::getModifyTime)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | 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.mes.controller.admin.collect.vo.MesCollectRealtimeHistoryPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectRealtimeHistoryDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°é-宿¶ç¶æåå² Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectRealtimeHistoryMapper extends BaseMapperX<MesCollectRealtimeHistoryDO> { |
| | | |
| | | default PageResult<MesCollectRealtimeHistoryDO> selectPage(MesCollectRealtimeHistoryPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesCollectRealtimeHistoryDO>() |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getDeviceCode, reqVO.getDeviceCode()) |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getMachineryId, reqVO.getMachineryId()) |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getTaskId, reqVO.getTaskId()) |
| | | .eqIfPresent(MesCollectRealtimeHistoryDO::getWorkOrderId, reqVO.getWorkOrderId()) |
| | | .betweenIfPresent(MesCollectRealtimeHistoryDO::getCollectTime, reqVO.getCollectTime()) |
| | | .orderByDesc(MesCollectRealtimeHistoryDO::getCollectTime)); |
| | | } |
| | | |
| | | default int deleteBefore(LocalDateTime before, int limit) { |
| | | return delete(new LambdaQueryWrapperX<MesCollectRealtimeHistoryDO>() |
| | | .lt(MesCollectRealtimeHistoryDO::getCollectTime, before) |
| | | .last("LIMIT " + limit)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectRealtimeDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-设å¤å®æ¶ç¶æ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectRealtimeMapper extends BaseMapperX<MesCollectRealtimeDO> { |
| | | |
| | | default MesCollectRealtimeDO selectByDeviceCode(String deviceCode) { |
| | | return selectOne(MesCollectRealtimeDO::getDeviceCode, deviceCode); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.MesCollectTechDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES æ°é-å·¥èºåæ°å¿«ç
§ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface MesCollectTechMapper extends BaseMapperX<MesCollectTechDO> { |
| | | |
| | | default MesCollectTechDO selectByDeviceCode(String deviceCode) { |
| | | return selectOne(MesCollectTechDO::getDeviceCode, deviceCode); |
| | | } |
| | | |
| | | } |
| | |
| | | return selectCount(MesDvMachineryDO::getMachineryTypeId, machineryTypeId); |
| | | } |
| | | |
| | | /** |
| | | * ææ°é设å¤ç¼å·æ¥è¯¢è®¾å¤ï¼MQTT devIdï¼ |
| | | */ |
| | | default MesDvMachineryDO selectByCollectDeviceCode(String collectDeviceCode) { |
| | | return selectOne(MesDvMachineryDO::getCollectDeviceCode, collectDeviceCode); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ææå·²é
ç½®æ°é设å¤ç¼å·çè®¾å¤ |
| | | */ |
| | | default java.util.List<MesDvMachineryDO> selectListWithCollectDeviceCode() { |
| | | return selectList(new LambdaQueryWrapperX<MesDvMachineryDO>() |
| | | .isNotNull(MesDvMachineryDO::getCollectDeviceCode) |
| | | .orderByAsc(MesDvMachineryDO::getId)); |
| | | } |
| | | |
| | | } |
| | |
| | | @Mapper |
| | | public interface MesDvRepairMapper extends BaseMapperX<MesDvRepairDO> { |
| | | |
| | | /** |
| | | * å è¡éæ¥è¯¢ç»´ä¿®å·¥åï¼å¤ä»¶åºåºæ¶é²æ¢å¹¶åæ£å |
| | | */ |
| | | default MesDvRepairDO lockForSpare(Long id) { |
| | | return selectOne(new LambdaQueryWrapperX<MesDvRepairDO>() |
| | | .eq(MesDvRepairDO::getId, id).last("FOR UPDATE")); |
| | | } |
| | | |
| | | default PageResult<MesDvRepairDO> selectPage(MesDvRepairPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesDvRepairDO>() |
| | | .likeIfPresent(MesDvRepairDO::getCode, reqVO.getCode()) |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.dv.spare; |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.spare.MesDvSpareMovementDO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo.MesDvSparePageReqVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import java.util.*; |
| | | @Mapper |
| | | public interface MesDvSpareMovementMapper extends BaseMapperX<MesDvSpareMovementDO> { |
| | | default MesDvSpareMovementDO byKey(String key) { |
| | | return selectOne(MesDvSpareMovementDO::getRequestKey,key); |
| | | } |
| | | default MesDvSpareMovementDO lock(Long id) { |
| | | return selectOne(new LambdaQueryWrapperX<MesDvSpareMovementDO>().eq(MesDvSpareMovementDO::getId,id).last("FOR UPDATE")); |
| | | } |
| | | default List<MesDvSpareMovementDO> returns(Collection<Long> ids) { |
| | | if (ids.isEmpty()) return List.of(); |
| | | return selectList(new LambdaQueryWrapperX<MesDvSpareMovementDO>() |
| | | .eq(MesDvSpareMovementDO::getType,4).in(MesDvSpareMovementDO::getOriginalId,ids)); |
| | | } |
| | | default PageResult<MesDvSpareMovementDO> page(MesDvSparePageReqVO req) { |
| | | return selectPage(req,new LambdaQueryWrapperX<MesDvSpareMovementDO>() |
| | | .eqIfPresent(MesDvSpareMovementDO::getSparePartId,req.getSparePartId()) |
| | | .eqIfPresent(MesDvSpareMovementDO::getRepairId,req.getRepairId()) |
| | | .eqIfPresent(MesDvSpareMovementDO::getRepairCode,req.getRepairCode()) |
| | | .eqIfPresent(MesDvSpareMovementDO::getType,req.getType()) |
| | | .orderByDesc(MesDvSpareMovementDO::getId)); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.dv.spare; |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.spare.MesDvSparePartDO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo.MesDvSparePageReqVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | @Mapper |
| | | public interface MesDvSparePartMapper extends BaseMapperX<MesDvSparePartDO> { |
| | | default MesDvSparePartDO lock(Long id) { |
| | | return selectOne(new LambdaQueryWrapperX<MesDvSparePartDO>().eq(MesDvSparePartDO::getId,id).last("FOR UPDATE")); |
| | | } |
| | | default PageResult<MesDvSparePartDO> page(MesDvSparePageReqVO req) { |
| | | return selectPage(req,new LambdaQueryWrapperX<MesDvSparePartDO>() |
| | | .eqIfPresent(MesDvSparePartDO::getCode,req.getCode()) |
| | | .likeIfPresent(MesDvSparePartDO::getName,req.getName()) |
| | | .eqIfPresent(MesDvSparePartDO::getStatus,req.getStatus()) |
| | | .apply(Boolean.TRUE.equals(req.getShortageOnly()),"stock_quantity < safety_quantity") |
| | | .orderByDesc(MesDvSparePartDO::getId)); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.energy.EnergyAlertLogDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | @Mapper |
| | | public interface EnergyAlertLogMapper extends BaseMapperX<EnergyAlertLogDO> {} |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.energy.EnergyAlertRuleDO; |
| | | import org.apache.ibatis.annotations.*; |
| | | |
| | | @Mapper |
| | | public interface EnergyAlertRuleMapper extends BaseMapperX<EnergyAlertRuleDO> { |
| | | // Serialize checks for one rule, including concurrent record submissions. |
| | | @Select("SELECT * FROM mes_energy_alert_rule WHERE id=#{id} AND deleted=0 FOR UPDATE") |
| | | EnergyAlertRuleDO lock(@Param("id") Long id); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.energy; |
| | | |
| | | 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.mes.controller.admin.energy.vo.EnergyRecordPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.energy.vo.EnergyAnalysisReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.energy.EnergyRecordDO; |
| | | import lombok.Data; |
| | | import org.apache.ibatis.annotations.*; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface EnergyRecordMapper extends BaseMapperX<EnergyRecordDO> { |
| | | @Select(""" |
| | | <script> |
| | | SELECT COALESCE(SUM(<choose><when test="rule.metric == 'AMOUNT' or rule.metric == 'MONTH_AMOUNT'">amount</when><otherwise>quantity</otherwise></choose>),0) |
| | | FROM mes_energy_record WHERE deleted=0 AND energy_type=#{rule.energyType} |
| | | <choose><when test="rule.metric == 'MONTH_QUANTITY' or rule.metric == 'MONTH_AMOUNT'"> |
| | | AND record_date >= #{date} AND record_date < DATE_ADD(#{date}, INTERVAL 1 MONTH) |
| | | </when><otherwise>AND record_date=#{date}</otherwise></choose> |
| | | <if test="rule.usageArea != null and rule.usageArea != ''">AND usage_area=#{rule.usageArea}</if> |
| | | <if test="rule.productCategory != null and rule.productCategory != ''">AND product_category=#{rule.productCategory}</if> |
| | | </script> |
| | | """) |
| | | BigDecimal selectDailyValue(@Param("date") java.time.LocalDate date, |
| | | @Param("rule") cn.iocoder.yudao.module.mes.dal.dataobject.energy.EnergyAlertRuleDO rule); |
| | | default PageResult<EnergyRecordDO> selectPage(EnergyRecordPageReqVO req) { |
| | | return selectPage(req, new LambdaQueryWrapperX<EnergyRecordDO>() |
| | | .geIfPresent(EnergyRecordDO::getRecordDate, req.getStartDate()) |
| | | .leIfPresent(EnergyRecordDO::getRecordDate, req.getEndDate()) |
| | | .eqIfPresent(EnergyRecordDO::getEnergyType, req.getEnergyType()) |
| | | .likeIfPresent(EnergyRecordDO::getUsageArea, req.getUsageArea()) |
| | | .eqIfPresent(EnergyRecordDO::getProductCategory, req.getProductCategory()) |
| | | .orderByDesc(EnergyRecordDO::getRecordDate, EnergyRecordDO::getId)); |
| | | } |
| | | |
| | | // ææ°æ®åºåç»ï¼é¿å
å è½½å
¨é¨å°è´¦ï¼ç§æ·æ¦æªå¨èªå¨æ·»å tenant_id æ¡ä»¶ã |
| | | @Select(""" |
| | | <script> |
| | | SELECT energy_type AS energyType, |
| | | <choose><when test="req.groupBy == 'MONTH'">DATE_FORMAT(record_date, '%Y-%m')</when> |
| | | <otherwise>DATE_FORMAT(record_date, '%Y-%m-%d')</otherwise></choose> AS period, |
| | | usage_area AS usageArea, SUM(quantity) AS quantity, SUM(amount) AS amount, |
| | | COUNT(*) AS recordCount |
| | | FROM mes_energy_record |
| | | WHERE deleted = 0 AND record_date BETWEEN #{req.startDate} AND #{req.endDate} |
| | | <if test="req.energyType != null and req.energyType != ''">AND energy_type = #{req.energyType}</if> |
| | | <if test="req.usageArea != null and req.usageArea != ''">AND usage_area LIKE CONCAT('%', #{req.usageArea}, '%')</if> |
| | | <if test="req.productCategory != null and req.productCategory != ''">AND product_category = #{req.productCategory}</if> |
| | | GROUP BY energy_type, period, usage_area |
| | | ORDER BY period, energy_type, usage_area |
| | | </script> |
| | | """) |
| | | List<Aggregate> selectAnalysis(@Param("req") EnergyAnalysisReqVO req); |
| | | |
| | | @Data |
| | | class Aggregate { |
| | | private String energyType; |
| | | private String period; |
| | | private String usageArea; |
| | | private BigDecimal quantity; |
| | | private BigDecimal amount; |
| | | private long recordCount; |
| | | } |
| | | } |
| | |
| | | .setSql("last_feedback_time = NOW()")); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å·¥ä½ç«ä¸æ£å¨è¿è¡çä»»å¡ï¼ç产ä¸ãé¨å宿ãå·²åå·¥ |
| | | * |
| | | * <p>æ°éæ¨¡åæ ¹æ®è®¾å¤ä¸æ¥çæ°æ®å®ä½å½å任塿¶ä½¿ç¨ã</p> |
| | | */ |
| | | default MesProTaskDO selectRunningTaskByWorkstationId(Long workstationId) { |
| | | return selectOne(new LambdaQueryWrapperX<MesProTaskDO>() |
| | | .eq(MesProTaskDO::getWorkstationId, workstationId) |
| | | .in(MesProTaskDO::getStatus, MesProTaskStatusEnum.PRODUCING.getStatus(), |
| | | MesProTaskStatusEnum.PARTIAL_FINISHED.getStatus(), MesProTaskStatusEnum.PAUSED.getStatus()) |
| | | .orderByDesc(MesProTaskDO::getLastFeedbackTime) |
| | | .orderByDesc(MesProTaskDO::getId) |
| | | .last("LIMIT 1")); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.qc.ledger; |
| | | |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerRespVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * MES æ£æµç»æå°è´¦ Mapper |
| | | * |
| | | * ä½¿ç¨ UNION ALL SQL ä»åç±»æ£éªåï¼IQC/IPQC/OQC/RQCï¼æåæ£éªåï¼åå
³èæ£éªç»ææç»ä¸æ£æµé¡¹ï¼ä¸è¡ä¸ä¸ªæ£æµé¡¹ç»æ |
| | | */ |
| | | @Mapper |
| | | public interface MesQcInspectionLedgerMapper { |
| | | |
| | | IPage<MesQcInspectionLedgerRespVO> selectInspectionLedgerPage(IPage<MesQcInspectionLedgerRespVO> page, |
| | | @Param("reqVO") MesQcInspectionLedgerPageReqVO reqVO); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.train.SafetyAccidentPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyAccidentDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
ç»è®° Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyAccidentMapper extends BaseMapperX<SafetyAccidentDO> { |
| | | |
| | | default PageResult<SafetyAccidentDO> selectPage(SafetyAccidentPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyAccidentDO>() |
| | | .likeIfPresent(SafetyAccidentDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(SafetyAccidentDO::getTitle, reqVO.getTitle()) |
| | | .eqIfPresent(SafetyAccidentDO::getAccidentType, reqVO.getAccidentType()) |
| | | .eqIfPresent(SafetyAccidentDO::getLevel, reqVO.getLevel()) |
| | | .eqIfPresent(SafetyAccidentDO::getStatus, reqVO.getStatus()) |
| | | .betweenIfPresent(SafetyAccidentDO::getOccurTime, reqVO.getOccurTime()) |
| | | .orderByDesc(SafetyAccidentDO::getOccurTime) |
| | | .orderByDesc(SafetyAccidentDO::getId)); |
| | | } |
| | | |
| | | default List<SafetyAccidentDO> selectListBetween(java.time.LocalDateTime begin, java.time.LocalDateTime end) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyAccidentDO>() |
| | | .geIfPresent(SafetyAccidentDO::getOccurTime, begin) |
| | | .leIfPresent(SafetyAccidentDO::getOccurTime, end) |
| | | .orderByAsc(SafetyAccidentDO::getOccurTime)); |
| | | } |
| | | |
| | | @Select("SELECT CONCAT(#{prefix}, LPAD(COUNT(*) + 1, 4, '0')) FROM safety_accident WHERE code LIKE CONCAT(#{prefix}, '%')") |
| | | String selectNextCode(@Param("prefix") String prefix); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.cert.SafetyCertificatePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyCertificateDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyCertificateMapper extends BaseMapperX<SafetyCertificateDO> { |
| | | |
| | | default PageResult<SafetyCertificateDO> selectPage(SafetyCertificatePageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyCertificateDO>() |
| | | .likeIfPresent(SafetyCertificateDO::getEmployeeName, reqVO.getEmployeeName()) |
| | | .likeIfPresent(SafetyCertificateDO::getEmployeeNo, reqVO.getEmployeeNo()) |
| | | .likeIfPresent(SafetyCertificateDO::getDeptName, reqVO.getDeptName()) |
| | | .eqIfPresent(SafetyCertificateDO::getCertType, reqVO.getCertType()) |
| | | .eqIfPresent(SafetyCertificateDO::getStatus, reqVO.getStatus()) |
| | | .likeIfPresent(SafetyCertificateDO::getCertNo, reqVO.getCertNo()) |
| | | .geIfPresent(SafetyCertificateDO::getExpireDate, reqVO.getExpireDateStart()) |
| | | .leIfPresent(SafetyCertificateDO::getExpireDate, reqVO.getExpireDateEnd()) |
| | | .orderByAsc(SafetyCertificateDO::getExpireDate) |
| | | .orderByDesc(SafetyCertificateDO::getId)); |
| | | } |
| | | |
| | | default SafetyCertificateDO selectByCertNo(String certNo) { |
| | | return selectOne(SafetyCertificateDO::getCertNo, certNo); |
| | | } |
| | | |
| | | /** æ¥è¯¢å³å°å°ææå·²è¿æçè¯ä»¶ï¼expireDate <= æªæ¢æ¥æï¼ */ |
| | | default List<SafetyCertificateDO> selectExpiringBefore(LocalDate deadline) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyCertificateDO>() |
| | | .le(SafetyCertificateDO::getExpireDate, deadline) |
| | | .orderByAsc(SafetyCertificateDO::getExpireDate)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.train.SafetyDrillPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyDrillDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ¼ç»è®°å½ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyDrillMapper extends BaseMapperX<SafetyDrillDO> { |
| | | |
| | | default PageResult<SafetyDrillDO> selectPage(SafetyDrillPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyDrillDO>() |
| | | .likeIfPresent(SafetyDrillDO::getTitle, reqVO.getTitle()) |
| | | .eqIfPresent(SafetyDrillDO::getDrillType, reqVO.getDrillType()) |
| | | .likeIfPresent(SafetyDrillDO::getOrganizer, reqVO.getOrganizer()) |
| | | .betweenIfPresent(SafetyDrillDO::getDrillDate, reqVO.getDrillDate()) |
| | | .orderByDesc(SafetyDrillDO::getDrillDate) |
| | | .orderByDesc(SafetyDrillDO::getId)); |
| | | } |
| | | |
| | | default List<SafetyDrillDO> selectListBetween(java.time.LocalDate begin, java.time.LocalDate end) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyDrillDO>() |
| | | .geIfPresent(SafetyDrillDO::getDrillDate, begin) |
| | | .leIfPresent(SafetyDrillDO::getDrillDate, end) |
| | | .orderByAsc(SafetyDrillDO::getDrillDate)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.hazard.SafetyHazardPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyHazardDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣 Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyHazardMapper extends BaseMapperX<SafetyHazardDO> { |
| | | |
| | | default PageResult<SafetyHazardDO> selectPage(SafetyHazardPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyHazardDO>() |
| | | .likeIfPresent(SafetyHazardDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(SafetyHazardDO::getTitle, reqVO.getTitle()) |
| | | .eqIfPresent(SafetyHazardDO::getLevel, reqVO.getLevel()) |
| | | .eqIfPresent(SafetyHazardDO::getSource, reqVO.getSource()) |
| | | .eqIfPresent(SafetyHazardDO::getStatus, reqVO.getStatus()) |
| | | .likeIfPresent(SafetyHazardDO::getAssignee, reqVO.getAssignee()) |
| | | .likeIfPresent(SafetyHazardDO::getLocation, reqVO.getLocation()) |
| | | .geIfPresent(SafetyHazardDO::getReportTime, reqVO.getReportTimeStart()) |
| | | .leIfPresent(SafetyHazardDO::getReportTime, reqVO.getReportTimeEnd()) |
| | | .orderByDesc(SafetyHazardDO::getReportTime) |
| | | .orderByDesc(SafetyHazardDO::getId)); |
| | | } |
| | | |
| | | /** è¶
è¿æ´æ¹æé䏿ªéç¯ç鿣 */ |
| | | default List<SafetyHazardDO> selectOverdue(java.time.LocalDate today) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyHazardDO>() |
| | | .lt(SafetyHazardDO::getRectifyDeadline, today) |
| | | .notIn(SafetyHazardDO::getStatus, "CLOSED") |
| | | .orderByAsc(SafetyHazardDO::getRectifyDeadline)); |
| | | } |
| | | |
| | | /** çæéæ£ç¼å·ï¼HZ + yyyyMMdd + 4 使µæ°´ */ |
| | | @Select("SELECT CONCAT(#{prefix}, LPAD(COUNT(*) + 1, 4, '0')) FROM safety_hazard WHERE code LIKE CONCAT(#{prefix}, '%')") |
| | | String selectNextCode(@Param("prefix") String prefix); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.inspection.SafetyInspectionPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyInspectionDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£è®°å½ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyInspectionMapper extends BaseMapperX<SafetyInspectionDO> { |
| | | |
| | | default PageResult<SafetyInspectionDO> selectPage(SafetyInspectionPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyInspectionDO>() |
| | | .eqIfPresent(SafetyInspectionDO::getPointId, reqVO.getPointId()) |
| | | .eqIfPresent(SafetyInspectionDO::getPointType, reqVO.getPointType()) |
| | | .likeIfPresent(SafetyInspectionDO::getInspector, reqVO.getInspector()) |
| | | .eqIfPresent(SafetyInspectionDO::getResult, reqVO.getResult()) |
| | | .betweenIfPresent(SafetyInspectionDO::getInspectTime, reqVO.getInspectTime()) |
| | | .orderByDesc(SafetyInspectionDO::getInspectTime) |
| | | .orderByDesc(SafetyInspectionDO::getId)); |
| | | } |
| | | |
| | | default List<SafetyInspectionDO> selectListByTimeRange(LocalDateTime begin, LocalDateTime end) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyInspectionDO>() |
| | | .geIfPresent(SafetyInspectionDO::getInspectTime, begin) |
| | | .leIfPresent(SafetyInspectionDO::getInspectTime, end) |
| | | .orderByAsc(SafetyInspectionDO::getInspectTime)); |
| | | } |
| | | |
| | | default Long selectCountByPointId(Long pointId) { |
| | | return selectCount(SafetyInspectionDO::getPointId, pointId); |
| | | } |
| | | |
| | | /** æ¥è¯¢æç¹ä½æè¿ä¸æ¬¡å·¡æ£è®°å½ */ |
| | | default SafetyInspectionDO selectLatestByPointId(Long pointId) { |
| | | return selectOne(new LambdaQueryWrapperX<SafetyInspectionDO>() |
| | | .eq(SafetyInspectionDO::getPointId, pointId) |
| | | .orderByDesc(SafetyInspectionDO::getInspectTime) |
| | | .last("LIMIT 1")); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.inspection.SafetyInspectionPointPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyInspectionPointDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyInspectionPointMapper extends BaseMapperX<SafetyInspectionPointDO> { |
| | | |
| | | default PageResult<SafetyInspectionPointDO> selectPage(SafetyInspectionPointPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyInspectionPointDO>() |
| | | .likeIfPresent(SafetyInspectionPointDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(SafetyInspectionPointDO::getName, reqVO.getName()) |
| | | .eqIfPresent(SafetyInspectionPointDO::getPointType, reqVO.getPointType()) |
| | | .likeIfPresent(SafetyInspectionPointDO::getWorkshopName, reqVO.getWorkshopName()) |
| | | .eqIfPresent(SafetyInspectionPointDO::getStatus, reqVO.getStatus()) |
| | | .orderByAsc(SafetyInspectionPointDO::getCode)); |
| | | } |
| | | |
| | | default SafetyInspectionPointDO selectByCode(String code) { |
| | | return selectOne(SafetyInspectionPointDO::getCode, code); |
| | | } |
| | | |
| | | default List<SafetyInspectionPointDO> selectListByStatus(Integer status) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyInspectionPointDO>() |
| | | .eq(SafetyInspectionPointDO::getStatus, status) |
| | | .orderByAsc(SafetyInspectionPointDO::getCode)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.material.SafetyMaterialPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyMaterialDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµå°è´¦ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyMaterialMapper extends BaseMapperX<SafetyMaterialDO> { |
| | | |
| | | default PageResult<SafetyMaterialDO> selectPage(SafetyMaterialPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyMaterialDO>() |
| | | .likeIfPresent(SafetyMaterialDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(SafetyMaterialDO::getName, reqVO.getName()) |
| | | .eqIfPresent(SafetyMaterialDO::getCategory, reqVO.getCategory()) |
| | | .eqIfPresent(SafetyMaterialDO::getStatus, reqVO.getStatus()) |
| | | .likeIfPresent(SafetyMaterialDO::getStorageLocation, reqVO.getStorageLocation()) |
| | | .orderByAsc(SafetyMaterialDO::getCategory) |
| | | .orderByAsc(SafetyMaterialDO::getCode)); |
| | | } |
| | | |
| | | default SafetyMaterialDO selectByCode(String code) { |
| | | return selectOne(SafetyMaterialDO::getCode, code); |
| | | } |
| | | |
| | | /** éå®åºåè¡ï¼é¿å
å¹¶ååºå
¥åºå¯¼è´åºåéä¹± */ |
| | | @Select("SELECT * FROM safety_material WHERE id = #{id} AND deleted = b'0' FOR UPDATE") |
| | | SafetyMaterialDO selectByIdForUpdate(@Param("id") Long id); |
| | | |
| | | /** ä½äºå®å
¨åºåçç©èµ */ |
| | | default List<SafetyMaterialDO> selectBelowSafeStock() { |
| | | return selectList(new LambdaQueryWrapperX<SafetyMaterialDO>() |
| | | .apply("stock_qty < safe_stock") |
| | | .orderByAsc(SafetyMaterialDO::getCode)); |
| | | } |
| | | |
| | | /** æææä¸´è¿çç©èµ */ |
| | | default List<SafetyMaterialDO> selectExpiringBefore(LocalDate deadline) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyMaterialDO>() |
| | | .isNotNull(SafetyMaterialDO::getExpireDate) |
| | | .le(SafetyMaterialDO::getExpireDate, deadline) |
| | | .orderByAsc(SafetyMaterialDO::getExpireDate)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.material.SafetyMaterialStockPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyMaterialStockDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµåºå
¥åºæµæ°´ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyMaterialStockMapper extends BaseMapperX<SafetyMaterialStockDO> { |
| | | |
| | | default PageResult<SafetyMaterialStockDO> selectPage(SafetyMaterialStockPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyMaterialStockDO>() |
| | | .eqIfPresent(SafetyMaterialStockDO::getMaterialId, reqVO.getMaterialId()) |
| | | .likeIfPresent(SafetyMaterialStockDO::getMaterialName, reqVO.getMaterialName()) |
| | | .eqIfPresent(SafetyMaterialStockDO::getCategory, reqVO.getCategory()) |
| | | .eqIfPresent(SafetyMaterialStockDO::getBizType, reqVO.getBizType()) |
| | | .betweenIfPresent(SafetyMaterialStockDO::getBizDate, reqVO.getBizDate()) |
| | | .orderByDesc(SafetyMaterialStockDO::getBizDate) |
| | | .orderByDesc(SafetyMaterialStockDO::getId)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyOrgDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç»ç»æ¶æ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyOrgMapper extends BaseMapperX<SafetyOrgDO> { |
| | | |
| | | default List<SafetyOrgDO> selectListOrdered() { |
| | | return selectList(new LambdaQueryWrapperX<SafetyOrgDO>() |
| | | .orderByAsc(SafetyOrgDO::getSort) |
| | | .orderByAsc(SafetyOrgDO::getId)); |
| | | } |
| | | |
| | | default List<SafetyOrgDO> selectListByParentId(Long parentId) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyOrgDO>() |
| | | .eq(SafetyOrgDO::getParentId, parentId) |
| | | .orderByAsc(SafetyOrgDO::getSort)); |
| | | } |
| | | |
| | | default Long selectCountByParentId(Long parentId) { |
| | | return selectCount(SafetyOrgDO::getParentId, parentId); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.train.SafetyTrainingPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyTrainingDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å¹è®è®°å½ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyTrainingMapper extends BaseMapperX<SafetyTrainingDO> { |
| | | |
| | | default PageResult<SafetyTrainingDO> selectPage(SafetyTrainingPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyTrainingDO>() |
| | | .likeIfPresent(SafetyTrainingDO::getTitle, reqVO.getTitle()) |
| | | .eqIfPresent(SafetyTrainingDO::getTrainingType, reqVO.getTrainingType()) |
| | | .likeIfPresent(SafetyTrainingDO::getTrainer, reqVO.getTrainer()) |
| | | .betweenIfPresent(SafetyTrainingDO::getTrainDate, reqVO.getTrainDate()) |
| | | .orderByDesc(SafetyTrainingDO::getTrainDate) |
| | | .orderByDesc(SafetyTrainingDO::getId)); |
| | | } |
| | | |
| | | default List<SafetyTrainingDO> selectListBetween(java.time.LocalDate begin, java.time.LocalDate end) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyTrainingDO>() |
| | | .geIfPresent(SafetyTrainingDO::getTrainDate, begin) |
| | | .leIfPresent(SafetyTrainingDO::getTrainDate, end) |
| | | .orderByAsc(SafetyTrainingDO::getTrainDate)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | 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.mes.controller.admin.safety.vo.permit.SafetyWorkPermitPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyWorkPermitDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.ibatis.annotations.Select; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyWorkPermitMapper extends BaseMapperX<SafetyWorkPermitDO> { |
| | | |
| | | default PageResult<SafetyWorkPermitDO> selectPage(SafetyWorkPermitPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<SafetyWorkPermitDO>() |
| | | .likeIfPresent(SafetyWorkPermitDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(SafetyWorkPermitDO::getTitle, reqVO.getTitle()) |
| | | .eqIfPresent(SafetyWorkPermitDO::getPermitType, reqVO.getPermitType()) |
| | | .eqIfPresent(SafetyWorkPermitDO::getStatus, reqVO.getStatus()) |
| | | .eqIfPresent(SafetyWorkPermitDO::getRiskLevel, reqVO.getRiskLevel()) |
| | | .likeIfPresent(SafetyWorkPermitDO::getApplicant, reqVO.getApplicant()) |
| | | .likeIfPresent(SafetyWorkPermitDO::getWorkshopName, reqVO.getWorkshopName()) |
| | | .betweenIfPresent(SafetyWorkPermitDO::getPlanStartTime, reqVO.getPlanStartTime()) |
| | | .orderByDesc(SafetyWorkPermitDO::getApplyTime) |
| | | .orderByDesc(SafetyWorkPermitDO::getId)); |
| | | } |
| | | |
| | | @Select("SELECT CONCAT(#{prefix}, LPAD(COUNT(*) + 1, 4, '0')) FROM safety_work_permit WHERE code LIKE CONCAT(#{prefix}, '%')") |
| | | String selectNextCode(@Param("prefix") String prefix); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.safety; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyWorkPermitMonitorDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ä½ä¸çæ¤è®°å½ Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SafetyWorkPermitMonitorMapper extends BaseMapperX<SafetyWorkPermitMonitorDO> { |
| | | |
| | | default List<SafetyWorkPermitMonitorDO> selectListByPermitId(Long permitId) { |
| | | return selectList(new LambdaQueryWrapperX<SafetyWorkPermitMonitorDO>() |
| | | .eq(SafetyWorkPermitMonitorDO::getPermitId, permitId) |
| | | .orderByDesc(SafetyWorkPermitMonitorDO::getMonitorTime)); |
| | | } |
| | | |
| | | default int deleteByPermitId(Long permitId) { |
| | | return delete(SafetyWorkPermitMonitorDO::getPermitId, permitId); |
| | | } |
| | | |
| | | } |
| | |
| | | ErrorCode PD_CTC_REEL_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_040_960_010, "导å
¥çå
·è®¡ç®æ°æ®ä¸è½ä¸ºç©ºï¼"); |
| | | ErrorCode PD_TECH_CONFIRM_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_040_960_011, "导å
¥ææ¯ç¡®è®¤å½æ°æ®ä¸è½ä¸ºç©ºï¼"); |
| | | |
| | | // ========== MES æ°é-æ¥è¦ï¼1-040-920-000ï¼ ========== |
| | | ErrorCode COLLECT_ALARM_NOT_EXISTS = new ErrorCode(1_040_920_001, "æ¥è¦è®°å½ä¸åå¨"); |
| | | ErrorCode COLLECT_ALARM_ALREADY_CLEARED = new ErrorCode(1_040_920_002, "该æ¥è¦å·²æ¶é¤ï¼æ ééå¤ç¡®è®¤"); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums; |
| | | |
| | | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| | | |
| | | /** |
| | | * MES 模åé误ç - å®å
¨çäº§åæ¨¡å |
| | | * |
| | | * å®å
¨ç产模åé误ç åºé´ï¼1_040_960_xxx |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | public interface SafetyErrorCodeConstants { |
| | | |
| | | // ========== å®å
¨ç»ç»æ¶æ 1_040_961_xxx ========== |
| | | ErrorCode SAFETY_ORG_NOT_EXISTS = new ErrorCode(1_040_961_000, "å®å
¨ç»ç»ä¸åå¨"); |
| | | ErrorCode SAFETY_ORG_PARENT_NOT_EXISTS = new ErrorCode(1_040_961_001, "ç¶çº§å®å
¨ç»ç»ä¸åå¨"); |
| | | ErrorCode SAFETY_ORG_PARENT_IS_SELF = new ErrorCode(1_040_961_002, "ä¸çº§ç»ç»ä¸è½éæ©èªå·±"); |
| | | ErrorCode SAFETY_ORG_PARENT_IS_CHILD = new ErrorCode(1_040_961_003, "ä¸çº§ç»ç»ä¸è½éæ©èªå·±çåç»ç»"); |
| | | ErrorCode SAFETY_ORG_HAS_CHILDREN = new ErrorCode(1_040_961_004, "åå¨åç»ç»ï¼æ æ³å é¤"); |
| | | |
| | | // ========== ç¹ç§ä½ä¸è¯ 1_040_962_xxx ========== |
| | | ErrorCode SAFETY_CERT_NOT_EXISTS = new ErrorCode(1_040_962_000, "ç¹ç§ä½ä¸è¯ä¸åå¨"); |
| | | ErrorCode SAFETY_CERT_NO_DUPLICATE = new ErrorCode(1_040_962_001, "è¯ä»¶ç¼å·å·²åå¨"); |
| | | ErrorCode SAFETY_CERT_EXPIRE_BEFORE_ISSUE = new ErrorCode(1_040_962_002, "æææä¸è½æ©äºåè¯æ¥æ"); |
| | | ErrorCode SAFETY_CERT_EMPLOYEE_NOT_EXISTS = new ErrorCode(1_040_962_003, "æè¯äººä¸åå¨ï¼è¯·ä»å工档æ¡ä¸éæ©"); |
| | | |
| | | // ========== å·¡æ£ç¹ä½ / å·¡æ£è®°å½ 1_040_963_xxx ========== |
| | | ErrorCode SAFETY_POINT_NOT_EXISTS = new ErrorCode(1_040_963_000, "å·¡æ£ç¹ä½ä¸åå¨"); |
| | | ErrorCode SAFETY_POINT_CODE_DUPLICATE = new ErrorCode(1_040_963_001, "ç¹ä½ç¼ç å·²åå¨"); |
| | | ErrorCode SAFETY_POINT_DISABLED = new ErrorCode(1_040_963_002, "å·¡æ£ç¹ä½å·²åç¨"); |
| | | ErrorCode SAFETY_INSPECTION_NOT_EXISTS = new ErrorCode(1_040_963_010, "å·¡æ£è®°å½ä¸åå¨"); |
| | | |
| | | // ========== 鿣éç¯ 1_040_964_xxx ========== |
| | | ErrorCode SAFETY_HAZARD_NOT_EXISTS = new ErrorCode(1_040_964_000, "éæ£è®°å½ä¸åå¨"); |
| | | ErrorCode SAFETY_HAZARD_STATUS_ERROR = new ErrorCode(1_040_964_001, "å½åéæ£ç¶æä¸å
许该æä½"); |
| | | ErrorCode SAFETY_HAZARD_ASSIGNEE_REQUIRED = new ErrorCode(1_040_964_002, "åæ´¾å¿
é¡»æå®æ´æ¹è´£ä»»äºº"); |
| | | ErrorCode SAFETY_HAZARD_SAME_OPERATOR = new ErrorCode(1_040_964_003, "æ´æ¹äººä¸å¤æ¥äººä¸è½æ¯åä¸äºº"); |
| | | |
| | | // ========== é«å±ä½ä¸ç¥¨ 1_040_965_xxx ========== |
| | | ErrorCode SAFETY_PERMIT_NOT_EXISTS = new ErrorCode(1_040_965_000, "ä½ä¸ç¥¨ä¸åå¨"); |
| | | ErrorCode SAFETY_PERMIT_STATUS_ERROR = new ErrorCode(1_040_965_001, "å½åä½ä¸ç¥¨ç¶æä¸å
许该æä½"); |
| | | ErrorCode SAFETY_PERMIT_TIME_INVALID = new ErrorCode(1_040_965_002, "计åç»ææ¶é´å¿
é¡»æäºå¼å§æ¶é´"); |
| | | ErrorCode SAFETY_PERMIT_NOT_APPROVED = new ErrorCode(1_040_965_003, "ä½ä¸ç¥¨æªå®¡æ¹éè¿ï¼ä¸è½å¼å§ä½ä¸"); |
| | | ErrorCode SAFETY_PERMIT_GUARDIAN_REQUIRED = new ErrorCode(1_040_965_004, "é«å±ä½ä¸å¿
é¡»æå®çæ¤äºº"); |
| | | ErrorCode SAFETY_PERMIT_SELF_APPROVE = new ErrorCode(1_040_965_005, "ç³è¯·äººä¸è½å®¡æ¹èªå·±çä½ä¸ç¥¨"); |
| | | ErrorCode SAFETY_PERMIT_MONITOR_NOT_EXISTS = new ErrorCode(1_040_965_010, "çæ¤è®°å½ä¸åå¨"); |
| | | |
| | | // ========== ç©èµå°è´¦ 1_040_966_xxx ========== |
| | | ErrorCode SAFETY_MATERIAL_NOT_EXISTS = new ErrorCode(1_040_966_000, "ç©èµä¸åå¨"); |
| | | ErrorCode SAFETY_MATERIAL_CODE_DUPLICATE = new ErrorCode(1_040_966_001, "ç©èµç¼ç å·²åå¨"); |
| | | ErrorCode SAFETY_MATERIAL_STOCK_NOT_ENOUGH = new ErrorCode(1_040_966_002, "åºåä¸è¶³ï¼æ æ³åºåº"); |
| | | ErrorCode SAFETY_MATERIAL_STOCK_RECORD_NOT_EXISTS = new ErrorCode(1_040_966_010, "åºå
¥åºæµæ°´ä¸åå¨"); |
| | | |
| | | // ========== å¹è® / æ¼ç» / äºæ
1_040_967_xxx ========== |
| | | ErrorCode SAFETY_TRAINING_NOT_EXISTS = new ErrorCode(1_040_967_000, "å¹è®è®°å½ä¸åå¨"); |
| | | ErrorCode SAFETY_DRILL_NOT_EXISTS = new ErrorCode(1_040_967_010, "æ¼ç»è®°å½ä¸åå¨"); |
| | | ErrorCode SAFETY_ACCIDENT_NOT_EXISTS = new ErrorCode(1_040_967_020, "äºæ
è®°å½ä¸åå¨"); |
| | | |
| | | // ========== ä¸»æ°æ®å¼ç¨ 1_040_969_xxx ========== |
| | | ErrorCode SAFETY_WORKSHOP_NOT_EXISTS = new ErrorCode(1_040_969_000, "车é´ä¸åå¨ï¼è¯·ä»è½¦é´ä¸»æ°æ®ä¸éæ©"); |
| | | ErrorCode SAFETY_EMPLOYEE_REQUIRED = new ErrorCode(1_040_969_001, "è¯·éæ©åå·¥"); |
| | | |
| | | // ========== å°è´¦å¯¼åº 1_040_968_xxx ========== |
| | | ErrorCode SAFETY_LEDGER_EXPORT_ITEM_UNKNOWN = new ErrorCode(1_040_968_000, "æªç¥çå°è´¦å¯¼åºé¡¹"); |
| | | ErrorCode SAFETY_LEDGER_DATE_RANGE_INVALID = new ErrorCode(1_040_968_001, "å¼å§æ¥æä¸è½æäºç»ææ¥æ"); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°éæ¥è¦ç¶æ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectAlarmStatusEnum { |
| | | |
| | | ACTIVE(0, "æªæ¶é¤"), |
| | | CLEARED(1, "å·²æ¶é¤"); |
| | | |
| | | private final Integer status; |
| | | private final String name; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°éæ¥æç±»å |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectMsgTypeEnum { |
| | | |
| | | REALTIME("realtime", "宿¶æ°æ®"), |
| | | SPC("spc", "卿è¿ç¨æ°æ®"), |
| | | TECH("tech", "å·¥èºåæ°"), |
| | | OP_LOG("opLog", "åæ°åæ´æ¥å¿"), |
| | | ALARM("alarm", "æ¥è¦"), |
| | | CONNECT("connect", "设å¤ä¸çº¿"), |
| | | DISCONNECT("disconnect", "设å¤ç¦»çº¿"), |
| | | UNKNOWN("unknown", "æªç¥ç±»å"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static MesCollectMsgTypeEnum getByType(String type) { |
| | | for (MesCollectMsgTypeEnum value : values()) { |
| | | if (value.type.equalsIgnoreCase(type)) { |
| | | return value; |
| | | } |
| | | } |
| | | return UNKNOWN; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°é设å¤è¿è¡æ¨¡å¼ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectOperateModeEnum { |
| | | |
| | | MANUAL(0, "æå¨"), |
| | | SEMI_AUTO(1, "åèªå¨"), |
| | | EYE_AUTO(2, "çµç¼èªå¨"), |
| | | TIME_AUTO(3, "æ¶é´èªå¨"), |
| | | MOLD_ADJUST(4, "è°æ¨¡ä½¿ç¨"); |
| | | |
| | | private final Integer mode; |
| | | private final String name; |
| | | |
| | | public static String getNameByMode(Integer mode) { |
| | | if (mode == null) { |
| | | return null; |
| | | } |
| | | for (MesCollectOperateModeEnum value : values()) { |
| | | if (value.mode.equals(mode)) { |
| | | return value.name; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.collect; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * MES æ°é设å¤è¿è¡ç¶æ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum MesCollectRunStatusEnum { |
| | | |
| | | STANDBY(1, "å¾
æº"), |
| | | PRODUCING(2, "ç产"); |
| | | |
| | | private final Integer status; |
| | | private final String name; |
| | | |
| | | public static String getNameByStatus(Integer status) { |
| | | if (status == null) { |
| | | return null; |
| | | } |
| | | for (MesCollectRunStatusEnum value : values()) { |
| | | if (value.status.equals(status)) { |
| | | return value.name; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
ç级æä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyAccidentLevelEnum { |
| | | |
| | | SLIGHT("SLIGHT", "è½»ä¼¤äºæ
"), |
| | | GENERAL("GENERAL", "ä¸è¬äºæ
"), |
| | | SEVERE("SEVERE", "éä¼¤äºæ
"), |
| | | MAJOR("MAJOR", "éå¤§äºæ
"); |
| | | |
| | | private final String level; |
| | | private final String name; |
| | | |
| | | public static String getNameByLevel(String level) { |
| | | for (SafetyAccidentLevelEnum value : values()) { |
| | | if (value.getLevel().equals(level)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return level; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
å¤çç¶ææä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyAccidentStatusEnum { |
| | | |
| | | REPORTED("REPORTED", "å·²ç»è®°"), |
| | | INVESTIGATING("INVESTIGATING", "è°æ¥ä¸"), |
| | | HANDLED("HANDLED", "å·²å¤ç"), |
| | | CLOSED("CLOSED", "å·²ç»æ¡"); |
| | | |
| | | private final String status; |
| | | private final String name; |
| | | |
| | | public static String getNameByStatus(String status) { |
| | | for (SafetyAccidentStatusEnum value : values()) { |
| | | if (value.getStatus().equals(status)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - äºæ
ç±»åæä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyAccidentTypeEnum { |
| | | |
| | | ELECTRIC_SHOCK("ELECTRIC_SHOCK", "触çµ"), |
| | | FIRE("FIRE", "ç«ç¾"), |
| | | FALL("FALL", "é«å¤å è½"), |
| | | OBJECT_STRIKE("OBJECT_STRIKE", "ç©ä½æå»"), |
| | | MECHANICAL("MECHANICAL", "æºæ¢°ä¼¤å®³"), |
| | | CHEMICAL("CHEMICAL", "䏿¯çªæ¯"), |
| | | VEHICLE("VEHICLE", "车è¾ä¼¤å®³"), |
| | | OTHER("OTHER", "å
¶ä»"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static String getNameByType(String type) { |
| | | for (SafetyAccidentTypeEnum value : values()) { |
| | | if (value.getType().equals(type)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯ç¶ææä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyCertificateStatusEnum { |
| | | |
| | | VALID("VALID", "ææ"), |
| | | EXPIRING("EXPIRING", "å³å°å°æ"), |
| | | EXPIRED("EXPIRED", "å·²è¿æ"), |
| | | REVOKED("REVOKED", "已注é"); |
| | | |
| | | private final String status; |
| | | private final String name; |
| | | |
| | | public static String getNameByStatus(String status) { |
| | | for (SafetyCertificateStatusEnum value : values()) { |
| | | if (value.getStatus().equals(status)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯ç±»åæä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyCertificateTypeEnum { |
| | | |
| | | LOW_VOLTAGE_ELECTRICIAN("LOW_VOLTAGE_ELECTRICIAN", "ä½åçµå·¥è¯"), |
| | | HIGH_VOLTAGE_OPERATION("HIGH_VOLTAGE_OPERATION", "é«åæä½è¯"), |
| | | WELDING("WELDING", "çæ¥ä¸çåå²ä½ä¸è¯"), |
| | | HOIST("HOIST", "èµ·éæºæ¢°ä½ä¸è¯"), |
| | | HEIGHT_WORK("HEIGHT_WORK", "é«å¤ä½ä¸è¯"), |
| | | LIMITED_SPACE("LIMITED_SPACE", "æé空é´ä½ä¸è¯"), |
| | | FORKLIFT("FORKLIFT", "å车ä½ä¸è¯"), |
| | | BOILER("BOILER", "é
çä½ä¸è¯"), |
| | | OTHER("OTHER", "å
¶ä»ç¹ç§ä½ä¸è¯"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static String getNameByType(String type) { |
| | | for (SafetyCertificateTypeEnum value : values()) { |
| | | if (value.getType().equals(type)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ¼ç»ç±»åæä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyDrillTypeEnum { |
| | | |
| | | FIRE("FIRE", "æ¶é²æ¼ç»"), |
| | | EMERGENCY_EVAC("EMERGENCY_EVAC", "åºæ¥çæ£æ¼ç»"), |
| | | ELECTRIC_ACCIDENT("ELECTRIC_ACCIDENT", "触çµäºæ
æ¼ç»"), |
| | | CHEMICAL_LEAK("CHEMICAL_LEAK", "å±ååæ³æ¼æ¼ç»"), |
| | | OTHER("OTHER", "å
¶ä»æ¼ç»"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static String getNameByType(String type) { |
| | | for (SafetyDrillTypeEnum value : values()) { |
| | | if (value.getType().equals(type)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣ç级æä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyHazardLevelEnum { |
| | | |
| | | GENERAL("GENERAL", "ä¸è¬éæ£"), |
| | | MAJOR("MAJOR", "é大鿣"); |
| | | |
| | | private final String level; |
| | | private final String name; |
| | | |
| | | public static String getNameByLevel(String level) { |
| | | for (SafetyHazardLevelEnum value : values()) { |
| | | if (value.getLevel().equals(level)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return level; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - éæ£æ¥æºæä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyHazardSourceEnum { |
| | | |
| | | INSPECTION("INSPECTION", "å·¡æ£åç°"), |
| | | SELF_CHECK("SELF_CHECK", "èªæ¥ä¸æ¥"), |
| | | REPORT("REPORT", "å工䏿¥"), |
| | | EXTERNAL("EXTERNAL", "å¤é¨æ£æ¥"); |
| | | |
| | | private final String source; |
| | | private final String name; |
| | | |
| | | public static String getNameBySource(String source) { |
| | | for (SafetyHazardSourceEnum value : values()) { |
| | | if (value.getSource().equals(source)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return source; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - éæ£ç¶ææä¸¾ |
| | | * |
| | | * <p>æµè½¬é¡ºåºï¼ä¸æ¥ â åæ´¾ â æ´æ¹ä¸ â å¾
夿¥ â å·²éç¯ / 夿¥ä¸éè¿ï¼éåæ´æ¹ï¼ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyHazardStatusEnum { |
| | | |
| | | REPORTED("REPORTED", "已䏿¥"), |
| | | ASSIGNED("ASSIGNED", "已忴¾"), |
| | | RECTIFYING("RECTIFYING", "æ´æ¹ä¸"), |
| | | RECHECKING("RECHECKING", "å¾
夿¥"), |
| | | REJECTED("REJECTED", "夿¥ä¸éè¿"), |
| | | CLOSED("CLOSED", "å·²éç¯"); |
| | | |
| | | private final String status; |
| | | private final String name; |
| | | |
| | | public static String getNameByStatus(String status) { |
| | | for (SafetyHazardStatusEnum value : values()) { |
| | | if (value.getStatus().equals(status)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | public static boolean isFinished(String status) { |
| | | return CLOSED.getStatus().equals(status); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£å¨ææä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyInspectCycleEnum { |
| | | |
| | | SHIFT("SHIFT", "æ¯ç"), |
| | | DAILY("DAILY", "æ¯æ¥"), |
| | | WEEKLY("WEEKLY", "æ¯å¨"), |
| | | MONTHLY("MONTHLY", "æ¯æ"); |
| | | |
| | | private final String cycle; |
| | | private final String name; |
| | | |
| | | public static String getNameByCycle(String cycle) { |
| | | for (SafetyInspectCycleEnum value : values()) { |
| | | if (value.getCycle().equals(cycle)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return cycle; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½ç±»åæä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyInspectionPointTypeEnum { |
| | | |
| | | HIGH_VOLTAGE_ROOM("HIGH_VOLTAGE_ROOM", "é«åé
çµå®¤"), |
| | | UNIT_AREA("UNIT_AREA", "æºç»åº"), |
| | | DANGER_CHEMICAL("DANGER_CHEMICAL", "å±åååº"), |
| | | FIRE_AREA("FIRE_AREA", "æ¶é²éç¹é¨ä½"), |
| | | WORKSHOP("WORKSHOP", "ç产车é´"), |
| | | OTHER("OTHER", "å
¶ä»"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static String getNameByType(String type) { |
| | | for (SafetyInspectionPointTypeEnum value : values()) { |
| | | if (value.getType().equals(type)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç©èµç±»å«æä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyMaterialCategoryEnum { |
| | | |
| | | INSULATING("INSULATING", "çµåç»ç¼ç¨å
·"), |
| | | HAZARD_CHEMICAL("HAZARD_CHEMICAL", "å±åå"), |
| | | FIRE("FIRE", "æ¶é²ç©èµ"), |
| | | PPE("PPE", "å³ä¿ç¨å"), |
| | | OTHER("OTHER", "å
¶ä»"); |
| | | |
| | | private final String category; |
| | | private final String name; |
| | | |
| | | public static String getNameByCategory(String category) { |
| | | for (SafetyMaterialCategoryEnum value : values()) { |
| | | if (value.getCategory().equals(category)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return category; |
| | | } |
| | | |
| | | /** æ¯å¦éè¦æææç®¡çï¼ç»ç¼ç¨å
·ä¸å±ååæä¿è´¨æï¼ */ |
| | | public static boolean requiresExpireDate(String category) { |
| | | return INSULATING.getCategory().equals(category) || HAZARD_CHEMICAL.getCategory().equals(category); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ç¶ææä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyPermitStatusEnum { |
| | | |
| | | DRAFT("DRAFT", "è稿"), |
| | | PENDING("PENDING", "å¾
审æ¹"), |
| | | APPROVED("APPROVED", "å·²æ¹å"), |
| | | REJECTED("REJECTED", "已驳å"), |
| | | IN_PROGRESS("IN_PROGRESS", "ä½ä¸ä¸"), |
| | | CLOSED("CLOSED", "å·²å®ç»"), |
| | | CANCELLED("CANCELLED", "å·²ä½åº"); |
| | | |
| | | private final String status; |
| | | private final String name; |
| | | |
| | | public static String getNameByStatus(String status) { |
| | | for (SafetyPermitStatusEnum value : values()) { |
| | | if (value.getStatus().equals(status)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ç±»åæä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyPermitTypeEnum { |
| | | |
| | | HOT_WORK("HOT_WORK", "å¨ç«ä½ä¸"), |
| | | LIVE_HIGH_VOLTAGE("LIVE_HIGH_VOLTAGE", "é«å带çµä½ä¸"), |
| | | LIMITED_SPACE("LIMITED_SPACE", "æé空é´ä½ä¸"), |
| | | WORK_AT_HEIGHT("WORK_AT_HEIGHT", "é«å¤ä½ä¸"), |
| | | LIFTING("LIFTING", "åè£
ä½ä¸"), |
| | | TEMP_ELECTRIC("TEMP_ELECTRIC", "临æ¶ç¨çµä½ä¸"), |
| | | OTHER("OTHER", "å
¶ä»ä½ä¸"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static String getNameByType(String type) { |
| | | for (SafetyPermitTypeEnum value : values()) { |
| | | if (value.getType().equals(type)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | /** æ¯å¦å¿
é¡»æå®çæ¤äºº */ |
| | | public static boolean requiresGuardian(String type) { |
| | | return HOT_WORK.getType().equals(type) || LIVE_HIGH_VOLTAGE.getType().equals(type) |
| | | || LIMITED_SPACE.getType().equals(type); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é£é©ç级æä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyRiskLevelEnum { |
| | | |
| | | LOW("LOW", "ä½"), |
| | | NORMAL("NORMAL", "ä¸è¬"), |
| | | HIGH("HIGH", "é«"), |
| | | VERY_HIGH("VERY_HIGH", "æé«"); |
| | | |
| | | private final String level; |
| | | private final String name; |
| | | |
| | | public static String getNameByLevel(String level) { |
| | | for (SafetyRiskLevelEnum value : values()) { |
| | | if (value.getLevel().equals(level)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return level; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.enums.safety; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å¹è®ç±»åæä¸¾ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum SafetyTrainingTypeEnum { |
| | | |
| | | SAFETY("SAFETY", "å®å
¨å¹è®"), |
| | | SKILL("SKILL", "æè½å¹è®"), |
| | | LAW("LAW", "æ³è§å®£è´¯"), |
| | | EMERGENCY("EMERGENCY", "åºæ¥æ¼ç»å¹è®"), |
| | | INDUCTION("INDUCTION", "ä¸çº§å®å
¨æè²"), |
| | | OTHER("OTHER", "å
¶ä»"); |
| | | |
| | | private final String type; |
| | | private final String name; |
| | | |
| | | public static String getNameByType(String type) { |
| | | for (SafetyTrainingTypeEnum value : values()) { |
| | | if (value.getType().equals(type)) { |
| | | return value.getName(); |
| | | } |
| | | } |
| | | return type; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.framework.collect.config; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * MES æ°éé
ç½® |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @ConfigurationProperties(prefix = "yudao.mes.collect") |
| | | @Data |
| | | public class MesCollectProperties { |
| | | |
| | | /** |
| | | * æ¥ææ ¼å¼ï¼æ³¨å¡æº /YLCY/IMM åè®®ï¼æ¥æå¸¦ topic åæ®µï¼ä¸»é¢æ«æ®µä¸ºæ¥æç±»åï¼ |
| | | */ |
| | | public static final String FORMAT_YLCY = "ylcy"; |
| | | /** |
| | | * æ¥ææ ¼å¼ï¼è®¾å¤ç½å
³åè®®ï¼ä¸»é¢åºå® gateway/xxxï¼æ¥æé¦å± key 为设å¤åï¼å¼ä¸ºå±æ§åå
¸ï¼ |
| | | */ |
| | | public static final String FORMAT_GATEWAY = "gateway"; |
| | | |
| | | private Mqtt mqtt = new Mqtt(); |
| | | private Retention retention = new Retention(); |
| | | |
| | | @Data |
| | | public static class Mqtt { |
| | | |
| | | /** |
| | | * æ¯å¦å¯ç¨æ°é MQTT 订é
|
| | | */ |
| | | private Boolean enabled = false; |
| | | /** |
| | | * Broker å°åï¼ä¾å¦ tcp://36.213.90.123:1883 |
| | | */ |
| | | private String url; |
| | | private String username; |
| | | private String password; |
| | | /** |
| | | * 客æ·ç«¯ ID åç¼ |
| | | */ |
| | | private String clientIdPrefix = "mes-collect"; |
| | | /** |
| | | * 主é¢åç¼ï¼ä¾å¦ /YLCY/IMMãgateway |
| | | */ |
| | | private String topicPrefix = "/YLCY/IMM"; |
| | | /** |
| | | * æ¥ææ ¼å¼ï¼è§ {@link MesCollectProperties#FORMAT_YLCY}ã{@link MesCollectProperties#FORMAT_GATEWAY} |
| | | */ |
| | | private String format = FORMAT_YLCY; |
| | | /** |
| | | * æ¾å¼æå®è®¢é
主é¢ï¼å¤ä¸ªç¨éå·åéï¼ä¸ºç©ºæ¶æ format + topicPrefix èªå¨æ¨å¯¼ |
| | | */ |
| | | private String topics; |
| | | private Integer qos = 0; |
| | | private Integer keepAlive = 65; |
| | | private Integer connectionTimeout = 10; |
| | | /** |
| | | * æ¥è¦ä¸»é¢åç¼ï¼æ¥æ topic åæ®µæä¸»é¢æ«æ®µå½ä¸æ¶ææ¥è¦å¤ç |
| | | */ |
| | | private String alarmTopicSuffix = "wm"; |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºè®¾å¤ç½å
³æ ¼å¼æ¥æ |
| | | */ |
| | | public boolean isGatewayFormat() { |
| | | return FORMAT_GATEWAY.equalsIgnoreCase(format == null ? "" : format.trim()); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Data |
| | | public static class Retention { |
| | | |
| | | /** |
| | | * åå§æ¥æä¿çå¤©æ° |
| | | */ |
| | | private Integer rawDays = 7; |
| | | /** |
| | | * 宿¶åå²ä¿çå¤©æ° |
| | | */ |
| | | private Integer realtimeDays = 30; |
| | | /** |
| | | * 忬¡æ¸
çæ¡æ° |
| | | */ |
| | | private Integer batchSize = 50000; |
| | | |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.framework.collect.mqtt; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.framework.collect.config.MesCollectProperties; |
| | | import cn.iocoder.yudao.module.mes.service.collect.MesCollectMessageDispatcher; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.paho.client.mqttv3.*; |
| | | import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; |
| | | import org.springframework.context.SmartLifecycle; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.ScheduledExecutorService; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * MES æ°é MQTT 客æ·ç«¯ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectMqttClient implements SmartLifecycle { |
| | | |
| | | private static final long RECONNECT_DELAY_SECONDS = 30L; |
| | | |
| | | @Resource |
| | | private MesCollectProperties properties; |
| | | @Resource |
| | | private MesCollectMessageDispatcher dispatcher; |
| | | |
| | | private volatile boolean running = false; |
| | | private MqttClient client; |
| | | private ScheduledExecutorService scheduler; |
| | | |
| | | @Override |
| | | public void start() { |
| | | MesCollectProperties.Mqtt mqtt = properties.getMqtt(); |
| | | if (!Boolean.TRUE.equals(mqtt.getEnabled())) { |
| | | log.info("[start][æ°é MQTT æªå¯ç¨]"); |
| | | return; |
| | | } |
| | | if (StrUtil.isBlank(mqtt.getUrl())) { |
| | | log.warn("[start][æ°é MQTT å·²å¯ç¨ä½ url 为空ï¼è·³è¿è¿æ¥]"); |
| | | return; |
| | | } |
| | | running = true; |
| | | scheduler = Executors.newSingleThreadScheduledExecutor(runnable -> { |
| | | Thread thread = new Thread(runnable, "mes-collect-mqtt-reconnect"); |
| | | thread.setDaemon(true); |
| | | return thread; |
| | | }); |
| | | scheduler.scheduleWithFixedDelay(this::ensureConnected, 0, RECONNECT_DELAY_SECONDS, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | private void ensureConnected() { |
| | | if (!running) { |
| | | return; |
| | | } |
| | | MesCollectProperties.Mqtt mqtt = properties.getMqtt(); |
| | | try { |
| | | if (client == null) { |
| | | client = new MqttClient(mqtt.getUrl(), buildClientId(), new MemoryPersistence()); |
| | | client.setCallback(new MqttCallbackExtended() { |
| | | @Override |
| | | public void connectComplete(boolean reconnect, String serverURI) { |
| | | subscribe(); |
| | | } |
| | | |
| | | @Override |
| | | public void connectionLost(Throwable cause) { |
| | | log.warn("[connectionLost][æ°é MQTT è¿æ¥æå¼ï¼{}]", cause == null ? "æªç¥åå " : cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void messageArrived(String topic, MqttMessage message) { |
| | | String payload = new String(message.getPayload(), StandardCharsets.UTF_8); |
| | | try { |
| | | dispatcher.dispatch(topic, payload); |
| | | } catch (Exception e) { |
| | | log.error("[messageArrived][主é¢({}) å
¥é失败]", topic, e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deliveryComplete(IMqttDeliveryToken token) { |
| | | // å½ååªè®¢é
ï¼ä¸åå¸ |
| | | } |
| | | }); |
| | | } |
| | | if (!client.isConnected()) { |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | | options.setAutomaticReconnect(true); |
| | | options.setCleanSession(true); |
| | | options.setKeepAliveInterval(mqtt.getKeepAlive()); |
| | | options.setConnectionTimeout(mqtt.getConnectionTimeout()); |
| | | if (StrUtil.isNotBlank(mqtt.getUsername())) { |
| | | options.setUserName(mqtt.getUsername()); |
| | | } |
| | | if (mqtt.getPassword() != null) { |
| | | options.setPassword(mqtt.getPassword().toCharArray()); |
| | | } |
| | | client.connect(options); |
| | | log.info("[ensureConnected][æ°é MQTT å·²è¿æ¥ï¼{}]", mqtt.getUrl()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("[ensureConnected][æ°é MQTT è¿æ¥/订é
失败ï¼{} ç§åéè¯ï¼{}]", |
| | | RECONNECT_DELAY_SECONDS, e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | private void subscribe() { |
| | | MesCollectProperties.Mqtt mqtt = properties.getMqtt(); |
| | | for (String topic : resolveSubscribeTopics(mqtt)) { |
| | | try { |
| | | client.subscribe(topic, mqtt.getQos()); |
| | | log.info("[subscribe][æ°é MQTT 订é
æåï¼{}]", topic); |
| | | } catch (Exception e) { |
| | | log.error("[subscribe][æ°é MQTT 订é
失败ï¼{}]", topic, e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è§£æéè¦è®¢é
ç主é¢ã |
| | | * |
| | | * <p>æ¾å¼é
ç½® topics ä¼å
ï¼ç½å
³æ ¼å¼è®¢é
æ´ä¸ªåç¼ï¼gateway/#ï¼ï¼ |
| | | * å 为ç½å
³é¤ attributes å¤è¿ä¼å connect / disconnectï¼åç»ä¹å¯è½æ°å¢ä¸»é¢ï¼ |
| | | * å
¶ä½æ ¼å¼æ²¿ç¨ /YLCY/IMM/+/+ 两级éé
ã</p> |
| | | */ |
| | | private List<String> resolveSubscribeTopics(MesCollectProperties.Mqtt mqtt) { |
| | | if (StrUtil.isNotBlank(mqtt.getTopics())) { |
| | | return Arrays.stream(mqtt.getTopics().split(",")) |
| | | .map(String::trim) |
| | | .filter(StrUtil::isNotBlank) |
| | | .toList(); |
| | | } |
| | | String prefix = normalizeTopicPrefix(mqtt.getTopicPrefix()); |
| | | return Collections.singletonList(mqtt.isGatewayFormat() ? prefix + "#" : prefix + "+/+"); |
| | | } |
| | | |
| | | private String normalizeTopicPrefix(String prefix) { |
| | | if (StrUtil.isBlank(prefix)) { |
| | | return ""; |
| | | } |
| | | return prefix.endsWith("/") ? prefix : prefix + "/"; |
| | | } |
| | | |
| | | private String buildClientId() { |
| | | String host; |
| | | try { |
| | | host = InetAddress.getLocalHost().getHostName(); |
| | | } catch (Exception e) { |
| | | host = "host"; |
| | | } |
| | | host = host.replaceAll("[^a-zA-Z0-9_-]", "_"); |
| | | String clientId = properties.getMqtt().getClientIdPrefix() + "-" + host + "-" |
| | | + Long.toHexString(System.nanoTime()); |
| | | return StrUtil.maxLength(clientId, 64); |
| | | } |
| | | |
| | | @Override |
| | | public void stop() { |
| | | running = false; |
| | | if (scheduler != null) { |
| | | scheduler.shutdownNow(); |
| | | scheduler = null; |
| | | } |
| | | if (client != null) { |
| | | try { |
| | | if (client.isConnected()) { |
| | | client.disconnect(); |
| | | } |
| | | } catch (Exception e) { |
| | | log.warn("[stop][æ°é MQTT æå¼å¤±è´¥ï¼{}]", e.getMessage()); |
| | | } |
| | | try { |
| | | client.close(true); |
| | | } catch (Exception e) { |
| | | log.warn("[stop][æ°é MQTT å
³é失败ï¼{}]", e.getMessage()); |
| | | } |
| | | client = null; |
| | | } |
| | | log.info("[stop][æ°é MQTT 已忢]"); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isRunning() { |
| | | return running; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.job.collect; |
| | | |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.MesCollectMessageMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.MesCollectRealtimeHistoryMapper; |
| | | import cn.iocoder.yudao.module.mes.framework.collect.config.MesCollectProperties; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°éå岿°æ®æ¸
çä»»å¡ |
| | | * |
| | | * <p>åå§æ¥æä¿ç 7 天ï¼å®æ¶åå²ä¿ç 30 å¤©ï¼æ¯æ¥ 03:30 æ§è¡ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectCleanupJob { |
| | | |
| | | @Resource |
| | | private MesCollectProperties properties; |
| | | @Resource |
| | | private MesCollectMessageMapper messageMapper; |
| | | @Resource |
| | | private MesCollectRealtimeHistoryMapper realtimeHistoryMapper; |
| | | |
| | | @Scheduled(cron = "0 30 3 * * ?") |
| | | public void execute() { |
| | | MesCollectProperties.Retention retention = properties.getRetention(); |
| | | int batchSize = retention.getBatchSize() == null || retention.getBatchSize() <= 0 |
| | | ? 50000 : retention.getBatchSize(); |
| | | int rawDeleted = deleteInBatches(() -> messageMapper.deleteBefore( |
| | | LocalDateTime.now().minusDays(retention.getRawDays()), batchSize), batchSize); |
| | | int realtimeDeleted = deleteInBatches(() -> realtimeHistoryMapper.deleteBefore( |
| | | LocalDateTime.now().minusDays(retention.getRealtimeDays()), batchSize), batchSize); |
| | | log.info("[execute][æ°éå岿¸
ç宿ï¼åå§æ¥æ {} æ¡ï¼å®æ¶åå² {} æ¡]", rawDeleted, realtimeDeleted); |
| | | } |
| | | |
| | | private int deleteInBatches(DeleteAction action, int batchSize) { |
| | | int total = 0; |
| | | int deleted; |
| | | do { |
| | | deleted = action.delete(); |
| | | total += deleted; |
| | | } while (deleted >= batchSize); |
| | | return total; |
| | | } |
| | | |
| | | @FunctionalInterface |
| | | private interface DeleteAction { |
| | | int delete(); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectMsgTypeEnum; |
| | | import tools.jackson.databind.JsonNode; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * MES æ°éæ¥æè§£æå·¥å
· |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectDataParser { |
| | | |
| | | private static final DateTimeFormatter DATE_TIME_FORMATTER = |
| | | DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss[.SSS]"); |
| | | |
| | | public JsonNode parsePayload(String payload) { |
| | | return JsonUtils.parseTree(payload); |
| | | } |
| | | |
| | | public JsonNode parseData(JsonNode root) { |
| | | JsonNode data = root.get("Data"); |
| | | if (data != null && data.isTextual()) { |
| | | try { |
| | | data = JsonUtils.parseTree(data.asText()); |
| | | } catch (Exception e) { |
| | | log.warn("[parseData][Data åæ®µä¸æ¯åæ³ JSONï¼æåæå¤çï¼{}]", StrUtil.maxLength(data.asText(), 200)); |
| | | return root; |
| | | } |
| | | } |
| | | return data != null && data.isObject() ? data : root; |
| | | } |
| | | |
| | | public String getText(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | return value == null || value.isNull() ? null : value.asText(); |
| | | } |
| | | |
| | | public Integer getInteger(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | if (value.isNumber()) { |
| | | return value.intValue(); |
| | | } |
| | | try { |
| | | return Integer.valueOf(value.asText().trim()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public Long getLong(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | if (value.isNumber()) { |
| | | return value.longValue(); |
| | | } |
| | | try { |
| | | return Long.valueOf(value.asText().trim()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public BigDecimal getDecimal(JsonNode node, String field) { |
| | | JsonNode value = node.get(field); |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | if (value.isNumber()) { |
| | | return value.decimalValue(); |
| | | } |
| | | try { |
| | | return new BigDecimal(value.asText().trim()); |
| | | } catch (NumberFormatException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æåæå®åç¼ + æ°åçåæ®µï¼å¦ T1..TnãET1..ETn |
| | | */ |
| | | public String extractNumberedFields(JsonNode data, String prefix) { |
| | | Map<String, Object> result = new LinkedHashMap<>(); |
| | | data.properties().forEach(entry -> { |
| | | String name = entry.getKey(); |
| | | if (!name.startsWith(prefix) || name.length() == prefix.length()) { |
| | | return; |
| | | } |
| | | String suffix = name.substring(prefix.length()); |
| | | if (!suffix.chars().allMatch(Character::isDigit)) { |
| | | return; |
| | | } |
| | | JsonNode value = entry.getValue(); |
| | | result.put(name, value != null && value.isNumber() ? value.decimalValue() : value == null ? null : value.asText()); |
| | | }); |
| | | if (result.isEmpty()) { |
| | | return null; |
| | | } |
| | | return JsonUtils.toJsonString(result); |
| | | } |
| | | |
| | | public LocalDateTime parseEventTime(JsonNode root) { |
| | | LocalDateTime time = parseTimeText(getText(root, "time")); |
| | | if (time != null) { |
| | | return time; |
| | | } |
| | | Long timestamp = getLong(root, "timestamp"); |
| | | if (timestamp == null) { |
| | | timestamp = getLong(root, "sendStamp"); |
| | | } |
| | | if (timestamp != null && timestamp > 0) { |
| | | Instant instant = timestamp > 1_000_000_000_000L |
| | | ? Instant.ofEpochMilli(timestamp) : Instant.ofEpochSecond(timestamp); |
| | | return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); |
| | | } |
| | | return LocalDateTime.now(); |
| | | } |
| | | |
| | | public LocalDateTime parseTimeText(String text) { |
| | | if (StrUtil.isBlank(text)) { |
| | | return null; |
| | | } |
| | | try { |
| | | return LocalDateTime.parse(text.trim(), DATE_TIME_FORMATTER); |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public String valueToString(JsonNode value) { |
| | | if (value == null || value.isNull()) { |
| | | return null; |
| | | } |
| | | return value.isValueNode() ? value.asText() : value.toString(); |
| | | } |
| | | |
| | | public MesCollectMsgTypeEnum resolveMsgType(String topicField, String mqttTopic, |
| | | JsonNode data, String alarmTopicSuffix) { |
| | | MesCollectMsgTypeEnum type = MesCollectMsgTypeEnum.getByType(topicField); |
| | | if (type != MesCollectMsgTypeEnum.UNKNOWN) { |
| | | return type; |
| | | } |
| | | if (StrUtil.isNotBlank(topicField) && StrUtil.equalsIgnoreCase(topicField, alarmTopicSuffix)) { |
| | | return MesCollectMsgTypeEnum.ALARM; |
| | | } |
| | | String suffix = extractTopicSuffix(mqttTopic); |
| | | if (StrUtil.isNotBlank(suffix)) { |
| | | type = MesCollectMsgTypeEnum.getByType(suffix); |
| | | if (type != MesCollectMsgTypeEnum.UNKNOWN) { |
| | | return type; |
| | | } |
| | | if (StrUtil.equalsIgnoreCase(suffix, alarmTopicSuffix)) { |
| | | return MesCollectMsgTypeEnum.ALARM; |
| | | } |
| | | } |
| | | if (data == null) { |
| | | return MesCollectMsgTypeEnum.UNKNOWN; |
| | | } |
| | | if (data.has("wmId")) { |
| | | return MesCollectMsgTypeEnum.ALARM; |
| | | } |
| | | if (data.has("varId")) { |
| | | return MesCollectMsgTypeEnum.OP_LOG; |
| | | } |
| | | if (data.has("CYCN")) { |
| | | return MesCollectMsgTypeEnum.SPC; |
| | | } |
| | | if (data.has("STS") || data.has("OPM")) { |
| | | return MesCollectMsgTypeEnum.REALTIME; |
| | | } |
| | | if (data.has("TS1") || data.has("CP1M")) { |
| | | return MesCollectMsgTypeEnum.TECH; |
| | | } |
| | | return MesCollectMsgTypeEnum.UNKNOWN; |
| | | } |
| | | |
| | | public String resolveDeviceId(JsonNode root, String mqttTopic) { |
| | | String deviceId = getText(root, "devId"); |
| | | if (StrUtil.isNotBlank(deviceId)) { |
| | | return deviceId.trim(); |
| | | } |
| | | String[] parts = mqttTopic == null ? new String[0] : mqttTopic.split("/"); |
| | | return parts.length >= 2 ? parts[parts.length - 2] : null; |
| | | } |
| | | |
| | | /** |
| | | * ç½å
³æ ¼å¼æ¥ææå
ï¼æ¥æé¦å± key æ¯è®¾å¤åï¼value æ¯è¯¥è®¾å¤ç屿§åå
¸ã |
| | | * |
| | | * <p>ä¾å¦ {"630æ¡ç»æº2":{"计米":268.3499}} ææ {630æ¡ç»æº2 -> {"计米":268.3499}}ï¼ |
| | | * è¿æ¥äºä»¶ {"device":"大æ"} è¿ç±»æå¹³æ¥ææ²¡æåµå¥å¯¹è±¡ï¼è¿å空 Map ç±è°ç¨æ¹å¦è¡å¤çã</p> |
| | | */ |
| | | public Map<String, JsonNode> splitGatewayDevices(JsonNode root) { |
| | | Map<String, JsonNode> devices = new LinkedHashMap<>(); |
| | | if (root == null || !root.isObject()) { |
| | | return devices; |
| | | } |
| | | root.properties().forEach(entry -> { |
| | | String deviceCode = StrUtil.trim(entry.getKey()); |
| | | JsonNode data = entry.getValue(); |
| | | if (StrUtil.isBlank(deviceCode) || data == null || !data.isObject()) { |
| | | return; |
| | | } |
| | | devices.put(deviceCode, data); |
| | | }); |
| | | return devices; |
| | | } |
| | | |
| | | /** |
| | | * å䏻颿«æ®µä½ä¸ºæ¥æç±»åï¼å¦ gateway/attributes -> attributesãgateway/disconnect -> disconnect |
| | | */ |
| | | public String extractTopicSuffix(String mqttTopic) { |
| | | if (StrUtil.isBlank(mqttTopic)) { |
| | | return null; |
| | | } |
| | | String[] parts = mqttTopic.split("/"); |
| | | return parts.length == 0 ? null : parts[parts.length - 1]; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.*; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.*; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectAlarmStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectMsgTypeEnum; |
| | | import tools.jackson.databind.JsonNode; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES æ°éæ°æ®è½åº Service |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class MesCollectDataService { |
| | | |
| | | @Resource |
| | | private MesCollectDataParser parser; |
| | | @Resource |
| | | private MesCollectMessageMapper messageMapper; |
| | | @Resource |
| | | private MesCollectRealtimeMapper realtimeMapper; |
| | | @Resource |
| | | private MesCollectRealtimeHistoryMapper realtimeHistoryMapper; |
| | | @Resource |
| | | private MesCollectCycleMapper cycleMapper; |
| | | @Resource |
| | | private MesCollectTechMapper techMapper; |
| | | @Resource |
| | | private MesCollectOperateLogMapper collectOperateLogMapper; |
| | | @Resource |
| | | private MesCollectAlarmMapper alarmMapper; |
| | | |
| | | public Long saveRawMessage(String deviceCode, Long machineryId, String mqttTopic, |
| | | MesCollectMsgTypeEnum msgType, LocalDateTime eventTime, String payload) { |
| | | MesCollectMessageDO message = MesCollectMessageDO.builder() |
| | | .deviceCode(deviceCode).machineryId(machineryId).mqttTopic(mqttTopic) |
| | | .msgType(msgType.getType()).eventTime(eventTime).rawPayload(payload) |
| | | .processStatus(0).receiveTime(LocalDateTime.now()).build(); |
| | | messageMapper.insert(message); |
| | | return message.getId(); |
| | | } |
| | | |
| | | public void markRawMessageFailed(Long id, String error) { |
| | | if (id == null) { |
| | | return; |
| | | } |
| | | messageMapper.updateById(MesCollectMessageDO.builder() |
| | | .id(id).processStatus(1).errorMsg(StrUtil.maxLength(error, 1000)).build()); |
| | | } |
| | | |
| | | public void saveRealtime(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | MesCollectRealtimeDO snapshot = MesCollectRealtimeDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .collectTime(eventTime) |
| | | .sts(parser.getInteger(data, "STS")) |
| | | .opm(parser.getInteger(data, "OPM")) |
| | | .asts(parser.getInteger(data, "ASTS")) |
| | | .ot(parser.getDecimal(data, "OT")) |
| | | .temps(parser.extractNumberedFields(data, "T")) |
| | | .dataJson(data.toString()) |
| | | .build(); |
| | | MesCollectRealtimeDO existing = realtimeMapper.selectByDeviceCode(deviceCode); |
| | | if (existing != null) { |
| | | snapshot.setId(existing.getId()); |
| | | realtimeMapper.updateById(snapshot); |
| | | } else { |
| | | try { |
| | | realtimeMapper.insert(snapshot); |
| | | } catch (DuplicateKeyException e) { |
| | | MesCollectRealtimeDO current = realtimeMapper.selectByDeviceCode(deviceCode); |
| | | if (current != null) { |
| | | snapshot.setId(current.getId()); |
| | | realtimeMapper.updateById(snapshot); |
| | | } |
| | | } |
| | | } |
| | | |
| | | MesCollectRealtimeHistoryDO history = MesCollectRealtimeHistoryDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .collectTime(eventTime) |
| | | .sts(snapshot.getSts()) |
| | | .opm(snapshot.getOpm()) |
| | | .asts(snapshot.getAsts()) |
| | | .ot(snapshot.getOt()) |
| | | .temps(snapshot.getTemps()) |
| | | .dataJson(snapshot.getDataJson()) |
| | | .build(); |
| | | try { |
| | | realtimeHistoryMapper.insert(history); |
| | | } catch (DuplicateKeyException ignored) { |
| | | // åä¸è®¾å¤åä¸ç§çé夿¥æï¼ç´æ¥å¿½ç¥ |
| | | } |
| | | } |
| | | |
| | | public void saveCycle(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | Long cycleNo = parser.getLong(data, "CYCN"); |
| | | MesCollectCycleDO cycle = MesCollectCycleDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .cycleNo(cycleNo == null ? 0L : cycleNo) |
| | | .collectTime(eventTime) |
| | | .ecyct(parser.getDecimal(data, "ECYCT")) |
| | | .eiss(parser.getDecimal(data, "EISS")) |
| | | .eivm(parser.getDecimal(data, "EIVM")) |
| | | .eipm(parser.getDecimal(data, "EIPM")) |
| | | .esipt(parser.getDecimal(data, "ESIPT")) |
| | | .esipp(parser.getDecimal(data, "ESIPP")) |
| | | .esips(parser.getDecimal(data, "ESIPS")) |
| | | .eipt(parser.getDecimal(data, "EIPT")) |
| | | .eipse(parser.getDecimal(data, "EIPSE")) |
| | | .eplst(parser.getDecimal(data, "EPLST")) |
| | | .eplsse(parser.getDecimal(data, "EPLSSE")) |
| | | .eplspm(parser.getDecimal(data, "EPLSPM")) |
| | | .etTemps(parser.extractNumberedFields(data, "ET")) |
| | | .dataJson(data.toString()) |
| | | .build(); |
| | | try { |
| | | cycleMapper.insert(cycle); |
| | | } catch (DuplicateKeyException ignored) { |
| | | // åä¸å¨æéå¤ä¸æ¥ï¼ç´æ¥å¿½ç¥ |
| | | } |
| | | } |
| | | |
| | | public void saveTech(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | MesCollectTechDO tech = MesCollectTechDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .collectTime(eventTime).dataJson(data.toString()).build(); |
| | | MesCollectTechDO existing = techMapper.selectByDeviceCode(deviceCode); |
| | | if (existing != null) { |
| | | tech.setId(existing.getId()); |
| | | techMapper.updateById(tech); |
| | | } else { |
| | | try { |
| | | techMapper.insert(tech); |
| | | } catch (DuplicateKeyException e) { |
| | | MesCollectTechDO current = techMapper.selectByDeviceCode(deviceCode); |
| | | if (current != null) { |
| | | tech.setId(current.getId()); |
| | | techMapper.updateById(tech); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void saveOperateLog(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | LocalDateTime modifyTime = parser.parseTimeText(parser.getText(data, "modifyTime")); |
| | | collectOperateLogMapper.insert(MesCollectOperateLogDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .varId(parser.getText(data, "varId")) |
| | | .oldValue(StrUtil.maxLength(parser.valueToString(data.get("lastValue")), 500)) |
| | | .newValue(StrUtil.maxLength(parser.valueToString(data.get("value")), 500)) |
| | | .modifyTime(modifyTime == null ? eventTime : modifyTime) |
| | | .collectTime(eventTime).dataJson(data.toString()) |
| | | .build()); |
| | | } |
| | | |
| | | public void saveAlarm(String deviceCode, Long machineryId, Long taskId, Long workOrderId, |
| | | LocalDateTime eventTime, JsonNode data) { |
| | | Integer wmId = parser.getInteger(data, "wmId"); |
| | | LocalDateTime wmTime = parser.parseTimeText(parser.getText(data, "wmTime")); |
| | | if (wmTime == null) { |
| | | wmTime = eventTime; |
| | | } |
| | | if (wmId != null && wmId == 0) { |
| | | alarmMapper.clearActiveByDeviceCode(deviceCode, wmTime); |
| | | return; |
| | | } |
| | | alarmMapper.insert(MesCollectAlarmDO.builder() |
| | | .machineryId(machineryId).deviceCode(deviceCode).taskId(taskId).workOrderId(workOrderId) |
| | | .wmId(wmId) |
| | | .wmMsg(StrUtil.maxLength(parser.getText(data, "wmMsg"), 500)) |
| | | .wmTime(wmTime) |
| | | .status(MesCollectAlarmStatusEnum.ACTIVE.getStatus()) |
| | | .collectTime(eventTime).dataJson(data.toString()) |
| | | .build()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectMsgTypeEnum; |
| | | import cn.iocoder.yudao.module.mes.framework.collect.config.MesCollectProperties; |
| | | import tools.jackson.databind.JsonNode; |
| | | import jakarta.annotation.PreDestroy; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Map; |
| | | import java.util.concurrent.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | /** |
| | | * MES æ°éæ¥æååå¨ |
| | | * |
| | | * <p>Paho åè°çº¿ç¨åªè´è´£å
¥éï¼è§£æä¸è½åºå¨å线ç¨ä¸ä¸²è¡æ§è¡ï¼ä¿è¯åä¸è®¾å¤æ¥è¦çç¶ææé¡ºåºå¤çã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class MesCollectMessageDispatcher { |
| | | |
| | | /** |
| | | * ç½å
³æ ¼å¼éæ¿è½½è®¾å¤å±æ§å¿«ç
§ç䏻颿«æ®µ |
| | | */ |
| | | private static final String ATTR_TOPIC_SUFFIX = "attributes"; |
| | | |
| | | @Resource |
| | | private MesCollectProperties properties; |
| | | @Resource |
| | | private MesCollectDataParser parser; |
| | | @Resource |
| | | private MesCollectDataService dataService; |
| | | @Resource |
| | | private MesDvMachineryMapper machineryMapper; |
| | | @Resource |
| | | private MesCollectTaskResolver taskResolver; |
| | | |
| | | private final ExecutorService executor = new ThreadPoolExecutor(1, 1, |
| | | 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(10_000), |
| | | new ThreadFactory() { |
| | | private final AtomicInteger index = new AtomicInteger(); |
| | | |
| | | @Override |
| | | public Thread newThread(Runnable runnable) { |
| | | Thread thread = new Thread(runnable, "mes-collect-dispatch-" + index.incrementAndGet()); |
| | | thread.setDaemon(true); |
| | | return thread; |
| | | } |
| | | }, new ThreadPoolExecutor.CallerRunsPolicy()); |
| | | |
| | | /** |
| | | * è®¾å¤æªç»å®å°è´¦æ¶çåè¦ç¼åï¼é¿å
æ¯æ¡æ¥æéå¤å·æ¥å¿ |
| | | */ |
| | | private final ConcurrentHashMap<String, Long> unboundWarnCache = new ConcurrentHashMap<>(); |
| | | |
| | | public void dispatch(String topic, String payload) { |
| | | executor.execute(() -> process(topic, payload)); |
| | | } |
| | | |
| | | private void process(String topic, String payload) { |
| | | // ç½å
³æ ¼å¼æ¥æç»æå®å
¨ä¸åï¼ä¸»é¢åºå®ã设å¤ä»¥æ¥æé¦å± key åºåï¼ï¼åç¬å¤ç |
| | | if (properties.getMqtt().isGatewayFormat()) { |
| | | processGateway(topic, payload); |
| | | return; |
| | | } |
| | | JsonNode root; |
| | | try { |
| | | root = parser.parsePayload(payload); |
| | | } catch (Exception e) { |
| | | log.warn("[process][主é¢({}) æ¥æä¸æ¯åæ³ JSONï¼{}]", topic, StrUtil.maxLength(payload, 200)); |
| | | dataService.markRawMessageFailed( |
| | | dataService.saveRawMessage(null, null, topic, MesCollectMsgTypeEnum.UNKNOWN, |
| | | LocalDateTime.now(), payload), |
| | | "æ¥æä¸æ¯åæ³ JSONï¼" + e.getMessage()); |
| | | return; |
| | | } |
| | | |
| | | JsonNode data = parser.parseData(root); |
| | | MesCollectMsgTypeEnum msgType = parser.resolveMsgType(parser.getText(root, "topic"), topic, data, |
| | | properties.getMqtt().getAlarmTopicSuffix()); |
| | | String deviceCode = parser.resolveDeviceId(root, topic); |
| | | LocalDateTime eventTime = parser.parseEventTime(root); |
| | | |
| | | MesDvMachineryDO machinery = StrUtil.isBlank(deviceCode) ? null |
| | | : machineryMapper.selectByCollectDeviceCode(deviceCode); |
| | | if (machinery == null && StrUtil.isNotBlank(deviceCode)) { |
| | | warnUnboundDevice(deviceCode); |
| | | } |
| | | Long machineryId = machinery == null ? null : machinery.getId(); |
| | | Long taskId = null; |
| | | Long workOrderId = null; |
| | | if (machinery != null && machinery.getWorkstationId() != null) { |
| | | MesProTaskDO task = taskResolver.resolve(machinery.getWorkstationId()); |
| | | if (task != null) { |
| | | taskId = task.getId(); |
| | | workOrderId = task.getWorkOrderId(); |
| | | } |
| | | } |
| | | |
| | | Long rawId = dataService.saveRawMessage(deviceCode, machineryId, topic, msgType, eventTime, payload); |
| | | try { |
| | | switch (msgType) { |
| | | case REALTIME -> dataService.saveRealtime(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case SPC -> dataService.saveCycle(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case TECH -> dataService.saveTech(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case OP_LOG -> dataService.saveOperateLog(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | case ALARM -> dataService.saveAlarm(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | default -> log.debug("[process][å¿½ç¥æªç¥ç±»åæ¥æï¼ä¸»é¢({})]", topic); |
| | | } |
| | | } catch (Exception e) { |
| | | dataService.markRawMessageFailed(rawId, e.getMessage()); |
| | | log.error("[process][主é¢({}) 设å¤({}) å¤ç失败]", topic, deviceCode, e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ç½å
³æ ¼å¼æ¥æå¤çã |
| | | * |
| | | * <p>attributesï¼æ¥æé¦å± key æ¯è®¾å¤åãvalue æ¯å±æ§åå
¸ï¼æè®¾å¤éå°è½å®æ¶æ°æ®ï¼ |
| | | * connect / disconnectï¼è¿æ¥äºä»¶ï¼åªççä¸è½å®æ¶æ°æ®ï¼ä¾¿äºææ¥è®¾å¤ç¦»çº¿ã</p> |
| | | */ |
| | | private void processGateway(String topic, String payload) { |
| | | JsonNode root; |
| | | try { |
| | | root = parser.parsePayload(payload); |
| | | } catch (Exception e) { |
| | | log.warn("[processGateway][主é¢({}) æ¥æä¸æ¯åæ³ JSONï¼{}]", topic, StrUtil.maxLength(payload, 200)); |
| | | dataService.markRawMessageFailed( |
| | | dataService.saveRawMessage(null, null, topic, MesCollectMsgTypeEnum.UNKNOWN, |
| | | LocalDateTime.now(), payload), |
| | | "æ¥æä¸æ¯åæ³ JSONï¼" + e.getMessage()); |
| | | return; |
| | | } |
| | | |
| | | // è¿æ¥äºä»¶ï¼{"device":"大æ"}ï¼æ²¡æå±æ§åå
¸ |
| | | if (!ATTR_TOPIC_SUFFIX.equalsIgnoreCase(parser.extractTopicSuffix(topic))) { |
| | | String deviceCode = StrUtil.trim(parser.getText(root, "device")); |
| | | MesDvMachineryDO machinery = StrUtil.isBlank(deviceCode) ? null |
| | | : machineryMapper.selectByCollectDeviceCode(deviceCode); |
| | | dataService.saveRawMessage(deviceCode, machinery == null ? null : machinery.getId(), topic, |
| | | MesCollectMsgTypeEnum.getByType(parser.extractTopicSuffix(topic)), |
| | | LocalDateTime.now(), payload); |
| | | return; |
| | | } |
| | | |
| | | Map<String, JsonNode> devices = parser.splitGatewayDevices(root); |
| | | if (devices.isEmpty()) { |
| | | log.debug("[processGateway][主é¢({}) æ¥æéæ²¡æè®¾å¤å±æ§ï¼{}]", topic, StrUtil.maxLength(payload, 200)); |
| | | dataService.saveRawMessage(null, null, topic, MesCollectMsgTypeEnum.UNKNOWN, LocalDateTime.now(), payload); |
| | | return; |
| | | } |
| | | // ç½å
³æ¥æä¸å¸¦æ¶é´æ³ï¼ç»ä¸ææ¥æ¶æ¶é´è½åº |
| | | LocalDateTime eventTime = parser.parseEventTime(root); |
| | | devices.forEach((deviceCode, data) -> { |
| | | MesDvMachineryDO machinery = machineryMapper.selectByCollectDeviceCode(deviceCode); |
| | | if (machinery == null) { |
| | | warnUnboundDevice(deviceCode); |
| | | } |
| | | Long machineryId = machinery == null ? null : machinery.getId(); |
| | | Long taskId = null; |
| | | Long workOrderId = null; |
| | | if (machinery != null && machinery.getWorkstationId() != null) { |
| | | MesProTaskDO task = taskResolver.resolve(machinery.getWorkstationId()); |
| | | if (task != null) { |
| | | taskId = task.getId(); |
| | | workOrderId = task.getWorkOrderId(); |
| | | } |
| | | } |
| | | Long rawId = dataService.saveRawMessage(deviceCode, machineryId, topic, |
| | | MesCollectMsgTypeEnum.REALTIME, eventTime, payload); |
| | | try { |
| | | dataService.saveRealtime(deviceCode, machineryId, taskId, workOrderId, eventTime, data); |
| | | } catch (Exception e) { |
| | | dataService.markRawMessageFailed(rawId, e.getMessage()); |
| | | log.error("[processGateway][主é¢({}) 设å¤({}) å¤ç失败]", topic, deviceCode, e); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void warnUnboundDevice(String deviceCode) { |
| | | long now = System.currentTimeMillis(); |
| | | Long last = unboundWarnCache.get(deviceCode); |
| | | if (last != null && now - last < 60_000L) { |
| | | return; |
| | | } |
| | | unboundWarnCache.put(deviceCode, now); |
| | | log.warn("[process][æ°é设å¤({}) æªç»å®ä»»ä½è®¾å¤å°è´¦ï¼æ°æ®å°æè®¾å¤ç¼å·è½åºï¼machineryId 为空]", deviceCode); |
| | | } |
| | | |
| | | @PreDestroy |
| | | public void destroy() { |
| | | executor.shutdownNow(); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.collect.vo.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.collect.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.collect.*; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectAlarmStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectOperateModeEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.collect.MesCollectRunStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.COLLECT_ALARM_ALREADY_CLEARED; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.COLLECT_ALARM_NOT_EXISTS; |
| | | |
| | | /** |
| | | * MES æ°éæ°æ®æ¥è¯¢ Service å®ç°ç±» |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class MesCollectQueryService { |
| | | |
| | | /** |
| | | * è¶
è¿è¯¥æ¶é¿æªééæ°æ®è§ä¸ºç¦»çº¿ |
| | | */ |
| | | private static final long ONLINE_TIMEOUT_MINUTES = 5L; |
| | | |
| | | @Resource |
| | | private MesDvMachineryMapper machineryMapper; |
| | | @Resource |
| | | private MesCollectRealtimeMapper realtimeMapper; |
| | | @Resource |
| | | private MesCollectRealtimeHistoryMapper realtimeHistoryMapper; |
| | | @Resource |
| | | private MesCollectCycleMapper cycleMapper; |
| | | @Resource |
| | | private MesCollectTechMapper techMapper; |
| | | @Resource |
| | | private MesCollectOperateLogMapper collectOperateLogMapper; |
| | | @Resource |
| | | private MesCollectAlarmMapper alarmMapper; |
| | | @Resource |
| | | private MesProWorkOrderMapper workOrderMapper; |
| | | @Resource |
| | | private MesCollectTaskResolver taskResolver; |
| | | @Resource |
| | | private MesMdWorkstationService workstationService; |
| | | |
| | | /** |
| | | * è·åå·²é
ç½®æ°éç¼ç ç设å¤å®æ¶ç¶æå表 |
| | | */ |
| | | public List<MesCollectDeviceRespVO> getDeviceList() { |
| | | List<MesDvMachineryDO> machineries = machineryMapper.selectListWithCollectDeviceCode(); |
| | | Map<Long, MesMdWorkstationDO> workstationMap = workstationService.getWorkstationMap( |
| | | machineries.stream().map(MesDvMachineryDO::getWorkstationId).filter(Objects::nonNull).toList()); |
| | | return machineries.stream().map(machinery -> { |
| | | MesCollectDeviceRespVO vo = new MesCollectDeviceRespVO(); |
| | | vo.setMachineryId(machinery.getId()); |
| | | vo.setMachineryCode(machinery.getCode()); |
| | | vo.setMachineryName(machinery.getName()); |
| | | vo.setCollectDeviceCode(machinery.getCollectDeviceCode()); |
| | | vo.setCollectEnabled(Boolean.TRUE.equals(machinery.getCollectEnabled())); |
| | | MesMdWorkstationDO workstation = workstationMap.get(machinery.getWorkstationId()); |
| | | if (workstation != null) { |
| | | vo.setWorkstationId(workstation.getId()); |
| | | vo.setWorkstationName(workstation.getName()); |
| | | } |
| | | |
| | | MesCollectRealtimeDO realtime = realtimeMapper.selectByDeviceCode(machinery.getCollectDeviceCode()); |
| | | if (realtime != null) { |
| | | vo.setLastCollectTime(realtime.getCollectTime()); |
| | | vo.setOnline(realtime.getCollectTime() != null |
| | | && realtime.getCollectTime().isAfter(LocalDateTime.now().minusMinutes(ONLINE_TIMEOUT_MINUTES))); |
| | | vo.setSts(realtime.getSts()); |
| | | vo.setStsName(MesCollectRunStatusEnum.getNameByStatus(realtime.getSts())); |
| | | vo.setOpm(realtime.getOpm()); |
| | | vo.setOpmName(MesCollectOperateModeEnum.getNameByMode(realtime.getOpm())); |
| | | vo.setOt(realtime.getOt()); |
| | | vo.setTemps(realtime.getTemps()); |
| | | // ç½å
³æ ¼å¼æ¥æçç»æååæ®µä¸ºç©ºï¼å端ãå½åæ°æ®ãåç´æ¥å±ç¤ºåå§ JSON |
| | | vo.setDataJson(realtime.getDataJson()); |
| | | } else { |
| | | vo.setOnline(false); |
| | | } |
| | | |
| | | MesProTaskDO task = taskResolver.resolve(machinery.getWorkstationId()); |
| | | if (task != null) { |
| | | vo.setTaskId(task.getId()); |
| | | vo.setTaskCode(task.getCode()); |
| | | vo.setTaskName(task.getName()); |
| | | vo.setWorkOrderId(task.getWorkOrderId()); |
| | | MesProWorkOrderDO workOrder = task.getWorkOrderId() != null |
| | | ? workOrderMapper.selectById(task.getWorkOrderId()) : null; |
| | | if (workOrder != null) { |
| | | vo.setWorkOrderCode(workOrder.getCode()); |
| | | } |
| | | } |
| | | vo.setActiveAlarmCount(alarmMapper.selectActiveCountByDeviceCode(machinery.getCollectDeviceCode())); |
| | | return vo; |
| | | }).toList(); |
| | | } |
| | | |
| | | /** |
| | | * è·åæå®æ°é设å¤ç宿¶ç¶æå¿«ç
§ |
| | | */ |
| | | public MesCollectRealtimeRespVO getRealtime(String deviceCode) { |
| | | MesCollectRealtimeDO realtime = realtimeMapper.selectByDeviceCode(deviceCode); |
| | | if (realtime == null) { |
| | | return null; |
| | | } |
| | | MesCollectRealtimeRespVO vo = BeanUtils.toBean(realtime, MesCollectRealtimeRespVO.class); |
| | | vo.setStsName(MesCollectRunStatusEnum.getNameByStatus(realtime.getSts())); |
| | | vo.setOpmName(MesCollectOperateModeEnum.getNameByMode(realtime.getOpm())); |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢å®æ¶ç¶æåå² |
| | | */ |
| | | public PageResult<MesCollectRealtimeRespVO> getRealtimeHistoryPage(MesCollectRealtimeHistoryPageReqVO reqVO) { |
| | | PageResult<MesCollectRealtimeHistoryDO> pageResult = realtimeHistoryMapper.selectPage(reqVO); |
| | | PageResult<MesCollectRealtimeRespVO> result = BeanUtils.toBean(pageResult, MesCollectRealtimeRespVO.class); |
| | | result.getList().forEach(vo -> { |
| | | vo.setStsName(MesCollectRunStatusEnum.getNameByStatus(vo.getSts())); |
| | | vo.setOpmName(MesCollectOperateModeEnum.getNameByMode(vo.getOpm())); |
| | | }); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢å¨æè¿ç¨æ°æ® |
| | | */ |
| | | public PageResult<MesCollectCycleRespVO> getCyclePage(MesCollectCyclePageReqVO reqVO) { |
| | | return BeanUtils.toBean(cycleMapper.selectPage(reqVO), MesCollectCycleRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * è·å忡卿è¿ç¨æ°æ® |
| | | */ |
| | | public MesCollectCycleRespVO getCycle(Long id) { |
| | | MesCollectCycleDO cycle = cycleMapper.selectById(id); |
| | | return cycle == null ? null : BeanUtils.toBean(cycle, MesCollectCycleRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * è·åæå®æ°é设å¤çææ°å·¥èºåæ°å¿«ç
§ |
| | | */ |
| | | public MesCollectTechRespVO getTech(String deviceCode) { |
| | | MesCollectTechDO tech = techMapper.selectByDeviceCode(deviceCode); |
| | | return tech == null ? null : BeanUtils.toBean(tech, MesCollectTechRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢åæ°åæ´æ¥å¿ |
| | | */ |
| | | public PageResult<MesCollectOperateLogRespVO> getOperateLogPage(MesCollectOperateLogPageReqVO reqVO) { |
| | | return BeanUtils.toBean(collectOperateLogMapper.selectPage(reqVO), MesCollectOperateLogRespVO.class); |
| | | } |
| | | |
| | | /** |
| | | * å页æ¥è¯¢æ¥è¦è®°å½ |
| | | */ |
| | | public PageResult<MesCollectAlarmRespVO> getAlarmPage(MesCollectAlarmPageReqVO reqVO) { |
| | | PageResult<MesCollectAlarmDO> pageResult = alarmMapper.selectPage(reqVO); |
| | | PageResult<MesCollectAlarmRespVO> result = BeanUtils.toBean(pageResult, MesCollectAlarmRespVO.class); |
| | | result.getList().forEach(vo -> vo.setStatusName(MesCollectAlarmStatusEnum.ACTIVE.getStatus().equals(vo.getStatus()) |
| | | ? MesCollectAlarmStatusEnum.ACTIVE.getName() : MesCollectAlarmStatusEnum.CLEARED.getName())); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 人工确认æ¶é¤æ¥è¦ |
| | | */ |
| | | public void ackAlarm(Long id) { |
| | | MesCollectAlarmDO alarm = alarmMapper.selectById(id); |
| | | if (alarm == null) { |
| | | throw exception(COLLECT_ALARM_NOT_EXISTS); |
| | | } |
| | | if (MesCollectAlarmStatusEnum.CLEARED.getStatus().equals(alarm.getStatus())) { |
| | | throw exception(COLLECT_ALARM_ALREADY_CLEARED); |
| | | } |
| | | MesCollectAlarmDO updateObj = new MesCollectAlarmDO(); |
| | | updateObj.setId(id); |
| | | updateObj.setStatus(MesCollectAlarmStatusEnum.CLEARED.getStatus()); |
| | | updateObj.setClearTime(LocalDateTime.now()); |
| | | alarmMapper.updateById(updateObj); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.collect; |
| | | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.task.MesProTaskMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * MES æ°é-ç产任å¡å
³èè§£æ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class MesCollectTaskResolver { |
| | | |
| | | private static final long CACHE_MILLIS = 30_000L; |
| | | |
| | | @Resource |
| | | private MesProTaskMapper taskMapper; |
| | | |
| | | private final ConcurrentHashMap<Long, CachedTask> cache = new ConcurrentHashMap<>(); |
| | | |
| | | /** |
| | | * æ¥è¯¢å·¥ä½ç«ä¸æ£å¨è¿è¡çç产任å¡ï¼ç产ä¸/é¨å宿/å·²åå·¥ï¼ |
| | | */ |
| | | public MesProTaskDO resolve(Long workstationId) { |
| | | if (workstationId == null) { |
| | | return null; |
| | | } |
| | | long now = System.currentTimeMillis(); |
| | | CachedTask cached = cache.get(workstationId); |
| | | if (cached != null && now - cached.time < CACHE_MILLIS) { |
| | | return cached.task; |
| | | } |
| | | MesProTaskDO task = taskMapper.selectRunningTaskByWorkstationId(workstationId); |
| | | cache.put(workstationId, new CachedTask(task, now)); |
| | | return task; |
| | | } |
| | | |
| | | private record CachedTask(MesProTaskDO task, long time) { |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.dv.spare; |
| | | |
| | | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.spare.vo.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.spare.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.dv.spare.*; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.dv.repair.MesDvRepairMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairStatusEnum; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.*; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | |
| | | /** å¤ä»¶åºååªéè¿çççæµæ°´åæ´ï¼å
æ°æ®ç¼è¾ä¸å
许è¦çåºåã */ |
| | | @Service |
| | | public class MesDvSpareService { |
| | | private static final ErrorCode INVALID = new ErrorCode(1_040_807_001, "å¤ä»¶æä½å¤±è´¥ï¼{}"); |
| | | private static final BigDecimal MAX_QUANTITY = new BigDecimal("999999999999999.999"); |
| | | @Resource private MesDvSparePartMapper partMapper; |
| | | @Resource private MesDvSpareMovementMapper movementMapper; |
| | | @Resource private MesDvRepairMapper repairMapper; |
| | | @Resource private MesDvMachineryMapper machineryMapper; |
| | | @Resource private AdminUserApi adminUserApi; |
| | | |
| | | @Transactional(rollbackFor=Exception.class, isolation=Isolation.READ_COMMITTED) |
| | | public Long create(MesDvSparePartSaveReqVO req, Long operator) { |
| | | validateMetadata(req); |
| | | MesDvSparePartDO part = BeanUtils.toBean(req,MesDvSparePartDO.class); |
| | | part.setStockQuantity(req.getInitialQuantity()); |
| | | partMapper.insert(part); |
| | | if (req.getInitialQuantity().signum()>0) { |
| | | writeMovement(part,1,req.getInitialQuantity(),BigDecimal.ZERO,null,null,null,operator, |
| | | "opening-"+UUID.randomUUID(),"ç»è®°åå§åºå"); |
| | | } |
| | | return part.getId(); |
| | | } |
| | | @Transactional(rollbackFor=Exception.class, isolation=Isolation.READ_COMMITTED) |
| | | public void update(MesDvSparePartSaveReqVO req) { |
| | | MesDvSparePartDO part = requirePart(req.getId()); |
| | | validateMetadata(req); |
| | | MesDvSparePartDO changes = BeanUtils.toBean(req,MesDvSparePartDO.class); |
| | | changes.setStockQuantity(part.getStockQuantity()); |
| | | partMapper.updateById(changes); |
| | | } |
| | | private void validateMetadata(MesDvSparePartSaveReqVO req) { |
| | | req.setCode(req.getCode().trim()); |
| | | req.setName(req.getName().trim()); |
| | | req.setUnit(req.getUnit().trim()); |
| | | if (req.getCode().isEmpty() || req.getName().isEmpty() || req.getUnit().isEmpty()) fail("ç¼ç ãåç§°ååä½ä¸è½ä¸ºç©º"); |
| | | var old=partMapper.selectOne(MesDvSparePartDO::getCode,req.getCode()); |
| | | if(old!=null&&!Objects.equals(old.getId(),req.getId())) fail("å¤ä»¶ç¼ç å·²åå¨"); |
| | | if(req.getId()!=null && movementMapper.selectCount(MesDvSpareMovementDO::getSparePartId,req.getId())>0) { |
| | | var saved=partMapper.selectById(req.getId()); |
| | | if(!Objects.equals(saved.getUnit(),req.getUnit())) fail("å·²æåºåæµæ°´çå¤ä»¶ä¸è½ä¿®æ¹è®¡éåä½"); |
| | | } |
| | | } |
| | | @Transactional(rollbackFor=Exception.class, isolation=Isolation.READ_COMMITTED) |
| | | public void delete(Long id) { |
| | | var part=requirePart(id); |
| | | if(part.getStockQuantity().signum()!=0 || movementMapper.selectCount(MesDvSpareMovementDO::getSparePartId,id)>0) |
| | | fail("æåºåæå·²ææµæ°´çå¤ä»¶ä¸è½å é¤ï¼è¯·åç¨"); |
| | | partMapper.deleteById(id); |
| | | } |
| | | public MesDvSparePartDO get(Long id) { return partMapper.selectById(id); } |
| | | public PageResult<MesDvSparePartDO> page(MesDvSparePageReqVO req) { return partMapper.page(req); } |
| | | public PageResult<MesDvSpareMovementRespVO> movements(MesDvSparePageReqVO req) { |
| | | var page=movementMapper.page(req); |
| | | var ids=page.getList().stream().filter(m->m.getType()==3).map(MesDvSpareMovementDO::getId).toList(); |
| | | Map<Long,BigDecimal> totals=new HashMap<>(); |
| | | movementMapper.returns(ids).forEach(m->totals.merge(m.getOriginalId(),m.getQuantity(),BigDecimal::add)); |
| | | return new PageResult<>(page.getList().stream().map(m-> { |
| | | var vo=BeanUtils.toBean(m,MesDvSpareMovementRespVO.class); |
| | | vo.setReturnedQuantity(totals.getOrDefault(m.getId(),BigDecimal.ZERO)); |
| | | vo.setReturnableQuantity(m.getType()==3?m.getQuantity().subtract(vo.getReturnedQuantity()):BigDecimal.ZERO); |
| | | return vo; |
| | | }).toList(),page.getTotal()); |
| | | } |
| | | @Transactional(rollbackFor=Exception.class, isolation=Isolation.READ_COMMITTED) |
| | | public Long receive(MesDvSpareActionReqVO req,Long operator) { |
| | | validateAction(req); |
| | | var part=requirePart(req.getSparePartId()); |
| | | Long prior=duplicate(req,2,operator,part.getId(),null,null,null); |
| | | if(prior!=null)return prior; |
| | | requireEnabled(part); |
| | | var before=part.getStockQuantity(); |
| | | changeStock(part,req.getQuantity()); |
| | | return writeMovement(part,2,req.getQuantity(),before,null,null,null,operator,req.getRequestKey(),req.getRemark()); |
| | | } |
| | | @Transactional(rollbackFor=Exception.class, isolation=Isolation.READ_COMMITTED) |
| | | public Long issue(MesDvSpareActionReqVO req,Long operator) { |
| | | validateAction(req); |
| | | if(req.getRepairId()==null || req.getSparePartId()==null || req.getReceiverUserId()==null) fail("è¯·éæ©ç»´ä¿®åãå¤ä»¶åé¢ç¨äºº"); |
| | | // ä¸ç»´ä¿®ç¶ææµè½¬ä½¿ç¨åä¸è¡éï¼å
ç»´ä¿®ååå¤ä»¶ï¼ä¿æä¸è´éåºã |
| | | var repair=repairMapper.lockForSpare(req.getRepairId()); |
| | | if(repair==null)fail("ç»´ä¿®åä¸åå¨"); |
| | | var part=requirePart(req.getSparePartId()); |
| | | Long prior=duplicate(req,3,operator,part.getId(),repair.getId(),null,req.getReceiverUserId()); |
| | | if(prior!=null)return prior; |
| | | if(!Objects.equals(repair.getStatus(),MesDvRepairStatusEnum.PREPARE.getStatus()) && |
| | | !Objects.equals(repair.getStatus(),MesDvRepairStatusEnum.CONFIRMED.getStatus())) |
| | | fail("ä»
è稿æç»´ä¿®ä¸çç»´ä¿®åå¯ä»¥é¢ç¨å¤ä»¶"); |
| | | requireEnabled(part); |
| | | var receiver=adminUserApi.getUser(req.getReceiverUserId()); |
| | | if(receiver==null || !Objects.equals(receiver.getStatus(),0))fail("é¢ç¨äººä¸å卿已åç¨"); |
| | | var before=part.getStockQuantity(); |
| | | changeStock(part,req.getQuantity().negate()); |
| | | return writeMovement(part,3,req.getQuantity(),before,repair,null,req.getReceiverUserId(), |
| | | operator,req.getRequestKey(),req.getRemark()); |
| | | } |
| | | @Transactional(rollbackFor=Exception.class, isolation=Isolation.READ_COMMITTED) |
| | | public Long returnPart(MesDvSpareActionReqVO req,Long operator) { |
| | | validateAction(req); |
| | | if(req.getOriginalId()==null)fail("è¯·éæ©åé¢ç¨è®°å½"); |
| | | var original=movementMapper.lock(req.getOriginalId()); |
| | | if(original==null || original.getType()!=3)fail("åé¢ç¨è®°å½ä¸åå¨"); |
| | | var part=requirePart(original.getSparePartId()); |
| | | Long prior=duplicate(req,4,operator,part.getId(),original.getRepairId(),original.getId(),original.getReceiverUserId()); |
| | | if(prior!=null)return prior; |
| | | BigDecimal returned=movementMapper.returns(List.of(original.getId())).stream() |
| | | .map(MesDvSpareMovementDO::getQuantity).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if(returned.add(req.getQuantity()).compareTo(original.getQuantity())>0)fail("éåæ°éè¶
è¿å°æªéåçé¢ç¨æ°é"); |
| | | var before=part.getStockQuantity(); |
| | | changeStock(part,req.getQuantity()); // å·²åç¨å¤ä»¶ä»å
许éåã |
| | | var record=snapshot(part,4,req.getQuantity(),before,operator,req.getRequestKey(),req.getRemark()); |
| | | record.setOriginalId(original.getId()); |
| | | record.setRepairId(original.getRepairId()); record.setRepairCode(original.getRepairCode()); |
| | | record.setMachineryId(original.getMachineryId()); record.setMachineryName(original.getMachineryName()); |
| | | record.setReceiverUserId(original.getReceiverUserId()); record.setReceiverName(original.getReceiverName()); |
| | | movementMapper.insert(record); |
| | | return record.getId(); |
| | | } |
| | | private Long duplicate(MesDvSpareActionReqVO req,int type,Long operator,Long partId,Long repairId,Long originalId,Long receiverId) { |
| | | var old=movementMapper.byKey(req.getRequestKey()); |
| | | if(old==null)return null; |
| | | if(old.getType()!=type || !Objects.equals(old.getOperatorUserId(),operator) |
| | | || !Objects.equals(old.getSparePartId(),partId) || !Objects.equals(old.getRepairId(),repairId) |
| | | || !Objects.equals(old.getOriginalId(),originalId) || !Objects.equals(old.getReceiverUserId(),receiverId) |
| | | || old.getQuantity().compareTo(req.getQuantity())!=0 || !Objects.equals(old.getRemark(),req.getRemark())) |
| | | fail("è¯·æ±æ è¯å·²ç¨äºå
¶ä»æä½ï¼è¯·å·æ°åéè¯"); |
| | | return old.getId(); |
| | | } |
| | | private void validateAction(MesDvSpareActionReqVO req) { |
| | | if(req.getQuantity()==null || req.getQuantity().signum()<=0 || req.getQuantity().scale()>3 |
| | | || req.getQuantity().compareTo(MAX_QUANTITY)>0)fail("æ°éå¿
须大äº0ï¼æå¤ä¸ä½å°æ°"); |
| | | if(req.getRemark()==null || req.getRemark().trim().isEmpty())fail("请填åæä½è¯´æ"); |
| | | } |
| | | private MesDvSparePartDO requirePart(Long id) { |
| | | if(id==null)fail("è¯·éæ©å¤ä»¶"); |
| | | var part=partMapper.lock(id); |
| | | if(part==null)fail("å¤ä»¶ä¸åå¨"); |
| | | return part; |
| | | } |
| | | private void requireEnabled(MesDvSparePartDO part) { if(!Objects.equals(part.getStatus(),0))fail("å¤ä»¶å·²åç¨"); } |
| | | private void changeStock(MesDvSparePartDO part,BigDecimal delta) { |
| | | var after=part.getStockQuantity().add(delta); |
| | | if(after.signum()<0)fail("åºåä¸è¶³ï¼å½åå¯ç¨ï¼"+part.getStockQuantity()+part.getUnit()); |
| | | if(after.compareTo(MAX_QUANTITY)>0)fail("åºåæ°éè¶
åºç³»ç»å
许èå´"); |
| | | part.setStockQuantity(after); |
| | | partMapper.updateById(new MesDvSparePartDO().setId(part.getId()).setStockQuantity(after)); |
| | | } |
| | | private MesDvSpareMovementDO snapshot(MesDvSparePartDO part,int type,BigDecimal qty,BigDecimal before, |
| | | Long operator,String key,String remark) { |
| | | return new MesDvSpareMovementDO().setRequestKey(key).setSparePartId(part.getId()) |
| | | .setSparePartCode(part.getCode()).setSparePartName(part.getName()).setSpecification(part.getSpecification()) |
| | | .setUnit(part.getUnit()).setType(type).setQuantity(qty).setBeforeQuantity(before) |
| | | .setAfterQuantity(part.getStockQuantity()).setOperatorUserId(operator).setRemark(remark); |
| | | } |
| | | private Long writeMovement(MesDvSparePartDO part,int type,BigDecimal qty,BigDecimal before,MesDvRepairDO repair, |
| | | Long original,Long receiver,Long operator,String key,String remark) { |
| | | var record=snapshot(part,type,qty,before,operator,key,remark).setOriginalId(original).setReceiverUserId(receiver); |
| | | if(receiver!=null)record.setReceiverName(adminUserApi.getUser(receiver).getNickname()); |
| | | if(repair!=null) { |
| | | var machine=machineryMapper.selectById(repair.getMachineryId()); |
| | | if(machine==null)fail("维修设å¤ä¸åå¨"); |
| | | record.setRepairId(repair.getId()).setRepairCode(repair.getCode()).setMachineryId(machine.getId()).setMachineryName(machine.getName()); |
| | | } |
| | | movementMapper.insert(record); |
| | | return record.getId(); |
| | | } |
| | | private static void fail(String reason) { throw exception(INVALID,reason); } |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.event.*; |
| | | |
| | | @Component @Slf4j |
| | | public class EnergyAlertListener { |
| | | @Resource private EnergyAlertService energyAlertService; |
| | | |
| | | @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) |
| | | public void onRecordChanged(EnergyRecordChangedEvent event) { |
| | | TenantUtils.execute(event.tenantId(), () -> { |
| | | for (var date : event.dates()) { |
| | | try { energyAlertService.check(date); } |
| | | catch (Exception e) { log.error("è½èé¢è¦æ£æ¥å¤±è´¥ tenant={} date={}", event.tenantId(), date, e); } |
| | | } |
| | | }); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| | | import cn.iocoder.yudao.framework.common.pojo.*; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.energy.vo.EnergyAlertRuleSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.energy.*; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.energy.*; |
| | | import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; |
| | | import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; |
| | | import cn.iocoder.yudao.module.system.service.user.AdminUserService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.*; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | |
| | | @Service @Slf4j |
| | | public class EnergyAlertService { |
| | | @Resource private EnergyAlertRuleMapper energyAlertRuleMapper; |
| | | @Resource private EnergyAlertLogMapper energyAlertLogMapper; |
| | | @Resource private EnergyRecordMapper energyRecordMapper; |
| | | @Resource private AdminUserService adminUserService; |
| | | @Resource private NotifyMessageSendApi notifyMessageSendApi; |
| | | |
| | | public PageResult<EnergyAlertRuleDO> page(PageParam page) { |
| | | return energyAlertRuleMapper.selectPage(page, new LambdaQueryWrapperX<EnergyAlertRuleDO>().orderByDesc(EnergyAlertRuleDO::getId)); |
| | | } |
| | | public PageResult<EnergyAlertLogDO> logs(PageParam page, LocalDate date, String status) { |
| | | return energyAlertLogMapper.selectPage(page, new LambdaQueryWrapperX<EnergyAlertLogDO>() |
| | | .eqIfPresent(EnergyAlertLogDO::getStatus, status) |
| | | .and(date != null, w -> w.and(day -> day.eq(EnergyAlertLogDO::getPeriodType, "DAY").eq(EnergyAlertLogDO::getRecordDate, date)) |
| | | .or(month -> month.eq(EnergyAlertLogDO::getPeriodType, "MONTH").eq(EnergyAlertLogDO::getRecordDate, date.withDayOfMonth(1)))) |
| | | .orderByDesc(EnergyAlertLogDO::getId)); |
| | | } |
| | | public Long save(EnergyAlertRuleSaveReqVO req) { |
| | | if (req.getId() != null) get(req.getId()); |
| | | adminUserService.validateUserList(req.getRecipientIds()); |
| | | EnergyAlertRuleDO rule = BeanUtils.toBean(req, EnergyAlertRuleDO.class); |
| | | rule.setName(req.getName().trim()); |
| | | rule.setUsageArea(req.getUsageArea() == null ? "" : req.getUsageArea().trim()); |
| | | rule.setProductCategory(req.getProductCategory() == null ? "" : req.getProductCategory().trim()); |
| | | rule.setRecipientIds(req.getRecipientIds().stream().distinct().map(String::valueOf).collect(Collectors.joining(","))); |
| | | if (rule.getId() == null) energyAlertRuleMapper.insert(rule); |
| | | else if (energyAlertRuleMapper.updateById(rule) == 0) throw missing(); |
| | | return rule.getId(); |
| | | } |
| | | public void delete(Long id) { |
| | | get(id); |
| | | if (energyAlertRuleMapper.deleteById(id) == 0) throw missing(); |
| | | } |
| | | private EnergyAlertRuleDO get(Long id) { |
| | | var rule = energyAlertRuleMapper.selectById(id); |
| | | if (rule == null) throw missing(); |
| | | return rule; |
| | | } |
| | | private RuntimeException missing() { return exception(new ErrorCode(1_040_951_000, "è½èé¢è¦è§åä¸åå¨")); } |
| | | |
| | | /** Check the selected day and its calendar month; successful sends commit with their history. */ |
| | | @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED, rollbackFor = Exception.class) |
| | | public Map<String, Integer> check(LocalDate date) { |
| | | int sent = 0, failed = 0; |
| | | var rules = energyAlertRuleMapper.selectList(new LambdaQueryWrapperX<EnergyAlertRuleDO>() |
| | | .eq(EnergyAlertRuleDO::getEnabled, true).orderByAsc(EnergyAlertRuleDO::getId)); |
| | | for (var candidate : rules) { |
| | | var rule = energyAlertRuleMapper.lock(candidate.getId()); |
| | | if (rule == null || !Boolean.TRUE.equals(rule.getEnabled())) continue; |
| | | boolean monthly = rule.getMetric().startsWith("MONTH_"); |
| | | LocalDate periodDate = monthly ? date.withDayOfMonth(1) : date; |
| | | String periodType = monthly ? "MONTH" : "DAY"; |
| | | boolean amount = rule.getMetric().endsWith("AMOUNT"); |
| | | BigDecimal actual = energyRecordMapper.selectDailyValue(periodDate, rule); |
| | | if (!exceeds(actual, rule.getThreshold())) continue; |
| | | for (String id : rule.getRecipientIds().split(",")) { |
| | | long recipient = Long.parseLong(id); |
| | | var log = energyAlertLogMapper.selectOne(new LambdaQueryWrapperX<EnergyAlertLogDO>() |
| | | .eq(EnergyAlertLogDO::getRuleId, rule.getId()).eq(EnergyAlertLogDO::getRecordDate, periodDate) |
| | | .eq(EnergyAlertLogDO::getPeriodType, periodType) |
| | | .eq(EnergyAlertLogDO::getRecipientId, recipient)); |
| | | if (log != null && "SENT".equals(log.getStatus())) continue; |
| | | if (log == null) log = new EnergyAlertLogDO(); |
| | | log.setRuleId(rule.getId()); log.setRuleName(rule.getName()); log.setRecordDate(periodDate); log.setPeriodType(periodType); |
| | | log.setEnergyType(rule.getEnergyType()); log.setMetric(rule.getMetric()); |
| | | log.setScope((rule.getUsageArea().isEmpty() ? "å
¨é¨åºå" : rule.getUsageArea()) + " / " |
| | | + (rule.getProductCategory().isEmpty() ? "å
¨é¨äº§å" : rule.getProductCategory())); |
| | | log.setActualValue(actual); log.setThreshold(rule.getThreshold()); log.setRecipientId(recipient); |
| | | log.setRecipientName(String.valueOf(recipient)); |
| | | try { |
| | | adminUserService.validateUserList(List.of(recipient)); |
| | | log.setRecipientName(adminUserService.getUser(recipient).getNickname()); |
| | | NotifySendSingleToUserReqDTO message = new NotifySendSingleToUserReqDTO(); |
| | | message.setUserId(recipient); message.setTemplateCode(monthly ? "energy_monthly_warning" : "energy_daily_warning"); |
| | | message.setTemplateParams(Map.of("ruleName", rule.getName(), "date", monthly ? java.time.YearMonth.from(date).toString() : date.toString(), |
| | | "energyName", energyName(rule.getEnergyType()), "scope", log.getScope(), |
| | | "metricName", amount ? "è´¹ç¨" : "ç¨é", |
| | | "actual", actual.toPlainString(), "threshold", rule.getThreshold().toPlainString(), |
| | | "unit", amount ? "å
" : unit(rule.getEnergyType()))); |
| | | Long messageId = notifyMessageSendApi.sendSingleMessageToAdmin(message); |
| | | if (messageId == null) throw new IllegalStateException("è½èé¢è¦éç¥æ¨¡æ¿å·²åç¨"); |
| | | log.setMessageId(messageId); log.setStatus("SENT"); log.setErrorMessage(""); sent++; |
| | | } catch (Exception e) { |
| | | logFailure(rule.getId(), date, recipient, e); |
| | | log.setStatus("FAILED"); |
| | | log.setErrorMessage("åé失败ï¼è¯·æ£æ¥æ¥æ¶äººæ¯å¦å¯ç¨ä»¥åéç¥æ¨¡æ¿ " + (monthly ? "energy_monthly_warning" : "energy_daily_warning") + " æ¯å¦å¯ç¨ï¼ç¶åéæ°æ£æ¥è¯¥æ¥æã"); |
| | | failed++; |
| | | } |
| | | if (log.getId() == null) energyAlertLogMapper.insert(log); else energyAlertLogMapper.updateById(log); |
| | | } |
| | | } |
| | | return Map.of("sent", sent, "failed", failed); |
| | | } |
| | | private void logFailure(Long ruleId, LocalDate date, long recipient, Exception cause) { |
| | | log.warn("è½èé¢è¦ç«å
éç¥åé失败 rule={} date={} recipient={}", ruleId, date, recipient, cause); |
| | | } |
| | | static boolean exceeds(BigDecimal actual, BigDecimal threshold) { return actual != null && actual.compareTo(threshold) > 0; } |
| | | public static String energyName(String type) { return switch (type) { case "WATER" -> "æ°´"; case "ELECTRICITY" -> "çµ"; default -> "è¸æ±½"; }; } |
| | | public static String unit(String type) { return switch (type) { case "WATER" -> "m³"; case "ELECTRICITY" -> "kWh"; default -> "t"; }; } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.energy; |
| | | |
| | | import cn.idev.excel.FastExcelFactory; |
| | | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| | | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.handler.ColumnWidthMatchStyleStrategy; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.energy.vo.*; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.springframework.stereotype.Service; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | |
| | | @Service |
| | | public class EnergyExportService { |
| | | @Resource private EnergyRecordService energyRecordService; |
| | | public void records(EnergyRecordPageReqVO req, HttpServletResponse response) throws IOException { |
| | | req.setPageNo(1); req.setPageSize(50_001); |
| | | var page = energyRecordService.page(req); |
| | | if (page.getTotal() > 50_000) throw exception(new ErrorCode(1_040_952_000, "忬¡æå¤å¯¼åº50000æ¡ï¼è¯·ç¼©å°æ¥æèå´")); |
| | | List<List<Object>> rows = page.getList().stream().map(r -> Arrays.<Object>asList(r.getRecordDate().toString(), |
| | | EnergyAlertService.energyName(r.getEnergyType()), r.getUsageArea(), r.getProductCategory(), r.getUsagePurpose(), |
| | | EnergyAlertService.unit(r.getEnergyType()), r.getQuantity(), r.getUnitPrice(), r.getAmount(), r.getRecorder(), r.getRemark())).toList(); |
| | | write(response, "è½èå°è´¦.xlsx", List.of(new Sheet("è½èå°è´¦", |
| | | List.of("æ¥æ", "è½æº", "使ç¨åºå", "产åç±»å«", "ç¨é", "ç¨éåä½", "ç¨é", "åä»·ï¼å
/åä½ï¼", "è´¹ç¨ï¼å
ï¼", "å½å
¥äºº", "夿³¨"), rows))); |
| | | } |
| | | public void analysis(EnergyAnalysisReqVO req, HttpServletResponse response) throws IOException { |
| | | var data = energyRecordService.analysis(req); |
| | | var head = List.of("ç»è®¡é¡¹", "è½æº", "ç¨éåä½", "ç¨é", "è´¹ç¨ï¼å
ï¼", "å½å
¥æ¡æ°"); |
| | | List<List<Object>> summary = data.getSummary().stream().map(r -> row("å计", r)).toList(); |
| | | List<List<Object>> trend = data.getTrend().stream().map(r -> row(r.getLabel(), r)).toList(); |
| | | List<List<Object>> areas = data.getAreas().stream().map(r -> row(r.getLabel(), r)).toList(); |
| | | List<List<Object>> scope = List.of(Arrays.asList("å¼å§æ¥æ", req.getStartDate().toString()), |
| | | Arrays.asList("ç»ææ¥æ", req.getEndDate().toString()), Arrays.asList("æ±æ»æ¹å¼", "MONTH".equals(req.getGroupBy()) ? "ææ" : "ææ¥"), |
| | | Arrays.asList("è½æº", req.getEnergyType() == null || req.getEnergyType().isEmpty() ? "å
¨é¨" : EnergyAlertService.energyName(req.getEnergyType())), |
| | | Arrays.asList("åºåå
³é®è¯", Objects.toString(req.getUsageArea(), "")), Arrays.asList("产åç±»å«", Objects.toString(req.getProductCategory(), "")), |
| | | Arrays.asList("æ»è´¹ç¨ï¼å
ï¼", data.getTotalAmount()), Arrays.asList("å½å
¥æ¡æ°", data.getRecordCount())); |
| | | write(response, "è½èåæ.xlsx", List.of(new Sheet("ç»è®¡å£å¾", List.of("项ç®", "å
容"), scope), |
| | | new Sheet("è½æºæ±æ»", head, summary), new Sheet("æ¥æè¶å¿", head, trend), new Sheet("åºåæ±æ»", head, areas))); |
| | | } |
| | | private List<Object> row(String label, EnergyAnalysisRespVO.Summary r) { |
| | | return Arrays.asList(label, EnergyAlertService.energyName(r.getEnergyType()), EnergyAlertService.unit(r.getEnergyType()), r.getQuantity(), r.getAmount(), r.getRecordCount()); |
| | | } |
| | | private record Sheet(String name, List<String> headers, List<List<Object>> rows) {} |
| | | private void write(HttpServletResponse response, String filename, List<Sheet> sheets) throws IOException { |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename)); |
| | | try (var writer = FastExcelFactory.write(response.getOutputStream()).autoCloseStream(false) |
| | | .registerWriteHandler(new ColumnWidthMatchStyleStrategy()).build()) { |
| | | for (int i = 0; i < sheets.size(); i++) { |
| | | var sheet = sheets.get(i); |
| | | writer.write(sheet.rows(), FastExcelFactory.writerSheet(i, sheet.name()) |
| | | .head(sheet.headers().stream().map(List::of).toList()).build()); |
| | | } |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.energy; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.Set; |
| | | |
| | | public record EnergyRecordChangedEvent(Long tenantId, Set<LocalDate> dates) {} |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.energy; |
| | | |
| | | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.energy.vo.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.energy.EnergyRecordDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.energy.EnergyRecordMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; |
| | | import java.util.Set; |
| | | import java.math.RoundingMode; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | |
| | | @Service |
| | | public class EnergyRecordService { |
| | | private static final ErrorCode NOT_EXISTS = new ErrorCode(1_040_950_000, "è½èè®°å½ä¸å卿已å é¤"); |
| | | private static final ErrorCode ID_REQUIRED = new ErrorCode(1_040_950_001, "ä¿®æ¹è½èè®°å½å¿
é¡»æä¾ç¼å·"); |
| | | @Resource |
| | | private EnergyRecordMapper recordMapper; |
| | | @Resource private ApplicationEventPublisher applicationEventPublisher; |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long create(EnergyRecordSaveReqVO req) { |
| | | EnergyRecordDO record = toRecord(req); |
| | | record.setId(null); |
| | | recordMapper.insert(record); |
| | | applicationEventPublisher.publishEvent(new EnergyRecordChangedEvent(TenantContextHolder.getTenantId(), Set.of(record.getRecordDate()))); |
| | | return record.getId(); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(EnergyRecordSaveReqVO req) { |
| | | if (req.getId() == null) { |
| | | throw exception(ID_REQUIRED); |
| | | } |
| | | EnergyRecordDO old = get(req.getId()); |
| | | if (recordMapper.updateById(toRecord(req)) == 0) { |
| | | throw exception(NOT_EXISTS); |
| | | } |
| | | var dates = new java.util.HashSet<>(Set.of(old.getRecordDate())); |
| | | dates.add(req.getRecordDate()); |
| | | applicationEventPublisher.publishEvent(new EnergyRecordChangedEvent(TenantContextHolder.getTenantId(), Set.copyOf(dates))); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(Long id) { |
| | | EnergyRecordDO old = get(id); |
| | | if (recordMapper.deleteById(id) == 0) { |
| | | throw exception(NOT_EXISTS); |
| | | } |
| | | applicationEventPublisher.publishEvent(new EnergyRecordChangedEvent(TenantContextHolder.getTenantId(), Set.of(old.getRecordDate()))); |
| | | } |
| | | |
| | | public EnergyRecordDO get(Long id) { |
| | | EnergyRecordDO record = recordMapper.selectById(id); |
| | | if (record == null) { |
| | | throw exception(NOT_EXISTS); |
| | | } |
| | | return record; |
| | | } |
| | | |
| | | public PageResult<EnergyRecordDO> page(EnergyRecordPageReqVO req) { |
| | | return recordMapper.selectPage(req); |
| | | } |
| | | |
| | | static EnergyRecordDO toRecord(EnergyRecordSaveReqVO req) { |
| | | EnergyRecordDO record = BeanUtils.toBean(req, EnergyRecordDO.class); |
| | | record.setUsageArea(req.getUsageArea().trim()); |
| | | record.setProductCategory(req.getProductCategory().trim()); |
| | | record.setUsagePurpose(req.getUsagePurpose().trim()); |
| | | record.setRecorder(req.getRecorder().trim()); |
| | | // ç©ºå¤æ³¨ä¹å¯å¨ä¿®æ¹æ¶æ¸
é¤ã |
| | | record.setRemark(req.getRemark() == null ? "" : req.getRemark().trim()); |
| | | record.setAmount(req.getQuantity().multiply(req.getUnitPrice()).setScale(2, RoundingMode.HALF_UP)); |
| | | return record; |
| | | } |
| | | |
| | | public EnergyAnalysisRespVO analysis(EnergyAnalysisReqVO req) { |
| | | return aggregate(recordMapper.selectAnalysis(req)); |
| | | } |
| | | |
| | | static EnergyAnalysisRespVO aggregate(List<EnergyRecordMapper.Aggregate> rows) { |
| | | EnergyAnalysisRespVO result = new EnergyAnalysisRespVO(); |
| | | Map<String, EnergyAnalysisRespVO.Summary> summary = new LinkedHashMap<>(); |
| | | for (String type : List.of("WATER", "ELECTRICITY", "STEAM")) { |
| | | EnergyAnalysisRespVO.Summary item = new EnergyAnalysisRespVO.Summary(); |
| | | item.setEnergyType(type); |
| | | summary.put(type, item); |
| | | } |
| | | Map<List<String>, EnergyAnalysisRespVO.Bucket> trend = new LinkedHashMap<>(); |
| | | Map<List<String>, EnergyAnalysisRespVO.Bucket> areas = new LinkedHashMap<>(); |
| | | for (EnergyRecordMapper.Aggregate row : rows) { |
| | | add(summary.get(row.getEnergyType()), row); |
| | | add(bucket(trend, row.getPeriod(), row.getEnergyType()), row); |
| | | add(bucket(areas, row.getUsageArea(), row.getEnergyType()), row); |
| | | result.setTotalAmount(result.getTotalAmount().add(row.getAmount())); |
| | | result.setRecordCount(result.getRecordCount() + row.getRecordCount()); |
| | | } |
| | | result.setSummary(List.copyOf(summary.values())); |
| | | result.setTrend(List.copyOf(trend.values())); |
| | | result.setAreas(List.copyOf(areas.values())); |
| | | return result; |
| | | } |
| | | |
| | | private static EnergyAnalysisRespVO.Bucket bucket(Map<List<String>, EnergyAnalysisRespVO.Bucket> map, |
| | | String label, String type) { |
| | | return map.computeIfAbsent(List.of(label, type), key -> { |
| | | EnergyAnalysisRespVO.Bucket item = new EnergyAnalysisRespVO.Bucket(); |
| | | item.setLabel(label); |
| | | item.setEnergyType(type); |
| | | return item; |
| | | }); |
| | | } |
| | | |
| | | private static void add(EnergyAnalysisRespVO.Summary item, EnergyRecordMapper.Aggregate row) { |
| | | item.setQuantity(item.getQuantity().add(row.getQuantity())); |
| | | item.setAmount(item.getAmount().add(row.getAmount())); |
| | | item.setRecordCount(item.getRecordCount() + row.getRecordCount()); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.qc.ledger; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerRespVO; |
| | | |
| | | /** |
| | | * MES æ£æµç»æå°è´¦ Service æ¥å£ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | public interface MesQcInspectionLedgerService { |
| | | |
| | | /** |
| | | * è·å¾æ£æµç»æå°è´¦å页ï¼åç±»æ£éªåç»ä¸æ¥è¯¢ï¼ä¸è¡ä¸ä¸ªæ£æµé¡¹ç»æï¼ |
| | | * |
| | | * @param pageReqVO å页æ¥è¯¢ |
| | | * @return å°è´¦å页 |
| | | */ |
| | | PageResult<MesQcInspectionLedgerRespVO> getInspectionLedgerPage(MesQcInspectionLedgerPageReqVO pageReqVO); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.qc.ledger; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.ledger.vo.MesQcInspectionLedgerRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcQualityExportVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.qc.ledger.MesQcInspectionLedgerMapper; |
| | | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| | | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| | | |
| | | /** |
| | | * MES æ£æµç»æå°è´¦ Service å®ç°ç±» |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class MesQcInspectionLedgerServiceImpl implements MesQcInspectionLedgerService { |
| | | |
| | | @Resource |
| | | private MesQcInspectionLedgerMapper ledgerMapper; |
| | | |
| | | @Resource |
| | | private MesMdItemService itemService; |
| | | @Resource |
| | | private MesMdUnitMeasureService unitMeasureService; |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | |
| | | @Override |
| | | public PageResult<MesQcInspectionLedgerRespVO> getInspectionLedgerPage(MesQcInspectionLedgerPageReqVO pageReqVO) { |
| | | // å页æ¥è¯¢ï¼åç±»æ£éªå UNION ALLï¼ |
| | | IPage<MesQcInspectionLedgerRespVO> page = MyBatisUtils.buildPage(pageReqVO); |
| | | ledgerMapper.selectInspectionLedgerPage(page, pageReqVO); |
| | | List<MesQcInspectionLedgerRespVO> list = page.getRecords(); |
| | | if (CollUtil.isEmpty(list)) { |
| | | return PageResult.empty(page.getTotal()); |
| | | } |
| | | // æ¹éæ¥è¯¢ç©æã计éåä½ãæ£æµäººåï¼å¹¶æ¼è£
å¤å®ä¾æ® |
| | | Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(convertSet(list, MesQcInspectionLedgerRespVO::getItemId)); |
| | | Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( |
| | | convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| | | convertSet(list, MesQcInspectionLedgerRespVO::getInspectorUserId)); |
| | | for (MesQcInspectionLedgerRespVO vo : list) { |
| | | findAndThen(itemMap, vo.getItemId(), item -> { |
| | | vo.setItemCode(item.getCode()); |
| | | vo.setItemName(item.getName()); |
| | | vo.setItemSpecification(item.getSpecification()); |
| | | findAndThen(unitMeasureMap, item.getUnitMeasureId(), unit -> vo.setUnitName(unit.getName())); |
| | | }); |
| | | findAndThen(userMap, vo.getInspectorUserId(), user -> vo.setInspectorName(user.getNickname())); |
| | | vo.setJudgementBasis(MesQcQualityExportVO.buildRangeText( |
| | | vo.getStandardValue(), vo.getMinThreshold(), vo.getMaxThreshold())); |
| | | } |
| | | return new PageResult<>(list, page.getTotal()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.hrm.api.employee.HrmEmployeeApi; |
| | | import cn.iocoder.yudao.module.hrm.api.employee.dto.HrmEmployeeSimpleDTO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert.SafetyCertificatePageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert.SafetyCertificateRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert.SafetyCertificateSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyCertificateDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyCertificateMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyCertificateStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyCertificateTypeEnum; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç¹ç§ä½ä¸è¯å°è´¦ Service |
| | | * |
| | | * <p>æ ¸å¿è½åï¼è¯ä¹¦å°æèªå¨é¢è¦ãç¶æç± {@link #resolveStatus} æ ¹æ®æææå®æ¶æ¨å¯¼ï¼ |
| | | * ä¸ä¾èµæå·¥ç»´æ¤ï¼é¿å
è¿ææªåæ¶æ´æ°ç¶æã</p> |
| | | * |
| | | * <p>æè¯äººéè¿ employeeId å
³è人åèµæºçå工档æ¡ï¼ |
| | | * æ°å¢/ä¿®æ¹æ¶ä»æ¡£æ¡å¸¦åºå§åãå·¥å·ãé¨é¨å¹¶è½ä¸ºå¿«ç
§ï¼æ¥è¯¢æ¶å®æ¶åå¡«ææ°æ¡£æ¡ä¿¡æ¯ï¼ |
| | | * åå·¥è°å²åè¯ä»¶å表ä¹ä¼è·çæ¾ç¤ºæ°é¨é¨ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class SafetyCertificateService { |
| | | |
| | | /** é»è®¤æåé¢è¦å¤©æ° */ |
| | | public static final int DEFAULT_WARN_DAYS = 30; |
| | | |
| | | @Resource |
| | | private SafetyCertificateMapper certificateMapper; |
| | | @Resource |
| | | private HrmEmployeeApi hrmEmployeeApi; |
| | | @Resource |
| | | private SafetyRefResolver refResolver; |
| | | |
| | | public Long createCertificate(SafetyCertificateSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | validateCertificateForCreate(reqVO); |
| | | SafetyCertificateDO cert = buildCertificate(reqVO, null); |
| | | certificateMapper.insert(cert); |
| | | return cert.getId(); |
| | | } |
| | | |
| | | public void updateCertificate(SafetyCertificateSaveReqVO reqVO) { |
| | | SafetyCertificateDO old = validateCertificateExists(reqVO.getId()); |
| | | validateCertificateForUpdate(reqVO, old); |
| | | SafetyCertificateDO cert = buildCertificate(reqVO, old); |
| | | certificateMapper.updateById(cert); |
| | | } |
| | | |
| | | public void deleteCertificate(Long id) { |
| | | validateCertificateExists(id); |
| | | certificateMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyCertificateDO getCertificate(Long id) { |
| | | return validateCertificateExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyCertificateDO> getCertificatePage(SafetyCertificatePageReqVO reqVO) { |
| | | return certificateMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢å³å°å°æ / å·²è¿æçè¯ä»¶å表 |
| | | * |
| | | * @param days æåé¢è¦å¤©æ°ï¼ä¸ºç©ºä½¿ç¨é»è®¤ 30 天 |
| | | */ |
| | | public List<SafetyCertificateDO> getExpiringCertificates(Integer days) { |
| | | int warnDays = days == null || days <= 0 ? DEFAULT_WARN_DAYS : days; |
| | | return certificateMapper.selectExpiringBefore(LocalDate.now().plusDays(warnDays)); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éè¡¥å
¨æè¯äººçææ°å工档æ¡ä¿¡æ¯ï¼å§åãå·¥å·ãé¨é¨ãææºãå
³èç¨æ·ï¼ |
| | | * |
| | | * <p>æ¥è¯¢æ¶ç¨æ¡£æ¡å®æ¶å¼è¦çå¿«ç
§å¼ï¼ä¿è¯åå·¥è°å²åå°è´¦åæ¥ï¼ |
| | | * å工档æ¡å·²è¢«å 餿¶åéå°å¿«ç
§å¼ï¼ä¿è¯åå²è¯ä»¶ä»å¯å±ç¤ºã</p> |
| | | */ |
| | | public void fillEmployeeInfo(List<SafetyCertificateDO> certs) { |
| | | List<Long> employeeIds = certs.stream() |
| | | .map(SafetyCertificateDO::getEmployeeId) |
| | | .filter(Objects::nonNull).distinct().toList(); |
| | | // ç¨ new HashMap<>() èé Map.of()ï¼employeeId å
许为 nullï¼ |
| | | // åé¢ employeeMap.get(cert.getEmployeeId()) å¨ç©ºéååºæ¯ä¼ get(null)ï¼ |
| | | // Map.of() ç get(null) 伿 NPE 导è´è¯ä»¶å表æ¥å£ 500ã |
| | | Map<Long, HrmEmployeeSimpleDTO> employeeMap = employeeIds.isEmpty() ? new HashMap<>() |
| | | : hrmEmployeeApi.getEmployeeList(employeeIds).stream() |
| | | .collect(Collectors.toMap(HrmEmployeeSimpleDTO::getId, e -> e, (a, b) -> a)); |
| | | certs.forEach(cert -> { |
| | | HrmEmployeeSimpleDTO employee = employeeMap.get(cert.getEmployeeId()); |
| | | if (employee != null) { |
| | | cert.setEmployeeName(employee.getName()); |
| | | cert.setEmployeeNo(employee.getEmployeeNo()); |
| | | cert.setDeptName(employee.getDeptName()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éè¡¥å
¨å±ç¤ºåæ®µï¼æè¯äººæ¡£æ¡ä¸æ¬¡æ§æ¥å¥½ï¼é¿å
éæ¡æ¥è¯¢ |
| | | */ |
| | | public void fillDisplayFieldsBatch(List<SafetyCertificateDO> certs, List<SafetyCertificateRespVO> resps) { |
| | | var employeeMap = refResolver.employeeMap(certs.stream().map(SafetyCertificateDO::getEmployeeId).toList()); |
| | | for (int i = 0; i < certs.size(); i++) { |
| | | fillDisplayFields(certs.get(i), resps.get(i), employeeMap.get(certs.get(i).getEmployeeId())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å个è¯ä»¶çå±ç¤ºå段补å
¨ï¼ç±»ååç§°ãç¶æåç§°ãå©ä½å¤©æ°ãæè¯äººæ¡£æ¡ï¼ |
| | | */ |
| | | public void fillDisplayFields(SafetyCertificateDO cert, SafetyCertificateRespVO respVO) { |
| | | fillDisplayFields(cert, respVO, cert.getEmployeeId() == null ? null |
| | | : hrmEmployeeApi.getEmployee(cert.getEmployeeId())); |
| | | } |
| | | |
| | | private void fillDisplayFields(SafetyCertificateDO cert, SafetyCertificateRespVO respVO, |
| | | HrmEmployeeSimpleDTO employee) { |
| | | respVO.setCertTypeName(SafetyCertificateTypeEnum.getNameByType(cert.getCertType())); |
| | | String status = resolveStatus(cert.getExpireDate(), cert.getWarnDays(), cert.getStatus()); |
| | | respVO.setStatus(status); |
| | | respVO.setStatusName(SafetyCertificateStatusEnum.getNameByStatus(status)); |
| | | if (cert.getExpireDate() != null) { |
| | | respVO.setRemainingDays(ChronoUnit.DAYS.between(LocalDate.now(), cert.getExpireDate())); |
| | | } |
| | | if (employee != null) { |
| | | respVO.setEmployeeName(employee.getName()); |
| | | respVO.setEmployeeNo(employee.getEmployeeNo()); |
| | | respVO.setDeptName(employee.getDeptName()); |
| | | respVO.setPhone(employee.getPhone()); |
| | | respVO.setUserId(employee.getUserId()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ææææ¨å¯¼ç¶æï¼å·²æ³¨éä¿æä¸åï¼è¿æ â EXPIREDï¼å¨é¢è¦æå
â EXPIRINGï¼å¦å VALID |
| | | * |
| | | * @param expireDate æææ |
| | | * @param warnDays æåé¢è¦å¤©æ° |
| | | * @param current å½åç¶æï¼ç¨äºä¿æ¤ REVOKED |
| | | */ |
| | | public static String resolveStatus(LocalDate expireDate, Integer warnDays, String current) { |
| | | if (SafetyCertificateStatusEnum.REVOKED.getStatus().equals(current)) { |
| | | return SafetyCertificateStatusEnum.REVOKED.getStatus(); |
| | | } |
| | | if (expireDate == null) { |
| | | return SafetyCertificateStatusEnum.VALID.getStatus(); |
| | | } |
| | | LocalDate today = LocalDate.now(); |
| | | if (expireDate.isBefore(today)) { |
| | | return SafetyCertificateStatusEnum.EXPIRED.getStatus(); |
| | | } |
| | | int days = warnDays == null || warnDays <= 0 ? DEFAULT_WARN_DAYS : warnDays; |
| | | if (!expireDate.isAfter(today.plusDays(days))) { |
| | | return SafetyCertificateStatusEnum.EXPIRING.getStatus(); |
| | | } |
| | | return SafetyCertificateStatusEnum.VALID.getStatus(); |
| | | } |
| | | |
| | | /** |
| | | * æå»º DOï¼æè¯äººå§å/å·¥å·/é¨é¨ä»å工档æ¡å¸¦åºå¹¶è½ä¸ºå¿«ç
§ |
| | | */ |
| | | private SafetyCertificateDO buildCertificate(SafetyCertificateSaveReqVO reqVO, SafetyCertificateDO old) { |
| | | HrmEmployeeSimpleDTO employee = hrmEmployeeApi.getEmployee(reqVO.getEmployeeId()); |
| | | if (employee == null) { |
| | | throw exception(SAFETY_CERT_EMPLOYEE_NOT_EXISTS); |
| | | } |
| | | SafetyCertificateDO cert = BeanUtils.toBean(reqVO, SafetyCertificateDO.class); |
| | | cert.setEmployeeId(employee.getId()); |
| | | cert.setEmployeeName(employee.getName()); |
| | | cert.setEmployeeNo(employee.getEmployeeNo()); |
| | | cert.setDeptName(employee.getDeptName()); |
| | | cert.setCertNo(StrUtil.trim(reqVO.getCertNo())); |
| | | cert.setWarnDays(reqVO.getWarnDays() == null ? DEFAULT_WARN_DAYS : reqVO.getWarnDays()); |
| | | // 已注éç¶æä¸å
许éè¿ç¼è¾æ¹å |
| | | String currentStatus = old == null ? reqVO.getStatus() : old.getStatus(); |
| | | cert.setStatus(resolveStatus(reqVO.getExpireDate(), cert.getWarnDays(), currentStatus)); |
| | | cert.setRemark(reqVO.getRemark() == null ? "" : reqVO.getRemark().trim()); |
| | | return cert; |
| | | } |
| | | |
| | | private void validateCertificateForCreate(SafetyCertificateSaveReqVO reqVO) { |
| | | validateExpireAfterIssue(reqVO); |
| | | if (certificateMapper.selectByCertNo(StrUtil.trim(reqVO.getCertNo())) != null) { |
| | | throw exception(SAFETY_CERT_NO_DUPLICATE); |
| | | } |
| | | } |
| | | |
| | | private void validateCertificateForUpdate(SafetyCertificateSaveReqVO reqVO, SafetyCertificateDO old) { |
| | | validateExpireAfterIssue(reqVO); |
| | | SafetyCertificateDO byCertNo = certificateMapper.selectByCertNo(StrUtil.trim(reqVO.getCertNo())); |
| | | if (byCertNo != null && !byCertNo.getId().equals(old.getId())) { |
| | | throw exception(SAFETY_CERT_NO_DUPLICATE); |
| | | } |
| | | } |
| | | |
| | | private void validateExpireAfterIssue(SafetyCertificateSaveReqVO reqVO) { |
| | | if (reqVO.getIssueDate() != null && reqVO.getExpireDate() != null |
| | | && !Objects.requireNonNull(reqVO.getExpireDate()).isAfter(reqVO.getIssueDate())) { |
| | | throw exception(SAFETY_CERT_EXPIRE_BEFORE_ISSUE); |
| | | } |
| | | } |
| | | |
| | | private SafetyCertificateDO validateCertificateExists(Long id) { |
| | | SafetyCertificateDO cert = id == null ? null : certificateMapper.selectById(id); |
| | | if (cert == null) { |
| | | throw exception(SAFETY_CERT_NOT_EXISTS); |
| | | } |
| | | return cert; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.infra.api.file.FileApi; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ç§»å¨ç«¯éä»¶ä¸ä¼ Service |
| | | * |
| | | * <p>å·¡æ£ã鿣ãä½ä¸ç¥¨ãæ¼ç»çç¯èçç°åºæç
§ç»ä¸èµ°è¿éï¼ |
| | | * è½å° infra æä»¶åå¨ï¼è¿åå¯è®¿é® URLï¼å¤ä¸ªéä»¶éå·æ¼æ¥ååå
¥ä¸å¡è¡¨ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class SafetyFileService { |
| | | |
| | | /** å个æä»¶æå¤§ 20MBï¼ææºåå¾è£ååè¶³å¤ */ |
| | | private static final long MAX_SIZE = 20L * 1024 * 1024; |
| | | /** å
许çå¾çç±»å */ |
| | | private static final List<String> ALLOWED_EXT = List.of( |
| | | "jpg", "jpeg", "png", "webp", "heic", "gif", "bmp", "pdf", "doc", "docx", "xls", "xlsx"); |
| | | |
| | | @Resource |
| | | private FileApi fileApi; |
| | | |
| | | /** |
| | | * ä¸ä¼ å个æä»¶ |
| | | * |
| | | * @param file æä»¶ |
| | | * @param bizType ä¸å¡ç±»åï¼safety/inspectionãsafety/hazard çï¼ï¼ç¨ä½åå¨ç®å½ |
| | | * @return æä»¶è®¿é® URL |
| | | */ |
| | | public String upload(MultipartFile file, String bizType) { |
| | | if (file == null || file.isEmpty()) { |
| | | throw new IllegalArgumentException("ä¸ä¼ æä»¶ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (file.getSize() > MAX_SIZE) { |
| | | throw new IllegalArgumentException("å个æä»¶ä¸è½è¶
è¿ 20MB"); |
| | | } |
| | | String originalName = StrUtil.blankToDefault(file.getOriginalFilename(), "photo.jpg"); |
| | | String ext = StrUtil.subAfter(originalName, ".", true).toLowerCase(); |
| | | if (StrUtil.isNotBlank(ext) && !ALLOWED_EXT.contains(ext)) { |
| | | throw new IllegalArgumentException("䏿¯æçæä»¶ç±»åï¼" + ext); |
| | | } |
| | | byte[] content; |
| | | try { |
| | | content = IoUtil.readBytes(file.getInputStream()); |
| | | } catch (IOException e) { |
| | | throw new IllegalStateException("读åä¸ä¼ æä»¶å¤±è´¥", e); |
| | | } |
| | | String directory = StrUtil.blankToDefault(bizType, "safety") + "/" + java.time.LocalDate.now(); |
| | | return fileApi.createFile(content, originalName, directory, file.getContentType()); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éä¸ä¼ ï¼ç§»å¨ç«¯ä¸æ¬¡æå¤å¼ ï¼ |
| | | * |
| | | * @return æä»¶ URL å表 |
| | | */ |
| | | public List<String> uploadBatch(List<MultipartFile> files, String bizType) { |
| | | if (files == null || files.isEmpty()) { |
| | | return List.of(); |
| | | } |
| | | if (files.size() > 9) { |
| | | throw new IllegalArgumentException("忬¡æå¤ä¸ä¼ 9 å¼ "); |
| | | } |
| | | List<String> urls = new ArrayList<>(); |
| | | for (MultipartFile file : files) { |
| | | urls.add(upload(file, bizType)); |
| | | } |
| | | return urls; |
| | | } |
| | | |
| | | /** |
| | | * å é¤éä»¶ï¼ä»éå·ä¸²éåé¤æä¸ª URLï¼ |
| | | */ |
| | | public String removeUrl(String urls, String target) { |
| | | if (StrUtil.isBlank(urls) || StrUtil.isBlank(target)) { |
| | | return urls; |
| | | } |
| | | return Arrays.stream(urls.split(",")) |
| | | .map(String::trim) |
| | | .filter(url -> !url.equals(target.trim())) |
| | | .reduce((a, b) -> a + "," + b) |
| | | .orElse(""); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyHazardDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyHazardMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyHazardLevelEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyHazardSourceEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyHazardStatusEnum; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - 鿣ç»è®°ä¸éç¯ Service |
| | | * |
| | | * <p>宿´éç¯ï¼ä¸æ¥ â åæ´¾ â æ´æ¹ â 夿¥ï¼éè¿åéç¯ï¼ä¸éè¿éåæ´æ¹ï¼ã |
| | | * æ¯ä¸ªç¯è齿 ¡éªå½åç¶æï¼é²æ¢è·³æ¥æé夿ä½ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class SafetyHazardService { |
| | | |
| | | private static final DateTimeFormatter CODE_DATE = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | |
| | | @Resource |
| | | private SafetyHazardMapper hazardMapper; |
| | | @Resource |
| | | private SafetyRefResolver refResolver; |
| | | |
| | | /** |
| | | * 鿣䏿¥ï¼å«ç§»å¨ç«¯æç
§ä¸ä¼ ç photoUrlsï¼ |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createHazard(SafetyHazardSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | SafetyHazardDO hazard = BeanUtils.toBean(reqVO, SafetyHazardDO.class); |
| | | hazard.setCode(hazardMapper.selectNextCode("HZ" + LocalDate.now().format(CODE_DATE))); |
| | | hazard.setTitle(StrUtil.trim(reqVO.getTitle())); |
| | | hazard.setReporterId(reqVO.getReporterId()); |
| | | hazard.setReporter(refResolver.requireEmployee(reqVO.getReporterId(), SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | hazard.setLevel(StrUtil.blankToDefault(reqVO.getLevel(), SafetyHazardLevelEnum.GENERAL.getLevel())); |
| | | hazard.setSource(StrUtil.blankToDefault(reqVO.getSource(), SafetyHazardSourceEnum.SELF_CHECK.getSource())); |
| | | hazard.setReportTime(reqVO.getReportTime() == null ? LocalDateTime.now() : reqVO.getReportTime()); |
| | | hazard.setStatus(SafetyHazardStatusEnum.REPORTED.getStatus()); |
| | | hazard.setRemark(reqVO.getRemark() == null ? "" : reqVO.getRemark().trim()); |
| | | hazardMapper.insert(hazard); |
| | | return hazard.getId(); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹éæ£åºç¡ä¿¡æ¯ï¼ä»
æªåæ´¾åå
许æ¹å
³é®åæ®µï¼ |
| | | */ |
| | | public void updateHazard(SafetyHazardSaveReqVO reqVO) { |
| | | SafetyHazardDO old = validateHazardExists(reqVO.getId()); |
| | | if (!SafetyHazardStatusEnum.REPORTED.getStatus().equals(old.getStatus()) |
| | | && !SafetyHazardStatusEnum.ASSIGNED.getStatus().equals(old.getStatus())) { |
| | | throw exception(SAFETY_HAZARD_STATUS_ERROR); |
| | | } |
| | | SafetyHazardDO update = BeanUtils.toBean(reqVO, SafetyHazardDO.class); |
| | | // ç¼å·ä¸ç¶æä¸å
许éè¿æ®éç¼è¾ä¿®æ¹ |
| | | update.setCode(null); |
| | | update.setStatus(null); |
| | | hazardMapper.updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * åæ´¾æ´æ¹è´£ä»»äºº |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void assignHazard(SafetyHazardAssignReqVO reqVO) { |
| | | SafetyHazardDO hazard = validateHazardExists(reqVO.getId()); |
| | | if (!SafetyHazardStatusEnum.REPORTED.getStatus().equals(hazard.getStatus()) |
| | | && !SafetyHazardStatusEnum.REJECTED.getStatus().equals(hazard.getStatus())) { |
| | | throw exception(SAFETY_HAZARD_STATUS_ERROR); |
| | | } |
| | | if (reqVO.getAssigneeId() == null) { |
| | | throw exception(SAFETY_HAZARD_ASSIGNEE_REQUIRED); |
| | | } |
| | | var assignee = refResolver.requireEmployee(reqVO.getAssigneeId(), SAFETY_HAZARD_ASSIGNEE_REQUIRED); |
| | | SafetyHazardDO update = new SafetyHazardDO(); |
| | | update.setId(hazard.getId()); |
| | | update.setAssigneeId(assignee.getId()); |
| | | update.setAssignee(assignee.getName()); |
| | | update.setAssignTime(LocalDateTime.now()); |
| | | update.setRectifyDeadline(reqVO.getRectifyDeadline()); |
| | | update.setStatus(SafetyHazardStatusEnum.RECTIFYING.getStatus()); |
| | | if (StrUtil.isNotBlank(reqVO.getRemark())) { |
| | | update.setRemark(reqVO.getRemark().trim()); |
| | | } |
| | | hazardMapper.updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * æäº¤æ´æ¹ç»æ |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void rectifyHazard(SafetyHazardRectifyReqVO reqVO) { |
| | | SafetyHazardDO hazard = validateHazardExists(reqVO.getId()); |
| | | if (!SafetyHazardStatusEnum.RECTIFYING.getStatus().equals(hazard.getStatus()) |
| | | && !SafetyHazardStatusEnum.REJECTED.getStatus().equals(hazard.getStatus())) { |
| | | throw exception(SAFETY_HAZARD_STATUS_ERROR); |
| | | } |
| | | SafetyHazardDO update = new SafetyHazardDO(); |
| | | update.setId(hazard.getId()); |
| | | update.setRectifyDesc(reqVO.getRectifyDesc().trim()); |
| | | update.setRectifyPhotoUrls(reqVO.getRectifyPhotoUrls()); |
| | | update.setRectifyTime(LocalDateTime.now()); |
| | | update.setStatus(SafetyHazardStatusEnum.RECHECKING.getStatus()); |
| | | hazardMapper.updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * 夿¥ï¼éè¿åéç¯ï¼ä¸éè¿éåæ´æ¹ã |
| | | * |
| | | * <p>æ ¡éªæ´æ¹äººä¸å¤æ¥äººä¸è½æ¯åä¸äººï¼ä¿è¯éç¯ç两级å离ã</p> |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void recheckHazard(SafetyHazardRecheckReqVO reqVO) { |
| | | SafetyHazardDO hazard = validateHazardExists(reqVO.getId()); |
| | | if (!SafetyHazardStatusEnum.RECHECKING.getStatus().equals(hazard.getStatus())) { |
| | | throw exception(SAFETY_HAZARD_STATUS_ERROR); |
| | | } |
| | | var rechecker = refResolver.requireEmployee(reqVO.getRecheckerId(), SAFETY_EMPLOYEE_REQUIRED); |
| | | // ç¨åå·¥ç¼å·æ¯è¾ï¼æ¯å§åæ¯è¾å¯é ï¼ååä¸å人 / æ¹åé½ä¸ä¼è¯¯å¤ï¼ |
| | | if (hazard.getAssigneeId() != null && hazard.getAssigneeId().equals(rechecker.getId())) { |
| | | throw exception(SAFETY_HAZARD_SAME_OPERATOR); |
| | | } |
| | | boolean passed = "PASSED".equals(reqVO.getRecheckResult()); |
| | | SafetyHazardDO update = new SafetyHazardDO(); |
| | | update.setId(hazard.getId()); |
| | | update.setRecheckerId(rechecker.getId()); |
| | | update.setRechecker(rechecker.getName()); |
| | | update.setRecheckTime(LocalDateTime.now()); |
| | | update.setRecheckResult(reqVO.getRecheckResult()); |
| | | update.setRecheckRemark(reqVO.getRecheckRemark()); |
| | | if (passed) { |
| | | update.setStatus(SafetyHazardStatusEnum.CLOSED.getStatus()); |
| | | update.setCloseTime(LocalDateTime.now()); |
| | | } else { |
| | | update.setStatus(SafetyHazardStatusEnum.REJECTED.getStatus()); |
| | | } |
| | | hazardMapper.updateById(update); |
| | | } |
| | | |
| | | public void deleteHazard(Long id) { |
| | | validateHazardExists(id); |
| | | hazardMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyHazardDO getHazard(Long id) { |
| | | return validateHazardExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyHazardDO> getHazardPage(SafetyHazardPageReqVO reqVO) { |
| | | reqVO.normalizeTimeRange(); |
| | | return hazardMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå填䏿¥äºº / æ´æ¹è´£ä»»äºº / 夿¥äººçææ°å§å |
| | | */ |
| | | public void fillPersonNames(List<SafetyHazardDO> hazards) { |
| | | if (CollUtil.isEmpty(hazards)) { |
| | | return; |
| | | } |
| | | var ids = new java.util.ArrayList<Long>(hazards.size() * 3); |
| | | hazards.forEach(h -> { ids.add(h.getReporterId()); ids.add(h.getAssigneeId()); ids.add(h.getRecheckerId()); }); |
| | | var employeeMap = refResolver.employeeMap(ids); |
| | | hazards.forEach(hazard -> { |
| | | var reporter = employeeMap.get(hazard.getReporterId()); |
| | | if (reporter != null) hazard.setReporter(reporter.getName()); |
| | | var assignee = employeeMap.get(hazard.getAssigneeId()); |
| | | if (assignee != null) hazard.setAssignee(assignee.getName()); |
| | | var rechecker = employeeMap.get(hazard.getRecheckerId()); |
| | | if (rechecker != null) hazard.setRechecker(rechecker.getName()); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * å±ç¤ºå段补å
¨ï¼ç级/æ¥æº/ç¶æåç§°ãè¶
ææ è®°ï¼ |
| | | */ |
| | | public static void fillHazardDisplay(SafetyHazardDO hazard, SafetyHazardRespVO respVO) { |
| | | respVO.setLevelName(SafetyHazardLevelEnum.getNameByLevel(hazard.getLevel())); |
| | | respVO.setSourceName(SafetyHazardSourceEnum.getNameBySource(hazard.getSource())); |
| | | respVO.setStatusName(SafetyHazardStatusEnum.getNameByStatus(hazard.getStatus())); |
| | | respVO.setRecheckResultName(switch (StrUtil.blankToDefault(hazard.getRecheckResult(), "")) { |
| | | case "PASSED" -> "éè¿"; |
| | | case "REJECTED" -> "ä¸éè¿"; |
| | | default -> ""; |
| | | }); |
| | | boolean overdue = hazard.getRectifyDeadline() != null |
| | | && hazard.getRectifyDeadline().isBefore(LocalDate.now()) |
| | | && !SafetyHazardStatusEnum.isFinished(hazard.getStatus()); |
| | | respVO.setOverdue(overdue); |
| | | } |
| | | |
| | | private SafetyHazardDO validateHazardExists(Long id) { |
| | | SafetyHazardDO hazard = id == null ? null : hazardMapper.selectById(id); |
| | | if (hazard == null) { |
| | | throw exception(SAFETY_HAZARD_NOT_EXISTS); |
| | | } |
| | | return hazard; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyInspectionDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyInspectionPointDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyInspectionMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyInspectionPointMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyInspectCycleEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyInspectionPointTypeEnum; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å·¡æ£ç¹ä½ä¸å·¡æ£è®°å½ Service |
| | | * |
| | | * <p>è¦çé«åé
çµå®¤ãæºç»åºçæ¥å¸¸å®å
¨å·¡æ£ãå·¡æ£åç°å¼å¸¸æ¶å¯ç´æ¥è½¬éæ£ä¸æ¥ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class SafetyInspectionService { |
| | | |
| | | @Resource |
| | | private SafetyInspectionPointMapper pointMapper; |
| | | @Resource |
| | | private SafetyInspectionMapper inspectionMapper; |
| | | @Resource |
| | | private SafetyRefResolver refResolver; |
| | | |
| | | // ==================== å·¡æ£ç¹ä½ ==================== |
| | | |
| | | public Long createPoint(SafetyInspectionPointSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | String code = StrUtil.trim(reqVO.getCode()); |
| | | if (pointMapper.selectByCode(code) != null) { |
| | | throw exception(SAFETY_POINT_CODE_DUPLICATE); |
| | | } |
| | | SafetyInspectionPointDO point = BeanUtils.toBean(reqVO, SafetyInspectionPointDO.class); |
| | | point.setCode(code); |
| | | point.setName(StrUtil.trim(reqVO.getName())); |
| | | point.setInspectCycle(StrUtil.blankToDefault(reqVO.getInspectCycle(), SafetyInspectCycleEnum.DAILY.getCycle())); |
| | | applyPointRefs(point, reqVO.getWorkshopId(), reqVO.getOwnerId()); |
| | | pointMapper.insert(point); |
| | | return point.getId(); |
| | | } |
| | | |
| | | public void updatePoint(SafetyInspectionPointSaveReqVO reqVO) { |
| | | SafetyInspectionPointDO old = validatePointExists(reqVO.getId()); |
| | | String code = StrUtil.trim(reqVO.getCode()); |
| | | SafetyInspectionPointDO byCode = pointMapper.selectByCode(code); |
| | | if (byCode != null && !byCode.getId().equals(old.getId())) { |
| | | throw exception(SAFETY_POINT_CODE_DUPLICATE); |
| | | } |
| | | SafetyInspectionPointDO point = BeanUtils.toBean(reqVO, SafetyInspectionPointDO.class); |
| | | point.setCode(code); |
| | | point.setName(StrUtil.trim(reqVO.getName())); |
| | | applyPointRefs(point, reqVO.getWorkshopId(), reqVO.getOwnerId()); |
| | | pointMapper.updateById(point); |
| | | } |
| | | |
| | | public void deletePoint(Long id) { |
| | | validatePointExists(id); |
| | | pointMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyInspectionPointDO getPoint(Long id) { |
| | | return validatePointExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyInspectionPointDO> getPointPage(SafetyInspectionPointPageReqVO reqVO) { |
| | | return pointMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | /** |
| | | * å¯ç¨ä¸çå·¡æ£ç¹ä½å表ï¼ç§»å¨ç«¯å·¡æ£éæ©ç¨ï¼ |
| | | */ |
| | | public List<SafetyInspectionPointDO> getEnabledPointList() { |
| | | return pointMapper.selectListByStatus(0); |
| | | } |
| | | |
| | | /** |
| | | * ç¹ä½çä¸»æ°æ®å¼ç¨ï¼è½¦é´ + 责任人ï¼ä»ä¸»æ°æ®å¸¦åºåç§°è½å¿«ç
§ |
| | | */ |
| | | private void applyPointRefs(SafetyInspectionPointDO point, Long workshopId, Long ownerId) { |
| | | point.setWorkshopId(workshopId); |
| | | if (workshopId == null) { |
| | | point.setWorkshopName(""); |
| | | } else { |
| | | point.setWorkshopName(refResolver.requireWorkshop(workshopId).getName()); |
| | | } |
| | | point.setOwnerId(ownerId); |
| | | if (ownerId == null) { |
| | | point.setOwnerName(""); |
| | | } else { |
| | | point.setOwnerName(refResolver.requireEmployee(ownerId, SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¹éåå¡«ç¹ä½ç车é´åä¸è´£ä»»äººå§åï¼ç¨ä¸»æ°æ®ææ°å¼è¦çå¿«ç
§ï¼ |
| | | */ |
| | | public void fillPointRefs(List<SafetyInspectionPointDO> points) { |
| | | if (CollUtil.isEmpty(points)) { |
| | | return; |
| | | } |
| | | var workshopMap = refResolver.workshopMap(points.stream().map(SafetyInspectionPointDO::getWorkshopId).toList()); |
| | | var employeeMap = refResolver.employeeMap(points.stream().map(SafetyInspectionPointDO::getOwnerId).toList()); |
| | | points.forEach(point -> { |
| | | var workshop = workshopMap.get(point.getWorkshopId()); |
| | | if (workshop != null) { |
| | | point.setWorkshopName(workshop.getName()); |
| | | } |
| | | var employee = employeeMap.get(point.getOwnerId()); |
| | | if (employee != null) { |
| | | point.setOwnerName(employee.getName()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | public static void fillPointDisplay(SafetyInspectionPointDO point, SafetyInspectionPointRespVO respVO) { |
| | | respVO.setPointTypeName(SafetyInspectionPointTypeEnum.getNameByType(point.getPointType())); |
| | | respVO.setInspectCycleName(SafetyInspectCycleEnum.getNameByCycle(point.getInspectCycle())); |
| | | } |
| | | |
| | | // ==================== å·¡æ£è®°å½ ==================== |
| | | |
| | | public Long createInspection(SafetyInspectionSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | SafetyInspectionPointDO point = validatePointExists(reqVO.getPointId()); |
| | | if (Integer.valueOf(1).equals(point.getStatus())) { |
| | | throw exception(SAFETY_POINT_DISABLED); |
| | | } |
| | | SafetyInspectionDO inspection = buildInspection(reqVO, point); |
| | | inspectionMapper.insert(inspection); |
| | | return inspection.getId(); |
| | | } |
| | | |
| | | public void updateInspection(SafetyInspectionSaveReqVO reqVO) { |
| | | SafetyInspectionDO old = validateInspectionExists(reqVO.getId()); |
| | | SafetyInspectionPointDO point = validatePointExists(reqVO.getPointId()); |
| | | SafetyInspectionDO inspection = buildInspection(reqVO, point); |
| | | inspection.setId(old.getId()); |
| | | inspectionMapper.updateById(inspection); |
| | | } |
| | | |
| | | public void deleteInspection(Long id) { |
| | | validateInspectionExists(id); |
| | | inspectionMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyInspectionDO getInspection(Long id) { |
| | | return validateInspectionExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyInspectionDO> getInspectionPage(SafetyInspectionPageReqVO reqVO) { |
| | | return inspectionMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | private SafetyInspectionDO buildInspection(SafetyInspectionSaveReqVO reqVO, SafetyInspectionPointDO point) { |
| | | SafetyInspectionDO inspection = BeanUtils.toBean(reqVO, SafetyInspectionDO.class); |
| | | inspection.setPointId(point.getId()); |
| | | inspection.setPointName(point.getName()); |
| | | inspection.setPointType(point.getPointType()); |
| | | inspection.setInspectorId(reqVO.getInspectorId()); |
| | | inspection.setInspector(refResolver.requireEmployee(reqVO.getInspectorId(), SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | inspection.setResult(StrUtil.blankToDefault(reqVO.getResult(), "NORMAL")); |
| | | inspection.setInspectTime(reqVO.getInspectTime() == null ? LocalDateTime.now() : reqVO.getInspectTime()); |
| | | inspection.setHazardCount(reqVO.getHazardCount() == null ? 0 : reqVO.getHazardCount()); |
| | | inspection.setRemark(reqVO.getRemark() == null ? "" : reqVO.getRemark().trim()); |
| | | return inspection; |
| | | } |
| | | |
| | | /** |
| | | * æ¹éåå¡«å·¡æ£äººææ°å§å |
| | | */ |
| | | public void fillInspectorNames(List<SafetyInspectionDO> records) { |
| | | if (CollUtil.isEmpty(records)) { |
| | | return; |
| | | } |
| | | var employeeMap = refResolver.employeeMap(records.stream().map(SafetyInspectionDO::getInspectorId).toList()); |
| | | records.forEach(record -> { |
| | | var employee = employeeMap.get(record.getInspectorId()); |
| | | if (employee != null) { |
| | | record.setInspector(employee.getName()); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** æè¿ä¸æ¬¡å·¡æ£æ¶é´ï¼ç¨äºç¹ä½å表å±ç¤ºï¼ */ |
| | | public LocalDateTime getLastInspectTime(Long pointId) { |
| | | SafetyInspectionDO latest = inspectionMapper.selectLatestByPointId(pointId); |
| | | return latest == null ? null : latest.getInspectTime(); |
| | | } |
| | | |
| | | private SafetyInspectionPointDO validatePointExists(Long id) { |
| | | SafetyInspectionPointDO point = id == null ? null : pointMapper.selectById(id); |
| | | if (point == null) { |
| | | throw exception(SAFETY_POINT_NOT_EXISTS); |
| | | } |
| | | return point; |
| | | } |
| | | |
| | | private SafetyInspectionDO validateInspectionExists(Long id) { |
| | | SafetyInspectionDO inspection = id == null ? null : inspectionMapper.selectById(id); |
| | | if (inspection == null) { |
| | | throw exception(SAFETY_INSPECTION_NOT_EXISTS); |
| | | } |
| | | return inspection; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.idev.excel.FastExcelFactory; |
| | | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.ledger.SafetyLedgerExportReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.*; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.*; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.SAFETY_LEDGER_DATE_RANGE_INVALID; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - çµåè¡ä¸æ ååå°è´¦å¯¼åº Service |
| | | * |
| | | * <p>æãå
¨å¥ãå¯¼åºæ¶ä¸æ¬¡çæå¤ Sheet å·¥ä½ç°¿ï¼è¦çå®å
¨æ ååæ£æ¥æéçå
¨é¨å°è´¦ï¼ |
| | | * ç»ç»æ¶æãç¹ç§ä½ä¸è¯ãå·¡æ£è®°å½ã鿣å°è´¦ãä½ä¸ç¥¨ãçæ¤è®°å½ãç©èµå°è´¦ã |
| | | * åºå
¥åºæµæ°´ãå¹è®è®°å½ãæ¼ç»è®°å½ãäºæ
ç»è®°ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class SafetyLedgerExportService { |
| | | |
| | | @Resource |
| | | private SafetyOrgService orgService; |
| | | @Resource |
| | | private SafetyCertificateService certificateService; |
| | | @Resource |
| | | private SafetyInspectionService inspectionService; |
| | | @Resource |
| | | private SafetyHazardService hazardService; |
| | | @Resource |
| | | private SafetyWorkPermitService permitService; |
| | | @Resource |
| | | private SafetyMaterialService materialService; |
| | | @Resource |
| | | private SafetyTrainingService trainingService; |
| | | |
| | | /** |
| | | * å¯¼åºæ ååå°è´¦ |
| | | */ |
| | | public void export(SafetyLedgerExportReqVO reqVO, HttpServletResponse response) throws IOException { |
| | | LocalDate start = reqVO.getStartDate(); |
| | | LocalDate end = reqVO.getEndDate(); |
| | | if (start != null && end != null && start.isAfter(end)) { |
| | | throw exception(SAFETY_LEDGER_DATE_RANGE_INVALID); |
| | | } |
| | | String type = reqVO.getType() == null ? "ALL" : reqVO.getType(); |
| | | List<Sheet> sheets = new ArrayList<>(); |
| | | if ("ALL".equals(type) || "CERT".equals(type)) { |
| | | sheets.add(certSheet()); |
| | | } |
| | | if ("ALL".equals(type) || "INSPECTION".equals(type)) { |
| | | sheets.add(inspectionSheet(start, end)); |
| | | } |
| | | if ("ALL".equals(type) || "HAZARD".equals(type)) { |
| | | sheets.add(hazardSheet(start, end)); |
| | | } |
| | | if ("ALL".equals(type) || "PERMIT".equals(type)) { |
| | | sheets.add(permitSheet(start, end)); |
| | | sheets.add(monitorSheet()); |
| | | } |
| | | if ("ALL".equals(type) || "MATERIAL".equals(type)) { |
| | | sheets.add(materialSheet()); |
| | | sheets.add(stockSheet(start, end)); |
| | | } |
| | | if ("ALL".equals(type) || "TRAINING".equals(type)) { |
| | | sheets.add(trainingSheet(start, end)); |
| | | } |
| | | if ("ALL".equals(type) || "DRILL".equals(type)) { |
| | | sheets.add(drillSheet(start, end)); |
| | | } |
| | | if ("ALL".equals(type) || "ACCIDENT".equals(type)) { |
| | | sheets.add(accidentSheet(start, end)); |
| | | } |
| | | String filename = switch (type) { |
| | | case "CERT" -> "ç¹ç§ä½ä¸è¯å°è´¦.xlsx"; |
| | | case "INSPECTION" -> "å®å
¨å·¡æ£å°è´¦.xlsx"; |
| | | case "HAZARD" -> "鿣å°è´¦.xlsx"; |
| | | case "PERMIT" -> "é«å±ä½ä¸ç¥¨å°è´¦.xlsx"; |
| | | case "MATERIAL" -> "åºæ¥ç©èµå°è´¦.xlsx"; |
| | | case "TRAINING" -> "å®å
¨å¹è®å°è´¦.xlsx"; |
| | | case "DRILL" -> "æ¶é²æ¼ç»å°è´¦.xlsx"; |
| | | case "ACCIDENT" -> "äºæ
ç»è®°å°è´¦.xlsx"; |
| | | default -> "å®å
¨ç产æ ååå°è´¦.xlsx"; |
| | | }; |
| | | write(response, filename, sheets); |
| | | } |
| | | |
| | | // ==================== å Sheet ==================== |
| | | |
| | | private Sheet certSheet() { |
| | | List<String> headers = List.of("æè¯äºº", "å·¥å·", "é¨é¨", "è¯ä»¶ç±»å", "è¯ä»¶ç¼å·", "åè¯æºå
³", |
| | | "åè¯æ¥æ", "æææè³", "䏿¬¡å¤å®¡", "ç¶æ", "é¢è¦å¤©æ°", "夿³¨"); |
| | | var pageReqVO = new cn.iocoder.yudao.module.mes.controller.admin.safety.vo.cert.SafetyCertificatePageReqVO(); |
| | | pageReqVO.setPageNo(1); |
| | | pageReqVO.setPageSize(50_000); |
| | | var certs = certificateService.getCertificatePage(pageReqVO).getList(); |
| | | // å¯¼åºæ¶ç¨å工档æ¡çææ°å§å/å·¥å·/é¨é¨ |
| | | certificateService.fillEmployeeInfo(certs); |
| | | List<List<Object>> rows = certs.stream() |
| | | .map(c -> Arrays.<Object>asList( |
| | | str(c.getEmployeeName()), str(c.getEmployeeNo()), str(c.getDeptName()), |
| | | SafetyCertificateTypeEnum.getNameByType(c.getCertType()), str(c.getCertNo()), |
| | | str(c.getIssuer()), date(c.getIssueDate()), date(c.getExpireDate()), |
| | | date(c.getReviewDate()), |
| | | SafetyCertificateStatusEnum.getNameByStatus(SafetyCertificateService.resolveStatus( |
| | | c.getExpireDate(), c.getWarnDays(), c.getStatus())), |
| | | Objects.toString(c.getWarnDays(), ""), str(c.getRemark()))) |
| | | .toList(); |
| | | return new Sheet("ç¹ç§ä½ä¸è¯å°è´¦", headers, rows); |
| | | } |
| | | |
| | | private Sheet inspectionSheet(LocalDate start, LocalDate end) { |
| | | List<String> headers = List.of("å·¡æ£æ¶é´", "ç¹ä½åç§°", "ç¹ä½ç±»å", "å·¡æ£äºº", "ç»æ", "å·¡æ£æ
åµ", "åç°éæ£æ°"); |
| | | var reqVO = new cn.iocoder.yudao.module.mes.controller.admin.safety.vo.inspection.SafetyInspectionPageReqVO(); |
| | | reqVO.setPageNo(1); |
| | | reqVO.setPageSize(50_000); |
| | | if (start != null && end != null) { |
| | | reqVO.setInspectTime(new java.time.LocalDateTime[]{start.atStartOfDay(), end.atTime(23, 59, 59)}); |
| | | } |
| | | var inspections = inspectionService.getInspectionPage(reqVO).getList(); |
| | | inspectionService.fillInspectorNames(inspections); |
| | | List<List<Object>> rows = inspections.stream() |
| | | .map(i -> Arrays.<Object>asList( |
| | | dateTime(i.getInspectTime()), str(i.getPointName()), |
| | | SafetyInspectionPointTypeEnum.getNameByType(i.getPointType()), |
| | | str(i.getInspector()), |
| | | "NORMAL".equals(i.getResult()) ? "æ£å¸¸" : "å¼å¸¸", |
| | | str(i.getContent()), Objects.toString(i.getHazardCount(), "0"))) |
| | | .toList(); |
| | | return new Sheet("å®å
¨å·¡æ£å°è´¦", headers, rows); |
| | | } |
| | | |
| | | private Sheet hazardSheet(LocalDate start, LocalDate end) { |
| | | List<String> headers = List.of("鿣ç¼å·", "æ é¢", "ç级", "æ¥æº", "ä½ç½®", "䏿¥äºº", "䏿¥æ¶é´", |
| | | "æ´æ¹è´£ä»»äºº", "æ´æ¹æé", "æ´æ¹æªæ½", "æ´æ¹æ¶é´", "夿¥äºº", "夿¥æ¶é´", "夿¥ç»è®º", "ç¶æ", "éç¯æ¶é´"); |
| | | var reqVO = new cn.iocoder.yudao.module.mes.controller.admin.safety.vo.hazard.SafetyHazardPageReqVO(); |
| | | reqVO.setPageNo(1); |
| | | reqVO.setPageSize(50_000); |
| | | if (start != null && end != null) { |
| | | reqVO.setReportTime(new java.time.LocalDateTime[]{start.atStartOfDay(), end.atTime(23, 59, 59)}); |
| | | } |
| | | var hazards = hazardService.getHazardPage(reqVO).getList(); |
| | | hazardService.fillPersonNames(hazards); |
| | | List<List<Object>> rows = hazards.stream() |
| | | .map(h -> Arrays.<Object>asList( |
| | | str(h.getCode()), str(h.getTitle()), |
| | | SafetyHazardLevelEnum.getNameByLevel(h.getLevel()), |
| | | SafetyHazardSourceEnum.getNameBySource(h.getSource()), |
| | | str(h.getLocation()), str(h.getReporter()), dateTime(h.getReportTime()), |
| | | str(h.getAssignee()), date(h.getRectifyDeadline()), str(h.getRectifyDesc()), |
| | | dateTime(h.getRectifyTime()), str(h.getRechecker()), dateTime(h.getRecheckTime()), |
| | | "PASSED".equals(str(h.getRecheckResult())) ? "éè¿" |
| | | : "REJECTED".equals(str(h.getRecheckResult())) ? "ä¸éè¿" : "", |
| | | SafetyHazardStatusEnum.getNameByStatus(h.getStatus()), dateTime(h.getCloseTime()))) |
| | | .toList(); |
| | | return new Sheet("鿣å°è´¦", headers, rows); |
| | | } |
| | | |
| | | private Sheet permitSheet(LocalDate start, LocalDate end) { |
| | | List<String> headers = List.of("ä½ä¸ç¥¨ç¼å·", "ä½ä¸ç±»å", "ä½ä¸åç§°", "ä½ä¸åºå", "ä½ä¸å°ç¹", "ç³è¯·äºº", |
| | | "ç³è¯·æ¶é´", "计åå¼å§", "计åç»æ", "å®é
å¼å§", "å®é
ç»æ", "é£é©ç级", "çæ¤äºº", |
| | | "审æ¹äºº", "å®¡æ¹æ¶é´", "å®¡æ¹æè§", "ç¶æ"); |
| | | var reqVO = new cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit.SafetyWorkPermitPageReqVO(); |
| | | reqVO.setPageNo(1); |
| | | reqVO.setPageSize(50_000); |
| | | if (start != null && end != null) { |
| | | reqVO.setPlanStartTime(new java.time.LocalDateTime[]{start.atStartOfDay(), end.atTime(23, 59, 59)}); |
| | | } |
| | | var permits = permitService.getPermitPage(reqVO).getList(); |
| | | permitService.fillPermitRefs(permits); |
| | | List<List<Object>> rows = permits.stream() |
| | | .map(p -> Arrays.<Object>asList( |
| | | str(p.getCode()), SafetyPermitTypeEnum.getNameByType(p.getPermitType()), |
| | | str(p.getTitle()), str(p.getWorkshopName()), str(p.getLocation()), |
| | | str(p.getApplicant()), dateTime(p.getApplyTime()), dateTime(p.getPlanStartTime()), |
| | | dateTime(p.getPlanEndTime()), dateTime(p.getActualStartTime()), dateTime(p.getActualEndTime()), |
| | | SafetyRiskLevelEnum.getNameByLevel(p.getRiskLevel()), str(p.getGuardian()), |
| | | str(p.getApprover()), dateTime(p.getApproveTime()), str(p.getApproveComment()), |
| | | SafetyPermitStatusEnum.getNameByStatus(p.getStatus()))) |
| | | .toList(); |
| | | return new Sheet("é«å±ä½ä¸ç¥¨å°è´¦", headers, rows); |
| | | } |
| | | |
| | | private Sheet monitorSheet() { |
| | | List<String> headers = List.of("ä½ä¸ç¥¨ç¼å·", "çæ¤æ¶é´", "çæ¤äºº", "çæ¤å
容", "å¼å¸¸æ
åµ"); |
| | | var reqVO = new cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit.SafetyWorkPermitPageReqVO(); |
| | | reqVO.setPageNo(1); |
| | | reqVO.setPageSize(5_000); |
| | | List<List<Object>> rows = new ArrayList<>(); |
| | | for (SafetyWorkPermitDO permit : permitService.getPermitPage(reqVO).getList()) { |
| | | var monitors = permitService.getMonitorList(permit.getId()); |
| | | permitService.fillMonitorGuardians(monitors); |
| | | for (SafetyWorkPermitMonitorDO monitor : monitors) { |
| | | rows.add(Arrays.asList(str(permit.getCode()), dateTime(monitor.getMonitorTime()), |
| | | str(monitor.getGuardian()), str(monitor.getMonitorContent()), str(monitor.getAbnormal()))); |
| | | } |
| | | } |
| | | return new Sheet("ä½ä¸çæ¤è®°å½", headers, rows); |
| | | } |
| | | |
| | | private Sheet materialSheet() { |
| | | List<String> headers = List.of("ç©èµç¼ç ", "ç©èµåç§°", "ç±»å«", "è§æ ¼åå·", "åä½", "åºåæ°é", |
| | | "å®å
¨åºå", "åæ¾ä½ç½®", "æææè³", "ä¿ç®¡äºº", "ç¶æ"); |
| | | var reqVO = new cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material.SafetyMaterialPageReqVO(); |
| | | reqVO.setPageNo(1); |
| | | reqVO.setPageSize(50_000); |
| | | var materials = materialService.getMaterialPage(reqVO).getList(); |
| | | materialService.fillManagers(materials); |
| | | List<List<Object>> rows = materials.stream() |
| | | .map(m -> Arrays.<Object>asList( |
| | | str(m.getCode()), str(m.getName()), |
| | | SafetyMaterialCategoryEnum.getNameByCategory(m.getCategory()), |
| | | str(m.getSpec()), str(m.getUnit()), number(m.getStockQty()), number(m.getSafeStock()), |
| | | str(m.getStorageLocation()), date(m.getExpireDate()), str(m.getManager()), |
| | | Integer.valueOf(0).equals(m.getStatus()) ? "å¯ç¨" : "åç¨")) |
| | | .toList(); |
| | | return new Sheet("åºæ¥ç©èµå°è´¦", headers, rows); |
| | | } |
| | | |
| | | private Sheet stockSheet(LocalDate start, LocalDate end) { |
| | | List<String> headers = List.of("ä¸å¡æ¥æ", "ç©èµåç§°", "ç±»å«", "ä¸å¡ç±»å", "æ°é", |
| | | "æä½ååºå", "æä½ååºå", "ç»å人", "é¢ç¨äºº", "ç¨é/å»å"); |
| | | var reqVO = new cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material.SafetyMaterialStockPageReqVO(); |
| | | reqVO.setPageNo(1); |
| | | reqVO.setPageSize(50_000); |
| | | if (start != null && end != null) { |
| | | reqVO.setBizDate(new LocalDate[]{start, end}); |
| | | } |
| | | List<List<Object>> rows = materialService.getStockPage(reqVO).getList().stream() |
| | | .map(s -> Arrays.<Object>asList( |
| | | date(s.getBizDate()), str(s.getMaterialName()), |
| | | SafetyMaterialCategoryEnum.getNameByCategory(s.getCategory()), |
| | | "IN".equals(s.getBizType()) ? "å
¥åº" : "åºåº", |
| | | number(s.getQuantity()), number(s.getStockBefore()), number(s.getStockAfter()), |
| | | str(s.getOperator()), str(s.getReceiver()), str(s.getPurpose()))) |
| | | .toList(); |
| | | return new Sheet("ç©èµåºå
¥åºæµæ°´", headers, rows); |
| | | } |
| | | |
| | | private Sheet trainingSheet(LocalDate start, LocalDate end) { |
| | | List<String> headers = List.of("å¹è®æ¥æ", "å¹è®ä¸»é¢", "å¹è®ç±»å", "妿¶", "讲å¸/ç»ç»äºº", |
| | | "å¹è®å°ç¹", "åå 人æ°", "å¹è®å
容", "èæ ¸æ
åµ"); |
| | | var trainings = trainingService.listTrainingBetween(start, end); |
| | | trainingService.fillTrainers(trainings); |
| | | List<List<Object>> rows = trainings.stream() |
| | | .map(t -> Arrays.<Object>asList( |
| | | date(t.getTrainDate()), str(t.getTitle()), |
| | | SafetyTrainingTypeEnum.getNameByType(t.getTrainingType()), |
| | | number(t.getDurationHours()), str(t.getTrainer()), str(t.getLocation()), |
| | | Objects.toString(t.getParticipantCount(), "0"), |
| | | str(t.getContent()), str(t.getExamResult()))) |
| | | .toList(); |
| | | return new Sheet("å®å
¨å¹è®å°è´¦", headers, rows); |
| | | } |
| | | |
| | | private Sheet drillSheet(LocalDate start, LocalDate end) { |
| | | List<String> headers = List.of("æ¼ç»æ¥æ", "æ¼ç»åç§°", "æ¼ç»ç±»å", "å°ç¹", "ç»ç»äºº", |
| | | "åå 人æ°", "æ¶é¿(åé)", "æ¼ç»è¿ç¨", "æ»ç»ä¸æ¹è¿"); |
| | | var drills = trainingService.listDrillBetween(start, end); |
| | | trainingService.fillOrganizers(drills); |
| | | List<List<Object>> rows = drills.stream() |
| | | .map(d -> Arrays.<Object>asList( |
| | | date(d.getDrillDate()), str(d.getTitle()), |
| | | SafetyDrillTypeEnum.getNameByType(d.getDrillType()), str(d.getLocation()), |
| | | str(d.getOrganizer()), Objects.toString(d.getParticipantCount(), "0"), |
| | | Objects.toString(d.getDurationMinutes(), ""), |
| | | str(d.getProcessDesc()), str(d.getSummary()))) |
| | | .toList(); |
| | | return new Sheet("æ¶é²æ¼ç»å°è´¦", headers, rows); |
| | | } |
| | | |
| | | private Sheet accidentSheet(LocalDate start, LocalDate end) { |
| | | List<String> headers = List.of("äºæ
ç¼å·", "äºæ
åç§°", "äºæ
ç±»å", "ç级", "åçæ¶é´", "åçå°ç¹", |
| | | "伤亡æ
åµ", "ç»æµæå¤±(å
)", "äºæ
ç»è¿", "åå åæ", "å¤çæªæ½", "ç¶æ"); |
| | | var accidents = trainingService.listAccidentBetween(start, end); |
| | | trainingService.fillAccidentRefs(accidents); |
| | | List<List<Object>> rows = accidents.stream() |
| | | .map(a -> Arrays.<Object>asList( |
| | | str(a.getCode()), str(a.getTitle()), |
| | | SafetyAccidentTypeEnum.getNameByType(a.getAccidentType()), |
| | | SafetyAccidentLevelEnum.getNameByLevel(a.getLevel()), |
| | | dateTime(a.getOccurTime()), str(a.getLocation()), str(a.getCasualtyDesc()), |
| | | number(a.getEconomicLoss()), str(a.getDescription()), str(a.getCauseAnalysis()), |
| | | str(a.getMeasures()), SafetyAccidentStatusEnum.getNameByStatus(a.getStatus()))) |
| | | .toList(); |
| | | return new Sheet("äºæ
ç»è®°å°è´¦", headers, rows); |
| | | } |
| | | |
| | | // ==================== å·¥å
·æ¹æ³ ==================== |
| | | |
| | | private static String str(String value) { |
| | | return value == null ? "" : value; |
| | | } |
| | | |
| | | private static String date(LocalDate value) { |
| | | return value == null ? "" : value.toString(); |
| | | } |
| | | |
| | | private static String dateTime(java.time.LocalDateTime value) { |
| | | return value == null ? "" : value.toString().replace('T', ' '); |
| | | } |
| | | |
| | | private static String number(java.math.BigDecimal value) { |
| | | return value == null ? "" : value.stripTrailingZeros().toPlainString(); |
| | | } |
| | | |
| | | private record Sheet(String name, List<String> headers, List<List<Object>> rows) { |
| | | } |
| | | |
| | | private void write(HttpServletResponse response, String filename, List<Sheet> sheets) throws IOException { |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename)); |
| | | try (var writer = FastExcelFactory.write(response.getOutputStream()).autoCloseStream(false).build()) { |
| | | for (int i = 0; i < sheets.size(); i++) { |
| | | Sheet sheet = sheets.get(i); |
| | | writer.write(sheet.rows(), FastExcelFactory.writerSheet(i, sheet.name()) |
| | | .head(sheet.headers().stream().map(List::of).toList()).build()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.material.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyMaterialDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyMaterialStockDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyMaterialMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyMaterialStockMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyMaterialCategoryEnum; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - åºæ¥ç©èµå°è´¦ä¸åºå
¥åº Service |
| | | * |
| | | * <p>è¦ççµåç»ç¼ç¨å
·ãå±ååãæ¶é²ç©èµãåºåºæ¶è¡éæ ¡éªåºåï¼é¿å
并忣å为è´ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class SafetyMaterialService { |
| | | |
| | | @Resource |
| | | private SafetyMaterialMapper materialMapper; |
| | | @Resource |
| | | private SafetyRefResolver refResolver; |
| | | @Resource |
| | | private SafetyMaterialStockMapper stockMapper; |
| | | |
| | | // ==================== ç©èµå°è´¦ ==================== |
| | | |
| | | public Long createMaterial(SafetyMaterialSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | String code = StrUtil.trim(reqVO.getCode()); |
| | | if (materialMapper.selectByCode(code) != null) { |
| | | throw exception(SAFETY_MATERIAL_CODE_DUPLICATE); |
| | | } |
| | | SafetyMaterialDO material = BeanUtils.toBean(reqVO, SafetyMaterialDO.class); |
| | | material.setCode(code); |
| | | material.setName(StrUtil.trim(reqVO.getName())); |
| | | material.setUnit(StrUtil.blankToDefault(reqVO.getUnit(), "个")); |
| | | applyManager(material, reqVO.getManagerId()); |
| | | material.setStockQty(reqVO.getStockQty() == null ? BigDecimal.ZERO : reqVO.getStockQty()); |
| | | material.setSafeStock(reqVO.getSafeStock() == null ? BigDecimal.ZERO : reqVO.getSafeStock()); |
| | | materialMapper.insert(material); |
| | | return material.getId(); |
| | | } |
| | | |
| | | public void updateMaterial(SafetyMaterialSaveReqVO reqVO) { |
| | | SafetyMaterialDO old = validateMaterialExists(reqVO.getId()); |
| | | String code = StrUtil.trim(reqVO.getCode()); |
| | | SafetyMaterialDO byCode = materialMapper.selectByCode(code); |
| | | if (byCode != null && !byCode.getId().equals(old.getId())) { |
| | | throw exception(SAFETY_MATERIAL_CODE_DUPLICATE); |
| | | } |
| | | SafetyMaterialDO material = BeanUtils.toBean(reqVO, SafetyMaterialDO.class); |
| | | material.setCode(code); |
| | | material.setName(StrUtil.trim(reqVO.getName())); |
| | | applyManager(material, reqVO.getManagerId()); |
| | | // åºåæ°éåªè½éè¿åºå
¥åºååå¨ï¼ç¦æ¢ç´æ¥ç¼è¾ |
| | | material.setStockQty(null); |
| | | materialMapper.updateById(material); |
| | | } |
| | | |
| | | public void deleteMaterial(Long id) { |
| | | validateMaterialExists(id); |
| | | materialMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyMaterialDO getMaterial(Long id) { |
| | | return validateMaterialExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyMaterialDO> getMaterialPage(SafetyMaterialPageReqVO reqVO) { |
| | | return materialMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | /** |
| | | * ä¿ç®¡äººï¼ä»å工档æ¡å¸¦åºå§åè½å¿«ç
§ |
| | | */ |
| | | private void applyManager(SafetyMaterialDO material, Long managerId) { |
| | | material.setManagerId(managerId); |
| | | material.setManager(managerId == null ? "" |
| | | : refResolver.requireEmployee(managerId, SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éåå¡«ä¿ç®¡äººææ°å§å |
| | | */ |
| | | public void fillManagers(List<SafetyMaterialDO> materials) { |
| | | if (CollUtil.isEmpty(materials)) { |
| | | return; |
| | | } |
| | | var employeeMap = refResolver.employeeMap(materials.stream().map(SafetyMaterialDO::getManagerId).toList()); |
| | | materials.forEach(material -> { |
| | | var employee = employeeMap.get(material.getManagerId()); |
| | | if (employee != null) material.setManager(employee.getName()); |
| | | }); |
| | | } |
| | | |
| | | public static void fillMaterialDisplay(SafetyMaterialDO material, SafetyMaterialRespVO respVO) { |
| | | respVO.setCategoryName(SafetyMaterialCategoryEnum.getNameByCategory(material.getCategory())); |
| | | BigDecimal stock = material.getStockQty() == null ? BigDecimal.ZERO : material.getStockQty(); |
| | | BigDecimal safe = material.getSafeStock() == null ? BigDecimal.ZERO : material.getSafeStock(); |
| | | respVO.setBelowSafeStock(safe.signum() > 0 && stock.compareTo(safe) < 0); |
| | | if (material.getExpireDate() != null) { |
| | | respVO.setExpireRemainingDays(ChronoUnit.DAYS.between(LocalDate.now(), material.getExpireDate())); |
| | | } |
| | | } |
| | | |
| | | // ==================== åºå
¥åº ==================== |
| | | |
| | | /** |
| | | * åºå
¥åºç»è®°ï¼è¡é读ååºå â 计ç®åå¨ â åæµæ°´ â åååºå |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createStock(SafetyMaterialStockSaveReqVO reqVO) { |
| | | SafetyMaterialDO material = materialMapper.selectByIdForUpdate(reqVO.getMaterialId()); |
| | | if (material == null) { |
| | | throw exception(SAFETY_MATERIAL_NOT_EXISTS); |
| | | } |
| | | BigDecimal before = material.getStockQty() == null ? BigDecimal.ZERO : material.getStockQty(); |
| | | boolean inbound = "IN".equals(reqVO.getBizType()); |
| | | BigDecimal after = inbound ? before.add(reqVO.getQuantity()) : before.subtract(reqVO.getQuantity()); |
| | | if (!inbound && after.signum() < 0) { |
| | | throw exception(SAFETY_MATERIAL_STOCK_NOT_ENOUGH); |
| | | } |
| | | SafetyMaterialStockDO stock = BeanUtils.toBean(reqVO, SafetyMaterialStockDO.class); |
| | | stock.setId(null); |
| | | stock.setMaterialName(material.getName()); |
| | | stock.setCategory(material.getCategory()); |
| | | stock.setQuantity(reqVO.getQuantity()); |
| | | stock.setStockBefore(before); |
| | | stock.setStockAfter(after); |
| | | stock.setBizDate(reqVO.getBizDate() == null ? LocalDate.now() : reqVO.getBizDate()); |
| | | stock.setOperator(StrUtil.trim(reqVO.getOperator())); |
| | | stockMapper.insert(stock); |
| | | |
| | | SafetyMaterialDO update = new SafetyMaterialDO(); |
| | | update.setId(material.getId()); |
| | | update.setStockQty(after); |
| | | materialMapper.updateById(update); |
| | | return stock.getId(); |
| | | } |
| | | |
| | | public PageResult<SafetyMaterialStockDO> getStockPage(SafetyMaterialStockPageReqVO reqVO) { |
| | | return stockMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | public static void fillStockDisplay(SafetyMaterialStockDO stock, SafetyMaterialStockRespVO respVO) { |
| | | respVO.setCategoryName(SafetyMaterialCategoryEnum.getNameByCategory(stock.getCategory())); |
| | | respVO.setBizTypeName("IN".equals(stock.getBizType()) ? "å
¥åº" : "åºåº"); |
| | | } |
| | | |
| | | /** |
| | | * é¢è¦æ¸
åï¼ä½äºå®å
¨åºåçç©èµ |
| | | */ |
| | | public List<SafetyMaterialDO> getBelowSafeStockList() { |
| | | return materialMapper.selectBelowSafeStock(); |
| | | } |
| | | |
| | | /** |
| | | * é¢è¦æ¸
åï¼æææä¸´è¿ï¼é»è®¤ 30 天å
ï¼çç©èµ |
| | | */ |
| | | public List<SafetyMaterialDO> getExpiringList(Integer days) { |
| | | int warnDays = days == null || days <= 0 ? 30 : days; |
| | | return materialMapper.selectExpiringBefore(LocalDate.now().plusDays(warnDays)); |
| | | } |
| | | |
| | | private SafetyMaterialDO validateMaterialExists(Long id) { |
| | | SafetyMaterialDO material = id == null ? null : materialMapper.selectById(id); |
| | | if (material == null) { |
| | | throw exception(SAFETY_MATERIAL_NOT_EXISTS); |
| | | } |
| | | return material; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.org.SafetyOrgRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.org.SafetyOrgSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyOrgDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyOrgMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å®å
¨ç»ç»æ¶æ Service |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class SafetyOrgService { |
| | | |
| | | @Resource |
| | | private SafetyOrgMapper safetyOrgMapper; |
| | | @Resource |
| | | private SafetyRefResolver refResolver; |
| | | |
| | | public Long createOrg(SafetyOrgSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | validateParent(reqVO.getParentId(), null); |
| | | SafetyOrgDO org = BeanUtils.toBean(reqVO, SafetyOrgDO.class); |
| | | org.setParentId(reqVO.getParentId() == null ? 0L : reqVO.getParentId()); |
| | | applyLeader(org, reqVO.getLeaderId()); |
| | | safetyOrgMapper.insert(org); |
| | | return org.getId(); |
| | | } |
| | | |
| | | public void updateOrg(SafetyOrgSaveReqVO reqVO) { |
| | | validateOrgExists(reqVO.getId()); |
| | | validateParent(reqVO.getParentId(), reqVO.getId()); |
| | | SafetyOrgDO org = BeanUtils.toBean(reqVO, SafetyOrgDO.class); |
| | | org.setParentId(reqVO.getParentId() == null ? 0L : reqVO.getParentId()); |
| | | applyLeader(org, reqVO.getLeaderId()); |
| | | safetyOrgMapper.updateById(org); |
| | | } |
| | | |
| | | /** |
| | | * è´è´£äººï¼ä»å工档æ¡å¸¦åºå§åä¸çµè¯å¹¶è½å¿«ç
§ |
| | | */ |
| | | private void applyLeader(SafetyOrgDO org, Long leaderId) { |
| | | org.setLeaderId(leaderId); |
| | | if (leaderId == null) { |
| | | org.setLeaderName(""); |
| | | return; |
| | | } |
| | | var employee = refResolver.requireEmployee(leaderId, SAFETY_EMPLOYEE_REQUIRED); |
| | | org.setLeaderName(employee.getName()); |
| | | org.setLeaderPhone(employee.getPhone()); |
| | | } |
| | | |
| | | public void deleteOrg(Long id) { |
| | | validateOrgExists(id); |
| | | if (safetyOrgMapper.selectCountByParentId(id) > 0) { |
| | | throw exception(SAFETY_ORG_HAS_CHILDREN); |
| | | } |
| | | safetyOrgMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyOrgDO getOrg(Long id) { |
| | | return validateOrgExists(id); |
| | | } |
| | | |
| | | /** |
| | | * åè´è´£äººææ°æ¡£æ¡ï¼ä¾åæ¡æ¥è¯¢åå¡«ç¨ï¼ |
| | | */ |
| | | public cn.iocoder.yudao.module.hrm.api.employee.dto.HrmEmployeeSimpleDTO getLeader(Long leaderId) { |
| | | return refResolver.findEmployee(leaderId); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç»ç»æ |
| | | */ |
| | | public List<SafetyOrgRespVO> getOrgTree() { |
| | | List<SafetyOrgDO> all = safetyOrgMapper.selectListOrdered(); |
| | | List<SafetyOrgRespVO> nodes = BeanUtils.toBean(all, SafetyOrgRespVO.class); |
| | | // è´è´£äººç¨åå·¥æ¡£æ¡ææ°å§åè¦çå¿«ç
§ï¼åå·¥æ¹å/è°å²åæ ä¹åæ¥ |
| | | var employeeMap = refResolver.employeeMap( |
| | | all.stream().map(SafetyOrgDO::getLeaderId).toList()); |
| | | nodes.forEach(node -> { |
| | | var employee = employeeMap.get(node.getLeaderId()); |
| | | if (employee != null) { |
| | | node.setLeaderName(employee.getName()); |
| | | } |
| | | }); |
| | | Map<Long, List<SafetyOrgRespVO>> grouped = nodes.stream() |
| | | .collect(Collectors.groupingBy(SafetyOrgRespVO::getParentId, Collectors.toList())); |
| | | nodes.forEach(node -> node.setChildren(grouped.getOrDefault(node.getId(), new ArrayList<>()))); |
| | | List<SafetyOrgRespVO> roots = grouped.getOrDefault(0L, new ArrayList<>()); |
| | | if (CollUtil.isEmpty(roots)) { |
| | | // å
¼å®¹ parentId 为空çèæ°æ® |
| | | roots = nodes.stream().filter(n -> n.getParentId() == null || n.getParentId() == 0L).toList(); |
| | | } |
| | | return roots; |
| | | } |
| | | |
| | | private void validateParent(Long parentId, Long selfId) { |
| | | if (parentId == null || parentId == 0L) { |
| | | return; |
| | | } |
| | | if (parentId.equals(selfId)) { |
| | | throw exception(SAFETY_ORG_PARENT_IS_SELF); |
| | | } |
| | | SafetyOrgDO parent = safetyOrgMapper.selectById(parentId); |
| | | if (parent == null) { |
| | | throw exception(SAFETY_ORG_PARENT_NOT_EXISTS); |
| | | } |
| | | // 鲿¢æç¶èç¹æå°èªå·±çååä¸ï¼å½¢æç¯ |
| | | if (selfId != null && isDescendant(parentId, selfId)) { |
| | | throw exception(SAFETY_ORG_PARENT_IS_CHILD); |
| | | } |
| | | } |
| | | |
| | | private boolean isDescendant(Long candidateId, Long ancestorId) { |
| | | Long current = candidateId; |
| | | int guard = 0; |
| | | while (current != null && current != 0L && guard++ < 100) { |
| | | if (current.equals(ancestorId)) { |
| | | return true; |
| | | } |
| | | SafetyOrgDO node = safetyOrgMapper.selectById(current); |
| | | if (node == null) { |
| | | return false; |
| | | } |
| | | current = node.getParentId(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | private SafetyOrgDO validateOrgExists(Long id) { |
| | | if (id == null) { |
| | | throw exception(SAFETY_ORG_NOT_EXISTS); |
| | | } |
| | | SafetyOrgDO org = safetyOrgMapper.selectById(id); |
| | | if (org == null) { |
| | | throw exception(SAFETY_ORG_NOT_EXISTS); |
| | | } |
| | | return org; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.*; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.*; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.ledger.SafetyOverviewRespVO; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.YearMonth; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - æ»è§ç»è®¡ Service |
| | | * |
| | | * <p>æä¾é¦é¡µ KPI ä¸è¶å¿æ°æ®ï¼å
¨é¨åºäºç°æå°è´¦å®æ¶è®¡ç®ï¼ä¸ååä½ç»è®¡è¡¨ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class SafetyOverviewService { |
| | | |
| | | private static final DateTimeFormatter MONTH_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM"); |
| | | /** è¶å¿å±ç¤ºææ° */ |
| | | private static final int TREND_MONTHS = 6; |
| | | |
| | | @Resource |
| | | private SafetyCertificateMapper certificateMapper; |
| | | @Resource |
| | | private SafetyHazardMapper hazardMapper; |
| | | @Resource |
| | | private SafetyWorkPermitMapper permitMapper; |
| | | @Resource |
| | | private SafetyMaterialMapper materialMapper; |
| | | @Resource |
| | | private SafetyTrainingMapper trainingMapper; |
| | | @Resource |
| | | private SafetyDrillMapper drillMapper; |
| | | @Resource |
| | | private SafetyAccidentMapper accidentMapper; |
| | | |
| | | public SafetyOverviewRespVO getOverview() { |
| | | SafetyOverviewRespVO overview = new SafetyOverviewRespVO(); |
| | | LocalDate today = LocalDate.now(); |
| | | |
| | | // ---------- ç¹ç§ä½ä¸è¯ ---------- |
| | | List<SafetyCertificateDO> certs = certificateMapper.selectList(); |
| | | long expiring = 0; |
| | | long expired = 0; |
| | | for (SafetyCertificateDO cert : certs) { |
| | | String status = SafetyCertificateService.resolveStatus( |
| | | cert.getExpireDate(), cert.getWarnDays(), cert.getStatus()); |
| | | if ("EXPIRED".equals(status)) { |
| | | expired++; |
| | | } else if ("EXPIRING".equals(status)) { |
| | | expiring++; |
| | | } |
| | | } |
| | | overview.setCertTotal((long) certs.size()); |
| | | overview.setCertExpiring(expiring); |
| | | overview.setCertExpired(expired); |
| | | |
| | | // ---------- 鿣 ---------- |
| | | List<SafetyHazardDO> hazards = hazardMapper.selectList(); |
| | | long hazardOpen = hazards.stream() |
| | | .filter(h -> !"CLOSED".equals(h.getStatus())).count(); |
| | | long hazardOverdue = hazardMapper.selectOverdue(today).size(); |
| | | long hazardClosed = hazards.size() - hazardOpen; |
| | | overview.setHazardTotal((long) hazards.size()); |
| | | overview.setHazardOpen(hazardOpen); |
| | | overview.setHazardOverdue(hazardOverdue); |
| | | overview.setHazardCloseRate(hazards.isEmpty() ? 0 |
| | | : (int) Math.round(hazardClosed * 100.0 / hazards.size())); |
| | | |
| | | // ---------- ä½ä¸ç¥¨ ---------- |
| | | List<SafetyWorkPermitDO> permits = permitMapper.selectList(); |
| | | overview.setPermitPending(permits.stream() |
| | | .filter(p -> "PENDING".equals(p.getStatus())).count()); |
| | | overview.setPermitInProgress(permits.stream() |
| | | .filter(p -> "IN_PROGRESS".equals(p.getStatus())).count()); |
| | | |
| | | // ---------- ç©èµ ---------- |
| | | overview.setMaterialBelowSafeStock((long) materialMapper.selectBelowSafeStock().size()); |
| | | overview.setMaterialExpiring((long) materialMapper.selectExpiringBefore(today.plusDays(30)).size()); |
| | | |
| | | // ---------- æ¬ææ´»å¨ ---------- |
| | | YearMonth currentMonth = YearMonth.from(today); |
| | | LocalDate monthStart = currentMonth.atDay(1); |
| | | LocalDate monthEnd = currentMonth.atEndOfMonth(); |
| | | overview.setTrainingThisMonth((long) trainingMapper.selectListBetween(monthStart, monthEnd).size()); |
| | | overview.setDrillThisMonth((long) drillMapper.selectListBetween(monthStart, monthEnd).size()); |
| | | overview.setAccidentThisMonth((long) accidentMapper.selectListBetween( |
| | | monthStart.atStartOfDay(), monthEnd.atTime(23, 59, 59)).size()); |
| | | |
| | | // ---------- è¶å¿ï¼è¿ 6 个æï¼ ---------- |
| | | overview.setHazardTrend(buildTrend(hazards.stream().map(SafetyHazardDO::getReportTime).toList())); |
| | | overview.setAccidentTrend(buildTrend(hazards.isEmpty() ? List.of() |
| | | : accidentMapper.selectList().stream().map(SafetyAccidentDO::getOccurTime).toList())); |
| | | |
| | | return overview; |
| | | } |
| | | |
| | | /** |
| | | * ææèåæ¶é´ç¹ï¼è¾åºè¿ N 个æçè¿ç»åºåï¼æ æ°æ®çæä»½è¡¥ 0ï¼ |
| | | */ |
| | | private List<SafetyOverviewRespVO.MonthlyCount> buildTrend(List<LocalDateTime> times) { |
| | | Map<String, Long> counts = new LinkedHashMap<>(); |
| | | YearMonth current = YearMonth.from(LocalDate.now()); |
| | | List<YearMonth> months = new ArrayList<>(); |
| | | for (int i = TREND_MONTHS - 1; i >= 0; i--) { |
| | | YearMonth month = current.minusMonths(i); |
| | | months.add(month); |
| | | counts.put(month.format(MONTH_FORMAT), 0L); |
| | | } |
| | | for (LocalDateTime time : times) { |
| | | if (time == null) { |
| | | continue; |
| | | } |
| | | String key = YearMonth.from(time).format(MONTH_FORMAT); |
| | | if (counts.containsKey(key)) { |
| | | counts.put(key, counts.get(key) + 1); |
| | | } |
| | | } |
| | | return months.stream().map(month -> { |
| | | SafetyOverviewRespVO.MonthlyCount item = new SafetyOverviewRespVO.MonthlyCount(); |
| | | item.setMonth(month.format(MONTH_FORMAT)); |
| | | item.setCount(counts.get(month.format(MONTH_FORMAT))); |
| | | return item; |
| | | }).toList(); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.module.hrm.api.employee.HrmEmployeeApi; |
| | | import cn.iocoder.yudao.module.hrm.api.employee.dto.HrmEmployeeSimpleDTO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkshopDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.md.workstation.MesMdWorkshopMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - ä¸»æ°æ®å¼ç¨è§£æå¨ |
| | | * |
| | | * <p>模åå
ææã人åãä¸ã车é´ãåæ®µç»ä¸èµ°è¿éè§£æï¼é¿å
æ¯ä¸ª Service éå¤åä¸éã</p> |
| | | * |
| | | * <p>ç»ä¸çº¦å®ï¼ä¸å¡è¡¨å {@code xxxId} å
³èä¸»æ°æ®ï¼åæ¶ä¿ç {@code xxxName} ä½ä¸ºå¿«ç
§ã |
| | | * ä¿åæ¶ä»ä¸»æ°æ®æå称带åºåå¿«ç
§ï¼æ¥è¯¢æ¶ç¨ä¸»æ°æ®ææ°å¼è¦çå¿«ç
§ï¼ |
| | | * è¿æ ·åå·¥è°å²ãè½¦é´æ¹ååå°è´¦ä¼èªå¨è·çåï¼èä¸»æ°æ®è¢«å æ¶èè®°å½ä»è½é å¿«ç
§å±ç¤ºã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Component |
| | | public class SafetyRefResolver { |
| | | |
| | | @Resource |
| | | private HrmEmployeeApi hrmEmployeeApi; |
| | | @Resource |
| | | private MesMdWorkshopMapper workshopMapper; |
| | | |
| | | // ==================== åå·¥ ==================== |
| | | |
| | | /** |
| | | * æåå·¥ç¼å·ååå·¥ï¼å¿
é¡»åå¨ |
| | | * |
| | | * @throws cn.iocoder.yudao.framework.common.exception.ServiceException åå·¥ä¸å卿¶æåº |
| | | */ |
| | | public HrmEmployeeSimpleDTO requireEmployee(Long employeeId, cn.iocoder.yudao.framework.common.exception.ErrorCode errorCode) { |
| | | if (employeeId == null) { |
| | | throw exception(errorCode); |
| | | } |
| | | HrmEmployeeSimpleDTO employee = hrmEmployeeApi.getEmployee(employeeId); |
| | | if (employee == null) { |
| | | throw exception(errorCode); |
| | | } |
| | | return employee; |
| | | } |
| | | |
| | | /** |
| | | * å¯ç©ºçå工解æï¼id 为空è¿å nullï¼ä¸æ ¡éªå卿§ï¼ç¨äºéå¿
å¡«åæ®µï¼ |
| | | */ |
| | | public HrmEmployeeSimpleDTO findEmployee(Long employeeId) { |
| | | return employeeId == null ? null : hrmEmployeeApi.getEmployee(employeeId); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éååå·¥ï¼è¿å id -> åå·¥ ç Map |
| | | */ |
| | | public Map<Long, HrmEmployeeSimpleDTO> employeeMap(Collection<Long> employeeIds) { |
| | | // 注æï¼è¿éå¿
é¡»è¿å坿¥å null key ç空 Mapã |
| | | // è°ç¨æ¹ä¼ç´æ¥ map.get(è®°å½éç xxxId)ï¼è xxxId å
许为 nullï¼ä¾å¦ç»ç»æªè®¾è´è´£äººã |
| | | // è¯ä»¶æªå
³èæè¯äººï¼ï¼Map.of() ç get(null) 伿 NPEï¼å¯¼è´å表æ¥å£ 500ã |
| | | if (CollUtil.isEmpty(employeeIds)) { |
| | | return new HashMap<>(); |
| | | } |
| | | List<Long> ids = employeeIds.stream().filter(Objects::nonNull).distinct().toList(); |
| | | if (ids.isEmpty()) { |
| | | return new HashMap<>(); |
| | | } |
| | | return hrmEmployeeApi.getEmployeeList(ids).stream() |
| | | .collect(Collectors.toMap(HrmEmployeeSimpleDTO::getId, e -> e, (a, b) -> a)); |
| | | } |
| | | |
| | | // ==================== è½¦é´ ==================== |
| | | |
| | | /** |
| | | * æè½¦é´ç¼å·å车é´ï¼å¿
é¡»åå¨ |
| | | */ |
| | | public MesMdWorkshopDO requireWorkshop(Long workshopId) { |
| | | if (workshopId == null) { |
| | | throw exception(SAFETY_WORKSHOP_NOT_EXISTS); |
| | | } |
| | | MesMdWorkshopDO workshop = workshopMapper.selectById(workshopId); |
| | | if (workshop == null) { |
| | | throw exception(SAFETY_WORKSHOP_NOT_EXISTS); |
| | | } |
| | | return workshop; |
| | | } |
| | | |
| | | /** |
| | | * å¯ç©ºç车é´è§£æ |
| | | */ |
| | | public MesMdWorkshopDO findWorkshop(Long workshopId) { |
| | | return workshopId == null ? null : workshopMapper.selectById(workshopId); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå车é´ï¼è¿å id -> è½¦é´ ç Map |
| | | */ |
| | | public Map<Long, MesMdWorkshopDO> workshopMap(Collection<Long> workshopIds) { |
| | | // åä¸ï¼è½¦é´ç¼å·å
许为 nullï¼ç©ºéåå¿
é¡»è¿å坿¥å null key ç Map |
| | | if (CollUtil.isEmpty(workshopIds)) { |
| | | return new HashMap<>(); |
| | | } |
| | | List<Long> ids = workshopIds.stream().filter(Objects::nonNull).distinct().toList(); |
| | | if (ids.isEmpty()) { |
| | | return new HashMap<>(); |
| | | } |
| | | return workshopMapper.selectBatchIds(ids).stream() |
| | | .collect(Collectors.toMap(MesMdWorkshopDO::getId, w -> w, (a, b) -> a)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.train.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyAccidentDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyDrillDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyTrainingDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyAccidentMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyDrillMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyTrainingMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.*; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - å¹è®ãæ¼ç»ãäºæ
ç»è®° Service |
| | | * |
| | | * <p>ä¸ç±»è®°å½ç»ä¸å½æ¡£ï¼ä¾æ ååå°è´¦å¯¼åºä½¿ç¨ã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class SafetyTrainingService { |
| | | |
| | | private static final DateTimeFormatter CODE_DATE = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | |
| | | @Resource |
| | | private SafetyTrainingMapper trainingMapper; |
| | | @Resource |
| | | private SafetyRefResolver refResolver; |
| | | @Resource |
| | | private SafetyDrillMapper drillMapper; |
| | | @Resource |
| | | private SafetyAccidentMapper accidentMapper; |
| | | |
| | | // ==================== å¹è® ==================== |
| | | |
| | | public Long createTraining(SafetyTrainingSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | SafetyTrainingDO training = BeanUtils.toBean(reqVO, SafetyTrainingDO.class); |
| | | training.setTitle(StrUtil.trim(reqVO.getTitle())); |
| | | training.setTrainingType(StrUtil.blankToDefault(reqVO.getTrainingType(), SafetyTrainingTypeEnum.SAFETY.getType())); |
| | | training.setTrainerId(reqVO.getTrainerId()); |
| | | training.setTrainer(reqVO.getTrainerId() == null ? "" |
| | | : refResolver.requireEmployee(reqVO.getTrainerId(), SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | training.setParticipantCount(resolveCount(reqVO.getParticipantCount(), reqVO.getParticipants())); |
| | | training.setRemark(reqVO.getRemark() == null ? "" : reqVO.getRemark().trim()); |
| | | trainingMapper.insert(training); |
| | | return training.getId(); |
| | | } |
| | | |
| | | public void updateTraining(SafetyTrainingSaveReqVO reqVO) { |
| | | validateTrainingExists(reqVO.getId()); |
| | | SafetyTrainingDO training = BeanUtils.toBean(reqVO, SafetyTrainingDO.class); |
| | | training.setTitle(StrUtil.trim(reqVO.getTitle())); |
| | | training.setParticipantCount(resolveCount(reqVO.getParticipantCount(), reqVO.getParticipants())); |
| | | trainingMapper.updateById(training); |
| | | } |
| | | |
| | | public void deleteTraining(Long id) { |
| | | validateTrainingExists(id); |
| | | trainingMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyTrainingDO getTraining(Long id) { |
| | | return validateTrainingExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyTrainingDO> getTrainingPage(SafetyTrainingPageReqVO reqVO) { |
| | | return trainingMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | /** |
| | | * äºæ
çä¸»æ°æ®å¼ç¨ï¼æå±è½¦é´ + ç»è®°äºº |
| | | */ |
| | | private void applyAccidentRefs(SafetyAccidentDO accident, SafetyAccidentSaveReqVO reqVO) { |
| | | accident.setWorkshopId(reqVO.getWorkshopId()); |
| | | accident.setWorkshopName(reqVO.getWorkshopId() == null ? "" |
| | | : refResolver.requireWorkshop(reqVO.getWorkshopId()).getName()); |
| | | accident.setReporterId(reqVO.getReporterId()); |
| | | accident.setReporter(reqVO.getReporterId() == null ? "" |
| | | : refResolver.requireEmployee(reqVO.getReporterId(), SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | } |
| | | |
| | | /** æ¹éåå¡«å¹è®è®²å¸ææ°å§å */ |
| | | public void fillTrainers(List<SafetyTrainingDO> trainings) { |
| | | if (CollUtil.isEmpty(trainings)) return; |
| | | var employeeMap = refResolver.employeeMap(trainings.stream().map(SafetyTrainingDO::getTrainerId).toList()); |
| | | trainings.forEach(t -> { |
| | | var e = employeeMap.get(t.getTrainerId()); |
| | | if (e != null) t.setTrainer(e.getName()); |
| | | }); |
| | | } |
| | | |
| | | /** æ¹éåå¡«æ¼ç»ç»ç»äººææ°å§å */ |
| | | public void fillOrganizers(List<SafetyDrillDO> drills) { |
| | | if (CollUtil.isEmpty(drills)) return; |
| | | var employeeMap = refResolver.employeeMap(drills.stream().map(SafetyDrillDO::getOrganizerId).toList()); |
| | | drills.forEach(d -> { |
| | | var e = employeeMap.get(d.getOrganizerId()); |
| | | if (e != null) d.setOrganizer(e.getName()); |
| | | }); |
| | | } |
| | | |
| | | /** æ¹éåå¡«äºæ
ç车é´åä¸ç»è®°äººå§å */ |
| | | public void fillAccidentRefs(List<SafetyAccidentDO> accidents) { |
| | | if (CollUtil.isEmpty(accidents)) return; |
| | | var workshopMap = refResolver.workshopMap(accidents.stream().map(SafetyAccidentDO::getWorkshopId).toList()); |
| | | var employeeMap = refResolver.employeeMap(accidents.stream().map(SafetyAccidentDO::getReporterId).toList()); |
| | | accidents.forEach(a -> { |
| | | var w = workshopMap.get(a.getWorkshopId()); |
| | | if (w != null) a.setWorkshopName(w.getName()); |
| | | var e = employeeMap.get(a.getReporterId()); |
| | | if (e != null) a.setReporter(e.getName()); |
| | | }); |
| | | } |
| | | |
| | | public static void fillTrainingDisplay(SafetyTrainingDO training, SafetyTrainingRespVO respVO) { |
| | | respVO.setTrainingTypeName(SafetyTrainingTypeEnum.getNameByType(training.getTrainingType())); |
| | | } |
| | | |
| | | // ==================== æ¼ç» ==================== |
| | | |
| | | public Long createDrill(SafetyDrillSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | SafetyDrillDO drill = BeanUtils.toBean(reqVO, SafetyDrillDO.class); |
| | | drill.setTitle(StrUtil.trim(reqVO.getTitle())); |
| | | drill.setDrillType(StrUtil.blankToDefault(reqVO.getDrillType(), SafetyDrillTypeEnum.FIRE.getType())); |
| | | drill.setOrganizerId(reqVO.getOrganizerId()); |
| | | drill.setOrganizer(reqVO.getOrganizerId() == null ? "" |
| | | : refResolver.requireEmployee(reqVO.getOrganizerId(), SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | drill.setParticipantCount(resolveCount(reqVO.getParticipantCount(), reqVO.getParticipants())); |
| | | drill.setRemark(reqVO.getRemark() == null ? "" : reqVO.getRemark().trim()); |
| | | drillMapper.insert(drill); |
| | | return drill.getId(); |
| | | } |
| | | |
| | | public void updateDrill(SafetyDrillSaveReqVO reqVO) { |
| | | validateDrillExists(reqVO.getId()); |
| | | SafetyDrillDO drill = BeanUtils.toBean(reqVO, SafetyDrillDO.class); |
| | | drill.setTitle(StrUtil.trim(reqVO.getTitle())); |
| | | drill.setParticipantCount(resolveCount(reqVO.getParticipantCount(), reqVO.getParticipants())); |
| | | drillMapper.updateById(drill); |
| | | } |
| | | |
| | | public void deleteDrill(Long id) { |
| | | validateDrillExists(id); |
| | | drillMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyDrillDO getDrill(Long id) { |
| | | return validateDrillExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyDrillDO> getDrillPage(SafetyDrillPageReqVO reqVO) { |
| | | return drillMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | public static void fillDrillDisplay(SafetyDrillDO drill, SafetyDrillRespVO respVO) { |
| | | respVO.setDrillTypeName(SafetyDrillTypeEnum.getNameByType(drill.getDrillType())); |
| | | } |
| | | |
| | | // ==================== äºæ
==================== |
| | | |
| | | public Long createAccident(SafetyAccidentSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | SafetyAccidentDO accident = BeanUtils.toBean(reqVO, SafetyAccidentDO.class); |
| | | accident.setCode(accidentMapper.selectNextCode("AC" + LocalDate.now().format(CODE_DATE))); |
| | | accident.setTitle(StrUtil.trim(reqVO.getTitle())); |
| | | accident.setLevel(StrUtil.blankToDefault(reqVO.getLevel(), SafetyAccidentLevelEnum.GENERAL.getLevel())); |
| | | accident.setStatus(StrUtil.blankToDefault(reqVO.getStatus(), SafetyAccidentStatusEnum.REPORTED.getStatus())); |
| | | applyAccidentRefs(accident, reqVO); |
| | | accident.setReportTime(reqVO.getReportTime() == null ? LocalDateTime.now() : reqVO.getReportTime()); |
| | | accident.setRemark(reqVO.getRemark() == null ? "" : reqVO.getRemark().trim()); |
| | | accidentMapper.insert(accident); |
| | | return accident.getId(); |
| | | } |
| | | |
| | | public void updateAccident(SafetyAccidentSaveReqVO reqVO) { |
| | | validateAccidentExists(reqVO.getId()); |
| | | SafetyAccidentDO accident = BeanUtils.toBean(reqVO, SafetyAccidentDO.class); |
| | | accident.setCode(null); |
| | | applyAccidentRefs(accident, reqVO); |
| | | accidentMapper.updateById(accident); |
| | | } |
| | | |
| | | public void deleteAccident(Long id) { |
| | | validateAccidentExists(id); |
| | | accidentMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyAccidentDO getAccident(Long id) { |
| | | return validateAccidentExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyAccidentDO> getAccidentPage(SafetyAccidentPageReqVO reqVO) { |
| | | return accidentMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | public static void fillAccidentDisplay(SafetyAccidentDO accident, SafetyAccidentRespVO respVO) { |
| | | respVO.setAccidentTypeName(SafetyAccidentTypeEnum.getNameByType(accident.getAccidentType())); |
| | | respVO.setLevelName(SafetyAccidentLevelEnum.getNameByLevel(accident.getLevel())); |
| | | respVO.setStatusName(SafetyAccidentStatusEnum.getNameByStatus(accident.getStatus())); |
| | | } |
| | | |
| | | // ==================== å°è´¦å¯¼åºç¨æ¥è¯¢ ==================== |
| | | |
| | | public List<SafetyTrainingDO> listTrainingBetween(LocalDate begin, LocalDate end) { |
| | | return trainingMapper.selectListBetween(begin, end); |
| | | } |
| | | |
| | | public List<SafetyDrillDO> listDrillBetween(LocalDate begin, LocalDate end) { |
| | | return drillMapper.selectListBetween(begin, end); |
| | | } |
| | | |
| | | public List<SafetyAccidentDO> listAccidentBetween(LocalDate begin, LocalDate end) { |
| | | return accidentMapper.selectListBetween( |
| | | begin == null ? null : begin.atStartOfDay(), |
| | | end == null ? null : end.atTime(23, 59, 59)); |
| | | } |
| | | |
| | | // ==================== ç§æ ==================== |
| | | |
| | | /** åå äººæ°æªå¡«æ¶ï¼æå§åéå·å鿰鿍æ */ |
| | | private static int resolveCount(Integer count, String participants) { |
| | | if (count != null && count > 0) { |
| | | return count; |
| | | } |
| | | if (StrUtil.isBlank(participants)) { |
| | | return 0; |
| | | } |
| | | return (int) java.util.Arrays.stream(participants.split("[,ï¼ã]")) |
| | | .map(String::trim).filter(StrUtil::isNotBlank).count(); |
| | | } |
| | | |
| | | private SafetyTrainingDO validateTrainingExists(Long id) { |
| | | SafetyTrainingDO training = id == null ? null : trainingMapper.selectById(id); |
| | | if (training == null) { |
| | | throw exception(SAFETY_TRAINING_NOT_EXISTS); |
| | | } |
| | | return training; |
| | | } |
| | | |
| | | private SafetyDrillDO validateDrillExists(Long id) { |
| | | SafetyDrillDO drill = id == null ? null : drillMapper.selectById(id); |
| | | if (drill == null) { |
| | | throw exception(SAFETY_DRILL_NOT_EXISTS); |
| | | } |
| | | return drill; |
| | | } |
| | | |
| | | private SafetyAccidentDO validateAccidentExists(Long id) { |
| | | SafetyAccidentDO accident = id == null ? null : accidentMapper.selectById(id); |
| | | if (accident == null) { |
| | | throw exception(SAFETY_ACCIDENT_NOT_EXISTS); |
| | | } |
| | | return accident; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.safety; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.safety.vo.permit.*; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyWorkPermitDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.safety.SafetyWorkPermitMonitorDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyWorkPermitMapper; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.safety.SafetyWorkPermitMonitorMapper; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyPermitStatusEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyPermitTypeEnum; |
| | | import cn.iocoder.yudao.module.mes.enums.safety.SafetyRiskLevelEnum; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.SafetyErrorCodeConstants.*; |
| | | |
| | | /** |
| | | * å®å
¨ç产 - é«å±ä½ä¸ç¥¨ Service |
| | | * |
| | | * <p>å¨ç«ãé«å带çµãæé空é´çä½ä¸ç线ä¸å®¡æ¹ä¸çµåçåã |
| | | * ç¶ææµè½¬ï¼è稿 â å¾
å®¡æ¹ â å·²æ¹å â ä½ä¸ä¸ â å·²å®ç»ï¼é©³å/ä½åºä¸ºç»æ¢æã</p> |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class SafetyWorkPermitService { |
| | | |
| | | private static final DateTimeFormatter CODE_DATE = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| | | |
| | | @Resource |
| | | private SafetyWorkPermitMapper permitMapper; |
| | | @Resource |
| | | private SafetyRefResolver refResolver; |
| | | @Resource |
| | | private SafetyWorkPermitMonitorMapper monitorMapper; |
| | | |
| | | /** |
| | | * æäº¤ä½ä¸ç³è¯·ï¼è稿æå¾
审æ¹ï¼ |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createPermit(SafetyWorkPermitSaveReqVO reqVO) { |
| | | reqVO.setId(null); |
| | | validateTimeRange(reqVO); |
| | | SafetyWorkPermitDO permit = BeanUtils.toBean(reqVO, SafetyWorkPermitDO.class); |
| | | permit.setCode(permitMapper.selectNextCode("WP" + LocalDate.now().format(CODE_DATE))); |
| | | permit.setTitle(StrUtil.trim(reqVO.getTitle())); |
| | | applyPermitRefs(permit, reqVO); |
| | | permit.setApplyTime(reqVO.getApplyTime() == null ? LocalDateTime.now() : reqVO.getApplyTime()); |
| | | permit.setRiskLevel(StrUtil.blankToDefault(reqVO.getRiskLevel(), SafetyRiskLevelEnum.NORMAL.getLevel())); |
| | | permit.setStatus(SafetyPermitStatusEnum.PENDING.getStatus()); |
| | | permit.setRemark(reqVO.getRemark() == null ? "" : reqVO.getRemark().trim()); |
| | | permitMapper.insert(permit); |
| | | return permit.getId(); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ä½ä¸ç¥¨ï¼ä»
è稿/å¾
审æ¹å¯æ¹ï¼ |
| | | */ |
| | | public void updatePermit(SafetyWorkPermitSaveReqVO reqVO) { |
| | | SafetyWorkPermitDO old = validatePermitExists(reqVO.getId()); |
| | | ensureStatus(old, SafetyPermitStatusEnum.DRAFT, SafetyPermitStatusEnum.PENDING); |
| | | validateTimeRange(reqVO); |
| | | SafetyWorkPermitDO update = BeanUtils.toBean(reqVO, SafetyWorkPermitDO.class); |
| | | update.setCode(null); |
| | | update.setStatus(null); |
| | | applyPermitRefs(update, reqVO); |
| | | permitMapper.updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * ä½ä¸ç¥¨çä¸»æ°æ®å¼ç¨ï¼ä½ä¸è½¦é´ + ç³è¯·äºº + çæ¤äººï¼ä»ä¸»æ°æ®å¸¦åºåç§°è½å¿«ç
§ |
| | | */ |
| | | private void applyPermitRefs(SafetyWorkPermitDO permit, SafetyWorkPermitSaveReqVO reqVO) { |
| | | permit.setWorkshopId(reqVO.getWorkshopId()); |
| | | permit.setWorkshopName(reqVO.getWorkshopId() == null ? "" |
| | | : refResolver.requireWorkshop(reqVO.getWorkshopId()).getName()); |
| | | var applicant = refResolver.requireEmployee(reqVO.getApplicantId(), SAFETY_EMPLOYEE_REQUIRED); |
| | | permit.setApplicantId(applicant.getId()); |
| | | permit.setApplicant(applicant.getName()); |
| | | permit.setGuardianId(reqVO.getGuardianId()); |
| | | permit.setGuardian(reqVO.getGuardianId() == null ? "" |
| | | : refResolver.requireEmployee(reqVO.getGuardianId(), SAFETY_EMPLOYEE_REQUIRED).getName()); |
| | | } |
| | | |
| | | /** |
| | | * 审æ¹ä½ä¸ç¥¨ |
| | | * |
| | | * <p>æ¹åæ¶æ ¡éªé«å±ä½ä¸ï¼å¨ç«/é«å带çµ/æé空é´ï¼å¿
é¡»æå®çæ¤äººï¼ |
| | | * ä¿è¯ä½ä¸ç¥¨çµåçåç宿´æ§ã</p> |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void approvePermit(SafetyWorkPermitApproveReqVO reqVO) { |
| | | SafetyWorkPermitDO permit = validatePermitExists(reqVO.getId()); |
| | | ensureStatus(permit, SafetyPermitStatusEnum.PENDING); |
| | | var approver = refResolver.requireEmployee(reqVO.getApproverId(), SAFETY_EMPLOYEE_REQUIRED); |
| | | // ç³è¯·äººä¸è½å®¡æ¹èªå·±çä½ä¸ç¥¨ï¼æåå·¥ç¼å·æ¯è¾ï¼é¿å
åå误å¤ï¼ |
| | | if (permit.getApplicantId() != null && permit.getApplicantId().equals(approver.getId())) { |
| | | throw exception(SAFETY_PERMIT_SELF_APPROVE); |
| | | } |
| | | boolean approved = "APPROVED".equals(reqVO.getDecision()); |
| | | if (approved && SafetyPermitTypeEnum.requiresGuardian(permit.getPermitType()) |
| | | && permit.getGuardianId() == null) { |
| | | throw exception(SAFETY_PERMIT_GUARDIAN_REQUIRED); |
| | | } |
| | | SafetyWorkPermitDO update = new SafetyWorkPermitDO(); |
| | | update.setId(permit.getId()); |
| | | update.setApproverId(approver.getId()); |
| | | update.setApprover(approver.getName()); |
| | | update.setApproveTime(LocalDateTime.now()); |
| | | update.setApproveComment(reqVO.getApproveComment()); |
| | | update.setStatus(approved ? SafetyPermitStatusEnum.APPROVED.getStatus() |
| | | : SafetyPermitStatusEnum.REJECTED.getStatus()); |
| | | permitMapper.updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * å¼å§ä½ä¸ï¼é¡»å·²æ¹åï¼ |
| | | */ |
| | | public void startPermit(Long id) { |
| | | SafetyWorkPermitDO permit = validatePermitExists(id); |
| | | if (!SafetyPermitStatusEnum.APPROVED.getStatus().equals(permit.getStatus())) { |
| | | throw exception(SAFETY_PERMIT_NOT_APPROVED); |
| | | } |
| | | SafetyWorkPermitDO update = new SafetyWorkPermitDO(); |
| | | update.setId(id); |
| | | update.setActualStartTime(LocalDateTime.now()); |
| | | update.setStatus(SafetyPermitStatusEnum.IN_PROGRESS.getStatus()); |
| | | permitMapper.updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * ç»æä½ä¸å¹¶å½æ¡£ |
| | | */ |
| | | public void closePermit(Long id) { |
| | | SafetyWorkPermitDO permit = validatePermitExists(id); |
| | | ensureStatus(permit, SafetyPermitStatusEnum.IN_PROGRESS); |
| | | SafetyWorkPermitDO update = new SafetyWorkPermitDO(); |
| | | update.setId(id); |
| | | update.setActualEndTime(LocalDateTime.now()); |
| | | update.setStatus(SafetyPermitStatusEnum.CLOSED.getStatus()); |
| | | permitMapper.updateById(update); |
| | | } |
| | | |
| | | /** |
| | | * ä½åºä½ä¸ç¥¨ï¼æªå®ç»ååå¯ä½åºï¼ |
| | | */ |
| | | public void cancelPermit(Long id) { |
| | | SafetyWorkPermitDO permit = validatePermitExists(id); |
| | | if (SafetyPermitStatusEnum.CLOSED.getStatus().equals(permit.getStatus()) |
| | | || SafetyPermitStatusEnum.CANCELLED.getStatus().equals(permit.getStatus())) { |
| | | throw exception(SAFETY_PERMIT_STATUS_ERROR); |
| | | } |
| | | SafetyWorkPermitDO update = new SafetyWorkPermitDO(); |
| | | update.setId(id); |
| | | update.setStatus(SafetyPermitStatusEnum.CANCELLED.getStatus()); |
| | | permitMapper.updateById(update); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deletePermit(Long id) { |
| | | validatePermitExists(id); |
| | | monitorMapper.deleteByPermitId(id); |
| | | permitMapper.deleteById(id); |
| | | } |
| | | |
| | | public SafetyWorkPermitDO getPermit(Long id) { |
| | | return validatePermitExists(id); |
| | | } |
| | | |
| | | public PageResult<SafetyWorkPermitDO> getPermitPage(SafetyWorkPermitPageReqVO reqVO) { |
| | | return permitMapper.selectPage(reqVO); |
| | | } |
| | | |
| | | // ==================== çæ¤è®°å½ ==================== |
| | | |
| | | public Long createMonitor(SafetyWorkPermitMonitorSaveReqVO reqVO) { |
| | | SafetyWorkPermitDO permit = validatePermitExists(reqVO.getPermitId()); |
| | | if (!SafetyPermitStatusEnum.IN_PROGRESS.getStatus().equals(permit.getStatus()) |
| | | && !SafetyPermitStatusEnum.APPROVED.getStatus().equals(permit.getStatus())) { |
| | | throw exception(SAFETY_PERMIT_STATUS_ERROR); |
| | | } |
| | | SafetyWorkPermitMonitorDO monitor = BeanUtils.toBean(reqVO, SafetyWorkPermitMonitorDO.class); |
| | | monitor.setId(null); |
| | | var guardian = refResolver.requireEmployee(reqVO.getGuardianId(), SAFETY_EMPLOYEE_REQUIRED); |
| | | monitor.setGuardianId(guardian.getId()); |
| | | monitor.setGuardian(guardian.getName()); |
| | | monitor.setMonitorTime(reqVO.getMonitorTime() == null ? LocalDateTime.now() : reqVO.getMonitorTime()); |
| | | monitorMapper.insert(monitor); |
| | | return monitor.getId(); |
| | | } |
| | | |
| | | public void deleteMonitor(Long id) { |
| | | if (id == null || monitorMapper.selectById(id) == null) { |
| | | throw exception(SAFETY_PERMIT_MONITOR_NOT_EXISTS); |
| | | } |
| | | monitorMapper.deleteById(id); |
| | | } |
| | | |
| | | public List<SafetyWorkPermitMonitorDO> getMonitorList(Long permitId) { |
| | | return monitorMapper.selectListByPermitId(permitId); |
| | | } |
| | | |
| | | // ==================== å±ç¤ºå段 ==================== |
| | | |
| | | /** |
| | | * æ¹éåå¡«ä½ä¸ç¥¨ç车é´åä¸ä¸ä¸ªäººåå§åï¼ç³è¯·äºº/审æ¹äºº/çæ¤äººï¼ |
| | | */ |
| | | public void fillPermitRefs(List<SafetyWorkPermitDO> permits) { |
| | | if (CollUtil.isEmpty(permits)) { |
| | | return; |
| | | } |
| | | var workshopMap = refResolver.workshopMap(permits.stream().map(SafetyWorkPermitDO::getWorkshopId).toList()); |
| | | var ids = new java.util.ArrayList<Long>(permits.size() * 3); |
| | | permits.forEach(p -> { ids.add(p.getApplicantId()); ids.add(p.getApproverId()); ids.add(p.getGuardianId()); }); |
| | | var employeeMap = refResolver.employeeMap(ids); |
| | | permits.forEach(permit -> { |
| | | var workshop = workshopMap.get(permit.getWorkshopId()); |
| | | if (workshop != null) permit.setWorkshopName(workshop.getName()); |
| | | var applicant = employeeMap.get(permit.getApplicantId()); |
| | | if (applicant != null) permit.setApplicant(applicant.getName()); |
| | | var approver = employeeMap.get(permit.getApproverId()); |
| | | if (approver != null) permit.setApprover(approver.getName()); |
| | | var guardian = employeeMap.get(permit.getGuardianId()); |
| | | if (guardian != null) permit.setGuardian(guardian.getName()); |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éåå¡«çæ¤è®°å½ççæ¤äººææ°å§å |
| | | */ |
| | | public void fillMonitorGuardians(List<SafetyWorkPermitMonitorDO> monitors) { |
| | | if (CollUtil.isEmpty(monitors)) { |
| | | return; |
| | | } |
| | | var employeeMap = refResolver.employeeMap( |
| | | monitors.stream().map(SafetyWorkPermitMonitorDO::getGuardianId).toList()); |
| | | monitors.forEach(monitor -> { |
| | | var employee = employeeMap.get(monitor.getGuardianId()); |
| | | if (employee != null) monitor.setGuardian(employee.getName()); |
| | | }); |
| | | } |
| | | |
| | | public static void fillPermitDisplay(SafetyWorkPermitDO permit, SafetyWorkPermitRespVO respVO) { |
| | | respVO.setPermitTypeName(SafetyPermitTypeEnum.getNameByType(permit.getPermitType())); |
| | | respVO.setRiskLevelName(SafetyRiskLevelEnum.getNameByLevel(permit.getRiskLevel())); |
| | | respVO.setStatusName(SafetyPermitStatusEnum.getNameByStatus(permit.getStatus())); |
| | | respVO.setGuardianRequired(SafetyPermitTypeEnum.requiresGuardian(permit.getPermitType())); |
| | | } |
| | | |
| | | private void validateTimeRange(SafetyWorkPermitSaveReqVO reqVO) { |
| | | if (reqVO.getPlanStartTime() != null && reqVO.getPlanEndTime() != null |
| | | && !reqVO.getPlanEndTime().isAfter(reqVO.getPlanStartTime())) { |
| | | throw exception(SAFETY_PERMIT_TIME_INVALID); |
| | | } |
| | | } |
| | | |
| | | private void ensureStatus(SafetyWorkPermitDO permit, SafetyPermitStatusEnum... allowed) { |
| | | for (SafetyPermitStatusEnum status : allowed) { |
| | | if (status.getStatus().equals(permit.getStatus())) { |
| | | return; |
| | | } |
| | | } |
| | | throw exception(SAFETY_PERMIT_STATUS_ERROR); |
| | | } |
| | | |
| | | private SafetyWorkPermitDO validatePermitExists(Long id) { |
| | | SafetyWorkPermitDO permit = id == null ? null : permitMapper.selectById(id); |
| | | if (permit == null) { |
| | | throw exception(SAFETY_PERMIT_NOT_EXISTS); |
| | | } |
| | | return permit; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.controller.admin.companyconfig; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.system.controller.admin.companyconfig.vo.SystemCompanyConfigRespVO; |
| | | import cn.iocoder.yudao.module.system.controller.admin.companyconfig.vo.SystemCompanyConfigSaveReqVO; |
| | | import cn.iocoder.yudao.module.system.dal.dataobject.companyconfig.SystemCompanyConfigDO; |
| | | import cn.iocoder.yudao.module.system.service.companyconfig.SystemCompanyConfigService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.annotation.security.PermitAll; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管çåå° - å
¬å¸åçä¿¡æ¯") |
| | | @RestController |
| | | @RequestMapping("/system/company-config") |
| | | @Validated |
| | | public class SystemCompanyConfigController { |
| | | |
| | | @Resource |
| | | private SystemCompanyConfigService companyConfigService; |
| | | |
| | | /** |
| | | * è·å¾å
¬å¸åçä¿¡æ¯ |
| | | * |
| | | * å
ç»å½å
¬å¼æ¥å£ï¼ä¾å端ç»å½é¡µ / åºç¨å¯å¨æ¶è¯»åå
¬å¸åç§°ãlogoãç»å½é¡µæ é¢ã |
| | | */ |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾å
¬å¸åçä¿¡æ¯ï¼å
ç»å½å
¬å¼ï¼") |
| | | @PermitAll |
| | | public CommonResult<SystemCompanyConfigRespVO> getCompanyConfig() { |
| | | SystemCompanyConfigDO config = companyConfigService.getCompanyConfig(); |
| | | return success(BeanUtils.toBean(config, SystemCompanyConfigRespVO.class)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿åå
¬å¸åçä¿¡æ¯ |
| | | * |
| | | * åè¡ upsertï¼éç»å½ä¸æ¥æ system:company-config:update æéã |
| | | * æééè¿èåãå
¬å¸ä¿¡æ¯é
ç½® - ä¿®æ¹ãææï¼è§ sql/mysql/system_company_config_menu.sqlï¼ã |
| | | */ |
| | | @PostMapping("/save") |
| | | @Operation(summary = "ä¿åå
¬å¸åçä¿¡æ¯") |
| | | @PreAuthorize("@ss.hasPermission('system:company-config:update')") |
| | | public CommonResult<Long> saveCompanyConfig(@Valid @RequestBody SystemCompanyConfigSaveReqVO reqVO) { |
| | | return success(companyConfigService.saveCompanyConfig(reqVO)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.controller.admin.companyconfig.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - å
¬å¸åçä¿¡æ¯ Response VO") |
| | | @Data |
| | | public class SystemCompanyConfigRespVO { |
| | | |
| | | @Schema(description = "主é®", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "å
¬å¸åç§°", example = "å®å¤ä¹æ³åå·¥") |
| | | private String companyName; |
| | | |
| | | @Schema(description = "logo æ°¸ä¹
å
¬å¼é¾æ¥ï¼previewURLï¼", example = "http://domain/admin-api/system/storage-blob/preview/xxx?publicKey=xxx") |
| | | private String logoUrl; |
| | | |
| | | @Schema(description = "logo 对åºç blob è®°å½ ID", example = "86") |
| | | private Long logoBlobId; |
| | | |
| | | @Schema(description = "ç»å½é¡µæ é¢", example = "å¶é è¿è¥ç®¡çå¹³å°") |
| | | private String loginTitle; |
| | | |
| | | @Schema(description = "ç»å½é¡µæè¿°", example = "å·¥ç¨åã髿§è½ãè·¨ç»ä»¶åºçå端模ç") |
| | | private String loginDescription; |
| | | |
| | | @Schema(description = "å建æ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.controller.admin.companyconfig.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import jakarta.validation.constraints.Size; |
| | | import lombok.Data; |
| | | |
| | | @Schema(description = "管çåå° - å
¬å¸åçä¿¡æ¯ä¿å Request VO") |
| | | @Data |
| | | public class SystemCompanyConfigSaveReqVO { |
| | | |
| | | @Schema(description = "主é®ï¼åè¡é
ç½®ï¼å¯ä¸ä¼ ï¼", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "å
¬å¸åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "å®å¤ä¹æ³åå·¥") |
| | | @NotBlank(message = "å
¬å¸åç§°ä¸è½ä¸ºç©º") |
| | | @Size(max = 128, message = "å
¬å¸åç§°ä¸è½è¶
è¿128个å符") |
| | | private String companyName; |
| | | |
| | | @Schema(description = "logo æ°¸ä¹
å
¬å¼é¾æ¥ï¼previewURLï¼", example = "http://domain/admin-api/system/storage-blob/preview/xxx?publicKey=xxx") |
| | | @Size(max = 512, message = "logo å°åä¸è½è¶
è¿512个å符") |
| | | private String logoUrl; |
| | | |
| | | @Schema(description = "logo 对åºç blob è®°å½ ID", example = "86") |
| | | private Long logoBlobId; |
| | | |
| | | @Schema(description = "ç»å½é¡µæ é¢", example = "å¶é è¿è¥ç®¡çå¹³å°") |
| | | @Size(max = 128, message = "ç»å½é¡µæ é¢ä¸è½è¶
è¿128个å符") |
| | | private String loginTitle; |
| | | |
| | | @Schema(description = "ç»å½é¡µæè¿°", example = "å·¥ç¨åã髿§è½ãè·¨ç»ä»¶åºçå端模ç") |
| | | @Size(max = 128, message = "ç»å½é¡µæè¿°ä¸è½è¶
è¿128个å符") |
| | | private String loginDescription; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.controller.admin.database; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.module.system.service.database.DatabaseBackupService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | @Tag(name = "管çåå° - æ°æ®åºå¤ä»½") |
| | | @RestController |
| | | @RequestMapping("/system/database") |
| | | public class DatabaseBackupController { |
| | | |
| | | @Resource |
| | | private DatabaseBackupService databaseBackupService; |
| | | |
| | | @GetMapping("/backup") |
| | | @Operation(summary = "ä¸è½½æ°æ®åºå¤ä»½") |
| | | @PreAuthorize("@ss.hasPermission('system:database:backup')") |
| | | public void backupDatabase(HttpServletResponse response) throws Exception { |
| | | databaseBackupService.backupDatabase(response); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.dal.dataobject.companyconfig; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * å
¬å¸åçä¿¡æ¯é
ç½® DO |
| | | * |
| | | * åè¡é
ç½®ï¼ä¿åå
¬å¸åç§°/logo/ç»å½é¡µæ é¢ï¼å端å¯å¨æ¶è¯»åå¹¶èå¨ç»å½é¡µãèåæ ãç½é¡µæ é¢ã |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @TableName("system_company_config") |
| | | @KeySequence("system_company_config_seq") // ç¨äº OracleãPostgreSQLãKingbaseãDB2ãH2 æ°æ®åºç主é®èªå¢ãå¦ææ¯ MySQL çæ°æ®åºï¼å¯ä¸åã |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class SystemCompanyConfigDO extends BaseDO { |
| | | |
| | | /** |
| | | * ä¸»é® |
| | | */ |
| | | private Long id; |
| | | /** |
| | | * å
¬å¸åç§° |
| | | */ |
| | | private String companyName; |
| | | /** |
| | | * logo æ°¸ä¹
å
¬å¼é¾æ¥ï¼public-upload è¿åç previewURLï¼ |
| | | */ |
| | | private String logoUrl; |
| | | /** |
| | | * logo 对åºç blob è®°å½ ID |
| | | */ |
| | | private Long logoBlobId; |
| | | /** |
| | | * ç»å½é¡µæ é¢ |
| | | */ |
| | | private String loginTitle; |
| | | /** |
| | | * ç»å½é¡µæè¿° |
| | | */ |
| | | private String loginDescription; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.dal.mysql.companyconfig; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.system.dal.dataobject.companyconfig.SystemCompanyConfigDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * å
¬å¸åçä¿¡æ¯é
ç½® Mapper |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Mapper |
| | | public interface SystemCompanyConfigMapper extends BaseMapperX<SystemCompanyConfigDO> { |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.service.companyconfig; |
| | | |
| | | import cn.iocoder.yudao.module.system.controller.admin.companyconfig.vo.SystemCompanyConfigSaveReqVO; |
| | | import cn.iocoder.yudao.module.system.dal.dataobject.companyconfig.SystemCompanyConfigDO; |
| | | |
| | | /** |
| | | * å
¬å¸åçä¿¡æ¯é
ç½® Service æ¥å£ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | public interface SystemCompanyConfigService { |
| | | |
| | | /** |
| | | * è·å¾å
¬å¸åçä¿¡æ¯ï¼åè¡é
ç½®ï¼ |
| | | * |
| | | * @return å
¬å¸åçä¿¡æ¯ï¼æªé
ç½®æ¶è¿å null |
| | | */ |
| | | SystemCompanyConfigDO getCompanyConfig(); |
| | | |
| | | /** |
| | | * ä¿åå
¬å¸åçä¿¡æ¯ï¼åè¡ upsertï¼ |
| | | * |
| | | * @param reqVO ä¿åè¯·æ± |
| | | * @return ä¸»é® |
| | | */ |
| | | Long saveCompanyConfig(SystemCompanyConfigSaveReqVO reqVO); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.service.companyconfig; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.system.controller.admin.companyconfig.vo.SystemCompanyConfigSaveReqVO; |
| | | import cn.iocoder.yudao.module.system.dal.dataobject.companyconfig.SystemCompanyConfigDO; |
| | | import cn.iocoder.yudao.module.system.dal.mysql.companyconfig.SystemCompanyConfigMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å
¬å¸åçä¿¡æ¯é
ç½® Service å®ç°ç±» |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class SystemCompanyConfigServiceImpl implements SystemCompanyConfigService { |
| | | |
| | | @Resource |
| | | private SystemCompanyConfigMapper companyConfigMapper; |
| | | |
| | | @Override |
| | | public SystemCompanyConfigDO getCompanyConfig() { |
| | | // åè¡é
ç½®ï¼æä¸»é®ååºåç¬¬ä¸æ¡ |
| | | List<SystemCompanyConfigDO> list = companyConfigMapper.selectList(new LambdaQueryWrapperX<SystemCompanyConfigDO>() |
| | | .orderByAsc(SystemCompanyConfigDO::getId) |
| | | .last("LIMIT 1")); |
| | | return CollUtil.getFirst(list); |
| | | } |
| | | |
| | | @Override |
| | | public Long saveCompanyConfig(SystemCompanyConfigSaveReqVO reqVO) { |
| | | SystemCompanyConfigDO config = getCompanyConfig(); |
| | | if (config == null) { |
| | | // 馿¬¡ä¿åï¼æå
¥ |
| | | SystemCompanyConfigDO insertObj = BeanUtils.toBean(reqVO, SystemCompanyConfigDO.class); |
| | | companyConfigMapper.insert(insertObj); |
| | | return insertObj.getId(); |
| | | } |
| | | // å·²åå¨ï¼æ´æ°åè¡ |
| | | SystemCompanyConfigDO updateObj = BeanUtils.toBean(reqVO, SystemCompanyConfigDO.class); |
| | | updateObj.setId(config.getId()); |
| | | companyConfigMapper.updateById(updateObj); |
| | | return config.getId(); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.service.database; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | public interface DatabaseBackupService { |
| | | |
| | | /** |
| | | * å¤ä»½æ°æ®åºï¼å¹¶å° SQL æä»¶åå
¥å° HTTP ååºä¸ |
| | | * |
| | | * @param response HTTP ååº |
| | | */ |
| | | void backupDatabase(HttpServletResponse response) throws Exception; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.system.service.database; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import cn.hutool.core.io.IoUtil; |
| | | import cn.hutool.core.util.HexUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.sql.DataSource; |
| | | import java.io.BufferedReader; |
| | | import java.io.BufferedWriter; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.OutputStream; |
| | | import java.io.OutputStreamWriter; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.sql.Connection; |
| | | import java.sql.ResultSet; |
| | | import java.sql.ResultSetMetaData; |
| | | import java.sql.Statement; |
| | | import java.sql.Types; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class DatabaseBackupServiceImpl implements DatabaseBackupService { |
| | | |
| | | /** å¤ä»½è¶
æ¶æ¶é´ï¼åéï¼ */ |
| | | private static final long BACKUP_TIMEOUT_MINUTES = 10; |
| | | /** MySQL 容å¨å
é¨ç«¯å£ */ |
| | | private static final String DOCKER_MYSQL_PORT = "3306"; |
| | | |
| | | @Value("${spring.datasource.dynamic.datasource.master.url:}") |
| | | private String dbUrl; |
| | | |
| | | @Value("${spring.datasource.dynamic.datasource.master.username:root}") |
| | | private String dbUsername; |
| | | |
| | | @Value("${spring.datasource.dynamic.datasource.master.password:}") |
| | | private String dbPassword; |
| | | |
| | | /** å¤ä»½å½ä»¤ï¼å¯æ¾å¼æå®ï¼å¦ docker exec mysql8 mysqldumpï¼ï¼ç空åèªå¨æ£æµæ¬å° mysqldump æ Docker MySQL å®¹å¨ */ |
| | | @Value("${yudao.database-backup.command:}") |
| | | private String backupCommand; |
| | | |
| | | /** å¤ä»½ç®æ æ°æ®åº hostï¼ç空å仿°æ®æº JDBC URL è§£æ */ |
| | | @Value("${yudao.database-backup.host:}") |
| | | private String backupHost; |
| | | |
| | | /** å¤ä»½ç®æ æ°æ®åº portï¼ç空å仿°æ®æº JDBC URL è§£æ */ |
| | | @Value("${yudao.database-backup.port:}") |
| | | private String backupPort; |
| | | |
| | | /** å¤ä»½ç®æ æ°æ®åºåï¼ç空å仿°æ®æº JDBC URL è§£æ */ |
| | | @Value("${yudao.database-backup.database:}") |
| | | private String backupDatabase; |
| | | |
| | | /** å¤ä»½è´¦å·ï¼ç空åä½¿ç¨æ°æ®æºè´¦å· */ |
| | | @Value("${yudao.database-backup.username:}") |
| | | private String backupUsername; |
| | | |
| | | /** å¤ä»½å¯ç ï¼ç空åä½¿ç¨æ°æ®æºå¯ç */ |
| | | @Value("${yudao.database-backup.password:}") |
| | | private String backupPassword; |
| | | |
| | | /** ä¸»æ°æ®æºï¼ç¨äº JDBC 导åºå
åº */ |
| | | @Resource |
| | | private DataSource dataSource; |
| | | |
| | | @Override |
| | | public void backupDatabase(HttpServletResponse response) throws Exception { |
| | | if (StrUtil.isEmpty(dbUrl)) { |
| | | throw new ServiceException(500, "æªæ¾å°æ°æ®åºè¿æ¥é
ç½®"); |
| | | } |
| | | |
| | | // å¤ä»½è¿æ¥çæ°æ®åºä¿¡æ¯ï¼ä¼å
ä½¿ç¨ yudao.database-backup é
ç½®ï¼æªé
ç½®çé¨å仿°æ®æº JDBC URL è§£æå
åº |
| | | String dbHost = backupHost; |
| | | String dbPort = backupPort; |
| | | String dbName = backupDatabase; |
| | | if (StrUtil.isEmpty(dbHost) || StrUtil.isEmpty(dbPort) || StrUtil.isEmpty(dbName)) { |
| | | Matcher matcher = Pattern.compile("jdbc:mysql://([^:]+):(\\d+)/([^?]+)").matcher(dbUrl); |
| | | if (matcher.find()) { |
| | | if (StrUtil.isEmpty(dbHost)) { |
| | | dbHost = matcher.group(1); |
| | | } |
| | | if (StrUtil.isEmpty(dbPort)) { |
| | | dbPort = matcher.group(2); |
| | | } |
| | | if (StrUtil.isEmpty(dbName)) { |
| | | dbName = matcher.group(3); |
| | | } |
| | | } |
| | | } |
| | | if (StrUtil.isEmpty(dbHost) || StrUtil.isEmpty(dbPort) || StrUtil.isEmpty(dbName)) { |
| | | log.warn("æ æ³ä»é
ç½®æ JDBC URL è§£æå®æ´çæ°æ®åºä¿¡æ¯: host={}, port={}, db={}", dbHost, dbPort, dbName); |
| | | throw new ServiceException(500, "æ æ³è§£ææ°æ®åºå¤ä»½è¿æ¥ä¿¡æ¯ï¼è¯·å¨ yudao.database-backup ä¸é
ç½® host/port/database"); |
| | | } |
| | | // localhost ç»ä¸èµ° TCP 127.0.0.1ï¼mysqldump 对 localhost å¯è½èµ° socket/loopbackï¼ |
| | | // èä¸åç¯å¢ root@localhost ç认è¯è¦æ±å·®å¼å¤§ï¼å¼ºå¶ TCP æ´ç¨³å® |
| | | if ("localhost".equalsIgnoreCase(dbHost)) { |
| | | dbHost = "127.0.0.1"; |
| | | } |
| | | String username = StrUtil.isEmpty(backupUsername) ? dbUsername : backupUsername; |
| | | String password = StrUtil.isEmpty(backupPassword) ? dbPassword : backupPassword; |
| | | |
| | | // ç»è£
åéå¤ä»½å½ä»¤ï¼æä¼å
çº§ä¾æ¬¡å°è¯ï¼æå¨é
ç½® > æ¬æº mysqldump > Docker å®¹å¨ mysqldump |
| | | List<List<String>> candidates = new ArrayList<>(); |
| | | List<String> labels = new ArrayList<>(); |
| | | if (StrUtil.isNotEmpty(backupCommand)) { |
| | | candidates.add(splitCommand(backupCommand)); |
| | | labels.add("æå¨é
ç½®å½ä»¤[" + backupCommand + "]"); |
| | | } |
| | | if (isLocalMysqldumpAvailable()) { |
| | | candidates.add(buildLocalMysqldumpCommand(dbHost, dbPort, username, password, dbName)); |
| | | labels.add("æ¬æº mysqldump"); |
| | | } |
| | | String container = findMysqlDockerContainer(dbPort); |
| | | if (StrUtil.isNotEmpty(container)) { |
| | | candidates.add(buildDockerExecCommand(container, username, password, dbName)); |
| | | labels.add("Docker 容å¨[" + container + "] mysqldump"); |
| | | } |
| | | log.info("æ°æ®åºå¤ä»½åéæ¹å¼ï¼{}", labels); |
| | | |
| | | // 便¬¡å°è¯ææå¤é¨å½ä»¤æ¹å¼ |
| | | List<String> failures = new ArrayList<>(); |
| | | String timestamp = DateUtil.format(new Date(), "yyyyMMdd_HHmmss"); |
| | | String fileName = "backup_" + timestamp + ".sql"; |
| | | for (int i = 0; i < candidates.size(); i++) { |
| | | File tempFile = File.createTempFile("backup_", ".sql"); |
| | | try { |
| | | String error = runMysqldump(candidates.get(i), password, tempFile); |
| | | if (error == null) { |
| | | log.info("æ°æ®åºå¤ä»½æåï¼ä½¿ç¨æ¹å¼ï¼{}", labels.get(i)); |
| | | downloadAttachment(response, tempFile, fileName); |
| | | return; |
| | | } |
| | | log.warn("å¤ä»½æ¹å¼ [{}] 失败ï¼{}", labels.get(i), error); |
| | | failures.add(labels.get(i) + "ï¼" + error); |
| | | } finally { |
| | | FileUtil.del(tempFile); |
| | | } |
| | | } |
| | | |
| | | // å¤é¨å½ä»¤å
¨é¨å¤±è´¥æä¸å¯ç¨æ¶ï¼ä½¿ç¨ JDBC 导åºå
åºï¼ä¿è¯ä»»ä½é¨ç½²ç¯å¢ï¼å¦åºç¨å®¹å¨å
æ mysqldump/dockerï¼é½è½å¤ä»½ |
| | | File tempFile = File.createTempFile("backup_", ".sql"); |
| | | try { |
| | | String error = exportByJdbc(tempFile); |
| | | if (error == null) { |
| | | log.info("æ°æ®åºå¤ä»½æåï¼ä½¿ç¨æ¹å¼ï¼JDBC 导åºå
åº"); |
| | | downloadAttachment(response, tempFile, fileName); |
| | | return; |
| | | } |
| | | log.warn("JDBC 导åºå
åºå¤±è´¥ï¼{}", error); |
| | | failures.add("JDBC 导åºå
åºï¼" + error); |
| | | } finally { |
| | | FileUtil.del(tempFile); |
| | | } |
| | | throw new ServiceException(500, "æ°æ®åºå¤ä»½å¤±è´¥ï¼" + String.join(" ï½ ", failures)); |
| | | } |
| | | |
| | | /** |
| | | * éè¿ JDBC ç´è¿æ°æ®åºå¯¼åºå»ºè¡¨è¯å¥ä¸å
¨éæ°æ®ï¼ä½ä¸ºå¤é¨å½ä»¤ä¸å¯ç¨æ¶çå
åºå¤ä»½æ¹å¼ |
| | | * |
| | | * @return æ§è¡æåè¿å nullï¼å¤±è´¥è¿åé误æè¿° |
| | | */ |
| | | private String exportByJdbc(File outputFile) { |
| | | try (Connection conn = dataSource.getConnection(); |
| | | BufferedWriter writer = new BufferedWriter( |
| | | new OutputStreamWriter(new FileOutputStream(outputFile), StandardCharsets.UTF_8))) { |
| | | writer.write("/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;\n"); |
| | | writer.write("/*!40101 SET NAMES utf8mb4 */;\n"); |
| | | writer.write("SET TIME_ZONE='+00:00';\n"); |
| | | writer.write("SET FOREIGN_KEY_CHECKS=0;\n"); |
| | | writer.write("SET UNIQUE_CHECKS=0;\n"); |
| | | writer.write("SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO';\n\n"); |
| | | try (Statement st = conn.createStatement(); |
| | | ResultSet rs = st.executeQuery("SHOW TABLES")) { |
| | | List<String> tables = new ArrayList<>(); |
| | | while (rs.next()) { |
| | | tables.add(rs.getString(1)); |
| | | } |
| | | for (String table : tables) { |
| | | exportTable(conn, writer, table); |
| | | } |
| | | } |
| | | writer.write("\nSET FOREIGN_KEY_CHECKS=1;\n"); |
| | | writer.write("SET UNIQUE_CHECKS=1;\n"); |
| | | writer.write("/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n"); |
| | | return null; |
| | | } catch (Exception e) { |
| | | log.error("JDBC 导åºå
åºå¤±è´¥", e); |
| | | return "JDBC 导åºå¼å¸¸: " + e.getMessage(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导åºåå¼ è¡¨ç建表è¯å¥ä¸å
¨é¨æ°æ® |
| | | */ |
| | | private void exportTable(Connection conn, BufferedWriter writer, String table) throws Exception { |
| | | String quoted = "`" + table.replace("`", "``") + "`"; |
| | | // 建表è¯å¥ |
| | | try (Statement st = conn.createStatement(); |
| | | ResultSet rs = st.executeQuery("SHOW CREATE TABLE " + quoted)) { |
| | | if (rs.next()) { |
| | | writer.write(rs.getString(2)); |
| | | writer.write(";\n\n"); |
| | | } |
| | | } |
| | | // å
¨éæ°æ®ï¼æµå¼è¯»åé¿å
大表å ç¨è¿å¤å
å |
| | | try (Statement st = conn.createStatement()) { |
| | | st.setFetchSize(Integer.MIN_VALUE); |
| | | try (ResultSet rs = st.executeQuery("SELECT * FROM " + quoted)) { |
| | | ResultSetMetaData meta = rs.getMetaData(); |
| | | int columnCount = meta.getColumnCount(); |
| | | int[] types = new int[columnCount]; |
| | | for (int i = 0; i < columnCount; i++) { |
| | | types[i] = meta.getColumnType(i + 1); |
| | | } |
| | | while (rs.next()) { |
| | | StringBuilder sb = new StringBuilder("INSERT INTO ").append(quoted).append(" VALUES ("); |
| | | for (int i = 0; i < columnCount; i++) { |
| | | if (i > 0) { |
| | | sb.append(','); |
| | | } |
| | | if (rs.getObject(i + 1) == null) { |
| | | sb.append("NULL"); |
| | | continue; |
| | | } |
| | | int type = types[i]; |
| | | if (type == Types.BIT) { |
| | | sb.append(rs.getBoolean(i + 1) ? '1' : '0'); |
| | | } else if (isBinaryType(type)) { |
| | | sb.append("X'").append(HexUtil.encodeHexStr(rs.getBytes(i + 1))).append("'"); |
| | | } else { |
| | | sb.append('\'').append(escapeSql(rs.getString(i + 1))).append('\''); |
| | | } |
| | | } |
| | | sb.append(");\n"); |
| | | writer.write(sb.toString()); |
| | | } |
| | | } |
| | | } |
| | | writer.write('\n'); |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦äºè¿å¶åç±»åï¼äºè¿å¶æ°æ®ä»¥åå
è¿å¶åé¢é导åºé¿å
ä¹±ç |
| | | */ |
| | | private boolean isBinaryType(int type) { |
| | | return type == Types.BINARY || type == Types.VARBINARY |
| | | || type == Types.LONGVARBINARY || type == Types.BLOB; |
| | | } |
| | | |
| | | /** |
| | | * SQL å符串åé¢éè½¬ä¹ |
| | | */ |
| | | private String escapeSql(String value) { |
| | | return value.replace("\\", "\\\\").replace("'", "''").replace("\0", "\\0"); |
| | | } |
| | | |
| | | /** |
| | | * æå»ºæ¬æº mysqldump å¤ä»½å½ä»¤ |
| | | */ |
| | | private List<String> buildLocalMysqldumpCommand(String host, String port, String username, String password, String dbName) { |
| | | List<String> command = new ArrayList<>(); |
| | | command.add("mysqldump"); |
| | | // MySQL 8 caching_sha2_password 认è¯é»è®¤ä¸è¯·æ±æå¡ç«¯å
¬é¥ï¼ä¼æ¥ Access denied (using password: YES) |
| | | command.add("--get-server-public-key"); |
| | | command.add("-h" + host); |
| | | command.add("-P" + port); |
| | | command.add("-u" + username); |
| | | if (StrUtil.isEmpty(password)) { |
| | | command.add("--skip-password"); |
| | | } |
| | | command.add(dbName); |
| | | return command; |
| | | } |
| | | |
| | | /** |
| | | * æå»ºéè¿ docker exec è°ç¨å®¹å¨å
mysqldump çå¤ä»½å½ä»¤ |
| | | */ |
| | | private List<String> buildDockerExecCommand(String container, String username, String password, String dbName) { |
| | | List<String> command = new ArrayList<>(); |
| | | command.add("docker"); |
| | | command.add("exec"); |
| | | // docker exec ä¸ä¼è½¬å宿主æºç¯å¢åéï¼å¯ç ééè¿ -e æ¾å¼ä¼ å
¥å®¹å¨ |
| | | if (StrUtil.isNotEmpty(password)) { |
| | | command.add("-e"); |
| | | command.add("MYSQL_PWD=" + password); |
| | | } |
| | | command.add(container); |
| | | command.add("mysqldump"); |
| | | command.add("--get-server-public-key"); |
| | | // 容å¨å
åºå®èµ° 127.0.0.1:3306 ç TCP è¿æ¥èªèº«ï¼ç»å¼ socket/loopback 认è¯å·®å¼ |
| | | command.add("-h127.0.0.1"); |
| | | command.add("-P" + DOCKER_MYSQL_PORT); |
| | | command.add("-u" + username); |
| | | if (StrUtil.isEmpty(password)) { |
| | | command.add("--skip-password"); |
| | | } |
| | | command.add(dbName); |
| | | return command; |
| | | } |
| | | |
| | | /** |
| | | * æ§è¡ mysqldump å½ä»¤ï¼å° stdout åå
¥ä¸´æ¶æä»¶ |
| | | * |
| | | * @return æ§è¡æåè¿å nullï¼å¤±è´¥è¿åé误æè¿° |
| | | */ |
| | | private String runMysqldump(List<String> command, String password, File outputFile) { |
| | | try { |
| | | ProcessBuilder pb = new ProcessBuilder(command); |
| | | // å¯ç éè¿ç¯å¢åéä¼ éï¼é¿å
åºç°å¨å½ä»¤è¡åè¿ç¨å表 |
| | | if (StrUtil.isNotEmpty(password)) { |
| | | pb.environment().put("MYSQL_PWD", password); |
| | | } |
| | | Process process = pb.start(); |
| | | |
| | | // åå°è¯»å stderrï¼é²æ¢ç®¡éç¼å²åºå满导è´è¿ç¨é»å¡ |
| | | StringBuilder stderr = new StringBuilder(); |
| | | Thread stderrThread = new Thread(() -> { |
| | | try (BufferedReader reader = new BufferedReader( |
| | | new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8))) { |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | stderr.append(line).append(System.lineSeparator()); |
| | | } |
| | | } catch (IOException ignored) { |
| | | } |
| | | }); |
| | | stderrThread.start(); |
| | | |
| | | // mysqldump è¾åºåå
¥æ¬å°ä¸´æ¶æä»¶ï¼docker exec åºæ¯è¾åºä¸ä¼è½å¨å®¹å¨å
æä»¶ç³»ç»ï¼ |
| | | try (InputStream in = process.getInputStream(); |
| | | OutputStream out = new FileOutputStream(outputFile)) { |
| | | IoUtil.copy(in, out); |
| | | } |
| | | |
| | | boolean finished = process.waitFor(BACKUP_TIMEOUT_MINUTES, TimeUnit.MINUTES); |
| | | stderrThread.join(); |
| | | if (!finished) { |
| | | process.destroyForcibly(); |
| | | return "æ§è¡è¶
æ¶ï¼è¶
è¿ " + BACKUP_TIMEOUT_MINUTES + " åéï¼"; |
| | | } |
| | | if (process.exitValue() != 0) { |
| | | return "exitCode=" + process.exitValue() + "ï¼" + stderr.toString().trim(); |
| | | } |
| | | return null; |
| | | } catch (IOException e) { |
| | | return "å¯å¨å½ä»¤å¤±è´¥: " + e.getMessage(); |
| | | } catch (InterruptedException e) { |
| | | Thread.currentThread().interrupt(); |
| | | return "æ§è¡è¢«ä¸æ: " + e.getMessage(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å°å¤ä»½æä»¶ä½ä¸ºéä»¶è¾åºå°ååº |
| | | */ |
| | | private void downloadAttachment(HttpServletResponse response, File file, String fileName) throws IOException { |
| | | response.setContentType("application/octet-stream; charset=UTF-8"); |
| | | response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fileName, "UTF-8") + "\""); |
| | | response.setContentLengthLong(file.length()); |
| | | try (FileInputStream fis = new FileInputStream(file); |
| | | OutputStream os = response.getOutputStream()) { |
| | | IoUtil.copy(fis, os); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å°é
ç½®çå½ä»¤å符串æç©ºç½ååä¸ºåæ°å表 |
| | | */ |
| | | private List<String> splitCommand(String command) { |
| | | List<String> parts = new ArrayList<>(); |
| | | for (String token : command.trim().split("\\s+")) { |
| | | parts.add(token); |
| | | } |
| | | return parts; |
| | | } |
| | | |
| | | /** |
| | | * æ£æµæ¬æº mysqldump æ¯å¦å¯ç¨ |
| | | */ |
| | | private boolean isLocalMysqldumpAvailable() { |
| | | try { |
| | | Process process = new ProcessBuilder("mysqldump", "--version").redirectErrorStream(true).start(); |
| | | boolean finished = process.waitFor(5, TimeUnit.SECONDS); |
| | | if (!finished) { |
| | | process.destroyForcibly(); |
| | | return false; |
| | | } |
| | | return process.exitValue() == 0; |
| | | } catch (IOException e) { |
| | | return false; |
| | | } catch (InterruptedException e) { |
| | | Thread.currentThread().interrupt(); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥æ¾è¿è¡ä¸ç MySQL Docker 容å¨ï¼ä¼å
éæ©ç«¯å£æ å°ä¸æ°æ®æºç«¯å£ä¸è´çå®¹å¨ |
| | | * |
| | | * @return 容å¨åï¼æªæ¾å°è¿å null |
| | | */ |
| | | private String findMysqlDockerContainer(String dbPort) { |
| | | try { |
| | | Process ps = new ProcessBuilder("docker", "ps", "--format", "{{.ID}}|{{.Names}}|{{.Image}}") |
| | | .redirectErrorStream(true).start(); |
| | | String output = IoUtil.read(ps.getInputStream(), StandardCharsets.UTF_8); |
| | | if (!ps.waitFor(10, TimeUnit.SECONDS) || ps.exitValue() != 0) { |
| | | return null; |
| | | } |
| | | List<String[]> containers = new ArrayList<>(); |
| | | for (String line : output.split("\n")) { |
| | | String[] parts = line.trim().split("\\|"); |
| | | if (parts.length == 3 && parts[2].startsWith("mysql")) { |
| | | containers.add(parts); |
| | | } |
| | | } |
| | | if (containers.isEmpty()) { |
| | | return null; |
| | | } |
| | | // ä¼å
éæ©ç«¯å£æ å°ä¸æ°æ®æºç«¯å£ä¸è´çå®¹å¨ |
| | | for (String[] container : containers) { |
| | | Process portProcess = new ProcessBuilder("docker", "port", container[0], "3306/tcp") |
| | | .redirectErrorStream(true).start(); |
| | | String portOutput = IoUtil.read(portProcess.getInputStream(), StandardCharsets.UTF_8); |
| | | if (portProcess.waitFor(10, TimeUnit.SECONDS) && portProcess.exitValue() == 0 |
| | | && portOutput.contains(dbPort)) { |
| | | return container[1]; |
| | | } |
| | | } |
| | | log.warn("æªå¹é
å°ç«¯å£æ å°ç MySQL 容å¨ï¼ä½¿ç¨ç¬¬ä¸ä¸ª: {}", containers.get(0)[1]); |
| | | return containers.get(0)[1]; |
| | | } catch (IOException e) { |
| | | log.warn("æ£æµ Docker ç¯å¢å¤±è´¥: {}", e.getMessage()); |
| | | return null; |
| | | } catch (InterruptedException e) { |
| | | Thread.currentThread().interrupt(); |
| | | return null; |
| | | } |
| | | } |
| | | } |