| ¶Ô±ÈÐÂÎļþ |
| | |
| | | # è®¾å¤æ°éï¼è®¾å¤æ°æ®ééï¼Â· å端èè°æ¹æ¡ |
| | | |
| | | ## æ¶åé¡µé¢ |
| | | |
| | | | é¡µé¢ | è·¯ç± | 说æ | |
| | | |------|------|------| |
| | | | è®¾å¤æ°é | 设å¤ç®¡ç â è®¾å¤æ°é | 宿¶æ°æ®ï¼åè®¾å¤ææ°é¥æµï¼+ åå²è®°å½ä¸¤ä¸ª Tab + æåæé® + 宿¶èªå¨å·æ° | |
| | | | 设å¤å°è´¦ | 设å¤ç®¡ç â 设å¤å°è´¦ | è¡¨åæ°å¢ãæ°é设å¤IDãåæ®µï¼æ¥ç详æ
æ°å¢ãæ°éæ°æ®ãTab å±ç¤ºè¯¥è®¾å¤å®æ¶ä¿¡å· | |
| | | |
| | | ## ä¸å¡æµç¨ä¸æ°æ®å¸¦å
¥ |
| | | |
| | | 1. **æåæ°æ®**ï¼é¡µé¢ç¹å»ãæåææ°æ°æ®ãâ è° `/mes/dv/telemetry/pull` â å端è°å¤é¨æ°éæ¥å£ `GET /api/jxjs/mesTb/getDeviceDetails`ï¼è¿ 5 åéè®¾å¤æ°æ®ï¼â éæ¡åå
¥ `mes_dv_telemetry` â è¿åæ¬æ¬¡æ°å¢æ¡æ°/è®¾å¤æ°/æåæ¶é´ã |
| | | 2. **宿¶æ¥ç**ï¼å®æ¶æ°æ® Tab è° `/mes/dv/telemetry/latest`ï¼æã设å¤+ä¿¡å·ãå»éä¿çææ°ä¸æ¡ï¼å¯å¼å¯ã宿¶èªå¨å·æ°ãæ¯ 30 ç§è½®è¯¢ä¸æ¬¡ã |
| | | 3. **å岿¥ç**ï¼åå²è®°å½ Tab è° `/mes/dv/telemetry/page` åé¡µï¼æ¯æè®¾å¤åç§°/ä¿¡å·åç§°/æ¯å¦å¼å¸¸/饿µæ¶é´åºé´è¿æ»¤ã |
| | | 4. **宿¶æå**ï¼ç³»ç»å
ç½®å®æ¶ä»»å¡ãè®¾å¤æ°éæ°æ®æåãæ¯ 5 åéèªå¨æå䏿¬¡ï¼é¿å
è¿ 5 åéçªå£æ°æ®ä¸¢å¤±ï¼é¡µé¢æ éæç¥ï¼ã |
| | | 5. **设å¤å
³è**ï¼è®¾å¤å°è´¦è¡¨åæå·¥ç»´æ¤ãæ°é设å¤IDãï¼`tb_device_id`ï¼å¯¹åºå¤é¨æ°é `tbDeviceId`ï¼ï¼å°è´¦è¯¦æ
ãæ°éæ°æ®ãTab ç¨è¯¥ ID è° `/latest?tbDeviceId=xx` å±ç¤ºè¯¥è®¾å¤å®æ¶ä¿¡å·ãæªå¡«æ°é设å¤IDæ¶è¯¥ Tab ç½®ç°ã |
| | | |
| | | ## API |
| | | |
| | | ### 1. æåæ°æ® `GET /mes/dv/telemetry/pull` |
| | | |
| | | æ 请æ±åæ°ãæé `mes:dv-telemetry:query`ã |
| | | |
| | | **ååºï¼** |
| | | |
| | | ```json |
| | | { |
| | | "code": 0, |
| | | "data": { |
| | | "recordCount": 120, |
| | | "deviceCount": 8, |
| | | "pullTime": "2026-08-20 10:00:00" |
| | | } |
| | | } |
| | | ``` |
| | | |
| | | | åæ®µ | ç±»å | 说æ | |
| | | |------|------|------| |
| | | | recordCount | Integer | æ¬æ¬¡æåæ°å¢æ°æ®æ¡æ° | |
| | | | deviceCount | Integer | æ¬æ¬¡æåæ¶åè®¾å¤æ° | |
| | | | pullTime | String | æåæ¶é´ | |
| | | |
| | | > å¤é¨æ¥å£æªé
ç½® `base-url` / è°ç¨å¤±è´¥ / è¿åå¼å¸¸æ¶ï¼è¿åé误ç `æ°éæ°æ®æå失败ï¼xxx`ï¼æ¥å£æ£å¸¸ä½è¿ 5 åéæ æ°æ®æ¶ recordCount=0ï¼ä¸æ¥éï¼ã |
| | | |
| | | ### 2. 宿¶æ°æ® `GET /mes/dv/telemetry/latest` |
| | | |
| | | | åæ° | ç±»å | å¿
å¡« | 说æ | |
| | | |------|------|------|------| |
| | | | tbDeviceId | String | å¦ | æ°é设å¤ID | |
| | | | deviceName | String | å¦ | 设å¤åç§°ï¼æ¨¡ç³ï¼ | |
| | | |
| | | **ååºï¼** `data` 为æ°ç»ï¼æ¯é¡¹ä¸ºä¸æ¡ã设å¤+ä¿¡å·ãææ°é¥æµè®°å½ï¼å段è§ä¸è¡¨ï¼ã |
| | | |
| | | ### 3. åå²è®°å½ `GET /mes/dv/telemetry/page` |
| | | |
| | | | åæ° | ç±»å | å¿
å¡« | 说æ | |
| | | |------|------|------|------| |
| | | | pageNo / pageSize | Integer | æ¯ | å页 | |
| | | | tbDeviceId | String | å¦ | æ°é设å¤ID | |
| | | | deviceName | String | å¦ | 设å¤åç§°ï¼æ¨¡ç³ï¼ | |
| | | | paramName | String | å¦ | ä¿¡å·åç§°ï¼æ¨¡ç³ï¼ | |
| | | | whetherAnomaly | Boolean | å¦ | æ¯å¦å¼å¸¸ï¼true/falseï¼ | |
| | | | shiftName | String | å¦ | çæ¬¡ | |
| | | | telemetryDataTime | String[] | å¦ | 饿µæ¶é´åºé´ï¼`yyyy-MM-dd HH:mm:ss` | |
| | | |
| | | **ååºï¼** `data` 为 `PageResult`ï¼`records` åæ®µåä¸è¡¨ã |
| | | |
| | | ### 4. 设å¤ä¸æ `GET /mes/dv/telemetry/device-list` |
| | | |
| | | æ åæ°ãè¿å饿µè¡¨ä¸å·²åºç°ç设å¤å»éå表ï¼`[{ tbDeviceId, deviceName }]`ï¼ä¾çéä¸æä½¿ç¨ã |
| | | |
| | | ### 饿µè®°å½å段ï¼latest / page éç¨ï¼ |
| | | |
| | | | åæ®µ | ç±»å | 说æ | |
| | | |------|------|------| |
| | | | id | Long | ç¼å· | |
| | | | tbDeviceId | String | æ°é设å¤ID | |
| | | | deviceName | String | 设å¤åç§° | |
| | | | paramName | String | ä¿¡å·åç§° | |
| | | | paramKeyName | String | 设å¤KEYåç§° | |
| | | | standardValue | String | æ åå¼ | |
| | | | timelyValue | String | ä¿¡å·å¼ï¼å®æ¶ï¼ | |
| | | | avgValue | String | åå¼ | |
| | | | maxValue | String | æå¤§å¼ | |
| | | | minValue | String | æå°å¼ | |
| | | | whetherAnomaly | Boolean | æ¯å¦å¼å¸¸ï¼true=å¼å¸¸ï¼ | |
| | | | telemetryDataTime | String | 饿µæ°æ®æ¶é´ | |
| | | | billNo | String | åæ®å· | |
| | | | shiftName | String | çæ¬¡ | |
| | | | pullTime | String | æåæ¶é´ | |
| | | | createTime | String | å建æ¶é´ | |
| | | |
| | | ## åæ®µå±ç¤ºè§å |
| | | |
| | | | åæ®µ | å±ç¤ºä½ç½® | 说æ | |
| | | |------|----------|------| |
| | | | deviceName | 宿¶/åå²å表ãçé | 设å¤åç§° | |
| | | | paramName | 宿¶/åå²å表 | ä¿¡å·åç§° | |
| | | | timelyValue | 宿¶/åå²å表 | ä¿¡å·å¼ï¼å®æ¶ï¼ | |
| | | | whetherAnomaly | 宿¶/åå²å表ãåå²çé | å¸å°æ¸²æä¸º Tagï¼æ£å¸¸(绿)/å¼å¸¸(红)ï¼çéç¨å¸å°é项 æ£å¸¸/å¼å¸¸ | |
| | | | shiftName | 宿¶/åå²å表 | çæ¬¡ | |
| | | | telemetryDataTime | 宿¶/åå²å表ãåå²çé | 饿µæ¶é´ï¼`YYYY-MM-DD HH:mm:ss` | |
| | | | standardValue / avgValue / maxValue / minValue | 宿¶å表 | æ åå¼ / åå¼ / æå¤§å¼ / æå°å¼ | |
| | | | billNo | åå²å表 | åæ®å· | |
| | | | pullTime | åå²å表 | æåæ¶é´ | |
| | | | æè¿æåæ¶é´ | 页é¢é¡¶é¨ | æåæåååæ¾ pullTime | |
| | | |
| | | ## ä¸å¡è§å说æ |
| | | |
| | | | åºæ¯ | è§å | |
| | | |------|------| |
| | | | æ°æ®æå | æå¨æé® + 宿¶ä»»å¡ï¼æ¯ 5 åéï¼åå¯è§¦åï¼åå
¥ `mes_dv_telemetry` | |
| | | | 宿¶æ°æ® | æãtbDeviceId + paramKeyNameãå»éä¿çææ°ï¼å±ç¤ºæè¿ä¸æ¬¡æåç»æ | |
| | | | å岿°æ® | æ¯æ¬¡æåå
¨éå
¥åºï¼å«éå¤ä¿¡å·ï¼ï¼æé¥æµæ¶é´ååºå页 | |
| | | | 设å¤å
³è | 设å¤å°è´¦ `tb_device_id` ä¸å¤é¨æ°é `tbDeviceId` 对åºï¼æªå¡«åå°è´¦è¯¦æ
ãæ°éæ°æ®ãTab ç¦ç¨ | |
| | | | æ¯å¦å¼å¸¸ | å端 `bit` åæ®µæ å° Booleanï¼åç«¯ç´æ¥æå¸å°æ¸²æï¼ä¸ä¾èµåå
¸ | |
| | | | 宿¶ä»»å¡ | é»è®¤æ¯ 5 åéæ§è¡ï¼å¯å¨ãç³»ç»ç®¡ç â 宿¶ä»»å¡ãè°æ´/åç¨ | |
| | | |
| | | ## 注æäºé¡¹ |
| | | |
| | | - æ°éæå¡å°åå¨å端 `yudao.mes.telemetry.base-url` é
ç½®ï¼`application-local.yaml`ï¼ï¼æªé
ç½®æ¶ `/pull` æ¥ãæ°éæ°æ®æå失败ãã |
| | | - å¤é¨æ¥å£ä»
ä¿çè¿ 5 åéæ°æ®ï¼è¶
è¿ä¸æå³ä¸¢ï¼å»ºè®®ä¿æå®æ¶ä»»å¡è¿è¡ï¼é¡µé¢æå¨æåä»
å宿¶å·æ°ç¨ã |
| | | - åå²è®°å½æ°æ®é伿ç»å¢é¿ï¼æ¥è¯¢å»ºè®®å¸¦é¥æµæ¶é´åºé´è¿æ»¤ã |
| | | - æ°é饿µä¸ºå¤é¨æ°æ®ï¼åªè¯»å±ç¤ºï¼æ æ°å¢/ä¿®æ¹/å é¤/å¯¼åºæä½ï¼ä»
ä¸ä¸ªãæ¥è¯¢ãæé®æé `mes:dv-telemetry:query`ã |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.compensation; |
| | | |
| | | 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.compensation.vo.AfterSaleCompensationAuditReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationRespVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationSaveReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.compensation.AfterSaleCompensationDO; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleCompensationAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.aftersales.service.compensation.AfterSaleCompensationService; |
| | | import cn.iocoder.yudao.module.crm.api.customer.CrmCustomerApi; |
| | | import cn.iocoder.yudao.module.crm.api.customer.dto.CrmCustomerRespDTO; |
| | | 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.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | 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/compensation") |
| | | @Validated |
| | | public class AfterSaleCompensationController { |
| | | |
| | | @Resource |
| | | private AfterSaleCompensationService compensationService; |
| | | |
| | | @Resource |
| | | private CrmCustomerApi customerApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "å建èµä»/æå¡è¡¥å¿å") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:create')") |
| | | public CommonResult<Long> createCompensation(@Valid @RequestBody AfterSaleCompensationSaveReqVO createReqVO) { |
| | | return success(compensationService.createCompensation(createReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "æ´æ°èµä»/æå¡è¡¥å¿å") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:update')") |
| | | public CommonResult<Boolean> updateCompensation(@Valid @RequestBody AfterSaleCompensationSaveReqVO updateReqVO) { |
| | | compensationService.updateCompensation(updateReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤èµä»/æå¡è¡¥å¿å") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:delete')") |
| | | public CommonResult<Boolean> deleteCompensation(@RequestParam("id") Long id) { |
| | | compensationService.deleteCompensation(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾èµä»/æå¡è¡¥å¿å") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:query')") |
| | | public CommonResult<AfterSaleCompensationRespVO> getCompensation(@RequestParam("id") Long id) { |
| | | AfterSaleCompensationDO compensation = compensationService.getCompensation(id); |
| | | return success(compensation != null ? BeanUtils.toBean(compensation, AfterSaleCompensationRespVO.class, vo -> { |
| | | vo.setAuditStatusName(AfterSaleCompensationAuditStatusEnum.getNameByStatus(compensation.getAuditStatus())); |
| | | }) : null); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾èµä»/æå¡è¡¥å¿åå页") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:query')") |
| | | public CommonResult<PageResult<AfterSaleCompensationRespVO>> getCompensationPage(@Valid AfterSaleCompensationPageReqVO pageReqVO) { |
| | | PageResult<AfterSaleCompensationDO> pageResult = compensationService.getCompensationPage(pageReqVO); |
| | | List<AfterSaleCompensationRespVO> list = buildCompensationDetailList(pageResult.getList()); |
| | | return success(new PageResult<>(list, pageResult.getTotal())); |
| | | } |
| | | |
| | | @PutMapping("/submit") |
| | | @Operation(summary = "æäº¤èµä»/æå¡è¡¥å¿å审æ¹") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:submit')") |
| | | public CommonResult<Boolean> submitCompensation(@RequestParam("id") Long id, |
| | | @RequestParam("processDefinitionKey") String processDefinitionKey) { |
| | | compensationService.submitCompensation(id, processDefinitionKey, getLoginUserId()); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/audit") |
| | | @Operation(summary = "审æ¹èµä»/æå¡è¡¥å¿åï¼éè¿/驳åï¼") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:audit')") |
| | | public CommonResult<Boolean> auditCompensation(@Valid @RequestBody AfterSaleCompensationAuditReqVO auditReqVO) { |
| | | compensationService.auditCompensation(auditReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approve-process-list") |
| | | @Operation(summary = "è·å¾èµä»/æå¡è¡¥å¿åå®¡æ¹æµç¨å®ä¹å表") |
| | | @PreAuthorize("@ss.hasPermission('aftersales:compensation:query')") |
| | | public CommonResult<List<Map<String, Object>>> getCompensationApproveProcessDefinitionList() { |
| | | return success(compensationService.getCompensationApproveProcessDefinitionList()); |
| | | } |
| | | |
| | | // ========== å
鍿¹æ³ï¼æ¹éæ¼è£
å
³èåç§° ========== |
| | | |
| | | private List<AfterSaleCompensationRespVO> buildCompensationDetailList(List<AfterSaleCompensationDO> compensationList) { |
| | | if (CollUtil.isEmpty(compensationList)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¹éå 载客æ·åç§° |
| | | Set<Long> customerIds = convertSet(compensationList, AfterSaleCompensationDO::getCustomerId); |
| | | Map<Long, CrmCustomerRespDTO> customerMap = customerApi.getCustomerMap(customerIds); |
| | | // æ¼è£
åç§°åæ®µ |
| | | return BeanUtils.toBean(compensationList, AfterSaleCompensationRespVO.class, vo -> { |
| | | CrmCustomerRespDTO customer = customerMap.get(vo.getCustomerId()); |
| | | if (customer != null) vo.setCustomerName(customer.getName()); |
| | | vo.setAuditStatusName(AfterSaleCompensationAuditStatusEnum.getNameByStatus(vo.getAuditStatus())); |
| | | }); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å®åèµä»/æå¡è¡¥å¿å å®¡æ¹ Request VO |
| | | */ |
| | | @Schema(description = "å®åèµä»/æå¡è¡¥å¿å - å®¡æ¹ Request VO") |
| | | @Data |
| | | public class AfterSaleCompensationAuditReqVO { |
| | | |
| | | @Schema(description = "èµä»åç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "èµä»åç¼å·ä¸è½ä¸ºç©º") |
| | | private Long id; |
| | | |
| | | @Schema(description = "审æ¹ç»æï¼20 éè¿ / 30 驳åï¼", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") |
| | | @NotNull(message = "审æ¹ç»æä¸è½ä¸ºç©º") |
| | | private Integer auditStatus; |
| | | |
| | | @Schema(description = "审æ¹å¤æ³¨", example = "åæèµä»") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.compensation.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 AfterSaleCompensationPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "èµä»åå·", example = "PS20260820001") |
| | | private String compensationNo; |
| | | |
| | | @Schema(description = "èµä»ç±»å", example = "1") |
| | | private Integer compensationType; |
| | | |
| | | @Schema(description = "å
³èå®åå·¥åç¼å·", example = "1") |
| | | private Long ticketId; |
| | | |
| | | @Schema(description = "客æ·ç¼å·", example = "1") |
| | | private Long customerId; |
| | | |
| | | @Schema(description = "审æ¹ç¶æ", example = "0") |
| | | private Integer auditStatus; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo; |
| | | |
| | | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| | | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| | | import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®åèµä»/æå¡è¡¥å¿å Response VO |
| | | */ |
| | | @Schema(description = "å®åèµä»/æå¡è¡¥å¿å Response VO") |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | public class AfterSaleCompensationRespVO { |
| | | |
| | | @Schema(description = "èµä»åç¼å·", example = "1") |
| | | @ExcelProperty("èµä»åç¼å·") |
| | | private Long id; |
| | | |
| | | @Schema(description = "èµä»åå·", example = "PS20260820001") |
| | | @ExcelProperty("èµä»åå·") |
| | | private String compensationNo; |
| | | |
| | | @Schema(description = "èµä»ç±»å: 1-æ
éèµä» 2-æå¡è¡¥å¿", example = "1") |
| | | @ExcelProperty(value = "èµä»ç±»å", converter = DictConvert.class) |
| | | @DictFormat(cn.iocoder.yudao.module.aftersales.enums.DictTypeConstants.AFTER_SALES_COMPENSATION_TYPE) |
| | | private Integer compensationType; |
| | | |
| | | @Schema(description = "å
³èå®åå·¥åç¼å·", example = "1") |
| | | private Long ticketId; |
| | | |
| | | @Schema(description = "客æ·ç¼å·", example = "1") |
| | | private Long customerId; |
| | | |
| | | @Schema(description = "客æ·åç§°", example = "åè½çµå") |
| | | private String customerName; |
| | | |
| | | @Schema(description = "å
³èéå®è®¢åç¼å·", example = "1") |
| | | private Long saleOrderId; |
| | | |
| | | @Schema(description = "èµä»éé¢", example = "1000.00") |
| | | @ExcelProperty("èµä»éé¢") |
| | | private BigDecimal amount; |
| | | |
| | | @Schema(description = "èµä»å¯¹è±¡", example = "å¼ ä¸") |
| | | @ExcelProperty("èµä»å¯¹è±¡") |
| | | private String payee; |
| | | |
| | | @Schema(description = "èµä»åå ", example = "产åæ
éå¯¼è´æå¤±") |
| | | @ExcelProperty("èµä»åå ") |
| | | private String reason; |
| | | |
| | | @Schema(description = "审æ¹ç¶æ", example = "0") |
| | | private Integer auditStatus; |
| | | |
| | | @Schema(description = "审æ¹ç¶æåç§°", example = "æªæäº¤") |
| | | private String auditStatusName; |
| | | |
| | | @Schema(description = "å®¡æ¹æµç¨å®ä¾ç¼å·") |
| | | private String processInstanceId; |
| | | |
| | | @Schema(description = "å®¡æ ¸äºº", example = "1") |
| | | private Long auditUserId; |
| | | |
| | | @Schema(description = "å®¡æ ¸æ¶é´") |
| | | private LocalDateTime auditTime; |
| | | |
| | | @Schema(description = "å®¡æ ¸å¤æ³¨") |
| | | private String auditRemark; |
| | | |
| | | @Schema(description = "æ¯ä»ç¶æï¼è´¦å¡èå¨é¢çï¼") |
| | | private Integer payStatus; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * å®åèµä»/æå¡è¡¥å¿å ä¿å Request VO |
| | | */ |
| | | @Schema(description = "å®åèµä»/æå¡è¡¥å¿å - ä¿å Request VO") |
| | | @Data |
| | | public class AfterSaleCompensationSaveReqVO { |
| | | |
| | | @Schema(description = "èµä»åç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "èµä»ç±»å: 1-æ
éèµä» 2-æå¡è¡¥å¿", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "èµä»ç±»åä¸è½ä¸ºç©º") |
| | | private Integer compensationType; |
| | | |
| | | @Schema(description = "å
³èå®åå·¥åç¼å·", example = "1") |
| | | private Long ticketId; |
| | | |
| | | @Schema(description = "客æ·ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "客æ·ä¸è½ä¸ºç©º") |
| | | private Long customerId; |
| | | |
| | | @Schema(description = "å
³èéå®è®¢åç¼å·", example = "1") |
| | | private Long saleOrderId; |
| | | |
| | | @Schema(description = "èµä»éé¢", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000.00") |
| | | @NotNull(message = "èµä»éé¢ä¸è½ä¸ºç©º") |
| | | private BigDecimal amount; |
| | | |
| | | @Schema(description = "èµä»å¯¹è±¡", example = "å¼ ä¸") |
| | | private String payee; |
| | | |
| | | @Schema(description = "èµä»åå ", requiredMode = Schema.RequiredMode.REQUIRED, example = "产åæ
éå¯¼è´æå¤±") |
| | | @NotEmpty(message = "èµä»åå ä¸è½ä¸ºç©º") |
| | | private String reason; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.dal.dataobject.compensation; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleCompensationAuditStatusEnum; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å®åèµä»/æå¡è¡¥å¿å DO |
| | | * |
| | | * å¯¹åº xlsx å®å 2ãæ
éèµä»ãæå¡è¡¥å¿â¦å
¨æµç¨è¿½æº¯ã |
| | | */ |
| | | @TableName("after_sale_compensation") |
| | | @KeySequence("after_sale_compensation_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class AfterSaleCompensationDO extends BaseDO { |
| | | |
| | | /** |
| | | * èµä»åç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | /** |
| | | * èµä»åå· |
| | | */ |
| | | private String compensationNo; |
| | | /** |
| | | * èµä»ç±»å: 1-æ
éèµä» 2-æå¡è¡¥å¿ |
| | | */ |
| | | private Integer compensationType; |
| | | /** |
| | | * å
³èå®åå·¥åç¼å·ï¼å
³è after_sale_ticket.id |
| | | */ |
| | | private Long ticketId; |
| | | /** |
| | | * 客æ·ç¼å· |
| | | */ |
| | | private Long customerId; |
| | | /** |
| | | * å
³èéå®è®¢åç¼å· |
| | | */ |
| | | private Long saleOrderId; |
| | | /** |
| | | * èµä»éé¢ |
| | | */ |
| | | private BigDecimal amount; |
| | | /** |
| | | * èµä»å¯¹è±¡ |
| | | */ |
| | | private String payee; |
| | | /** |
| | | * èµä»åå |
| | | */ |
| | | private String reason; |
| | | /** |
| | | * 审æ¹ç¶æ |
| | | * |
| | | * æä¸¾ {@link AfterSaleCompensationAuditStatusEnum} |
| | | */ |
| | | private Integer auditStatus; |
| | | /** |
| | | * å®¡æ¹æµç¨å®ä¾ç¼å· |
| | | */ |
| | | private String processInstanceId; |
| | | /** |
| | | * å®¡æ ¸äºº |
| | | */ |
| | | private Long auditUserId; |
| | | /** |
| | | * å®¡æ ¸æ¶é´ |
| | | */ |
| | | private LocalDateTime auditTime; |
| | | /** |
| | | * å®¡æ ¸å¤æ³¨ |
| | | */ |
| | | private String auditRemark; |
| | | /** |
| | | * æ¯ä»ç¶æï¼è´¦å¡èå¨é¢çï¼æ¥è´¢å¡å使ç¨ï¼ |
| | | */ |
| | | private Integer payStatus; |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.dal.mysql.compensation; |
| | | |
| | | 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.controller.admin.compensation.vo.AfterSaleCompensationPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.compensation.AfterSaleCompensationDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * å®åèµä»/æå¡è¡¥å¿å Mapper |
| | | */ |
| | | @Mapper |
| | | public interface AfterSaleCompensationMapper extends BaseMapperX<AfterSaleCompensationDO> { |
| | | |
| | | default AfterSaleCompensationDO selectByCompensationNo(String compensationNo) { |
| | | return selectOne(AfterSaleCompensationDO::getCompensationNo, compensationNo); |
| | | } |
| | | |
| | | default PageResult<AfterSaleCompensationDO> selectPage(AfterSaleCompensationPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<AfterSaleCompensationDO>() |
| | | .likeIfPresent(AfterSaleCompensationDO::getCompensationNo, reqVO.getCompensationNo()) |
| | | .eqIfPresent(AfterSaleCompensationDO::getCompensationType, reqVO.getCompensationType()) |
| | | .eqIfPresent(AfterSaleCompensationDO::getTicketId, reqVO.getTicketId()) |
| | | .eqIfPresent(AfterSaleCompensationDO::getCustomerId, reqVO.getCustomerId()) |
| | | .eqIfPresent(AfterSaleCompensationDO::getAuditStatus, reqVO.getAuditStatus()) |
| | | .orderByDesc(AfterSaleCompensationDO::getId)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.enums; |
| | | |
| | | import cn.iocoder.yudao.framework.common.core.ArrayValuable; |
| | | import lombok.Getter; |
| | | import lombok.RequiredArgsConstructor; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * å®åçèµä»/è¡¥å¿å审æ¹ç¶æ |
| | | */ |
| | | @RequiredArgsConstructor |
| | | @Getter |
| | | public enum AfterSaleCompensationAuditStatusEnum implements ArrayValuable<Integer> { |
| | | |
| | | DRAFT(0, "æªæäº¤"), |
| | | PROCESS(10, "审æ¹ä¸"), |
| | | APPROVE(20, "å®¡æ ¸éè¿"), |
| | | REJECT(30, "å®¡æ ¸ä¸éè¿"), |
| | | CANCEL(40, "已忶"); |
| | | |
| | | private final Integer status; |
| | | private final String name; |
| | | |
| | | public static final Integer[] ARRAYS = Arrays.stream(values()).map(AfterSaleCompensationAuditStatusEnum::getStatus).toArray(Integer[]::new); |
| | | |
| | | public static String getNameByStatus(Integer status) { |
| | | if (status == null) return null; |
| | | for (AfterSaleCompensationAuditStatusEnum e : values()) { |
| | | if (e.getStatus().equals(status)) return e.getName(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Integer[] array() { |
| | | return ARRAYS; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.enums; |
| | | |
| | | /** |
| | | * å®å模ååå
¸ç±»å |
| | | */ |
| | | public interface DictTypeConstants { |
| | | |
| | | String AFTER_SALES_COMPENSATION_TYPE = "after_sale_compensation_type"; |
| | | |
| | | } |
| | |
| | | ErrorCode REPAIR_NOT_EXISTS = new ErrorCode(1_022_003_000, "维修记å½ä¸åå¨"); |
| | | ErrorCode REPAIR_UPDATE_FAIL_STATUS = new ErrorCode(1_022_003_001, "æ´æ°ç»´ä¿®ç¶æå¤±è´¥ï¼åå ï¼å·²ç»æ¯è¯¥ç¶æ"); |
| | | |
| | | // ========== èµä»/æå¡è¡¥å¿å 1-022-004-000 ========== |
| | | ErrorCode COMPENSATION_NOT_EXISTS = new ErrorCode(1_022_004_000, "èµä»/æå¡è¡¥å¿åä¸åå¨"); |
| | | ErrorCode COMPENSATION_NO_EXISTS = new ErrorCode(1_022_004_001, "çæèµä»åå·éå¤ï¼è¯·éè¯"); |
| | | ErrorCode COMPENSATION_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_022_004_002, "æäº¤èµä»å审æ¹å¤±è´¥ï¼åå ï¼èµä»å䏿¯èç¨¿ç¶æ"); |
| | | ErrorCode COMPENSATION_BPM_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1_022_004_003, "èµä»åå®¡æ¹æµç¨ä¸åå¨ææªæ¿æ´»ï¼è¯·æ£æ¥ BPM é
ç½®"); |
| | | ErrorCode COMPENSATION_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_022_004_004, "æ´æ°èµä»å审æ¹ç¶æå¤±è´¥ï¼åå ï¼èµä»åä¸å¤äºå®¡æ¹ä¸"); |
| | | ErrorCode COMPENSATION_DELETE_FAIL_NOT_DRAFT = new ErrorCode(1_022_004_005, "èµä»å䏿¯èç¨¿ç¶æï¼æ æ³å é¤"); |
| | | ErrorCode COMPENSATION_TICKET_NOT_EXISTS = new ErrorCode(1_022_004_006, "å
³èçå®åå·¥åä¸åå¨"); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.service.compensation; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationAuditReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationSaveReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.compensation.AfterSaleCompensationDO; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * å®åèµä»/æå¡è¡¥å¿å Service æ¥å£ |
| | | */ |
| | | public interface AfterSaleCompensationService { |
| | | |
| | | Long createCompensation(AfterSaleCompensationSaveReqVO createReqVO); |
| | | |
| | | void updateCompensation(AfterSaleCompensationSaveReqVO updateReqVO); |
| | | |
| | | void deleteCompensation(Long id); |
| | | |
| | | AfterSaleCompensationDO getCompensation(Long id); |
| | | |
| | | PageResult<AfterSaleCompensationDO> getCompensationPage(AfterSaleCompensationPageReqVO pageReqVO); |
| | | |
| | | /** |
| | | * æäº¤èµä»åå®¡æ¹ |
| | | */ |
| | | void submitCompensation(Long id, String processDefinitionKey, Long userId); |
| | | |
| | | /** |
| | | * 审æ¹èµä»åï¼éè¿/驳åï¼ |
| | | */ |
| | | void auditCompensation(AfterSaleCompensationAuditReqVO auditReqVO); |
| | | |
| | | /** |
| | | * æ´æ°èµä»å审æ¹ç¶æï¼BPM çå¬åè°ï¼ |
| | | */ |
| | | void updateCompensationAuditStatus(Long id, Integer bpmResult); |
| | | |
| | | /** |
| | | * è·å¾èµä»åå®¡æ¹æµç¨å®ä¹å表 |
| | | */ |
| | | List<Map<String, Object>> getCompensationApproveProcessDefinitionList(); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.service.compensation; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | 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.aftersales.controller.admin.compensation.vo.AfterSaleCompensationAuditReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationPageReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.controller.admin.compensation.vo.AfterSaleCompensationSaveReqVO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.compensation.AfterSaleCompensationDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.mysql.compensation.AfterSaleCompensationMapper; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleCompensationAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.aftersales.enums.ErrorCodeConstants; |
| | | import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; |
| | | import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; |
| | | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; |
| | | import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; |
| | | import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | import static cn.iocoder.yudao.module.aftersales.util.AfterSaleCompensationStatusUtils.convertBpmResultToAuditStatus; |
| | | |
| | | /** |
| | | * å®åèµä»/æå¡è¡¥å¿å Service å®ç°ç±» |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @Slf4j |
| | | public class AfterSaleCompensationServiceImpl implements AfterSaleCompensationService { |
| | | |
| | | private static final Integer AUDIT_DRAFT = 0; |
| | | private static final Integer AUDIT_PASS = 20; |
| | | |
| | | /** |
| | | * BPM èµä»å®¡æ¹åç±»ç¼ç |
| | | */ |
| | | private static final String COMPENSATION_APPROVE_CATEGORY_CODE = "compensation_approve"; |
| | | |
| | | @Resource |
| | | private AfterSaleCompensationMapper compensationMapper; |
| | | @Resource |
| | | private BpmProcessInstanceApi bpmProcessInstanceApi; |
| | | @Resource |
| | | private BpmCategoryService bpmCategoryService; |
| | | @Resource |
| | | private BpmProcessDefinitionService bpmProcessDefinitionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createCompensation(AfterSaleCompensationSaveReqVO createReqVO) { |
| | | String compensationNo = generateCompensationNo(); |
| | | if (compensationMapper.selectByCompensationNo(compensationNo) != null) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_NO_EXISTS); |
| | | } |
| | | AfterSaleCompensationDO entity = BeanUtils.toBean(createReqVO, AfterSaleCompensationDO.class, req -> req |
| | | .setCompensationNo(compensationNo) |
| | | .setAuditStatus(AUDIT_DRAFT)); |
| | | compensationMapper.insert(entity); |
| | | return entity.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void updateCompensation(AfterSaleCompensationSaveReqVO updateReqVO) { |
| | | AfterSaleCompensationDO exists = compensationMapper.selectById(updateReqVO.getId()); |
| | | if (exists == null) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_NOT_EXISTS); |
| | | } |
| | | if (ObjUtil.notEqual(exists.getAuditStatus(), AUDIT_DRAFT)) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_DELETE_FAIL_NOT_DRAFT); |
| | | } |
| | | AfterSaleCompensationDO entity = BeanUtils.toBean(updateReqVO, AfterSaleCompensationDO.class, req -> req |
| | | .setCompensationNo(exists.getCompensationNo()) |
| | | .setAuditStatus(exists.getAuditStatus())); |
| | | compensationMapper.updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteCompensation(Long id) { |
| | | AfterSaleCompensationDO exists = compensationMapper.selectById(id); |
| | | if (exists == null) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_NOT_EXISTS); |
| | | } |
| | | if (ObjUtil.notEqual(exists.getAuditStatus(), AUDIT_DRAFT)) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_DELETE_FAIL_NOT_DRAFT); |
| | | } |
| | | compensationMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public AfterSaleCompensationDO getCompensation(Long id) { |
| | | return compensationMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<AfterSaleCompensationDO> getCompensationPage(AfterSaleCompensationPageReqVO pageReqVO) { |
| | | return compensationMapper.selectPage(pageReqVO); |
| | | } |
| | | |
| | | @Override |
| | | public void submitCompensation(Long id, String processDefinitionKey, Long userId) { |
| | | // 1. æ ¡éªèµä»åæ¯å¦å¨èç¨¿ç¶æ |
| | | AfterSaleCompensationDO compensation = compensationMapper.selectById(id); |
| | | if (compensation == null) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_NOT_EXISTS); |
| | | } |
| | | if (ObjUtil.notEqual(compensation.getAuditStatus(), AfterSaleCompensationAuditStatusEnum.DRAFT.getStatus())) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_SUBMIT_FAIL_NOT_DRAFT); |
| | | } |
| | | |
| | | // 2. æ ¡éªèµä»å®¡æ¹åç±»åæµç¨å®ä¹æ¯å¦åå¨ï¼ä¸ä¼ å
¥çæµç¨å®ä¹å¤äºæ¿æ´»ç¶æ |
| | | validateCompensationApproveCategoryAndProcessDefinition(); |
| | | ProcessDefinition processDefinition = bpmProcessDefinitionService.getActiveProcessDefinition(processDefinitionKey); |
| | | if (processDefinition == null) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | |
| | | // 3. å建èµä»å®¡æ¹æµç¨å®ä¾ |
| | | String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, |
| | | new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(processDefinitionKey) |
| | | .setBusinessKey(String.valueOf(id))); |
| | | |
| | | // 4. æ´æ°èµä»åæµç¨ç¼å·ä¸å®¡æ¹ç¶æ |
| | | compensationMapper.updateById(new AfterSaleCompensationDO().setId(id).setProcessInstanceId(processInstanceId) |
| | | .setAuditStatus(AfterSaleCompensationAuditStatusEnum.PROCESS.getStatus())); |
| | | } |
| | | |
| | | @Override |
| | | public void auditCompensation(AfterSaleCompensationAuditReqVO auditReqVO) { |
| | | AfterSaleCompensationDO exists = compensationMapper.selectById(auditReqVO.getId()); |
| | | if (exists == null) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_NOT_EXISTS); |
| | | } |
| | | AfterSaleCompensationDO update = new AfterSaleCompensationDO(); |
| | | update.setId(exists.getId()); |
| | | update.setAuditStatus(auditReqVO.getAuditStatus()); |
| | | update.setAuditUserId(getLoginUserId()); |
| | | update.setAuditTime(LocalDateTime.now()); |
| | | if (StrUtil.isNotBlank(auditReqVO.getRemark())) { |
| | | update.setAuditRemark(auditReqVO.getRemark()); |
| | | } |
| | | compensationMapper.updateById(update); |
| | | } |
| | | |
| | | @Override |
| | | public void updateCompensationAuditStatus(Long id, Integer bpmResult) { |
| | | // 1.1 æ ¡éªèµä»åæ¯å¦åå¨ |
| | | AfterSaleCompensationDO compensation = compensationMapper.selectById(id); |
| | | if (compensation == null) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_NOT_EXISTS); |
| | | } |
| | | // 1.2 åªæå®¡æ¹ä¸ï¼å¯ä»¥æ´æ°å®¡æ¹ç»æ |
| | | if (ObjUtil.notEqual(compensation.getAuditStatus(), AfterSaleCompensationAuditStatusEnum.PROCESS.getStatus())) { |
| | | log.error("[updateCompensationAuditStatus][compensation({}) ä¸å¤äºå®¡æ¹ä¸ï¼æ æ³æ´æ°å®¡æ¹ç»æ({})]", compensation.getId(), bpmResult); |
| | | throw exception(ErrorCodeConstants.COMPENSATION_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); |
| | | } |
| | | |
| | | // 2. æ´æ°èµä»å审æ¹ç»æ |
| | | Integer auditStatus = convertBpmResultToAuditStatus(bpmResult); |
| | | compensationMapper.updateById(new AfterSaleCompensationDO().setId(id).setAuditStatus(auditStatus)); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getCompensationApproveProcessDefinitionList() { |
| | | // 1. æ ¡éªèµä»å®¡æ¹åç±»åæµç¨å®ä¹æ¯å¦åå¨ |
| | | validateCompensationApproveCategoryAndProcessDefinition(); |
| | | |
| | | // 2. è·ååç±»ä¸çæµç¨å®ä¹ä¿¡æ¯ |
| | | List<BpmProcessDefinitionInfoDO> definitionInfoList = bpmProcessDefinitionService |
| | | .getProcessDefinitionInfoListByCategory(COMPENSATION_APPROVE_CATEGORY_CODE); |
| | | |
| | | // 3. è·åæµç¨å®ä¹è¯¦æ
|
| | | Set<String> processDefinitionIds = convertSet(definitionInfoList, BpmProcessDefinitionInfoDO::getProcessDefinitionId); |
| | | List<ProcessDefinition> processDefinitions = bpmProcessDefinitionService.getProcessDefinitionList(processDefinitionIds); |
| | | |
| | | // 4. è¿æ»¤ï¼åªä¿çæ¿æ´»ç¶æï¼ä¸ç¸å key åªä¿çææ°çæ¬ |
| | | Map<String, ProcessDefinition> latestVersionMap = new HashMap<>(); |
| | | for (ProcessDefinition pd : processDefinitions) { |
| | | if (pd.isSuspended()) { |
| | | continue; |
| | | } |
| | | ProcessDefinition existing = latestVersionMap.get(pd.getKey()); |
| | | if (existing == null || pd.getVersion() > existing.getVersion()) { |
| | | latestVersionMap.put(pd.getKey(), pd); |
| | | } |
| | | } |
| | | |
| | | // 5. è¿åæµç¨å®ä¹å表 |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (ProcessDefinition pd : latestVersionMap.values()) { |
| | | Map<String, Object> item = new HashMap<>(); |
| | | item.put("id", pd.getId()); |
| | | item.put("key", pd.getKey()); |
| | | item.put("name", pd.getName()); |
| | | item.put("version", pd.getVersion()); |
| | | result.add(item); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éª BPM èµä»å®¡æ¹åç±»åæµç¨å®ä¹æ¯å¦åå¨ |
| | | */ |
| | | private void validateCompensationApproveCategoryAndProcessDefinition() { |
| | | // 1. æ ¡éªåç±»æ¯å¦åå¨ |
| | | Map<String, ?> categoryMap = bpmCategoryService.getCategoryMap(Collections.singletonList(COMPENSATION_APPROVE_CATEGORY_CODE)); |
| | | if (!categoryMap.containsKey(COMPENSATION_APPROVE_CATEGORY_CODE)) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | |
| | | // 2. æ ¡éªåç±»ä¸æ¯å¦æå¯ç¨çæµç¨å®ä¹ |
| | | List<BpmProcessDefinitionInfoDO> definitionInfoList = bpmProcessDefinitionService |
| | | .getProcessDefinitionInfoListByCategory(COMPENSATION_APPROVE_CATEGORY_CODE); |
| | | if (CollUtil.isEmpty(definitionInfoList)) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | |
| | | // 3. æ ¡éªæ¯å¦ææ¿æ´»ç¶æçæµç¨å®ä¹ |
| | | Set<String> processDefinitionIds = convertSet(definitionInfoList, BpmProcessDefinitionInfoDO::getProcessDefinitionId); |
| | | List<ProcessDefinition> processDefinitions = bpmProcessDefinitionService.getProcessDefinitionList(processDefinitionIds); |
| | | boolean hasActiveDefinition = processDefinitions.stream().anyMatch(pd -> !pd.isSuspended()); |
| | | if (!hasActiveDefinition) { |
| | | throw exception(ErrorCodeConstants.COMPENSATION_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | } |
| | | |
| | | private String generateCompensationNo() { |
| | | return "PS" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) |
| | | + RandomUtil.randomNumbers(4); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.service.compensation.listener; |
| | | |
| | | import cn.iocoder.yudao.module.aftersales.dal.dataobject.compensation.AfterSaleCompensationDO; |
| | | import cn.iocoder.yudao.module.aftersales.dal.mysql.compensation.AfterSaleCompensationMapper; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleCompensationAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.aftersales.service.compensation.AfterSaleCompensationService; |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * èµä»/æå¡è¡¥å¿å审æ¹çç»æçå¬å¨å®ç°ç±» |
| | | * |
| | | * éè¿ businessKeyï¼èµä»åIDï¼å¹é
ï¼è䏿¯åºå®çæµç¨å®ä¹ Keyï¼ |
| | | * è¿æ ·å¯ä»¥æ¯æåç±»ä¸ä»»æ Key çæµç¨æ¨¡åã |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class AfterSaleCompensationStatusListener implements ApplicationListener<BpmProcessInstanceStatusEvent> { |
| | | |
| | | @Resource |
| | | private AfterSaleCompensationService compensationService; |
| | | @Resource |
| | | private AfterSaleCompensationMapper compensationMapper; |
| | | |
| | | @Override |
| | | public void onApplicationEvent(BpmProcessInstanceStatusEvent event) { |
| | | // éè¿ businessKey æ¥è¯¢èµä»å |
| | | Long compensationId; |
| | | try { |
| | | compensationId = Long.parseLong(event.getBusinessKey()); |
| | | } catch (NumberFormatException e) { |
| | | return; // businessKey 䏿¯æ°åï¼å¿½ç¥ |
| | | } |
| | | |
| | | AfterSaleCompensationDO compensation = compensationMapper.selectById(compensationId); |
| | | if (compensation == null) { |
| | | return; // 䏿¯èµä»åï¼å¿½ç¥ |
| | | } |
| | | |
| | | // åªæå®¡æ¹ä¸ç¶æçèµä»åæå¤ç |
| | | if (!AfterSaleCompensationAuditStatusEnum.PROCESS.getStatus().equals(compensation.getAuditStatus())) { |
| | | log.warn("[onApplicationEvent] èµä»å({}) ä¸å¤äºå®¡æ¹ä¸ç¶æï¼å½åç¶æ: {}", compensationId, compensation.getAuditStatus()); |
| | | return; |
| | | } |
| | | |
| | | log.info("[onApplicationEvent] èµä»å({}) 审æ¹ç¶ææ´æ°: {}", compensationId, event.getStatus()); |
| | | // æ´æ°å®¡æ¹ç¶æ |
| | | compensationService.updateCompensationAuditStatus(compensationId, event.getStatus()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.aftersales.util; |
| | | |
| | | import cn.hutool.core.lang.Assert; |
| | | import cn.iocoder.yudao.module.aftersales.enums.AfterSaleCompensationAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum; |
| | | |
| | | /** |
| | | * å®åèµä»/è¡¥å¿åæµç¨å·¥å
·ç±» |
| | | */ |
| | | public class AfterSaleCompensationStatusUtils { |
| | | |
| | | /** |
| | | * BPM 审æ¹ç»æè½¬æ¢ |
| | | */ |
| | | public static Integer convertBpmResultToAuditStatus(Integer bpmResult) { |
| | | Integer auditStatus = BpmTaskStatusEnum.APPROVE.getStatus().equals(bpmResult) ? AfterSaleCompensationAuditStatusEnum.APPROVE.getStatus() |
| | | : BpmTaskStatusEnum.REJECT.getStatus().equals(bpmResult) ? AfterSaleCompensationAuditStatusEnum.REJECT.getStatus() |
| | | : BpmTaskStatusEnum.CANCEL.getStatus().equals(bpmResult) ? AfterSaleCompensationAuditStatusEnum.CANCEL.getStatus() : null; |
| | | Assert.notNull(auditStatus, "BPM 审æ¹ç»æ({}) 转æ¢å¤±è´¥", bpmResult); |
| | | return auditStatus; |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.bi.controller.admin.decision.vo.DecisionForecastReqVO; |
| | | import cn.iocoder.yudao.module.bi.controller.admin.decision.vo.DecisionForecastRespVO; |
| | | import cn.iocoder.yudao.module.bi.controller.admin.decision.vo.DecisionForecastWorkOrderCreateReqVO; |
| | | import cn.iocoder.yudao.module.bi.dal.dataobject.decision.BiForecastDataDO; |
| | | import cn.iocoder.yudao.module.bi.service.decision.BiForecastService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @PostMapping("/generate-work-order") |
| | | @Operation(summary = "è´è·é¢æµèå¨å建ç产工å") |
| | | @PreAuthorize("@ss.hasPermission('bi:decision-forecast:generate-work-order')") |
| | | public CommonResult<Long> generateWorkOrder(@Valid @RequestBody DecisionForecastWorkOrderCreateReqVO reqVO) { |
| | | return success(forecastService.createWorkOrderFromForecast(reqVO)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.bi.controller.admin.decision.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - è´è·é¢æµèå¨å建工å Request VO") |
| | | @Data |
| | | public class DecisionForecastWorkOrderCreateReqVO { |
| | | |
| | | @Schema(description = "è´è·é¢æµæ°æ®ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @NotNull(message = "è´è·é¢æµæ°æ®ç¼å·ä¸è½ä¸ºç©º") |
| | | private Long forecastId; |
| | | |
| | | @Schema(description = "å·¥ååç§°", example = "è´è·é¢æµ-åçµå·¥å") |
| | | private String workOrderName; |
| | | |
| | | @Schema(description = "å·¥åç±»åï¼4çµåè¿ç»´/5åçµ/6æ£ä¿®ï¼", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") |
| | | @NotNull(message = "å·¥åç±»åä¸è½ä¸ºç©º") |
| | | private Integer workOrderType; |
| | | |
| | | @Schema(description = "éæ±æ¥æ", example = "2026-08-20 00:00:00") |
| | | private LocalDateTime requestDate; |
| | | |
| | | @Schema(description = "ç产æ°é", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.00") |
| | | private BigDecimal quantity; |
| | | |
| | | @Schema(description = "夿³¨", example = "ç±è´è·é¢æµèªå¨çæ") |
| | | private String remark; |
| | | |
| | | } |
| | |
| | | ErrorCode ALERT_RECORD_NOT_EXISTS = new ErrorCode(1_080_201, "é¢è¦è®°å½ä¸åå¨"); |
| | | ErrorCode ALERT_RECORD_ALREADY_HANDLED = new ErrorCode(1_080_202, "é¢è¦è®°å½å·²å¤ç"); |
| | | |
| | | // ========== å³çæ¯æ - è´è·é¢æµ 1_080_221 ~ 1_080_240 ========== |
| | | ErrorCode BI_FORECAST_NOT_EXISTS = new ErrorCode(1_080_221, "è´è·é¢æµæ°æ®ä¸åå¨"); |
| | | |
| | | } |
| | |
| | | package cn.iocoder.yudao.module.bi.service.decision; |
| | | |
| | | import cn.iocoder.yudao.module.bi.controller.admin.decision.vo.DecisionForecastWorkOrderCreateReqVO; |
| | | import cn.iocoder.yudao.module.bi.dal.dataobject.decision.BiForecastDataDO; |
| | | |
| | | import java.time.LocalDateTime; |
| | |
| | | |
| | | void generateForecast(String forecastCode, LocalDateTime pointTime); |
| | | |
| | | /** |
| | | * è´è·é¢æµèå¨å建ç产工åï¼è¿ç»´/åçµ/æ£ä¿®ç±»ï¼ |
| | | * |
| | | * @param reqVO åå»ºè¯·æ± |
| | | * @return å·¥åç¼å· |
| | | */ |
| | | Long createWorkOrderFromForecast(DecisionForecastWorkOrderCreateReqVO reqVO); |
| | | |
| | | } |
| | |
| | | package cn.iocoder.yudao.module.bi.service.decision; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.iocoder.yudao.module.bi.controller.admin.decision.vo.DecisionForecastWorkOrderCreateReqVO; |
| | | import cn.iocoder.yudao.module.bi.dal.dataobject.decision.BiForecastDataDO; |
| | | import cn.iocoder.yudao.module.bi.dal.mysql.decision.BiForecastDataMapper; |
| | | import cn.iocoder.yudao.module.mes.api.workorder.MesProWorkOrderApi; |
| | | import cn.iocoder.yudao.module.mes.api.workorder.dto.MesProWorkOrderCreateReqDTO; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | 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.bi.enums.ErrorCodeConstants.BI_FORECAST_NOT_EXISTS; |
| | | |
| | | /** |
| | | * è´è·é¢æµ Service å®ç° |
| | |
| | | @Service |
| | | public class BiForecastServiceImpl implements BiForecastService { |
| | | |
| | | /** |
| | | * 工忥æºç±»åï¼è´è·é¢æµï¼ä¸åå
¸ mes_pro_work_order_source_type ç value=4 ä¸è´ï¼ |
| | | */ |
| | | private static final Integer WORK_ORDER_SOURCE_TYPE_FORECAST = 4; |
| | | |
| | | @Resource |
| | | private BiForecastDataMapper forecastDataMapper; |
| | | @Resource |
| | | private MesProWorkOrderApi mesProWorkOrderApi; |
| | | |
| | | @Override |
| | | public List<BiForecastDataDO> getForecastList(String forecastCode, LocalDateTime beginTime, LocalDateTime endTime) { |
| | |
| | | forecastDataMapper.insert(forecast); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createWorkOrderFromForecast(DecisionForecastWorkOrderCreateReqVO reqVO) { |
| | | // 1. æ ¡éªé¢æµæ°æ®åå¨ |
| | | BiForecastDataDO forecast = forecastDataMapper.selectById(reqVO.getForecastId()); |
| | | if (forecast == null) { |
| | | throw exception(BI_FORECAST_NOT_EXISTS); |
| | | } |
| | | // 2. ç»è£
å·¥å DTO å¹¶è°ç¨ MES API åå»ºï¼æ 产åå·¥åï¼è·³ BOMï¼ |
| | | MesProWorkOrderCreateReqDTO dto = new MesProWorkOrderCreateReqDTO(); |
| | | dto.setCode(generateWorkOrderCode()); |
| | | dto.setName(reqVO.getWorkOrderName() != null |
| | | ? reqVO.getWorkOrderName() |
| | | : ("è´è·é¢æµ-" + forecast.getForecastName())); |
| | | dto.setType(reqVO.getWorkOrderType()); |
| | | dto.setOrderSourceType(WORK_ORDER_SOURCE_TYPE_FORECAST); |
| | | dto.setOrderSourceCode(forecast.getForecastCode()); |
| | | dto.setRequestDate(reqVO.getRequestDate()); |
| | | dto.setQuantity(reqVO.getQuantity()); |
| | | dto.setRemark(reqVO.getRemark()); |
| | | return mesProWorkOrderApi.createWorkOrder(dto); |
| | | } |
| | | |
| | | private String generateWorkOrderCode() { |
| | | return "GZ" + DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss") |
| | | + String.format("%03d", (int) (Math.random() * 1000)); |
| | | } |
| | | |
| | | } |
| | |
| | | BpmCategoryDO category = MapUtil.get(categoryMap, definition.getCategory(), BpmCategoryDO.class); |
| | | return buildProcessDefinition(definition, deployment, processDefinitionInfo, form, category, null); |
| | | }); |
| | | // æåº |
| | | result.sort(Comparator.comparing(BpmProcessDefinitionRespVO::getSort)); |
| | | // æåºï¼æ process_definition_info çæµç¨å®ä¹ sort 为 nullï¼æ¾æåï¼é¿å
NPE |
| | | result.sort(Comparator.comparing(BpmProcessDefinitionRespVO::getSort, Comparator.nullsLast(Comparator.naturalOrder()))); |
| | | return result; |
| | | } |
| | | |
| | |
| | | ErrorCode ATTENDANCE_EXCEPTION_BPM_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1_030_004_015, "èå¤å¼å¸¸å®¡æ¹æµç¨ä¸åå¨"); |
| | | ErrorCode ATTENDANCE_CLOCK_ALREADY_CLOCKED = new ErrorCode(1_030_004_016, "å·²æè¿å¡ï¼è¯·å¿é夿å¡"); |
| | | |
| | | // ========== 绩æèæ ¸ 1-030-008-000 ========== |
| | | ErrorCode PERFORMANCE_APPRAISE_NOT_EXISTS = new ErrorCode(1_030_008_000, "绩æèæ ¸æ¹æ¡ä¸åå¨"); |
| | | ErrorCode PERFORMANCE_APPRAISE_ITEM_NOT_EXISTS = new ErrorCode(1_030_008_001, "èæ ¸ææ ä¸åå¨"); |
| | | ErrorCode PERFORMANCE_APPRAISE_UPDATE_FAIL_NOT_DRAFT = new ErrorCode(1_030_008_002, "绩æèæ ¸æ¹æ¡æ´æ°å¤±è´¥ï¼åå ï¼ä¸æ¯èç¨¿ç¶æ"); |
| | | ErrorCode PERFORMANCE_APPRAISE_SUBMIT_FAIL_NOT_DRAFT = new ErrorCode(1_030_008_003, "绩æèæ ¸æ¹æ¡æäº¤å¤±è´¥ï¼åå ï¼ä¸æ¯èç¨¿ç¶æ"); |
| | | ErrorCode PERFORMANCE_APPRAISE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS = new ErrorCode(1_030_008_004, "æ´æ°ç»©æèæ ¸å®¡æ¹ç¶æå¤±è´¥ï¼åå ï¼ä¸æ¯å®¡æ¹ä¸ç¶æ"); |
| | | ErrorCode PERFORMANCE_APPRAISE_BPM_PROCESS_DEFINITION_NOT_EXISTS = new ErrorCode(1_030_008_005, "绩æèæ ¸å®¡æ¹æµç¨ä¸åå¨ææªæ¿æ´»ï¼è¯·æ£æ¥ BPM é
ç½®"); |
| | | ErrorCode PERFORMANCE_APPRAISE_ITEM_EMPTY = new ErrorCode(1_030_008_006, "èæ ¸ææ ä¸è½ä¸ºç©º"); |
| | | ErrorCode PERFORMANCE_APPRAISE_RESULT_NOT_EXISTS = new ErrorCode(1_030_008_007, "èæ ¸ç»æä¸åå¨"); |
| | | ErrorCode PERFORMANCE_APPRAISE_RESULT_ITEM_NOT_EXISTS = new ErrorCode(1_030_008_008, "èæ ¸ææ è¯åä¸åå¨"); |
| | | ErrorCode PERFORMANCE_APPRAISE_SCORE_FAIL_STATUS = new ErrorCode(1_030_008_009, "è¯å失败ï¼åå ï¼æ¹æ¡ä¸æ¯å·²åå¸/è¿è¡ä¸ç¶æ"); |
| | | |
| | | // ========== èªé
¬ç®¡ç 1-030-005-000 ========== |
| | | ErrorCode SALARY_STRUCTURE_NOT_EXISTS = new ErrorCode(1_030_005_000, "èªé
¬ç»æä¸åå¨"); |
| | | ErrorCode EMPLOYEE_SALARY_NOT_EXISTS = new ErrorCode(1_030_005_001, "åå·¥èªé
¬æ¡£æ¡ä¸åå¨"); |
| | |
| | | <version>${revision}</version> |
| | | </dependency> |
| | | |
| | | <!-- MES ä¸å¡ç»ä»¶ï¼å·¥æ¶ç»è®¡è·¨æ¨¡åèåæ¥å·¥æ°æ® --> |
| | | <dependency> |
| | | <groupId>cn.iocoder.boot</groupId> |
| | | <artifactId>yudao-module-mes-api</artifactId> |
| | | <version>${revision}</version> |
| | | </dependency> |
| | | |
| | | <!-- ä¸å¡ç»ä»¶ --> |
| | | <dependency> |
| | | <groupId>cn.iocoder.boot</groupId> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise; |
| | | |
| | | 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.hrm.controller.admin.performanceappraise.vo.*; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.*; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService; |
| | | import cn.iocoder.yudao.module.hrm.service.performanceappraise.HrmPerformanceAppraiseService; |
| | | 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.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | |
| | | @Tag(name = "管çåå° - HRM 绩æèæ ¸æ¹æ¡") |
| | | @RestController |
| | | @RequestMapping("/hrm/performance-appraise") |
| | | @Validated |
| | | public class HrmPerformanceAppraiseController { |
| | | |
| | | @Resource |
| | | private HrmPerformanceAppraiseService appraiseService; |
| | | @Resource |
| | | private HrmEmployeeService employeeService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "å建绩æèæ ¸æ¹æ¡") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:create')") |
| | | public CommonResult<Long> createAppraise(@Valid @RequestBody HrmPerformanceAppraiseSaveReqVO createReqVO) { |
| | | return success(appraiseService.createAppraise(createReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "æ´æ°ç»©æèæ ¸æ¹æ¡") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:update')") |
| | | public CommonResult<Boolean> updateAppraise(@Valid @RequestBody HrmPerformanceAppraiseSaveReqVO updateReqVO) { |
| | | appraiseService.updateAppraise(updateReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤ç»©æèæ ¸æ¹æ¡") |
| | | @Parameter(name = "ids", description = "ç¼å·æ°ç»", required = true) |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:delete')") |
| | | public CommonResult<Boolean> deleteAppraise(@RequestParam("ids") List<Long> ids) { |
| | | appraiseService.deleteAppraise(ids); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾ç»©æèæ ¸æ¹æ¡") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:query')") |
| | | public CommonResult<HrmPerformanceAppraiseRespVO> getAppraise(@RequestParam("id") Long id) { |
| | | HrmPerformanceAppraiseDO appraise = appraiseService.getAppraise(id); |
| | | if (appraise == null) { |
| | | return success(null); |
| | | } |
| | | return success(buildAppraiseRespVO(appraise)); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾ç»©æèæ ¸æ¹æ¡å页") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:query')") |
| | | public CommonResult<PageResult<HrmPerformanceAppraiseRespVO>> getAppraisePage(@Valid HrmPerformanceAppraisePageReqVO pageReqVO) { |
| | | PageResult<HrmPerformanceAppraiseDO> pageResult = appraiseService.getAppraisePage(pageReqVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | | return success(PageResult.empty(pageResult.getTotal())); |
| | | } |
| | | List<HrmPerformanceAppraiseRespVO> list = pageResult.getList().stream() |
| | | .map(this::buildAppraiseRespVO).collect(Collectors.toList()); |
| | | return success(new PageResult<>(list, pageResult.getTotal())); |
| | | } |
| | | |
| | | // ========== èæ ¸ææ ========== |
| | | |
| | | @GetMapping("/item-list") |
| | | @Operation(summary = "è·å¾ç»©æèæ ¸ææ å表") |
| | | @Parameter(name = "appraiseId", description = "æ¹æ¡ç¼å·", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:query')") |
| | | public CommonResult<List<HrmPerformanceAppraiseItemRespVO>> getAppraiseItemList(@RequestParam("appraiseId") Long appraiseId) { |
| | | return success(BeanUtils.toBean(appraiseService.getAppraiseItemList(appraiseId), HrmPerformanceAppraiseItemRespVO.class)); |
| | | } |
| | | |
| | | @PostMapping("/item-save") |
| | | @Operation(summary = "ä¿å绩æèæ ¸ææ ï¼æ´è¡¨æ¿æ¢ï¼") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:update')") |
| | | public CommonResult<Boolean> saveAppraiseItems(@Valid @RequestBody HrmPerformanceAppraiseItemSaveReqVO saveReqVO) { |
| | | appraiseService.saveAppraiseItems(saveReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | // ========== å®¡æ¹ ========== |
| | | |
| | | @PostMapping("/submit") |
| | | @Operation(summary = "æäº¤ç»©æèæ ¸æ¹æ¡å®¡æ¹") |
| | | @Parameter(name = "id", description = "æ¹æ¡ç¼å·", required = true) |
| | | @Parameter(name = "processDefinitionKey", description = "æµç¨å®ä¹Key", required = true) |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:submit')") |
| | | public CommonResult<Boolean> submitAppraise(@RequestParam("id") Long id, |
| | | @RequestParam("processDefinitionKey") String processDefinitionKey) { |
| | | appraiseService.submitAppraise(id, processDefinitionKey, getLoginUserId()); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/audit") |
| | | @Operation(summary = "审æ¹ç»©æèæ ¸æ¹æ¡ï¼éè¿/驳åï¼") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:audit')") |
| | | public CommonResult<Boolean> auditAppraise(@Valid @RequestBody HrmPerformanceAppraiseAuditReqVO auditReqVO) { |
| | | appraiseService.auditAppraise(auditReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approve-process-list") |
| | | @Operation(summary = "è·å¾ç»©æèæ ¸æ¹æ¡å®¡æ¹æµç¨å®ä¹å表") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:query')") |
| | | public CommonResult<List<Map<String, Object>>> getAppraiseApproveProcessDefinitionList() { |
| | | return success(appraiseService.getAppraiseApproveProcessDefinitionList()); |
| | | } |
| | | |
| | | // ========== è¯å/ç»æ ========== |
| | | |
| | | @GetMapping("/result-page") |
| | | @Operation(summary = "è·å¾ç»©æèæ ¸ç»æå页") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:query')") |
| | | public CommonResult<PageResult<HrmPerformanceAppraiseResultRespVO>> getAppraiseResultPage( |
| | | @Valid HrmPerformanceAppraiseResultPageReqVO pageReqVO) { |
| | | PageResult<HrmPerformanceAppraiseResultDO> pageResult = appraiseService.getAppraiseResultPage(pageReqVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | | return success(PageResult.empty(pageResult.getTotal())); |
| | | } |
| | | Map<Long, HrmEmployeeDO> employeeMap = employeeService.getEmployeeList( |
| | | convertSet(pageResult.getList(), HrmPerformanceAppraiseResultDO::getEmployeeId)).stream() |
| | | .collect(Collectors.toMap(HrmEmployeeDO::getId, e -> e, (a, b) -> a)); |
| | | List<HrmPerformanceAppraiseResultRespVO> list = pageResult.getList().stream() |
| | | .map(result -> buildResultRespVO(result, employeeMap.get(result.getEmployeeId()))) |
| | | .collect(Collectors.toList()); |
| | | return success(new PageResult<>(list, pageResult.getTotal())); |
| | | } |
| | | |
| | | @PostMapping("/result-save") |
| | | @Operation(summary = "ä¿ååå·¥èæ ¸ç»æï¼èªå¨è®¡ç®ç»¼åå¾å䏿¡£çº§ï¼") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:update')") |
| | | public CommonResult<Boolean> saveAppraiseResult(@Valid @RequestBody HrmPerformanceAppraiseResultSaveReqVO saveReqVO) { |
| | | appraiseService.saveAppraiseResult(saveReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/result") |
| | | @Operation(summary = "è·å¾åå·¥èæ ¸ç»æï¼å«ææ æç»ï¼") |
| | | @Parameter(name = "appraiseId", description = "æ¹æ¡ç¼å·", required = true, example = "1") |
| | | @Parameter(name = "employeeId", description = "åå·¥ç¼å·", required = true, example = "100") |
| | | @PreAuthorize("@ss.hasPermission('hrm:performance-appraise:query')") |
| | | public CommonResult<HrmPerformanceAppraiseResultRespVO> getAppraiseResult( |
| | | @RequestParam("appraiseId") Long appraiseId, |
| | | @RequestParam("employeeId") Long employeeId) { |
| | | HrmPerformanceAppraiseResultDO result = appraiseService.getAppraiseResult(appraiseId, employeeId); |
| | | if (result == null) { |
| | | return success(null); |
| | | } |
| | | return success(buildResultRespVO(result, employeeService.getEmployee(employeeId))); |
| | | } |
| | | |
| | | // ========== å
鍿¹æ³ï¼æ¼è£
VO ========== |
| | | |
| | | private HrmPerformanceAppraiseRespVO buildAppraiseRespVO(HrmPerformanceAppraiseDO appraise) { |
| | | HrmPerformanceAppraiseRespVO vo = BeanUtils.toBean(appraise, HrmPerformanceAppraiseRespVO.class); |
| | | vo.setStatusName(convertAppraiseStatusName(appraise.getStatus())); |
| | | vo.setAuditStatusName(HrmAuditStatusEnum.getNameByStatus(appraise.getAuditStatus())); |
| | | vo.setItemCount(appraiseService.getAppraiseItemList(appraise.getId()).size()); |
| | | HrmPerformanceAppraiseResultPageReqVO reqVO = new HrmPerformanceAppraiseResultPageReqVO(); |
| | | reqVO.setAppraiseId(appraise.getId()); |
| | | reqVO.setPageSize(1); |
| | | reqVO.setPageNo(1); |
| | | vo.setResultCount(Math.toIntExact(appraiseService.getAppraiseResultPage(reqVO).getTotal())); |
| | | return vo; |
| | | } |
| | | |
| | | private HrmPerformanceAppraiseResultRespVO buildResultRespVO(HrmPerformanceAppraiseResultDO result, HrmEmployeeDO employee) { |
| | | HrmPerformanceAppraiseResultRespVO vo = BeanUtils.toBean(result, HrmPerformanceAppraiseResultRespVO.class); |
| | | if (employee != null) { |
| | | vo.setEmployeeName(employee.getName()); |
| | | } |
| | | List<HrmPerformanceAppraiseResultItemDO> itemDOs = appraiseService.getAppraiseResultItems(result.getId()); |
| | | if (CollUtil.isNotEmpty(itemDOs)) { |
| | | vo.setItems(BeanUtils.toBean(itemDOs, HrmPerformanceAppraiseResultRespVO.Item.class)); |
| | | } |
| | | return vo; |
| | | } |
| | | |
| | | private String convertAppraiseStatusName(Integer status) { |
| | | return switch (status == null ? -1 : status) { |
| | | case 0 -> "è稿"; |
| | | case 10 -> "å·²åå¸"; |
| | | case 20 -> "è¿è¡ä¸"; |
| | | case 30 -> "已宿"; |
| | | default -> ""; |
| | | }; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ å®¡æ¹ Request VO |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸æ¹æ¡ - å®¡æ¹ Request VO") |
| | | @Data |
| | | public class HrmPerformanceAppraiseAuditReqVO { |
| | | |
| | | @Schema(description = "æ¹æ¡ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "æ¹æ¡ç¼å·ä¸è½ä¸ºç©º") |
| | | private Long id; |
| | | |
| | | @Schema(description = "审æ¹ç»æï¼20 éè¿ / 30 驳åï¼", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") |
| | | @NotNull(message = "审æ¹ç»æä¸è½ä¸ºç©º") |
| | | private Integer auditStatus; |
| | | |
| | | @Schema(description = "审æ¹å¤æ³¨", example = "åæåå¸") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo; |
| | | |
| | | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| | | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ææ Response VO |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸ææ Response VO") |
| | | @Data |
| | | public class HrmPerformanceAppraiseItemRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "èæ ¸æ¹æ¡ç¼å·", example = "1") |
| | | private Long appraiseId; |
| | | |
| | | @Schema(description = "ææ åç§°", example = "å·¥ä½ä¸ç»©") |
| | | @ExcelProperty("ææ åç§°") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "æé", example = "30.00") |
| | | @ExcelProperty("æé") |
| | | private BigDecimal weight; |
| | | |
| | | @Schema(description = "è¯åæ å", example = "æå£åº¦ç®æ è¾¾æçè¯å") |
| | | @ExcelProperty("è¯åæ å") |
| | | private String scoringStandard; |
| | | |
| | | @Schema(description = "è¯å人类å", example = "1") |
| | | @ExcelProperty(value = "è¯å人类å", converter = DictConvert.class) |
| | | @DictFormat(cn.iocoder.yudao.module.hrm.enums.DictTypeConstants.HRM_PERFORMANCE_SCORER_TYPE) |
| | | private Integer scorerType; |
| | | |
| | | @Schema(description = "æåº", example = "1") |
| | | private Integer sort; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.Valid; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ææ ä¿å Request VOï¼æ´è¡¨æ¿æ¢ï¼ |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸ææ - ä¿å Request VOï¼æ´è¡¨æ¿æ¢ï¼") |
| | | @Data |
| | | public class HrmPerformanceAppraiseItemSaveReqVO { |
| | | |
| | | @Schema(description = "èæ ¸æ¹æ¡ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "èæ ¸æ¹æ¡ä¸è½ä¸ºç©º") |
| | | private Long appraiseId; |
| | | |
| | | @Schema(description = "èæ ¸ææ å表") |
| | | @Valid |
| | | private List<Item> items; |
| | | |
| | | @Schema(description = "èæ ¸ææ ") |
| | | @Data |
| | | public static class Item { |
| | | |
| | | @Schema(description = "ææ ç¼å·ï¼ä¿®æ¹æ¶å¿
å¡«ï¼", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "ææ åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "å·¥ä½ä¸ç»©") |
| | | @NotNull(message = "ææ åç§°ä¸è½ä¸ºç©º") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "æé", requiredMode = Schema.RequiredMode.REQUIRED, example = "30.00") |
| | | @NotNull(message = "æéä¸è½ä¸ºç©º") |
| | | private BigDecimal weight; |
| | | |
| | | @Schema(description = "è¯åæ å", example = "æå£åº¦ç®æ è¾¾æçè¯å") |
| | | private String scoringStandard; |
| | | |
| | | @Schema(description = "è¯å人类å: 1-èªè¯ 2-ä¸çº§è¯", example = "1") |
| | | private Integer scorerType; |
| | | |
| | | @Schema(description = "æåº", example = "1") |
| | | private Integer sort; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.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; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ å页 Request VO |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸æ¹æ¡ - å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class HrmPerformanceAppraisePageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ¹æ¡åç§°", example = "8æç»©æèæ ¸") |
| | | private String name; |
| | | |
| | | @Schema(description = "èæ ¸å¨æç±»å", example = "1") |
| | | private Integer periodType; |
| | | |
| | | @Schema(description = "æ¹æ¡ç¶æ", example = "0") |
| | | private Integer status; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo; |
| | | |
| | | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| | | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| | | import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ Response VO |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸æ¹æ¡ Response VO") |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | public class HrmPerformanceAppraiseRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | @ExcelProperty("ç¼å·") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¹æ¡åç§°", example = "8æç»©æèæ ¸") |
| | | @ExcelProperty("æ¹æ¡åç§°") |
| | | private String name; |
| | | |
| | | @Schema(description = "èæ ¸å¨æç±»å", example = "1") |
| | | @ExcelProperty(value = "èæ ¸å¨æç±»å", converter = DictConvert.class) |
| | | @DictFormat(cn.iocoder.yudao.module.hrm.enums.DictTypeConstants.HRM_PERFORMANCE_PERIOD_TYPE) |
| | | private Integer periodType; |
| | | |
| | | @Schema(description = "èæ ¸å¨ææè¿°", example = "2026-08") |
| | | @ExcelProperty("èæ ¸å¨æ") |
| | | private String period; |
| | | |
| | | @Schema(description = "èæ ¸èå´ç±»å", example = "1") |
| | | @ExcelProperty(value = "èæ ¸èå´", converter = DictConvert.class) |
| | | @DictFormat(cn.iocoder.yudao.module.hrm.enums.DictTypeConstants.HRM_PERFORMANCE_SCOPE_TYPE) |
| | | private Integer scopeType; |
| | | |
| | | @Schema(description = "æ¹æ¡ç¶æ", example = "0") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "æ¹æ¡ç¶æåç§°", example = "è稿") |
| | | private String statusName; |
| | | |
| | | @Schema(description = "审æ¹ç¶æ", example = "0") |
| | | private Integer auditStatus; |
| | | |
| | | @Schema(description = "审æ¹ç¶æåç§°", example = "è稿") |
| | | private String auditStatusName; |
| | | |
| | | @Schema(description = "å®¡æ¹æµç¨å®ä¾ç¼å·") |
| | | private String processInstanceId; |
| | | |
| | | @Schema(description = "å®¡æ ¸äºº", example = "1") |
| | | private Long auditUserId; |
| | | |
| | | @Schema(description = "å®¡æ ¸æ¶é´") |
| | | private LocalDateTime auditTime; |
| | | |
| | | @Schema(description = "å®¡æ ¸å¤æ³¨") |
| | | private String auditRemark; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | @ExcelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "èæ ¸ææ æ°", example = "5") |
| | | private Integer itemCount; |
| | | |
| | | @Schema(description = "å·²è¯å人æ°", example = "3") |
| | | private Integer resultCount; |
| | | |
| | | @Schema(description = "å建æ¶é´") |
| | | @ExcelProperty("å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.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; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ç»æ å页 Request VO |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸ç»æ - å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class HrmPerformanceAppraiseResultPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "èæ ¸æ¹æ¡ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Long appraiseId; |
| | | |
| | | @Schema(description = "åå·¥ç¼å·", example = "100") |
| | | private Long employeeId; |
| | | |
| | | @Schema(description = "档级", example = "1") |
| | | private Integer grade; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo; |
| | | |
| | | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| | | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ç»æ Response VOï¼æåå·¥èåï¼ |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸ç»æ Response VOï¼æåå·¥èåï¼") |
| | | @Data |
| | | public class HrmPerformanceAppraiseResultRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "èæ ¸æ¹æ¡ç¼å·", example = "1") |
| | | private Long appraiseId; |
| | | |
| | | @Schema(description = "åå·¥ç¼å·", example = "100") |
| | | private Long employeeId; |
| | | |
| | | @Schema(description = "åå·¥åç§°", example = "å¼ ä¸") |
| | | @ExcelProperty("åå·¥") |
| | | private String employeeName; |
| | | |
| | | @Schema(description = "èªè¯æ»å", example = "90.00") |
| | | @ExcelProperty("èªè¯æ»å") |
| | | private BigDecimal selfScore; |
| | | |
| | | @Schema(description = "ä¸çº§è¯æ»å", example = "85.00") |
| | | @ExcelProperty("ä¸çº§è¯æ»å") |
| | | private BigDecimal superiorScore; |
| | | |
| | | @Schema(description = "综åå¾å", example = "87.50") |
| | | @ExcelProperty("综åå¾å") |
| | | private BigDecimal finalScore; |
| | | |
| | | @Schema(description = "档级", example = "2") |
| | | @ExcelProperty(value = "档级", converter = DictConvert.class) |
| | | @DictFormat(cn.iocoder.yudao.module.hrm.enums.DictTypeConstants.HRM_PERFORMANCE_GRADE) |
| | | private Integer grade; |
| | | |
| | | @Schema(description = "è¯è¯") |
| | | @ExcelProperty("è¯è¯") |
| | | private String comment; |
| | | |
| | | @Schema(description = "ææ è¯åæç»") |
| | | private List<Item> items; |
| | | |
| | | @Schema(description = "ææ è¯åæç»é¡¹") |
| | | @Data |
| | | public static class Item { |
| | | |
| | | @Schema(description = "ç»ææç»ç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "èæ ¸ææ ç¼å·", example = "1") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "ææ åç§°", example = "å·¥ä½ä¸ç»©") |
| | | private String itemName; |
| | | |
| | | @Schema(description = "æé", example = "30.00") |
| | | private BigDecimal weight; |
| | | |
| | | @Schema(description = "èªè¯å¾å", example = "90.00") |
| | | private BigDecimal selfScore; |
| | | |
| | | @Schema(description = "ä¸çº§è¯å¾å", example = "85.00") |
| | | private BigDecimal superiorScore; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.Valid; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ç»æ ä¿å Request VOï¼æå工鿿 æåï¼ |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸ç»æ - ä¿å Request VOï¼æå工鿿 æåï¼") |
| | | @Data |
| | | public class HrmPerformanceAppraiseResultSaveReqVO { |
| | | |
| | | @Schema(description = "èæ ¸æ¹æ¡ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "èæ ¸æ¹æ¡ä¸è½ä¸ºç©º") |
| | | private Long appraiseId; |
| | | |
| | | @Schema(description = "åå·¥ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| | | @NotNull(message = "åå·¥ä¸è½ä¸ºç©º") |
| | | private Long employeeId; |
| | | |
| | | @Schema(description = "è¯è¯") |
| | | private String comment; |
| | | |
| | | @Schema(description = "ææ è¯åæç»") |
| | | @Valid |
| | | private List<Item> items; |
| | | |
| | | @Schema(description = "ææ è¯åæç»é¡¹") |
| | | @Data |
| | | public static class Item { |
| | | |
| | | @Schema(description = "èæ ¸ææ ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @NotNull(message = "èæ ¸ææ ä¸è½ä¸ºç©º") |
| | | private Long itemId; |
| | | |
| | | @Schema(description = "èªè¯å¾å", example = "90.00") |
| | | private BigDecimal selfScore; |
| | | |
| | | @Schema(description = "ä¸çº§è¯å¾å", example = "85.00") |
| | | private BigDecimal superiorScore; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ ä¿å Request VO |
| | | */ |
| | | @Schema(description = "HRM 绩æèæ ¸æ¹æ¡ - ä¿å Request VO") |
| | | @Data |
| | | public class HrmPerformanceAppraiseSaveReqVO { |
| | | |
| | | @Schema(description = "ç¼å·ï¼ä¿®æ¹æ¶å¿
å¡«ï¼", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¹æ¡åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "8æç»©æèæ ¸") |
| | | @NotEmpty(message = "æ¹æ¡åç§°ä¸è½ä¸ºç©º") |
| | | private String name; |
| | | |
| | | @Schema(description = "èæ ¸å¨æç±»å: 1-æåº¦ 2-å£åº¦ 3-年度", example = "1") |
| | | private Integer periodType; |
| | | |
| | | @Schema(description = "èæ ¸å¨ææè¿°, å¦ 2026-08", example = "2026-08") |
| | | private String period; |
| | | |
| | | @Schema(description = "èæ ¸èå´ç±»å: 1-å
¨é¨åå·¥ 2-æå®çç»", example = "1") |
| | | private Integer scopeType; |
| | | |
| | | @Schema(description = "夿³¨") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.workhour; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo.HrmEmployeeWorkHourReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo.HrmEmployeeWorkHourRespVO; |
| | | import cn.iocoder.yudao.module.hrm.service.workhour.HrmWorkHourStatisticsService; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryReqDTO; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | 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.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | @Tag(name = "管çåå° - HRM å·¥æ¶ç»è®¡") |
| | | @RestController |
| | | @RequestMapping("/hrm/work-hour-statistics") |
| | | @Validated |
| | | public class HrmWorkHourStatisticsController { |
| | | |
| | | @Resource |
| | | private HrmWorkHourStatisticsService workHourStatisticsService; |
| | | |
| | | @GetMapping("/employee-summary") |
| | | @Operation(summary = "å工工æ¶ç»è®¡ï¼èå¤å£å¾ï¼") |
| | | @PreAuthorize("@ss.hasPermission('hrm:work-hour-statistics:query')") |
| | | public CommonResult<List<HrmEmployeeWorkHourRespVO>> getEmployeeWorkHourSummary( |
| | | HrmEmployeeWorkHourReqVO reqVO) { |
| | | return success(workHourStatisticsService.getEmployeeWorkHourSummary(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/team-summary") |
| | | @Operation(summary = "çç»å·¥æ¶ç»è®¡ï¼æ¥å·¥å£å¾ï¼") |
| | | @PreAuthorize("@ss.hasPermission('hrm:work-hour-statistics:query')") |
| | | public CommonResult<List<MesProWorkHourSummaryRespDTO>> getTeamWorkHourSummary( |
| | | MesProWorkHourSummaryReqDTO reqDTO) { |
| | | return success(workHourStatisticsService.getTeamWorkHourSummary(reqDTO)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Schema(description = "管çåå° - å工工æ¶ç»è®¡ Request VO") |
| | | @Data |
| | | public class HrmEmployeeWorkHourReqVO { |
| | | |
| | | @Schema(description = "åå·¥ç¼å·") |
| | | private Long userId; |
| | | |
| | | @Schema(description = "é¨é¨ç¼å·") |
| | | private Long deptId; |
| | | |
| | | @Schema(description = "å¼å§æ¥æ") |
| | | private LocalDate startDate; |
| | | |
| | | @Schema(description = "ç»ææ¥æ") |
| | | private LocalDate endDate; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Schema(description = "管çåå° - å工工æ¶ç»è®¡ Response VO") |
| | | @Data |
| | | public class HrmEmployeeWorkHourRespVO { |
| | | |
| | | @Schema(description = "åå·¥ç¼å·") |
| | | private Long userId; |
| | | |
| | | @Schema(description = "åå·¥å§å") |
| | | private String userName; |
| | | |
| | | @Schema(description = "é¨é¨ç¼å·") |
| | | private Long deptId; |
| | | |
| | | @Schema(description = "é¨é¨åç§°") |
| | | private String deptName; |
| | | |
| | | @Schema(description = "åºå¤å¤©æ°") |
| | | private Integer workDays; |
| | | |
| | | @Schema(description = "æ£å¸¸å·¥æ¶ï¼äººæ¶ï¼") |
| | | private BigDecimal workHours; |
| | | |
| | | @Schema(description = "å çå·¥æ¶ï¼äººæ¶ï¼") |
| | | private BigDecimal overtimeHours; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmAuditStatusEnum; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ DO |
| | | * |
| | | * å¯¹åº xlsx 人å 1ã绩æèæ ¸å
¨æµç¨ä¸å¡ã |
| | | */ |
| | | @TableName("hrm_performance_appraise") |
| | | @KeySequence("hrm_performance_appraise_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class HrmPerformanceAppraiseDO extends BaseDO { |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * æ¹æ¡åç§° |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * èæ ¸å¨æç±»å: 1-æåº¦ 2-å£åº¦ 3-年度 |
| | | */ |
| | | private Integer periodType; |
| | | |
| | | /** |
| | | * èæ ¸å¨ææè¿°, å¦ 2026-08 / 2026-Q3 |
| | | */ |
| | | private String period; |
| | | |
| | | /** |
| | | * èæ ¸èå´ç±»å: 1-å
¨é¨åå·¥ 2-æå®çç» |
| | | */ |
| | | private Integer scopeType; |
| | | |
| | | /** |
| | | * æ¹æ¡ç¶æ: 0-è稿 10-å·²åå¸ 20-è¿è¡ä¸ 30-已宿 |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 审æ¹ç¶æ |
| | | * |
| | | * æä¸¾ {@link HrmAuditStatusEnum} |
| | | */ |
| | | private Integer auditStatus; |
| | | |
| | | /** |
| | | * å®¡æ¹æµç¨å®ä¾ç¼å· |
| | | */ |
| | | private String processInstanceId; |
| | | |
| | | /** |
| | | * å®¡æ ¸äºº |
| | | */ |
| | | private Long auditUserId; |
| | | |
| | | /** |
| | | * å®¡æ ¸æ¶é´ |
| | | */ |
| | | private LocalDateTime auditTime; |
| | | |
| | | /** |
| | | * å®¡æ ¸å¤æ³¨ |
| | | */ |
| | | private String auditRemark; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ææ DO |
| | | */ |
| | | @TableName("hrm_performance_appraise_item") |
| | | @KeySequence("hrm_performance_appraise_item_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class HrmPerformanceAppraiseItemDO extends BaseDO { |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * èæ ¸æ¹æ¡ç¼å· |
| | | */ |
| | | private Long appraiseId; |
| | | |
| | | /** |
| | | * ææ åç§° |
| | | */ |
| | | private String itemName; |
| | | |
| | | /** |
| | | * æé |
| | | */ |
| | | private BigDecimal weight; |
| | | |
| | | /** |
| | | * è¯åæ å |
| | | */ |
| | | private String scoringStandard; |
| | | |
| | | /** |
| | | * è¯å人类å: 1-èªè¯ 2-ä¸çº§è¯ |
| | | */ |
| | | private Integer scorerType; |
| | | |
| | | /** |
| | | * æåº |
| | | */ |
| | | private Integer sort; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ç»æ DOï¼æåå·¥æ±æ»ï¼ |
| | | */ |
| | | @TableName("hrm_performance_appraise_result") |
| | | @KeySequence("hrm_performance_appraise_result_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class HrmPerformanceAppraiseResultDO extends BaseDO { |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * èæ ¸æ¹æ¡ç¼å· |
| | | */ |
| | | private Long appraiseId; |
| | | |
| | | /** |
| | | * åå·¥ç¼å· |
| | | */ |
| | | private Long employeeId; |
| | | |
| | | /** |
| | | * èªè¯æ»å |
| | | */ |
| | | private BigDecimal selfScore; |
| | | |
| | | /** |
| | | * ä¸çº§è¯æ»å |
| | | */ |
| | | private BigDecimal superiorScore; |
| | | |
| | | /** |
| | | * 综åå¾å |
| | | */ |
| | | private BigDecimal finalScore; |
| | | |
| | | /** |
| | | * 档级: 1-ä¼ç§ 2-è¯å¥½ 3-åæ ¼ 4-å¾
æ¹è¿ |
| | | */ |
| | | private Integer grade; |
| | | |
| | | /** |
| | | * è¯è¯ |
| | | */ |
| | | private String comment; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ç»ææç» DOï¼æåå·¥Ãææ ï¼ |
| | | */ |
| | | @TableName("hrm_performance_appraise_result_item") |
| | | @KeySequence("hrm_performance_appraise_result_item_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class HrmPerformanceAppraiseResultItemDO extends BaseDO { |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * èæ ¸ç»æç¼å·ï¼å
³è hrm_performance_appraise_result.id |
| | | */ |
| | | private Long resultId; |
| | | |
| | | /** |
| | | * èæ ¸ææ ç¼å·ï¼å
³è hrm_performance_appraise_item.id |
| | | */ |
| | | private Long itemId; |
| | | |
| | | /** |
| | | * ææ åç§°ï¼åä½ï¼ |
| | | */ |
| | | private String itemName; |
| | | |
| | | /** |
| | | * æéï¼åä½ï¼ |
| | | */ |
| | | private BigDecimal weight; |
| | | |
| | | /** |
| | | * èªè¯å¾å |
| | | */ |
| | | private BigDecimal selfScore; |
| | | |
| | | /** |
| | | * ä¸çº§è¯å¾å |
| | | */ |
| | | private BigDecimal superiorScore; |
| | | |
| | | } |
| | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.attendance.vo.HrmAttendanceRecordPageReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo.HrmEmployeeWorkHourReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.attendance.HrmAttendanceRecordDO; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * è夿å¡è®°å½ Mapper |
| | |
| | | .orderByDesc(HrmAttendanceRecordDO::getDate)); |
| | | } |
| | | |
| | | /** |
| | | * å工工æ¶ç»è®¡ï¼èå¤å£å¾ï¼ï¼æåå·¥èååºå¤å¤©æ°ãæ£å¸¸å·¥æ¶ä¸å çå·¥æ¶ |
| | | */ |
| | | default List<Map<String, Object>> selectWorkHourSummary(HrmEmployeeWorkHourReqVO reqVO) { |
| | | return selectMaps(new QueryWrapper<HrmAttendanceRecordDO>() |
| | | .select("user_id", |
| | | "COUNT(*) AS work_days", |
| | | "SUM(IFNULL(work_hours, 0)) AS work_hours", |
| | | "SUM(IFNULL(overtime_hours, 0)) AS overtime_hours") |
| | | .eq(reqVO.getUserId() != null, "user_id", reqVO.getUserId()) |
| | | .eq(reqVO.getDeptId() != null, "dept_id", reqVO.getDeptId()) |
| | | .ge(reqVO.getStartDate() != null, "date", reqVO.getStartDate()) |
| | | .le(reqVO.getEndDate() != null, "date", reqVO.getEndDate()) |
| | | .groupBy("user_id")); |
| | | } |
| | | |
| | | default HrmAttendanceRecordDO selectByUserIdAndDate(Long userId, LocalDate date) { |
| | | return selectOne(new LambdaQueryWrapperX<HrmAttendanceRecordDO>() |
| | | .eq(HrmAttendanceRecordDO::getUserId, userId) |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.mysql.performanceappraise; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseItemDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ææ Mapper |
| | | */ |
| | | @Mapper |
| | | public interface HrmPerformanceAppraiseItemMapper extends BaseMapperX<HrmPerformanceAppraiseItemDO> { |
| | | |
| | | default List<HrmPerformanceAppraiseItemDO> selectListByAppraiseId(Long appraiseId) { |
| | | return selectList(new LambdaQueryWrapperX<HrmPerformanceAppraiseItemDO>() |
| | | .eq(HrmPerformanceAppraiseItemDO::getAppraiseId, appraiseId) |
| | | .orderByAsc(HrmPerformanceAppraiseItemDO::getSort) |
| | | .orderByAsc(HrmPerformanceAppraiseItemDO::getId)); |
| | | } |
| | | |
| | | default void deleteByAppraiseId(Long appraiseId) { |
| | | delete(new LambdaQueryWrapperX<HrmPerformanceAppraiseItemDO>() |
| | | .eq(HrmPerformanceAppraiseItemDO::getAppraiseId, appraiseId)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.mysql.performanceappraise; |
| | | |
| | | 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.hrm.controller.admin.performanceappraise.vo.HrmPerformanceAppraisePageReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ Mapper |
| | | */ |
| | | @Mapper |
| | | public interface HrmPerformanceAppraiseMapper extends BaseMapperX<HrmPerformanceAppraiseDO> { |
| | | |
| | | default PageResult<HrmPerformanceAppraiseDO> selectPage(HrmPerformanceAppraisePageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<HrmPerformanceAppraiseDO>() |
| | | .likeIfPresent(HrmPerformanceAppraiseDO::getName, reqVO.getName()) |
| | | .eqIfPresent(HrmPerformanceAppraiseDO::getPeriodType, reqVO.getPeriodType()) |
| | | .eqIfPresent(HrmPerformanceAppraiseDO::getStatus, reqVO.getStatus()) |
| | | .orderByDesc(HrmPerformanceAppraiseDO::getId)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.mysql.performanceappraise; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseResultItemDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ç»ææç» Mapper |
| | | */ |
| | | @Mapper |
| | | public interface HrmPerformanceAppraiseResultItemMapper extends BaseMapperX<HrmPerformanceAppraiseResultItemDO> { |
| | | |
| | | default List<HrmPerformanceAppraiseResultItemDO> selectListByResultId(Long resultId) { |
| | | return selectList(new LambdaQueryWrapperX<HrmPerformanceAppraiseResultItemDO>() |
| | | .eq(HrmPerformanceAppraiseResultItemDO::getResultId, resultId) |
| | | .orderByAsc(HrmPerformanceAppraiseResultItemDO::getId)); |
| | | } |
| | | |
| | | default void deleteByResultId(Long resultId) { |
| | | delete(new LambdaQueryWrapperX<HrmPerformanceAppraiseResultItemDO>() |
| | | .eq(HrmPerformanceAppraiseResultItemDO::getResultId, resultId)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.dal.mysql.performanceappraise; |
| | | |
| | | 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.hrm.controller.admin.performanceappraise.vo.HrmPerformanceAppraiseResultPageReqVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseResultDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸ç»æ Mapper |
| | | */ |
| | | @Mapper |
| | | public interface HrmPerformanceAppraiseResultMapper extends BaseMapperX<HrmPerformanceAppraiseResultDO> { |
| | | |
| | | default HrmPerformanceAppraiseResultDO selectByAppraiseIdAndEmployeeId(Long appraiseId, Long employeeId) { |
| | | return selectOne(new LambdaQueryWrapperX<HrmPerformanceAppraiseResultDO>() |
| | | .eq(HrmPerformanceAppraiseResultDO::getAppraiseId, appraiseId) |
| | | .eq(HrmPerformanceAppraiseResultDO::getEmployeeId, employeeId)); |
| | | } |
| | | |
| | | default PageResult<HrmPerformanceAppraiseResultDO> selectPage(HrmPerformanceAppraiseResultPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<HrmPerformanceAppraiseResultDO>() |
| | | .eqIfPresent(HrmPerformanceAppraiseResultDO::getAppraiseId, reqVO.getAppraiseId()) |
| | | .eqIfPresent(HrmPerformanceAppraiseResultDO::getEmployeeId, reqVO.getEmployeeId()) |
| | | .eqIfPresent(HrmPerformanceAppraiseResultDO::getGrade, reqVO.getGrade()) |
| | | .orderByAsc(HrmPerformanceAppraiseResultDO::getEmployeeId)); |
| | | } |
| | | |
| | | default void deleteByAppraiseId(Long appraiseId) { |
| | | delete(new LambdaQueryWrapperX<HrmPerformanceAppraiseResultDO>() |
| | | .eq(HrmPerformanceAppraiseResultDO::getAppraiseId, appraiseId)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.enums; |
| | | |
| | | /** |
| | | * HRM 模ååå
¸ç±»å |
| | | */ |
| | | public interface DictTypeConstants { |
| | | |
| | | String HRM_PERFORMANCE_PERIOD_TYPE = "hrm_performance_period_type"; |
| | | |
| | | String HRM_PERFORMANCE_SCOPE_TYPE = "hrm_performance_scope_type"; |
| | | |
| | | String HRM_PERFORMANCE_SCORER_TYPE = "hrm_performance_scorer_type"; |
| | | |
| | | String HRM_PERFORMANCE_GRADE = "hrm_performance_grade"; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.service.performanceappraise; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo.*; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseItemDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseResultDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseResultItemDO; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ Service æ¥å£ |
| | | */ |
| | | public interface HrmPerformanceAppraiseService { |
| | | |
| | | Long createAppraise(HrmPerformanceAppraiseSaveReqVO createReqVO); |
| | | |
| | | void updateAppraise(HrmPerformanceAppraiseSaveReqVO updateReqVO); |
| | | |
| | | void deleteAppraise(Collection<Long> ids); |
| | | |
| | | HrmPerformanceAppraiseDO getAppraise(Long id); |
| | | |
| | | PageResult<HrmPerformanceAppraiseDO> getAppraisePage(HrmPerformanceAppraisePageReqVO pageReqVO); |
| | | |
| | | /** |
| | | * è·å¾èæ ¸ææ å表 |
| | | */ |
| | | List<HrmPerformanceAppraiseItemDO> getAppraiseItemList(Long appraiseId); |
| | | |
| | | /** |
| | | * ä¿åèæ ¸ææ ï¼æ´è¡¨æ¿æ¢ï¼ |
| | | */ |
| | | void saveAppraiseItems(HrmPerformanceAppraiseItemSaveReqVO saveReqVO); |
| | | |
| | | /** |
| | | * æäº¤ç»©æèæ ¸æ¹æ¡å®¡æ¹ |
| | | */ |
| | | void submitAppraise(Long id, String processDefinitionKey, Long userId); |
| | | |
| | | /** |
| | | * 审æ¹ç»©æèæ ¸æ¹æ¡ï¼éè¿/驳åï¼manualï¼ |
| | | */ |
| | | void auditAppraise(HrmPerformanceAppraiseAuditReqVO auditReqVO); |
| | | |
| | | /** |
| | | * æ´æ°ç»©æèæ ¸æ¹æ¡å®¡æ¹ç¶æï¼BPM çå¬åè°ï¼ |
| | | */ |
| | | void updateAppraiseAuditStatus(Long id, Integer bpmResult); |
| | | |
| | | /** |
| | | * è·å¾ç»©æèæ ¸æ¹æ¡å®¡æ¹æµç¨å®ä¹å表 |
| | | */ |
| | | List<Map<String, Object>> getAppraiseApproveProcessDefinitionList(); |
| | | |
| | | /** |
| | | * ä¿ååå·¥èæ ¸ç»æï¼æå工鿿 æåï¼èªå¨è®¡ç®ç»¼åå¾å䏿¡£çº§ï¼ |
| | | */ |
| | | void saveAppraiseResult(HrmPerformanceAppraiseResultSaveReqVO saveReqVO); |
| | | |
| | | /** |
| | | * è·å¾èæ ¸ç»æå页 |
| | | */ |
| | | PageResult<HrmPerformanceAppraiseResultDO> getAppraiseResultPage(HrmPerformanceAppraiseResultPageReqVO pageReqVO); |
| | | |
| | | /** |
| | | * è·å¾èæ ¸ç»æï¼æåå·¥èåï¼å«ææ æç»ï¼ |
| | | */ |
| | | HrmPerformanceAppraiseResultDO getAppraiseResult(Long appraiseId, Long employeeId); |
| | | |
| | | /** |
| | | * è·å¾èæ ¸ç»æææ æç» |
| | | */ |
| | | List<HrmPerformanceAppraiseResultItemDO> getAppraiseResultItems(Long resultId); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.service.performanceappraise; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| | | import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; |
| | | import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; |
| | | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; |
| | | import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; |
| | | import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.performanceappraise.vo.*; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.*; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.performanceappraise.*; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| | | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | import static cn.iocoder.yudao.module.hrm.util.HrmAuditStatusUtils.convertBpmResultToAuditStatus; |
| | | |
| | | /** |
| | | * HRM 绩æèæ ¸æ¹æ¡ Service å®ç°ç±» |
| | | */ |
| | | @Service |
| | | @Validated |
| | | @Slf4j |
| | | public class HrmPerformanceAppraiseServiceImpl implements HrmPerformanceAppraiseService { |
| | | |
| | | /** |
| | | * æ¹æ¡ç¶æï¼0 è稿 / 10 å·²åå¸ / 20 è¿è¡ä¸ / 30 已宿 |
| | | */ |
| | | private static final Integer STATUS_DRAFT = 0; |
| | | private static final Integer STATUS_PUBLISHED = 10; |
| | | private static final Integer STATUS_PROCESSING = 20; |
| | | |
| | | /** |
| | | * 档级ï¼1 ä¼ç§(â¥90) / 2 è¯å¥½(â¥80) / 3 åæ ¼(â¥60) / 4 å¾
æ¹è¿(<60) |
| | | */ |
| | | private static final BigDecimal GRADE_EXCELLENT = new BigDecimal("90"); |
| | | private static final BigDecimal GRADE_GOOD = new BigDecimal("80"); |
| | | private static final BigDecimal GRADE_PASS = new BigDecimal("60"); |
| | | private static final Integer GRADE_EXCELLENT_CODE = 1; |
| | | private static final Integer GRADE_GOOD_CODE = 2; |
| | | private static final Integer GRADE_PASS_CODE = 3; |
| | | private static final Integer GRADE_IMPROVE_CODE = 4; |
| | | |
| | | /** |
| | | * è¯å人类åï¼1 èªè¯ / 2 ä¸çº§è¯ |
| | | */ |
| | | private static final Integer SCORER_SELF = 1; |
| | | private static final Integer SCORER_SUPERIOR = 2; |
| | | |
| | | /** |
| | | * BPM 绩æèæ ¸å®¡æ¹åç±»ç¼ç |
| | | */ |
| | | private static final String APPRAISE_APPROVE_CATEGORY_CODE = "performance_appraise_approve"; |
| | | |
| | | @Resource |
| | | private HrmPerformanceAppraiseMapper appraiseMapper; |
| | | @Resource |
| | | private HrmPerformanceAppraiseItemMapper itemMapper; |
| | | @Resource |
| | | private HrmPerformanceAppraiseResultMapper resultMapper; |
| | | @Resource |
| | | private HrmPerformanceAppraiseResultItemMapper resultItemMapper; |
| | | @Resource |
| | | private BpmProcessInstanceApi bpmProcessInstanceApi; |
| | | @Resource |
| | | private BpmCategoryService bpmCategoryService; |
| | | @Resource |
| | | private BpmProcessDefinitionService bpmProcessDefinitionService; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createAppraise(HrmPerformanceAppraiseSaveReqVO createReqVO) { |
| | | HrmPerformanceAppraiseDO appraise = BeanUtils.toBean(createReqVO, HrmPerformanceAppraiseDO.class, req -> req |
| | | .setStatus(STATUS_DRAFT) |
| | | .setAuditStatus(HrmAuditStatusEnum.DRAFT.getStatus())); |
| | | appraiseMapper.insert(appraise); |
| | | return appraise.getId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateAppraise(HrmPerformanceAppraiseSaveReqVO updateReqVO) { |
| | | HrmPerformanceAppraiseDO oldAppraise = validateAppraiseCanModify(updateReqVO.getId()); |
| | | HrmPerformanceAppraiseDO updateObj = BeanUtils.toBean(updateReqVO, HrmPerformanceAppraiseDO.class, req -> req |
| | | .setStatus(oldAppraise.getStatus()) |
| | | .setAuditStatus(oldAppraise.getAuditStatus()) |
| | | .setProcessInstanceId(oldAppraise.getProcessInstanceId())); |
| | | appraiseMapper.updateById(updateObj); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteAppraise(Collection<Long> ids) { |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | for (Long id : ids) { |
| | | validateAppraiseCanModify(id); |
| | | // å 餿æ ä¸ç»æ |
| | | itemMapper.deleteByAppraiseId(id); |
| | | List<HrmPerformanceAppraiseResultDO> results = resultMapper.selectList( |
| | | new LambdaQueryWrapperX<HrmPerformanceAppraiseResultDO>() |
| | | .eq(HrmPerformanceAppraiseResultDO::getAppraiseId, id)); |
| | | for (HrmPerformanceAppraiseResultDO result : results) { |
| | | resultItemMapper.deleteByResultId(result.getId()); |
| | | } |
| | | resultMapper.deleteByAppraiseId(id); |
| | | appraiseMapper.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public HrmPerformanceAppraiseDO getAppraise(Long id) { |
| | | return appraiseMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<HrmPerformanceAppraiseDO> getAppraisePage(HrmPerformanceAppraisePageReqVO pageReqVO) { |
| | | return appraiseMapper.selectPage(pageReqVO); |
| | | } |
| | | |
| | | @Override |
| | | public List<HrmPerformanceAppraiseItemDO> getAppraiseItemList(Long appraiseId) { |
| | | return itemMapper.selectListByAppraiseId(appraiseId); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveAppraiseItems(HrmPerformanceAppraiseItemSaveReqVO saveReqVO) { |
| | | HrmPerformanceAppraiseDO appraise = validateAppraiseCanModify(saveReqVO.getAppraiseId()); |
| | | // æ´è¡¨æ¿æ¢ |
| | | itemMapper.deleteByAppraiseId(appraise.getId()); |
| | | if (CollUtil.isEmpty(saveReqVO.getItems())) { |
| | | return; |
| | | } |
| | | int sort = 0; |
| | | for (HrmPerformanceAppraiseItemSaveReqVO.Item item : saveReqVO.getItems()) { |
| | | Integer itemSort = item.getSort() != null ? item.getSort() : sort++; |
| | | HrmPerformanceAppraiseItemDO itemDO = BeanUtils.toBean(item, HrmPerformanceAppraiseItemDO.class, req -> req |
| | | .setAppraiseId(appraise.getId()) |
| | | .setSort(itemSort)); |
| | | itemMapper.insert(itemDO); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void submitAppraise(Long id, String processDefinitionKey, Long userId) { |
| | | // 1. æ ¡éªæ¹æ¡æ¯å¦å¨èç¨¿ç¶æ |
| | | HrmPerformanceAppraiseDO appraise = appraiseMapper.selectById(id); |
| | | if (appraise == null) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_NOT_EXISTS); |
| | | } |
| | | if (ObjUtil.notEqual(appraise.getAuditStatus(), HrmAuditStatusEnum.DRAFT.getStatus())) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_SUBMIT_FAIL_NOT_DRAFT); |
| | | } |
| | | if (CollUtil.isEmpty(itemMapper.selectListByAppraiseId(id))) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_ITEM_EMPTY); |
| | | } |
| | | |
| | | // 2. æ ¡éªå®¡æ¹åç±»åæµç¨å®ä¹æ¯å¦åå¨ï¼ä¸ä¼ å
¥çæµç¨å®ä¹å¤äºæ¿æ´»ç¶æ |
| | | validateAppraiseApproveCategoryAndProcessDefinition(); |
| | | ProcessDefinition processDefinition = bpmProcessDefinitionService.getActiveProcessDefinition(processDefinitionKey); |
| | | if (processDefinition == null) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | |
| | | // 3. åå»ºå®¡æ¹æµç¨å®ä¾ |
| | | String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, |
| | | new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(processDefinitionKey) |
| | | .setBusinessKey(String.valueOf(id))); |
| | | |
| | | // 4. æ´æ°æ¹æ¡æµç¨ç¼å·ä¸å®¡æ¹ç¶æ |
| | | appraiseMapper.updateById(new HrmPerformanceAppraiseDO().setId(id).setProcessInstanceId(processInstanceId) |
| | | .setAuditStatus(HrmAuditStatusEnum.PROCESS.getStatus())); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void auditAppraise(HrmPerformanceAppraiseAuditReqVO auditReqVO) { |
| | | HrmPerformanceAppraiseDO appraise = validateAppraiseExists(auditReqVO.getId()); |
| | | if (ObjUtil.notEqual(appraise.getAuditStatus(), HrmAuditStatusEnum.PROCESS.getStatus())) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); |
| | | } |
| | | Integer auditStatus = auditReqVO.getAuditStatus(); |
| | | if (!Objects.equals(auditStatus, HrmAuditStatusEnum.APPROVE.getStatus()) |
| | | && !Objects.equals(auditStatus, HrmAuditStatusEnum.REJECT.getStatus())) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); |
| | | } |
| | | HrmPerformanceAppraiseDO update = new HrmPerformanceAppraiseDO() |
| | | .setId(appraise.getId()) |
| | | .setAuditStatus(auditStatus) |
| | | .setAuditUserId(getLoginUserId()) |
| | | .setAuditTime(LocalDateTime.now()); |
| | | if (auditReqVO.getRemark() != null) { |
| | | update.setAuditRemark(auditReqVO.getRemark()); |
| | | } |
| | | // 审æ¹éè¿ -> æ¹æ¡åå¸ |
| | | if (Objects.equals(auditStatus, HrmAuditStatusEnum.APPROVE.getStatus())) { |
| | | update.setStatus(STATUS_PUBLISHED); |
| | | } |
| | | appraiseMapper.updateById(update); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateAppraiseAuditStatus(Long id, Integer bpmResult) { |
| | | // 1.1 æ ¡éªæ¹æ¡æ¯å¦åå¨ |
| | | HrmPerformanceAppraiseDO appraise = appraiseMapper.selectById(id); |
| | | if (appraise == null) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_NOT_EXISTS); |
| | | } |
| | | // 1.2 åªæå®¡æ¹ä¸ï¼å¯ä»¥æ´æ°å®¡æ¹ç»æ |
| | | if (ObjUtil.notEqual(appraise.getAuditStatus(), HrmAuditStatusEnum.PROCESS.getStatus())) { |
| | | log.error("[updateAppraiseAuditStatus][appraise({}) ä¸å¤äºå®¡æ¹ä¸ï¼æ æ³æ´æ°å®¡æ¹ç»æ({})]", appraise.getId(), bpmResult); |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_UPDATE_AUDIT_STATUS_FAIL_NOT_PROCESS); |
| | | } |
| | | |
| | | // 2. æ´æ°æ¹æ¡å®¡æ¹ç»æ |
| | | Integer auditStatus = convertBpmResultToAuditStatus(bpmResult); |
| | | HrmPerformanceAppraiseDO update = new HrmPerformanceAppraiseDO().setId(id).setAuditStatus(auditStatus); |
| | | if (Objects.equals(auditStatus, HrmAuditStatusEnum.APPROVE.getStatus())) { |
| | | update.setStatus(STATUS_PUBLISHED); |
| | | } |
| | | appraiseMapper.updateById(update); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getAppraiseApproveProcessDefinitionList() { |
| | | // 1. æ ¡éªå®¡æ¹åç±»åæµç¨å®ä¹æ¯å¦åå¨ |
| | | validateAppraiseApproveCategoryAndProcessDefinition(); |
| | | |
| | | // 2. è·ååç±»ä¸çæµç¨å®ä¹ä¿¡æ¯ |
| | | List<BpmProcessDefinitionInfoDO> definitionInfoList = bpmProcessDefinitionService |
| | | .getProcessDefinitionInfoListByCategory(APPRAISE_APPROVE_CATEGORY_CODE); |
| | | |
| | | // 3. è·åæµç¨å®ä¹è¯¦æ
|
| | | Set<String> processDefinitionIds = convertSet(definitionInfoList, BpmProcessDefinitionInfoDO::getProcessDefinitionId); |
| | | List<ProcessDefinition> processDefinitions = bpmProcessDefinitionService.getProcessDefinitionList(processDefinitionIds); |
| | | |
| | | // 4. è¿æ»¤ï¼åªä¿çæ¿æ´»ç¶æï¼ä¸ç¸å key åªä¿çææ°çæ¬ |
| | | Map<String, ProcessDefinition> latestVersionMap = new HashMap<>(); |
| | | for (ProcessDefinition pd : processDefinitions) { |
| | | if (pd.isSuspended()) { |
| | | continue; |
| | | } |
| | | ProcessDefinition existing = latestVersionMap.get(pd.getKey()); |
| | | if (existing == null || pd.getVersion() > existing.getVersion()) { |
| | | latestVersionMap.put(pd.getKey(), pd); |
| | | } |
| | | } |
| | | |
| | | // 5. è¿åæµç¨å®ä¹å表 |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (ProcessDefinition pd : latestVersionMap.values()) { |
| | | Map<String, Object> item = new HashMap<>(); |
| | | item.put("id", pd.getId()); |
| | | item.put("key", pd.getKey()); |
| | | item.put("name", pd.getName()); |
| | | item.put("version", pd.getVersion()); |
| | | result.add(item); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveAppraiseResult(HrmPerformanceAppraiseResultSaveReqVO saveReqVO) { |
| | | // 1. æ ¡éªæ¹æ¡ç¶æå
许è¯å |
| | | HrmPerformanceAppraiseDO appraise = appraiseMapper.selectById(saveReqVO.getAppraiseId()); |
| | | if (appraise == null) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_NOT_EXISTS); |
| | | } |
| | | if (!Objects.equals(appraise.getStatus(), STATUS_PUBLISHED) |
| | | && !Objects.equals(appraise.getStatus(), STATUS_PROCESSING)) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_SCORE_FAIL_STATUS); |
| | | } |
| | | |
| | | // 2. å è½½ææ éåï¼æ ¡éªææ è¯åæ¯å¦å®æ´ |
| | | List<HrmPerformanceAppraiseItemDO> items = itemMapper.selectListByAppraiseId(appraise.getId()); |
| | | if (CollUtil.isEmpty(items)) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_ITEM_EMPTY); |
| | | } |
| | | Map<Long, HrmPerformanceAppraiseItemDO> itemMap = convertMap(items, HrmPerformanceAppraiseItemDO::getId); |
| | | if (CollUtil.isEmpty(saveReqVO.getItems()) || saveReqVO.getItems().size() != items.size()) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_RESULT_ITEM_NOT_EXISTS); |
| | | } |
| | | for (HrmPerformanceAppraiseResultSaveReqVO.Item score : saveReqVO.getItems()) { |
| | | if (!itemMap.containsKey(score.getItemId())) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_RESULT_ITEM_NOT_EXISTS); |
| | | } |
| | | } |
| | | |
| | | // 3. æåå·¥ upsert ç»æ |
| | | Long resultId; |
| | | HrmPerformanceAppraiseResultDO oldResult = resultMapper.selectByAppraiseIdAndEmployeeId(appraise.getId(), saveReqVO.getEmployeeId()); |
| | | if (oldResult != null) { |
| | | resultId = oldResult.getId(); |
| | | } else { |
| | | HrmPerformanceAppraiseResultDO newResult = new HrmPerformanceAppraiseResultDO() |
| | | .setAppraiseId(appraise.getId()) |
| | | .setEmployeeId(saveReqVO.getEmployeeId()); |
| | | resultMapper.insert(newResult); |
| | | resultId = newResult.getId(); |
| | | } |
| | | resultItemMapper.deleteByResultId(resultId); |
| | | |
| | | // 4. 计ç®åææ å¾åãæ»å䏿¡£çº§ |
| | | BigDecimal sumWeight = BigDecimal.ZERO; |
| | | BigDecimal weightedFinal = BigDecimal.ZERO; |
| | | BigDecimal weightedSelf = BigDecimal.ZERO; |
| | | BigDecimal weightedSuperior = BigDecimal.ZERO; |
| | | for (HrmPerformanceAppraiseResultSaveReqVO.Item score : saveReqVO.getItems()) { |
| | | HrmPerformanceAppraiseItemDO item = itemMap.get(score.getItemId()); |
| | | BigDecimal weight = item.getWeight() == null ? BigDecimal.ONE : item.getWeight(); |
| | | BigDecimal selfScore = score.getSelfScore() == null ? BigDecimal.ZERO : score.getSelfScore(); |
| | | BigDecimal superiorScore = score.getSuperiorScore() == null ? BigDecimal.ZERO : score.getSuperiorScore(); |
| | | // åææ åï¼1 èªè¯ / 2 ä¸çº§è¯ / å
¶ä» 两è
å¹³å |
| | | BigDecimal itemScore; |
| | | if (Objects.equals(item.getScorerType(), SCORER_SELF)) { |
| | | itemScore = selfScore; |
| | | } else if (Objects.equals(item.getScorerType(), SCORER_SUPERIOR)) { |
| | | itemScore = superiorScore; |
| | | } else { |
| | | itemScore = selfScore.add(superiorScore).divide(BigDecimal.valueOf(2), 2, RoundingMode.HALF_UP); |
| | | } |
| | | sumWeight = sumWeight.add(weight); |
| | | weightedFinal = weightedFinal.add(weight.multiply(itemScore)); |
| | | weightedSelf = weightedSelf.add(weight.multiply(selfScore)); |
| | | weightedSuperior = weightedSuperior.add(weight.multiply(superiorScore)); |
| | | |
| | | // ä¿åæç» |
| | | resultItemMapper.insert(new HrmPerformanceAppraiseResultItemDO() |
| | | .setResultId(resultId) |
| | | .setItemId(item.getId()) |
| | | .setItemName(item.getItemName()) |
| | | .setWeight(weight) |
| | | .setSelfScore(selfScore) |
| | | .setSuperiorScore(superiorScore)); |
| | | } |
| | | BigDecimal selfTotal = weightedSelf.divide(sumWeight, 1, RoundingMode.HALF_UP); |
| | | BigDecimal superiorTotal = weightedSuperior.divide(sumWeight, 1, RoundingMode.HALF_UP); |
| | | BigDecimal finalScore = weightedFinal.divide(sumWeight, 1, RoundingMode.HALF_UP); |
| | | |
| | | // 5. æ´æ°ç»æ |
| | | resultMapper.updateById(new HrmPerformanceAppraiseResultDO() |
| | | .setId(resultId) |
| | | .setSelfScore(selfTotal) |
| | | .setSuperiorScore(superiorTotal) |
| | | .setFinalScore(finalScore) |
| | | .setGrade(calcGrade(finalScore)) |
| | | .setComment(saveReqVO.getComment())); |
| | | |
| | | // 6. æ¹æ¡ç¶ææµè½¬ï¼å·²åå¸ -> è¿è¡ä¸ |
| | | if (Objects.equals(appraise.getStatus(), STATUS_PUBLISHED)) { |
| | | appraiseMapper.updateById(new HrmPerformanceAppraiseDO().setId(appraise.getId()).setStatus(STATUS_PROCESSING)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<HrmPerformanceAppraiseResultDO> getAppraiseResultPage(HrmPerformanceAppraiseResultPageReqVO pageReqVO) { |
| | | return resultMapper.selectPage(pageReqVO); |
| | | } |
| | | |
| | | @Override |
| | | public HrmPerformanceAppraiseResultDO getAppraiseResult(Long appraiseId, Long employeeId) { |
| | | return resultMapper.selectByAppraiseIdAndEmployeeId(appraiseId, employeeId); |
| | | } |
| | | |
| | | @Override |
| | | public List<HrmPerformanceAppraiseResultItemDO> getAppraiseResultItems(Long resultId) { |
| | | return resultItemMapper.selectListByResultId(resultId); |
| | | } |
| | | |
| | | // ========== ç§ææ¹æ³ ========== |
| | | |
| | | private Integer calcGrade(BigDecimal finalScore) { |
| | | if (finalScore == null) { |
| | | return null; |
| | | } |
| | | if (finalScore.compareTo(GRADE_EXCELLENT) >= 0) { |
| | | return GRADE_EXCELLENT_CODE; |
| | | } |
| | | if (finalScore.compareTo(GRADE_GOOD) >= 0) { |
| | | return GRADE_GOOD_CODE; |
| | | } |
| | | if (finalScore.compareTo(GRADE_PASS) >= 0) { |
| | | return GRADE_PASS_CODE; |
| | | } |
| | | return GRADE_IMPROVE_CODE; |
| | | } |
| | | |
| | | private HrmPerformanceAppraiseDO validateAppraiseExists(Long id) { |
| | | HrmPerformanceAppraiseDO appraise = appraiseMapper.selectById(id); |
| | | if (appraise == null) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_NOT_EXISTS); |
| | | } |
| | | return appraise; |
| | | } |
| | | |
| | | private HrmPerformanceAppraiseDO validateAppraiseCanModify(Long id) { |
| | | HrmPerformanceAppraiseDO appraise = validateAppraiseExists(id); |
| | | if (ObjUtil.notEqual(appraise.getStatus(), STATUS_DRAFT)) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_UPDATE_FAIL_NOT_DRAFT); |
| | | } |
| | | return appraise; |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éª BPM 绩æèæ ¸å®¡æ¹åç±»åæµç¨å®ä¹æ¯å¦åå¨ |
| | | */ |
| | | private void validateAppraiseApproveCategoryAndProcessDefinition() { |
| | | // 1. æ ¡éªåç±»æ¯å¦åå¨ |
| | | Map<String, ?> categoryMap = bpmCategoryService.getCategoryMap(Collections.singletonList(APPRAISE_APPROVE_CATEGORY_CODE)); |
| | | if (!categoryMap.containsKey(APPRAISE_APPROVE_CATEGORY_CODE)) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | |
| | | // 2. æ ¡éªåç±»ä¸æ¯å¦æå¯ç¨çæµç¨å®ä¹ |
| | | List<BpmProcessDefinitionInfoDO> definitionInfoList = bpmProcessDefinitionService |
| | | .getProcessDefinitionInfoListByCategory(APPRAISE_APPROVE_CATEGORY_CODE); |
| | | if (CollUtil.isEmpty(definitionInfoList)) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | |
| | | // 3. æ ¡éªæ¯å¦ææ¿æ´»ç¶æçæµç¨å®ä¹ |
| | | Set<String> processDefinitionIds = convertSet(definitionInfoList, BpmProcessDefinitionInfoDO::getProcessDefinitionId); |
| | | List<ProcessDefinition> processDefinitions = bpmProcessDefinitionService.getProcessDefinitionList(processDefinitionIds); |
| | | boolean hasActiveDefinition = processDefinitions.stream().anyMatch(pd -> !pd.isSuspended()); |
| | | if (!hasActiveDefinition) { |
| | | throw exception(ErrorCodeConstants.PERFORMANCE_APPRAISE_BPM_PROCESS_DEFINITION_NOT_EXISTS); |
| | | } |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.service.performanceappraise.listener; |
| | | |
| | | import cn.iocoder.yudao.module.bpm.api.event.BpmProcessInstanceStatusEvent; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.performanceappraise.HrmPerformanceAppraiseDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.performanceappraise.HrmPerformanceAppraiseMapper; |
| | | import cn.iocoder.yudao.module.hrm.enums.HrmAuditStatusEnum; |
| | | import cn.iocoder.yudao.module.hrm.service.performanceappraise.HrmPerformanceAppraiseService; |
| | | import jakarta.annotation.Resource; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.context.ApplicationListener; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 绩æèæ ¸æ¹æ¡å®¡æ¹çç»æçå¬å¨å®ç°ç±» |
| | | * |
| | | * éè¿ businessKeyï¼æ¹æ¡IDï¼å¹é
ï¼è䏿¯åºå®çæµç¨å®ä¹ Keyï¼ |
| | | * è¿æ ·å¯ä»¥æ¯æåç±»ä¸ä»»æ Key çæµç¨æ¨¡åã |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class HrmPerformanceAppraiseStatusListener implements ApplicationListener<BpmProcessInstanceStatusEvent> { |
| | | |
| | | @Resource |
| | | private HrmPerformanceAppraiseService appraiseService; |
| | | @Resource |
| | | private HrmPerformanceAppraiseMapper appraiseMapper; |
| | | |
| | | @Override |
| | | public void onApplicationEvent(BpmProcessInstanceStatusEvent event) { |
| | | // éè¿ businessKey æ¥è¯¢èæ ¸æ¹æ¡ |
| | | Long appraiseId; |
| | | try { |
| | | appraiseId = Long.parseLong(event.getBusinessKey()); |
| | | } catch (NumberFormatException e) { |
| | | return; // businessKey 䏿¯æ°åï¼å¿½ç¥ |
| | | } |
| | | |
| | | HrmPerformanceAppraiseDO appraise = appraiseMapper.selectById(appraiseId); |
| | | if (appraise == null) { |
| | | return; // 䏿¯ç»©æèæ ¸æ¹æ¡ï¼å¿½ç¥ |
| | | } |
| | | |
| | | // åªæå®¡æ¹ä¸ç¶æçæ¹æ¡æå¤ç |
| | | if (!HrmAuditStatusEnum.PROCESS.getStatus().equals(appraise.getAuditStatus())) { |
| | | log.warn("[onApplicationEvent] èæ ¸æ¹æ¡({}) ä¸å¤äºå®¡æ¹ä¸ç¶æï¼å½åç¶æ: {}", appraiseId, appraise.getAuditStatus()); |
| | | return; |
| | | } |
| | | |
| | | log.info("[onApplicationEvent] èæ ¸æ¹æ¡({}) 审æ¹ç¶ææ´æ°: {}", appraiseId, event.getStatus()); |
| | | // æ´æ°å®¡æ¹ç¶æ |
| | | appraiseService.updateAppraiseAuditStatus(appraiseId, event.getStatus()); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.service.workhour; |
| | | |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo.HrmEmployeeWorkHourReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo.HrmEmployeeWorkHourRespVO; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryReqDTO; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryRespDTO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * HRM å·¥æ¶ç»è®¡ Service æ¥å£ |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | public interface HrmWorkHourStatisticsService { |
| | | |
| | | /** |
| | | * å工工æ¶ç»è®¡ï¼èå¤å£å¾ï¼ |
| | | */ |
| | | List<HrmEmployeeWorkHourRespVO> getEmployeeWorkHourSummary(HrmEmployeeWorkHourReqVO reqVO); |
| | | |
| | | /** |
| | | * çç»å·¥æ¶ç»è®¡ï¼æ¥å·¥å£å¾ï¼è·¨æ¨¡åèå MESï¼ |
| | | */ |
| | | List<MesProWorkHourSummaryRespDTO> getTeamWorkHourSummary(MesProWorkHourSummaryReqDTO reqDTO); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.hrm.service.workhour; |
| | | |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo.HrmEmployeeWorkHourReqVO; |
| | | import cn.iocoder.yudao.module.hrm.controller.admin.workhour.vo.HrmEmployeeWorkHourRespVO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.attendance.HrmAttendanceRecordDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO; |
| | | import cn.iocoder.yudao.module.hrm.dal.mysql.attendance.HrmAttendanceRecordMapper; |
| | | import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService; |
| | | import cn.iocoder.yudao.module.mes.api.task.MesProTaskApi; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryReqDTO; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryRespDTO; |
| | | 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.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * HRM å·¥æ¶ç»è®¡ Service å®ç°ç±» |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | public class HrmWorkHourStatisticsServiceImpl implements HrmWorkHourStatisticsService { |
| | | |
| | | @Resource |
| | | private HrmAttendanceRecordMapper attendanceRecordMapper; |
| | | @Resource |
| | | private HrmEmployeeService employeeService; |
| | | @Resource |
| | | private DeptApi deptApi; |
| | | @Resource |
| | | private MesProTaskApi mesProTaskApi; |
| | | |
| | | @Override |
| | | public List<HrmEmployeeWorkHourRespVO> getEmployeeWorkHourSummary(HrmEmployeeWorkHourReqVO reqVO) { |
| | | List<Map<String, Object>> rows = attendanceRecordMapper.selectWorkHourSummary(reqVO); |
| | | List<HrmEmployeeWorkHourRespVO> list = new ArrayList<>(rows.size()); |
| | | for (Map<String, Object> row : rows) { |
| | | HrmEmployeeWorkHourRespVO vo = new HrmEmployeeWorkHourRespVO(); |
| | | Long userId = row.get("user_id") instanceof Number |
| | | ? ((Number) row.get("user_id")).longValue() : null; |
| | | vo.setUserId(userId); |
| | | vo.setWorkDays(row.get("work_days") instanceof Number |
| | | ? ((Number) row.get("work_days")).intValue() : 0); |
| | | vo.setWorkHours(toDecimal(row.get("work_hours"))); |
| | | vo.setOvertimeHours(toDecimal(row.get("overtime_hours"))); |
| | | // å¡«å
åå·¥å§åä¸é¨é¨ |
| | | if (userId != null) { |
| | | HrmEmployeeDO employee = employeeService.getEmployee(userId); |
| | | if (employee != null) { |
| | | vo.setUserName(employee.getName()); |
| | | vo.setDeptId(employee.getDeptId()); |
| | | if (employee.getDeptId() != null) { |
| | | DeptRespDTO dept = deptApi.getDept(employee.getDeptId()); |
| | | if (dept != null) { |
| | | vo.setDeptName(dept.getName()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | list.add(vo); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List<MesProWorkHourSummaryRespDTO> getTeamWorkHourSummary(MesProWorkHourSummaryReqDTO reqDTO) { |
| | | return mesProTaskApi.getTeamWorkHourSummary(reqDTO); |
| | | } |
| | | |
| | | private BigDecimal toDecimal(Object value) { |
| | | if (value instanceof Number) { |
| | | return new BigDecimal(value.toString()); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.api.task; |
| | | |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryReqDTO; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryRespDTO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * MES çäº§ä»»å¡ API æ¥å£ |
| | | * |
| | | * <p>ä¾ HRM 模åè°ç¨ï¼å®ç°ãå·¥æ¶ç»è®¡ã跨模åèå¨ï¼æçç»è忥工任å¡çå ç¨å·¥æ¶ |
| | | * ï¼ç产æ¶é¿ duration åä½ä¸ºäººæ¥ï¼1 äººæ¥ = 8 人æ¶ï¼ã |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | public interface MesProTaskApi { |
| | | |
| | | /** |
| | | * çç»å·¥æ¶ç»è®¡ï¼æ¥å·¥å£å¾ï¼ |
| | | * |
| | | * @param reqDTO æ¶é´èå´ |
| | | * @return æçç»èåçæ¥å·¥å·¥æ¶å表 |
| | | */ |
| | | List<MesProWorkHourSummaryRespDTO> getTeamWorkHourSummary(MesProWorkHourSummaryReqDTO reqDTO); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.api.task.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES çäº§ä»»å¡æ¥å·¥å·¥æ¶ç»è®¡ Request DTO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "RPC æå¡ - MES çäº§ä»»å¡æ¥å·¥å·¥æ¶ç»è®¡ Request DTO") |
| | | @Data |
| | | public class MesProWorkHourSummaryReqDTO { |
| | | |
| | | @Schema(description = "å¼å§æ¶é´") |
| | | private LocalDateTime startTime; |
| | | |
| | | @Schema(description = "ç»ææ¶é´") |
| | | private LocalDateTime endTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.api.task.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * MES çäº§ä»»å¡æ¥å·¥å·¥æ¶ç»è®¡ Response DTO |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "RPC æå¡ - MES çäº§ä»»å¡æ¥å·¥å·¥æ¶ç»è®¡ Response DTO") |
| | | @Data |
| | | public class MesProWorkHourSummaryRespDTO { |
| | | |
| | | @Schema(description = "çç»ç¼å·") |
| | | private Long teamId; |
| | | |
| | | @Schema(description = "çç»åç§°") |
| | | private String teamName; |
| | | |
| | | @Schema(description = "任塿°") |
| | | private Integer taskCount; |
| | | |
| | | @Schema(description = "æ»ç产æ¶é¿ï¼äººæ¥ï¼") |
| | | private Integer totalDuration; |
| | | |
| | | @Schema(description = "æ»å·¥æ¶ï¼äººæ¶ = äººæ¥ Ã 8ï¼") |
| | | private BigDecimal workHours; |
| | | |
| | | } |
| | |
| | | package cn.iocoder.yudao.module.mes.api.workorder; |
| | | |
| | | import cn.iocoder.yudao.module.mes.api.workorder.dto.MesProWorkOrderCreateReqDTO; |
| | | |
| | | /** |
| | | * MES ç产工å API æ¥å£ |
| | | * |
| | | * <p>ä¾ CRM 模åè°ç¨ï¼å®ç°ååæä»¤ãä¸åãçå®è·¨æ¨¡åèå¨ï¼æ§è¡æä»¤æ¶ç¡®è®¤ç®æ å·¥åã |
| | | * åæ¶æä»¤æ¶åæ¶ç®æ å·¥åï¼ä½¿ CRM ååæä»¤ä¸ååªæ¯è®°å½ä¸ç¶ææµè½¬ã |
| | | * |
| | | * <p>åæ¶ä¾ BI å³çæ¯ææ¨¡åè°ç¨ï¼å®ç°ãè´è·é¢æµãèå¨å建è¿ç»´/åçµ/æ£ä¿®ç±»å·¥åã |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | |
| | | */ |
| | | void cancelWorkOrder(Long id); |
| | | |
| | | /** |
| | | * å建工åï¼èç¨¿ç¶æï¼ |
| | | * |
| | | * <p>ç¨äºå³çæ¯æãè´è·é¢æµãèå¨å建è¿ç»´/åçµ/æ£ä¿®ç±»ç产工åã |
| | | * |
| | | * @param reqDTO åå»ºè¯·æ± |
| | | * @return å·¥åç¼å· |
| | | */ |
| | | Long createWorkOrder(MesProWorkOrderCreateReqDTO reqDTO); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.api.workorder.dto; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * MES ç产工åå建 Request DTO |
| | | * |
| | | * <p>ä¾ BI å³çæ¯ææ¨¡åè°ç¨ï¼å®ç°ãè´è·é¢æµãèå¨å建è¿ç»´/åçµ/æ£ä¿®ç±»å·¥åã |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Schema(description = "RPC æå¡ - MES ç产工åå建 Request DTO") |
| | | @Data |
| | | public class MesProWorkOrderCreateReqDTO { |
| | | |
| | | @Schema(description = "å·¥åç¼ç ", example = "WO-001") |
| | | private String code; |
| | | |
| | | @Schema(description = "å·¥ååç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "è´è·é¢æµ-åçµå·¥å") |
| | | private String name; |
| | | |
| | | @Schema(description = "å·¥åç±»å", requiredMode = Schema.RequiredMode.REQUIRED, example = "4") |
| | | private Integer type; |
| | | |
| | | @Schema(description = "æ¥æºç±»å", requiredMode = Schema.RequiredMode.REQUIRED, example = "4") |
| | | private Integer orderSourceType; |
| | | |
| | | @Schema(description = "æ¥æºåæ®ç¼å·", example = "load_forecast_daily") |
| | | private String orderSourceCode; |
| | | |
| | | @Schema(description = "éæ±æ¥æ", example = "2026-08-20 00:00:00") |
| | | private LocalDateTime requestDate; |
| | | |
| | | @Schema(description = "ç产æ°é", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.00") |
| | | private BigDecimal quantity; |
| | | |
| | | @Schema(description = "夿³¨", example = "ç±è´è·é¢æµèªå¨çæ") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.api.task; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryReqDTO; |
| | | import cn.iocoder.yudao.module.mes.api.task.dto.MesProWorkHourSummaryRespDTO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.task.MesProTaskMapper; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * MES çäº§ä»»å¡ API å®ç°ç±» |
| | | * |
| | | * @author è¶
级管çå |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class MesProTaskApiImpl implements MesProTaskApi { |
| | | |
| | | @Resource |
| | | private MesProTaskMapper taskMapper; |
| | | |
| | | @Override |
| | | public List<MesProWorkHourSummaryRespDTO> getTeamWorkHourSummary(MesProWorkHourSummaryReqDTO reqDTO) { |
| | | List<Map<String, Object>> rows = taskMapper.selectWorkHourSummary( |
| | | reqDTO == null ? null : reqDTO.getStartTime(), |
| | | reqDTO == null ? null : reqDTO.getEndTime()); |
| | | List<MesProWorkHourSummaryRespDTO> list = new ArrayList<>(rows.size()); |
| | | for (Map<String, Object> row : rows) { |
| | | MesProWorkHourSummaryRespDTO dto = new MesProWorkHourSummaryRespDTO(); |
| | | dto.setTeamId(numberToLong(row.get("team_id"))); |
| | | dto.setTeamName(StrUtil.toStringOrNull(row.get("team_name"))); |
| | | dto.setTaskCount(numberToInt(row.get("task_count"))); |
| | | dto.setTotalDuration(numberToInt(row.get("total_duration"))); |
| | | int totalDuration = dto.getTotalDuration() == null ? 0 : dto.getTotalDuration(); |
| | | dto.setWorkHours(BigDecimal.valueOf(totalDuration * 8L)); |
| | | list.add(dto); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private Long numberToLong(Object value) { |
| | | return value instanceof Number ? ((Number) value).longValue() : null; |
| | | } |
| | | |
| | | private Integer numberToInt(Object value) { |
| | | return value instanceof Number ? ((Number) value).intValue() : null; |
| | | } |
| | | |
| | | } |
| | |
| | | package cn.iocoder.yudao.module.mes.api.workorder; |
| | | |
| | | import cn.iocoder.yudao.module.mes.api.workorder.dto.MesProWorkOrderCreateReqDTO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.workorder.vo.MesProWorkOrderSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | workOrderService.cancelWorkOrder(id); |
| | | } |
| | | |
| | | @Override |
| | | public Long createWorkOrder(MesProWorkOrderCreateReqDTO reqDTO) { |
| | | MesProWorkOrderSaveReqVO workOrderReq = BeanUtils.toBean(reqDTO, MesProWorkOrderSaveReqVO.class); |
| | | return workOrderService.createWorkOrder(workOrderReq); |
| | | } |
| | | |
| | | } |
| | |
| | | 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.dv.telemetry.vo.MesDvTelemetryCheckSummaryRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryDeviceRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryLatestReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryPageReqVO; |
| | |
| | | return success(telemetryService.getDeviceList()); |
| | | } |
| | | |
| | | @GetMapping("/check") |
| | | @Operation(summary = "ä¾çµåæ°æ¯å¯¹æ ¡éªæç»ï¼åè®¾å¤ææ°åæ° vs æ åå¼ï¼") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-telemetry:query')") |
| | | public CommonResult<List<MesDvTelemetryRespVO>> getCheckList(MesDvTelemetryLatestReqVO reqVO) { |
| | | List<MesDvTelemetryDO> list = telemetryService.getLatestTelemetry(reqVO); |
| | | return success(BeanUtils.toBean(list, MesDvTelemetryRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/check-summary") |
| | | @Operation(summary = "ä¾çµåæ°æ¯å¯¹æ ¡éªç»è®¡ï¼æè®¾å¤èåå¼å¸¸çï¼") |
| | | @PreAuthorize("@ss.hasPermission('mes:dv-telemetry:query')") |
| | | public CommonResult<List<MesDvTelemetryCheckSummaryRespVO>> getCheckSummary(MesDvTelemetryLatestReqVO reqVO) { |
| | | return success(telemetryService.getCheckSummary(reqVO)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | @Schema(description = "管çåå° - MES è®¾å¤æ°éæ¯å¯¹æ ¡éªç»è®¡ Response VO") |
| | | @Data |
| | | public class MesDvTelemetryCheckSummaryRespVO { |
| | | |
| | | @Schema(description = "æ°é设å¤ID") |
| | | private String tbDeviceId; |
| | | |
| | | @Schema(description = "设å¤åç§°") |
| | | private String deviceName; |
| | | |
| | | @Schema(description = "åæ°æ»æ°") |
| | | private Integer totalCount; |
| | | |
| | | @Schema(description = "æ£å¸¸åæ°æ°") |
| | | private Integer normalCount; |
| | | |
| | | @Schema(description = "å¼å¸¸åæ°æ°") |
| | | private Integer anomalyCount; |
| | | |
| | | @Schema(description = "å¼å¸¸çï¼%ï¼") |
| | | private BigDecimal anomalyRate; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan; |
| | | |
| | | 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.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.alternativeplan.MesProAlternativePlanDO; |
| | | import cn.iocoder.yudao.module.mes.service.pro.alternativeplan.MesProAlternativePlanService; |
| | | 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; |
| | | |
| | | @Tag(name = "管çåå° - MES ä½ä¸æ¿ä»£æ¹æ¡") |
| | | @RestController |
| | | @RequestMapping("/mes/pro/alternative-plan") |
| | | @Validated |
| | | public class MesProAlternativePlanController { |
| | | |
| | | @Resource |
| | | private MesProAlternativePlanService planService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "å建ä½ä¸æ¿ä»£æ¹æ¡") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:create')") |
| | | public CommonResult<Long> createPlan(@Valid @RequestBody MesProAlternativePlanSaveReqVO createReqVO) { |
| | | return success(planService.createPlan(createReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "æ´æ°ä½ä¸æ¿ä»£æ¹æ¡") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:update')") |
| | | public CommonResult<Boolean> updatePlan(@Valid @RequestBody MesProAlternativePlanSaveReqVO updateReqVO) { |
| | | planService.updatePlan(updateReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤ä½ä¸æ¿ä»£æ¹æ¡") |
| | | @Parameter(name = "ids", description = "ç¼å·æ°ç»", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:delete')") |
| | | public CommonResult<Boolean> deletePlan(@RequestParam("ids") List<Long> ids) { |
| | | planService.deletePlan(ids); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾ä½ä¸æ¿ä»£æ¹æ¡") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:query')") |
| | | public CommonResult<MesProAlternativePlanRespVO> getPlan(@RequestParam("id") Long id) { |
| | | MesProAlternativePlanDO plan = planService.getPlan(id); |
| | | return success(plan != null ? BeanUtils.toBean(plan, MesProAlternativePlanRespVO.class) : null); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾ä½ä¸æ¿ä»£æ¹æ¡å页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:query')") |
| | | public CommonResult<PageResult<MesProAlternativePlanRespVO>> getPlanPage(@Valid MesProAlternativePlanPageReqVO pageReqVO) { |
| | | PageResult<MesProAlternativePlanDO> pageResult = planService.getPlanPage(pageReqVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | | return success(PageResult.empty(pageResult.getTotal())); |
| | | } |
| | | return success(BeanUtils.toBean(pageResult, MesProAlternativePlanRespVO.class)); |
| | | } |
| | | |
| | | @PutMapping("/publish") |
| | | @Operation(summary = "åå¸ä½ä¸æ¿ä»£æ¹æ¡") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-alternative-plan:update')") |
| | | public CommonResult<Boolean> publishPlan(@RequestParam("id") Long id) { |
| | | planService.publishPlan(id); |
| | | return success(true); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.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; |
| | | |
| | | @Schema(description = "管çåå° - MES ä½ä¸æ¿ä»£æ¹æ¡å页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesProAlternativePlanPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ¹æ¡ç¼ç ", example = "TD20260820001") |
| | | private String code; |
| | | |
| | | @Schema(description = "æ¹æ¡åç§°", example = "çº¿è·¯å·¡æ£æ¿ä»£æ¹æ¡") |
| | | private String name; |
| | | |
| | | @Schema(description = "主工åºç¼å·", example = "100") |
| | | private Long mainProcessId; |
| | | |
| | | @Schema(description = "ç¶æï¼0=è稿ï¼10=å·²åå¸ï¼", example = "0") |
| | | private Integer status; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo; |
| | | |
| | | import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES ä½ä¸æ¿ä»£æ¹æ¡ Response VO") |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | public class MesProAlternativePlanRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @ExcelProperty("ç¼å·") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¹æ¡ç¼ç ", example = "TD20260820001") |
| | | @ExcelProperty("æ¹æ¡ç¼ç ") |
| | | private String code; |
| | | |
| | | @Schema(description = "æ¹æ¡åç§°", example = "çº¿è·¯å·¡æ£æ¿ä»£æ¹æ¡") |
| | | @ExcelProperty("æ¹æ¡åç§°") |
| | | private String name; |
| | | |
| | | @Schema(description = "主工åºç¼å·", example = "100") |
| | | private Long mainProcessId; |
| | | |
| | | @Schema(description = "主工åºåç§°", example = "线路巡æ£") |
| | | @ExcelProperty("主工åº") |
| | | private String mainProcessName; |
| | | |
| | | @Schema(description = "æ¿ä»£å·¥åºç¼å·", example = "101") |
| | | private Long altProcessId; |
| | | |
| | | @Schema(description = "æ¿ä»£å·¥åºåç§°", example = "æ 人æºå·¡æ£") |
| | | @ExcelProperty("æ¿ä»£å·¥åº") |
| | | private String altProcessName; |
| | | |
| | | @Schema(description = "æ¿ä»£æ¡ä»¶", example = "è®¾å¤æ
é/è´è·åé/人åä¸è¶³") |
| | | @ExcelProperty("æ¿ä»£æ¡ä»¶") |
| | | private String altCondition; |
| | | |
| | | @Schema(description = "éç¨èå´", example = "110kV 线路") |
| | | @ExcelProperty("éç¨èå´") |
| | | private String scope; |
| | | |
| | | @Schema(description = "ç¶æï¼0=è稿ï¼10=å·²åå¸ï¼", example = "0") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "夿³¨", example = "夿³¨") |
| | | @ExcelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "å建æ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @ExcelProperty("å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.Data; |
| | | |
| | | @Schema(description = "管çåå° - MES ä½ä¸æ¿ä»£æ¹æ¡æ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class MesProAlternativePlanSaveReqVO { |
| | | |
| | | @Schema(description = "ç¼å·ï¼ä¿®æ¹æ¶å¿
å¡«ï¼", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¹æ¡åç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "çº¿è·¯å·¡æ£æ¿ä»£æ¹æ¡") |
| | | @NotEmpty(message = "æ¹æ¡åç§°ä¸è½ä¸ºç©º") |
| | | private String name; |
| | | |
| | | @Schema(description = "主工åºç¼å·", example = "100") |
| | | private Long mainProcessId; |
| | | |
| | | @Schema(description = "主工åºåç§°", example = "线路巡æ£") |
| | | private String mainProcessName; |
| | | |
| | | @Schema(description = "æ¿ä»£å·¥åºç¼å·", example = "101") |
| | | private Long altProcessId; |
| | | |
| | | @Schema(description = "æ¿ä»£å·¥åºåç§°", example = "æ 人æºå·¡æ£") |
| | | private String altProcessName; |
| | | |
| | | @Schema(description = "æ¿ä»£æ¡ä»¶", example = "è®¾å¤æ
é/è´è·åé/人åä¸è¶³") |
| | | private String altCondition; |
| | | |
| | | @Schema(description = "éç¨èå´", example = "110kV 线路") |
| | | private String scope; |
| | | |
| | | @Schema(description = "夿³¨", example = "夿³¨") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar; |
| | | |
| | | 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.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.maintenancecalendar.MesProMaintenanceCalendarDO; |
| | | import cn.iocoder.yudao.module.mes.service.pro.maintenancecalendar.MesProMaintenanceCalendarService; |
| | | 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; |
| | | |
| | | @Tag(name = "管çåå° - MES çµåè¿ç»´æ¥å") |
| | | @RestController |
| | | @RequestMapping("/mes/pro/maintenance-calendar") |
| | | @Validated |
| | | public class MesProMaintenanceCalendarController { |
| | | |
| | | @Resource |
| | | private MesProMaintenanceCalendarService calendarService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "å建çµåè¿ç»´æ¥å") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:create')") |
| | | public CommonResult<Long> createCalendar(@Valid @RequestBody MesProMaintenanceCalendarSaveReqVO createReqVO) { |
| | | return success(calendarService.createCalendar(createReqVO)); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @Operation(summary = "æ´æ°çµåè¿ç»´æ¥å") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:update')") |
| | | public CommonResult<Boolean> updateCalendar(@Valid @RequestBody MesProMaintenanceCalendarSaveReqVO updateReqVO) { |
| | | calendarService.updateCalendar(updateReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "å é¤çµåè¿ç»´æ¥å") |
| | | @Parameter(name = "ids", description = "ç¼å·æ°ç»", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:delete')") |
| | | public CommonResult<Boolean> deleteCalendar(@RequestParam("ids") List<Long> ids) { |
| | | calendarService.deleteCalendar(ids); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "è·å¾çµåè¿ç»´æ¥å") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:query')") |
| | | public CommonResult<MesProMaintenanceCalendarRespVO> getCalendar(@RequestParam("id") Long id) { |
| | | MesProMaintenanceCalendarDO calendar = calendarService.getCalendar(id); |
| | | return success(calendar != null ? BeanUtils.toBean(calendar, MesProMaintenanceCalendarRespVO.class) : null); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "è·å¾çµåè¿ç»´æ¥åå页") |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:query')") |
| | | public CommonResult<PageResult<MesProMaintenanceCalendarRespVO>> getCalendarPage(@Valid MesProMaintenanceCalendarPageReqVO pageReqVO) { |
| | | PageResult<MesProMaintenanceCalendarDO> pageResult = calendarService.getCalendarPage(pageReqVO); |
| | | if (CollUtil.isEmpty(pageResult.getList())) { |
| | | return success(PageResult.empty(pageResult.getTotal())); |
| | | } |
| | | return success(BeanUtils.toBean(pageResult, MesProMaintenanceCalendarRespVO.class)); |
| | | } |
| | | |
| | | @PutMapping("/publish") |
| | | @Operation(summary = "åå¸çµåè¿ç»´æ¥å") |
| | | @Parameter(name = "id", description = "ç¼å·", required = true) |
| | | @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:update')") |
| | | public CommonResult<Boolean> publishCalendar(@RequestParam("id") Long id) { |
| | | calendarService.publishCalendar(id); |
| | | return success(true); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.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 java.time.LocalDate; |
| | | |
| | | @Schema(description = "管çåå° - MES çµåè¿ç»´æ¥åå页 Request VO") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | public class MesProMaintenanceCalendarPageReqVO extends PageParam { |
| | | |
| | | @Schema(description = "æ¥åç¼ç ", example = "RL20260820001") |
| | | private String code; |
| | | |
| | | @Schema(description = "æ¥ååç§°", example = "8æåçµè¿ç»´æç") |
| | | private String name; |
| | | |
| | | @Schema(description = "ä½ä¸æ¥æ", example = "2026-08-20") |
| | | private LocalDate workDate; |
| | | |
| | | @Schema(description = "çæ¬¡", example = "1") |
| | | private Integer shift; |
| | | |
| | | @Schema(description = "ä½ä¸ç±»åï¼1åçµè¿ç»´/2线路巡æ£/3åçµè¿ç»´/4å¨è½å
æ¾çµ/5çµç½è°åº¦ï¼", example = "1") |
| | | private Integer workType; |
| | | |
| | | @Schema(description = "ç¶æï¼0=è稿ï¼10=å·²åå¸ï¼", example = "0") |
| | | private Integer status; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo; |
| | | |
| | | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| | | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| | | import cn.idev.excel.annotation.ExcelIgnoreUnannotated; |
| | | import cn.idev.excel.annotation.ExcelProperty; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Schema(description = "管çåå° - MES çµåè¿ç»´æ¥å Response VO") |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | public class MesProMaintenanceCalendarRespVO { |
| | | |
| | | @Schema(description = "ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @ExcelProperty("ç¼å·") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¥åç¼ç ", example = "RL20260820001") |
| | | @ExcelProperty("æ¥åç¼ç ") |
| | | private String code; |
| | | |
| | | @Schema(description = "æ¥ååç§°", example = "8æåçµè¿ç»´æç") |
| | | @ExcelProperty("æ¥ååç§°") |
| | | private String name; |
| | | |
| | | @Schema(description = "ä½ä¸æ¥æ", example = "2026-08-20") |
| | | @ExcelProperty("ä½ä¸æ¥æ") |
| | | private LocalDate workDate; |
| | | |
| | | @Schema(description = "çæ¬¡", example = "1") |
| | | @ExcelProperty(value = "çæ¬¡", converter = DictConvert.class) |
| | | @DictFormat(cn.iocoder.yudao.module.mes.enums.DictTypeConstants.MES_CAL_SHIFT_TYPE) |
| | | private Integer shift; |
| | | |
| | | @Schema(description = "ä½ä¸ç±»å", example = "1") |
| | | @ExcelProperty(value = "ä½ä¸ç±»å", converter = DictConvert.class) |
| | | @DictFormat(cn.iocoder.yudao.module.mes.enums.DictTypeConstants.MES_PRO_CALENDAR_WORK_TYPE) |
| | | private Integer workType; |
| | | |
| | | @Schema(description = "ä½ä¸åºå/线路", example = "110kV ååºçº¿") |
| | | @ExcelProperty("ä½ä¸åºå") |
| | | private String region; |
| | | |
| | | @Schema(description = "å¼ççç»ç¼å·", example = "100") |
| | | private Long teamId; |
| | | |
| | | @Schema(description = "å¼ççç»åç§°", example = "åçµè¿ç»´ä¸ç") |
| | | @ExcelProperty("å¼ççç»") |
| | | private String teamName; |
| | | |
| | | @Schema(description = "å¼ç人å", example = "å¼ ä¸,æå") |
| | | @ExcelProperty("å¼ç人å") |
| | | private String personnel; |
| | | |
| | | @Schema(description = "ç¶æï¼0=è稿ï¼10=å·²åå¸ï¼", example = "0") |
| | | private Integer status; |
| | | |
| | | @Schema(description = "夿³¨", example = "夿³¨") |
| | | @ExcelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @Schema(description = "å建æ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | @ExcelProperty("å建æ¶é´") |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | @Schema(description = "管çåå° - MES çµåè¿ç»´æ¥åæ°å¢/ä¿®æ¹ Request VO") |
| | | @Data |
| | | public class MesProMaintenanceCalendarSaveReqVO { |
| | | |
| | | @Schema(description = "ç¼å·ï¼ä¿®æ¹æ¶å¿
å¡«ï¼", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "æ¥ååç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "8æåçµè¿ç»´æç") |
| | | @NotEmpty(message = "æ¥ååç§°ä¸è½ä¸ºç©º") |
| | | private String name; |
| | | |
| | | @Schema(description = "ä½ä¸æ¥æ", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026-08-20") |
| | | @NotNull(message = "ä½ä¸æ¥æä¸è½ä¸ºç©º") |
| | | private LocalDate workDate; |
| | | |
| | | @Schema(description = "çæ¬¡", example = "1") |
| | | private Integer shift; |
| | | |
| | | @Schema(description = "ä½ä¸ç±»åï¼1åçµè¿ç»´/2线路巡æ£/3åçµè¿ç»´/4å¨è½å
æ¾çµ/5çµç½è°åº¦ï¼", example = "1") |
| | | private Integer workType; |
| | | |
| | | @Schema(description = "ä½ä¸åºå/线路", example = "110kV ååºçº¿") |
| | | private String region; |
| | | |
| | | @Schema(description = "å¼ççç»ç¼å·", example = "100") |
| | | private Long teamId; |
| | | |
| | | @Schema(description = "å¼ççç»åç§°", example = "åçµè¿ç»´ä¸ç") |
| | | private String teamName; |
| | | |
| | | @Schema(description = "å¼ç人å", example = "å¼ ä¸,æå") |
| | | private String personnel; |
| | | |
| | | @Schema(description = "夿³¨", example = "夿³¨") |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.pro.alternativeplan; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | /** |
| | | * MES ä½ä¸æ¿ä»£æ¹æ¡ DO |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | @TableName("mes_pro_alternative_plan") |
| | | @KeySequence("mes_pro_alternative_plan_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesProAlternativePlanDO extends BaseDO { |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * æ¹æ¡ç¼ç |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * æ¹æ¡åç§° |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 主工åºç¼å· |
| | | */ |
| | | private Long mainProcessId; |
| | | |
| | | /** |
| | | * 主工åºåç§° |
| | | */ |
| | | private String mainProcessName; |
| | | |
| | | /** |
| | | * æ¿ä»£å·¥åºç¼å· |
| | | */ |
| | | private Long altProcessId; |
| | | |
| | | /** |
| | | * æ¿ä»£å·¥åºåç§° |
| | | */ |
| | | private String altProcessName; |
| | | |
| | | /** |
| | | * æ¿ä»£æ¡ä»¶ï¼å¦ï¼è®¾å¤æ
é/è´è·åé/人åä¸è¶³ï¼ |
| | | */ |
| | | private String altCondition; |
| | | |
| | | /** |
| | | * éç¨èå´ |
| | | */ |
| | | private String scope; |
| | | |
| | | /** |
| | | * ç¶æ |
| | | * |
| | | * 0: è稿 |
| | | * 10: å·²åå¸ |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.dataobject.pro.maintenancecalendar; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.*; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * MES çµåè¿ç»´æ¥å DO |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | @TableName("mes_pro_maintenance_calendar") |
| | | @KeySequence("mes_pro_maintenance_calendar_seq") |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @ToString(callSuper = true) |
| | | @Builder |
| | | @NoArgsConstructor |
| | | @AllArgsConstructor |
| | | public class MesProMaintenanceCalendarDO extends BaseDO { |
| | | |
| | | /** |
| | | * ç¼å· |
| | | */ |
| | | @TableId |
| | | private Long id; |
| | | |
| | | /** |
| | | * æ¥åç¼ç |
| | | */ |
| | | private String code; |
| | | |
| | | /** |
| | | * æ¥ååç§° |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * ä½ä¸æ¥æ |
| | | */ |
| | | private LocalDate workDate; |
| | | |
| | | /** |
| | | * çæ¬¡ï¼åå
¸ {@link DictTypeConstants#MES_CAL_SHIFT_TYPE}ï¼ |
| | | */ |
| | | private Integer shift; |
| | | |
| | | /** |
| | | * ä½ä¸ç±»åï¼åå
¸ {@link DictTypeConstants#MES_PRO_CALENDAR_WORK_TYPE}ï¼ |
| | | */ |
| | | private Integer workType; |
| | | |
| | | /** |
| | | * ä½ä¸åºå/线路 |
| | | */ |
| | | private String region; |
| | | |
| | | /** |
| | | * å¼ççç»ç¼å· |
| | | */ |
| | | private Long teamId; |
| | | |
| | | /** |
| | | * å¼ççç»åç§° |
| | | */ |
| | | private String teamName; |
| | | |
| | | /** |
| | | * å¼ç人å |
| | | */ |
| | | private String personnel; |
| | | |
| | | /** |
| | | * ç¶æ |
| | | * |
| | | * 0: è稿 |
| | | * 10: å·²åå¸ |
| | | */ |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 夿³¨ |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.pro.alternativeplan; |
| | | |
| | | 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.pro.alternativeplan.vo.MesProAlternativePlanPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.alternativeplan.MesProAlternativePlanDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES ä½ä¸æ¿ä»£æ¹æ¡ Mapper |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | @Mapper |
| | | public interface MesProAlternativePlanMapper extends BaseMapperX<MesProAlternativePlanDO> { |
| | | |
| | | default MesProAlternativePlanDO selectByCode(String code) { |
| | | return selectOne(MesProAlternativePlanDO::getCode, code); |
| | | } |
| | | |
| | | default PageResult<MesProAlternativePlanDO> selectPage(MesProAlternativePlanPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesProAlternativePlanDO>() |
| | | .likeIfPresent(MesProAlternativePlanDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(MesProAlternativePlanDO::getName, reqVO.getName()) |
| | | .eqIfPresent(MesProAlternativePlanDO::getMainProcessId, reqVO.getMainProcessId()) |
| | | .eqIfPresent(MesProAlternativePlanDO::getStatus, reqVO.getStatus()) |
| | | .orderByDesc(MesProAlternativePlanDO::getId)); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.dal.mysql.pro.maintenancecalendar; |
| | | |
| | | 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.pro.maintenancecalendar.vo.MesProMaintenanceCalendarPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.maintenancecalendar.MesProMaintenanceCalendarDO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * MES çµåè¿ç»´æ¥å Mapper |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | @Mapper |
| | | public interface MesProMaintenanceCalendarMapper extends BaseMapperX<MesProMaintenanceCalendarDO> { |
| | | |
| | | default PageResult<MesProMaintenanceCalendarDO> selectPage(MesProMaintenanceCalendarPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MesProMaintenanceCalendarDO>() |
| | | .likeIfPresent(MesProMaintenanceCalendarDO::getCode, reqVO.getCode()) |
| | | .likeIfPresent(MesProMaintenanceCalendarDO::getName, reqVO.getName()) |
| | | .eqIfPresent(MesProMaintenanceCalendarDO::getWorkDate, reqVO.getWorkDate()) |
| | | .eqIfPresent(MesProMaintenanceCalendarDO::getShift, reqVO.getShift()) |
| | | .eqIfPresent(MesProMaintenanceCalendarDO::getWorkType, reqVO.getWorkType()) |
| | | .eqIfPresent(MesProMaintenanceCalendarDO::getStatus, reqVO.getStatus()) |
| | | .orderByDesc(MesProMaintenanceCalendarDO::getWorkDate) |
| | | .orderByDesc(MesProMaintenanceCalendarDO::getId)); |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteProcessDO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; |
| | | import cn.iocoder.yudao.module.mes.enums.pro.MesProTaskStatusEnum; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * MES çäº§ä»»å¡ Mapper |
| | |
| | | .orderByDesc(MesProTaskDO::getId)); |
| | | } |
| | | |
| | | /** |
| | | * çç»æ¥å·¥å·¥æ¶ç»è®¡ï¼æçç»èå任塿°ä¸ç产æ¶é¿ï¼duration 人æ¥ï¼ |
| | | * |
| | | * @param startTime ç产å¼å§æ¶é´ä¸é |
| | | * @param endTime ç产å¼å§æ¶é´ä¸é |
| | | */ |
| | | default List<Map<String, Object>> selectWorkHourSummary(LocalDateTime startTime, LocalDateTime endTime) { |
| | | return selectMaps(new QueryWrapper<MesProTaskDO>() |
| | | .select("team_id", "team_name", |
| | | "COUNT(*) AS task_count", |
| | | "SUM(IFNULL(duration, 0)) AS total_duration") |
| | | // æ¥å·¥å£å¾ï¼æé¤è稿/已忶ï¼ä»
ç»è®¡å®é
è¿å
¥ç产çä»»å¡ |
| | | .notIn("status", MesProTaskStatusEnum.PREPARE.getStatus(), MesProTaskStatusEnum.CANCELED.getStatus()) |
| | | .ge(startTime != null, "start_time", startTime) |
| | | .le(endTime != null, "start_time", endTime) |
| | | .groupBy("team_id", "team_name")); |
| | | } |
| | | |
| | | default void updateProducedQuantity(Long id, |
| | | BigDecimal incrProducedQuantity, |
| | | BigDecimal incrQualifyQuantity, |
| | |
| | | String MES_PD_PRICE_OBJECT_TYPE = "mes_pd_price_object_type"; // å®ä»·å¯¹è±¡ç±»åï¼1æå¡å¥é¤/2çµåç级/3ç¨çµç±»åï¼ |
| | | String MES_PD_DISCOUNT_POLICY_TYPE = "mes_pd_discount_policy_type"; // 伿 çç¥ç±»åï¼1ææ£/2ç«åï¼ |
| | | String MES_PD_TIERED_PRICE_STATUS = "mes_pd_tiered_price_status"; // é¶æ¢¯çµä»·å¯ç¨ç¶æ |
| | | |
| | | // ========== å·¥èºè®¾è®¡-ä½ä¸æ¿ä»£æ¹æ¡/çµåè¿ç»´æ¥åï¼PRO-EXTï¼ ========== |
| | | String MES_PRO_CALENDAR_WORK_TYPE = "mes_pro_calendar_work_type"; // MES çµåè¿ç»´æ¥åä½ä¸ç±»åï¼1åçµè¿ç»´/2线路巡æ£/3åçµè¿ç»´/4å¨è½å
æ¾çµ/5çµç½è°åº¦ï¼ |
| | | } |
| | |
| | | ErrorCode WMS_APPROVAL_STATUS_INVALID = new ErrorCode(1_040_900_004, "åæ®ç¶æä¸æ£ç¡®ï¼æ æ³æäº¤å®¡æ¹"); |
| | | ErrorCode WMS_APPROVAL_ALREADY_SUBMITTED = new ErrorCode(1_040_900_005, "忮已æäº¤å®¡æ¹ï¼è¯·å¿éå¤æäº¤"); |
| | | |
| | | // ========== MES å·¥èºè®¾è®¡-ä½ä¸æ¿ä»£æ¹æ¡/çµåè¿ç»´æ¥åï¼1-040-901-000ï¼ ========== |
| | | ErrorCode MES_PRO_ALTERNATIVE_PLAN_NOT_EXISTS = new ErrorCode(1_040_901_000, "ä½ä¸æ¿ä»£æ¹æ¡ä¸åå¨"); |
| | | ErrorCode MES_PRO_ALTERNATIVE_PLAN_NOT_PREPARE = new ErrorCode(1_040_901_001, "ä½ä¸æ¿ä»£æ¹æ¡ç¶æä¸æ£ç¡®ï¼æ æ³æ§è¡è¯¥æä½"); |
| | | ErrorCode MES_PRO_MAINTENANCE_CALENDAR_NOT_EXISTS = new ErrorCode(1_040_901_100, "çµåè¿ç»´æ¥åä¸åå¨"); |
| | | ErrorCode MES_PRO_MAINTENANCE_CALENDAR_NOT_PREPARE = new ErrorCode(1_040_901_101, "çµåè¿ç»´æ¥åç¶æä¸æ£ç¡®ï¼æ æ³æ§è¡è¯¥æä½"); |
| | | |
| | | } |
| | |
| | | |
| | | ORDER(1, "客æ·è®¢å"), |
| | | STORE(2, "åºåå¤è´§"), |
| | | MAINTENANCE_PLAN(3, "è¿ç»´è®¡å"); |
| | | MAINTENANCE_PLAN(3, "è¿ç»´è®¡å"), |
| | | FORECAST(4, "è´è·é¢æµ"); |
| | | |
| | | public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesProWorkOrderSourceTypeEnum::getType).toArray(Integer[]::new); |
| | | |
| | |
| | | package cn.iocoder.yudao.module.mes.service.dv.telemetry; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryCheckSummaryRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryDeviceRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryLatestReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryPageReqVO; |
| | |
| | | List<MesDvTelemetryDeviceRespVO> getDeviceList(); |
| | | |
| | | /** |
| | | * ä¾çµåæ°æ¯å¯¹æ ¡éªç»è®¡ï¼æè®¾å¤èåææ°åæ°ï¼è¾åºæ£å¸¸/å¼å¸¸æ°ä¸å¼å¸¸ç |
| | | */ |
| | | List<MesDvTelemetryCheckSummaryRespVO> getCheckSummary(MesDvTelemetryLatestReqVO reqVO); |
| | | |
| | | /** |
| | | * è°ç¨å¤é¨æ°éæ¥å£æåè¿ 5 åéè®¾å¤æ°æ®å¹¶å
¥åº |
| | | */ |
| | | MesDvTelemetryPullRespVO pullTelemetry(); |
| | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| | | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryCheckSummaryRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryDeviceRespVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryLatestReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.dv.telemetry.vo.MesDvTelemetryPageReqVO; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<MesDvTelemetryCheckSummaryRespVO> getCheckSummary(MesDvTelemetryLatestReqVO reqVO) { |
| | | List<MesDvTelemetryDO> list = getLatestTelemetry(reqVO); |
| | | Map<String, MesDvTelemetryCheckSummaryRespVO> deviceMap = new LinkedHashMap<>(); |
| | | for (MesDvTelemetryDO row : list) { |
| | | String key = StrUtil.blankToDefault(row.getTbDeviceId(), ""); |
| | | MesDvTelemetryCheckSummaryRespVO vo = deviceMap.get(key); |
| | | if (vo == null) { |
| | | vo = new MesDvTelemetryCheckSummaryRespVO(); |
| | | vo.setTbDeviceId(row.getTbDeviceId()); |
| | | vo.setDeviceName(row.getDeviceName()); |
| | | vo.setTotalCount(0); |
| | | vo.setNormalCount(0); |
| | | vo.setAnomalyCount(0); |
| | | deviceMap.put(key, vo); |
| | | } |
| | | vo.setTotalCount(vo.getTotalCount() + 1); |
| | | if (Boolean.TRUE.equals(row.getWhetherAnomaly())) { |
| | | vo.setAnomalyCount(vo.getAnomalyCount() + 1); |
| | | } else { |
| | | vo.setNormalCount(vo.getNormalCount() + 1); |
| | | } |
| | | } |
| | | List<MesDvTelemetryCheckSummaryRespVO> result = new ArrayList<>(deviceMap.values()); |
| | | for (MesDvTelemetryCheckSummaryRespVO vo : result) { |
| | | if (vo.getTotalCount() != null && vo.getTotalCount() > 0) { |
| | | BigDecimal rate = BigDecimal.valueOf(vo.getAnomalyCount() * 100.0 / vo.getTotalCount()); |
| | | vo.setAnomalyRate(rate.setScale(1, RoundingMode.HALF_UP)); |
| | | } else { |
| | | vo.setAnomalyRate(BigDecimal.ZERO); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<MesDvTelemetryDeviceRespVO> getDeviceList() { |
| | | List<MesDvTelemetryDeviceRespVO> result = new ArrayList<>(); |
| | | for (MesDvTelemetryDO row : telemetryMapper.selectDeviceList()) { |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.pro.alternativeplan; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.alternativeplan.MesProAlternativePlanDO; |
| | | |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * MES ä½ä¸æ¿ä»£æ¹æ¡ Service æ¥å£ |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | public interface MesProAlternativePlanService { |
| | | |
| | | Long createPlan(MesProAlternativePlanSaveReqVO createReqVO); |
| | | |
| | | void updatePlan(MesProAlternativePlanSaveReqVO updateReqVO); |
| | | |
| | | void deletePlan(Collection<Long> ids); |
| | | |
| | | MesProAlternativePlanDO getPlan(Long id); |
| | | |
| | | PageResult<MesProAlternativePlanDO> getPlanPage(MesProAlternativePlanPageReqVO pageReqVO); |
| | | |
| | | void publishPlan(Long id); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.pro.alternativeplan; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | 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.pro.alternativeplan.vo.MesProAlternativePlanPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.alternativeplan.vo.MesProAlternativePlanSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.alternativeplan.MesProAlternativePlanDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.alternativeplan.MesProAlternativePlanMapper; |
| | | import jakarta.annotation.Resource; |
| | | 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.Objects; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MES_PRO_ALTERNATIVE_PLAN_NOT_EXISTS; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MES_PRO_ALTERNATIVE_PLAN_NOT_PREPARE; |
| | | |
| | | /** |
| | | * MES ä½ä¸æ¿ä»£æ¹æ¡ Service å®ç°ç±» |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class MesProAlternativePlanServiceImpl implements MesProAlternativePlanService { |
| | | |
| | | private static final Integer STATUS_DRAFT = 0; |
| | | private static final Integer STATUS_PUBLISHED = 10; |
| | | |
| | | @Resource |
| | | private MesProAlternativePlanMapper planMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createPlan(MesProAlternativePlanSaveReqVO createReqVO) { |
| | | MesProAlternativePlanDO plan = BeanUtils.toBean(createReqVO, MesProAlternativePlanDO.class, req -> req |
| | | .setCode(generateCode()) |
| | | .setStatus(STATUS_DRAFT)); |
| | | planMapper.insert(plan); |
| | | return plan.getId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updatePlan(MesProAlternativePlanSaveReqVO updateReqVO) { |
| | | MesProAlternativePlanDO oldPlan = validatePlanCanModify(updateReqVO.getId()); |
| | | MesProAlternativePlanDO updateObj = BeanUtils.toBean(updateReqVO, MesProAlternativePlanDO.class, req -> req |
| | | .setCode(oldPlan.getCode()) |
| | | .setStatus(oldPlan.getStatus())); |
| | | planMapper.updateById(updateObj); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deletePlan(Collection<Long> ids) { |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | for (Long id : ids) { |
| | | validatePlanCanModify(id); |
| | | planMapper.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public MesProAlternativePlanDO getPlan(Long id) { |
| | | return planMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<MesProAlternativePlanDO> getPlanPage(MesProAlternativePlanPageReqVO pageReqVO) { |
| | | return planMapper.selectPage(pageReqVO); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void publishPlan(Long id) { |
| | | MesProAlternativePlanDO plan = validatePlanExists(id); |
| | | if (!Objects.equals(plan.getStatus(), STATUS_DRAFT)) { |
| | | throw exception(MES_PRO_ALTERNATIVE_PLAN_NOT_PREPARE); |
| | | } |
| | | planMapper.updateById(new MesProAlternativePlanDO().setId(id).setStatus(STATUS_PUBLISHED)); |
| | | } |
| | | |
| | | private String generateCode() { |
| | | return "TD" + DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss") |
| | | + String.format("%03d", (int) (Math.random() * 1000)); |
| | | } |
| | | |
| | | private MesProAlternativePlanDO validatePlanExists(Long id) { |
| | | MesProAlternativePlanDO plan = planMapper.selectById(id); |
| | | if (plan == null) { |
| | | throw exception(MES_PRO_ALTERNATIVE_PLAN_NOT_EXISTS); |
| | | } |
| | | return plan; |
| | | } |
| | | |
| | | private MesProAlternativePlanDO validatePlanCanModify(Long id) { |
| | | MesProAlternativePlanDO plan = validatePlanExists(id); |
| | | if (!Objects.equals(plan.getStatus(), STATUS_DRAFT)) { |
| | | throw exception(MES_PRO_ALTERNATIVE_PLAN_NOT_PREPARE); |
| | | } |
| | | return plan; |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.pro.maintenancecalendar; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.maintenancecalendar.MesProMaintenanceCalendarDO; |
| | | |
| | | import java.util.Collection; |
| | | |
| | | /** |
| | | * MES çµåè¿ç»´æ¥å Service æ¥å£ |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | public interface MesProMaintenanceCalendarService { |
| | | |
| | | Long createCalendar(MesProMaintenanceCalendarSaveReqVO createReqVO); |
| | | |
| | | void updateCalendar(MesProMaintenanceCalendarSaveReqVO updateReqVO); |
| | | |
| | | void deleteCalendar(Collection<Long> ids); |
| | | |
| | | MesProMaintenanceCalendarDO getCalendar(Long id); |
| | | |
| | | PageResult<MesProMaintenanceCalendarDO> getCalendarPage(MesProMaintenanceCalendarPageReqVO pageReqVO); |
| | | |
| | | void publishCalendar(Long id); |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mes.service.pro.maintenancecalendar; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | 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.pro.maintenancecalendar.vo.MesProMaintenanceCalendarPageReqVO; |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.maintenancecalendar.MesProMaintenanceCalendarDO; |
| | | import cn.iocoder.yudao.module.mes.dal.mysql.pro.maintenancecalendar.MesProMaintenanceCalendarMapper; |
| | | import jakarta.annotation.Resource; |
| | | 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.Objects; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MES_PRO_MAINTENANCE_CALENDAR_NOT_EXISTS; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MES_PRO_MAINTENANCE_CALENDAR_NOT_PREPARE; |
| | | |
| | | /** |
| | | * MES çµåè¿ç»´æ¥å Service å®ç°ç±» |
| | | * |
| | | * @author xiaoyi |
| | | */ |
| | | @Service |
| | | @Validated |
| | | public class MesProMaintenanceCalendarServiceImpl implements MesProMaintenanceCalendarService { |
| | | |
| | | private static final Integer STATUS_DRAFT = 0; |
| | | private static final Integer STATUS_PUBLISHED = 10; |
| | | |
| | | @Resource |
| | | private MesProMaintenanceCalendarMapper calendarMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createCalendar(MesProMaintenanceCalendarSaveReqVO createReqVO) { |
| | | MesProMaintenanceCalendarDO calendar = BeanUtils.toBean(createReqVO, MesProMaintenanceCalendarDO.class, req -> req |
| | | .setCode(generateCode()) |
| | | .setStatus(STATUS_DRAFT)); |
| | | calendarMapper.insert(calendar); |
| | | return calendar.getId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateCalendar(MesProMaintenanceCalendarSaveReqVO updateReqVO) { |
| | | MesProMaintenanceCalendarDO oldCalendar = validateCalendarCanModify(updateReqVO.getId()); |
| | | MesProMaintenanceCalendarDO updateObj = BeanUtils.toBean(updateReqVO, MesProMaintenanceCalendarDO.class, req -> req |
| | | .setCode(oldCalendar.getCode()) |
| | | .setStatus(oldCalendar.getStatus())); |
| | | calendarMapper.updateById(updateObj); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteCalendar(Collection<Long> ids) { |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | for (Long id : ids) { |
| | | validateCalendarCanModify(id); |
| | | calendarMapper.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public MesProMaintenanceCalendarDO getCalendar(Long id) { |
| | | return calendarMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public PageResult<MesProMaintenanceCalendarDO> getCalendarPage(MesProMaintenanceCalendarPageReqVO pageReqVO) { |
| | | return calendarMapper.selectPage(pageReqVO); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void publishCalendar(Long id) { |
| | | MesProMaintenanceCalendarDO calendar = validateCalendarExists(id); |
| | | if (!Objects.equals(calendar.getStatus(), STATUS_DRAFT)) { |
| | | throw exception(MES_PRO_MAINTENANCE_CALENDAR_NOT_PREPARE); |
| | | } |
| | | calendarMapper.updateById(new MesProMaintenanceCalendarDO().setId(id).setStatus(STATUS_PUBLISHED)); |
| | | } |
| | | |
| | | private String generateCode() { |
| | | return "RL" + DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmss") |
| | | + String.format("%03d", (int) (Math.random() * 1000)); |
| | | } |
| | | |
| | | private MesProMaintenanceCalendarDO validateCalendarExists(Long id) { |
| | | MesProMaintenanceCalendarDO calendar = calendarMapper.selectById(id); |
| | | if (calendar == null) { |
| | | throw exception(MES_PRO_MAINTENANCE_CALENDAR_NOT_EXISTS); |
| | | } |
| | | return calendar; |
| | | } |
| | | |
| | | private MesProMaintenanceCalendarDO validateCalendarCanModify(Long id) { |
| | | MesProMaintenanceCalendarDO calendar = validateCalendarExists(id); |
| | | if (!Objects.equals(calendar.getStatus(), STATUS_DRAFT)) { |
| | | throw exception(MES_PRO_MAINTENANCE_CALENDAR_NOT_PREPARE); |
| | | } |
| | | return calendar; |
| | | } |
| | | |
| | | } |