Browse Source

回库驳回

hyy 1 tháng trước cách đây
mục cha
commit
65ab082eb6

+ 5 - 4
yudao-module-museums/yudao-module-museums-api/src/main/java/cn/iocoder/yudao/module/museums/enums/ErrorCodeConstants.java

@@ -31,10 +31,11 @@ public class ErrorCodeConstants {
     public static final ErrorCode ONLY_PASSED_FIRST_CAN_SECOND_INSTANCE = new ErrorCode(1-016-001-010, "仅一审通过状态的标本可进行二审操作");
     public static final ErrorCode APPROVING_REJECTION_MUST_FILL_REASON = new ErrorCode(1-016-001-011, "审批驳回时必须填写驳回原因");
     public static final ErrorCode EXISTS_SPECIMEN_IS_LENDING_OUT = new ErrorCode(1-016-001-003, "存在状态为借出中的标本,无法提交出库申请");
-    public static final ErrorCode ONLY_PASSED_SECOND_INSTANCE_OUTBOUND = new ErrorCode(1-016-001-010, "仅二审通过状态的标本可确认出库");
-    public static final ErrorCode ONLY_OUTBOUND_SPECIMEN_CAN_RETURNED = new ErrorCode(1-016-001-010, "只有已出库状态的标本出库单才能进行回库操作");
-    public static final ErrorCode YOU_HAVE_CONFIRMED_THAT_SPECIMEN = new ErrorCode(1-016-001-010, "您已经确认过该标本出库");
-    public static final ErrorCode YOU_HAVE_CONFIRMED_THAT_SPECIMEN_RETURNED = new ErrorCode(1-016-001-010, "您已经确认过该标本出库");
+    public static final ErrorCode ONLY_PASSED_SECOND_INSTANCE_OUTBOUND = new ErrorCode(1-016-001-011, "仅二审通过状态的标本可确认出库");
+    public static final ErrorCode ONLY_OUTBOUND_SPECIMEN_CAN_RETURNED = new ErrorCode(1-016-001-012, "只有已出库状态的标本出库单才能进行回库操作");
+    public static final ErrorCode YOU_HAVE_CONFIRMED_THAT_SPECIMEN = new ErrorCode(1-016-001-013, "您已经确认过该标本出库");
+    public static final ErrorCode YOU_HAVE_CONFIRMED_THAT_SPECIMEN_RETURNED = new ErrorCode(1-016-001-014, "您已经确认过该标本出库");
+    public static final ErrorCode ONLY_OUTBOUND_SPECIMEN_CAN_REJECT_RETURNED = new ErrorCode(1-016-001-015, "只有已出库状态的标本出库单才能进行回库操作");
 
     // ========== 博物馆照片组 1-016-002-000 ==========
     public static final ErrorCode PHOTO_GROUP_NOT_EXISTS = new ErrorCode(1-016-002-000, "博物馆照片组记录不存在");

+ 3 - 1
yudao-module-museums/yudao-module-museums-api/src/main/java/cn/iocoder/yudao/module/museums/enums/social/LogRecordConstants.java

@@ -29,8 +29,10 @@ public interface LogRecordConstants {
     String MUSEUMS_SPECIMEN_OUTBOUND_ORDER_MODIFICATION = "修改出库单";
     String MUSEUMS_SPECIMEN_OUTBOUND_CONFIRM = "确认标本出库";
     String MUSEUMS_SPECIMEN_RETURN_SUB_TYPE = "确认标本回库";
+    String MUSEUMS_SPECIMEN_REJECT_RETURN_SUB_TYPE = "确认标本回库";
     String MUSEUMS_SPECIMEN_CREATE_OUTBOUND_SUCCESS = "成功创建标本出库单【{{#specimenOutbound.id}}】,申请人: {{#createReqVO.applicantName}},申请单位: {{#createReqVO.applicationUsage}},研究项目: {{#createReqVO.projectName}}";
-    String MUSEUMS_SPECIMEN_UPDATE_RETURN_SUCCESS = "成功更新标本回库单【{{#existingSpecimen.id}}】, 标本状况: {{#existingSpecimen.specimenCondition}}, 退还人: {{#updateReqVO.returner}}, 点收人: {{#updateReqVO.receiver}}, 备注: {{#updateReqVO.remarks}}";
+    String MUSEUMS_SPECIMEN_UPDATE_RETURN_SUCCESS = "成功更新标本回库单【{{#existingSpecimen.id}}】, 标本状况: {{#existingSpecimen.specimenCondition}}, 退还人: {{#updateReqVO.returner}}, 点收人: {{#updateReqVO.receiver}}, 备注: {{#updateReqVO.remarks}},标本成功回库";
+    String MUSEUMS_SPECIMEN_UPDATE_REJECT_RETURN_SUCCESS = "标本回库单【{{#existingSpecimen.id}}】被驳回,驳回原因: {{#returnRejectReason}}";
     String MUSEUMS_SPECIMEN_UPDATE_RECOMPILE_SUCCESS = "成功修改标本出库单【{{#updateReqVO.id}}】:{_DIFF{#updateReqVO}}";
     String MUSEUMS_SPECIMEN_CREATE_CONFIEM_OUTBOUND_SUCCESS = "{{#operatorNickname}}和{{#twoOperatorNickname}}确认了标本出库";
     String MUSEUMS_SPECIMEN_APPROVE_OUTBOUND_SUCCESS = "审批结果:{{#approvalMessage}},审批人:{{#userNickname}},审批意见:{{#processInstanceId}}{{#rejectionReasons}}";

+ 0 - 1
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/controller/admin/photogroup/PhotoGroupController.java

@@ -131,5 +131,4 @@ public class PhotoGroupController {
             throw exception(PHOTO_GROUP_UPLOAD_FAILED);
         }
     }
-
 }

+ 8 - 1
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/controller/admin/specimenoutbound/SpecimenOutboundController.java

@@ -101,7 +101,6 @@ public class SpecimenOutboundController {
         return success(true);
     }
 
-    //用于回库表单填写(完成)
     @PutMapping("/update")
     @Operation(summary = "填写标本回库单")
     @PreAuthorize("@ss.hasPermission('museums:specimen-outbound:update')")
@@ -110,6 +109,14 @@ public class SpecimenOutboundController {
         return success(true);
     }
 
+    @PutMapping("/rejectReturn")
+    @Operation(summary = "填写标本回库单")
+    @PreAuthorize("@ss.hasPermission('museums:specimen-outbound:update')")
+    public CommonResult<Boolean> rejectSpecimenOutbound(@Valid @RequestBody SpecimenOutboundRejectReturnReqVO updateReqVO) {
+        specimenOutboundService.rejectSpecimenOutbound(updateReqVO);
+        return success(true);
+    }
+
     @DeleteMapping("/delete")
     @Operation(summary = "删除标本出库回库信息")
     @Parameter(name = "id", description = "编号", required = true)

+ 18 - 0
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/controller/admin/specimenoutbound/vo/SpecimenOutboundRejectReturnReqVO.java

@@ -0,0 +1,18 @@
+package cn.iocoder.yudao.module.museums.controller.admin.specimenoutbound.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 驳回标本回库 Request VO")
+@Data
+public class SpecimenOutboundRejectReturnReqVO {
+
+    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    private Long id;
+
+    @Schema(description = "一回库确认员")
+    private String returnConfirm;
+
+    @Schema(description = "回库驳回原因")
+    private String returnRejectReason;
+}

+ 4 - 0
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/dal/dataobject/specimenoutbound/SpecimenOutboundDO.java

@@ -126,6 +126,10 @@ public class SpecimenOutboundDO extends BaseDO {
      * 二回库确认员
      */
     private Long twoReturnConfirm;
+    /**
+     * 回库驳回原因
+     */
+    private String returnRejectReason;
     /**
      * 一审时间
      */

+ 7 - 1
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/service/specimenoutbound/SpecimenOutboundService.java

@@ -32,12 +32,18 @@ public interface SpecimenOutboundService {
      */
     void updateSpecimenOutbound(@Valid SpecimenOutboundReturnReqVO updateReqVO);
 
+    /**
+     * 驳回标本回库
+     *
+     * @param updateReqVO 更新信息
+     */
+    void rejectSpecimenOutbound(@Valid SpecimenOutboundRejectReturnReqVO updateReqVO);
+
     /**
      * 确认标本出库
      *
      * @param id       编号
      * @param operator 出库员ID
-     * @return
      */
     String confirmOutbound(Long id, Long operator);
 

+ 43 - 1
yudao-module-museums/yudao-module-museums-biz/src/main/java/cn/iocoder/yudao/module/museums/service/specimenoutbound/SpecimenOutboundServiceImpl.java

@@ -369,7 +369,6 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
         }
     }
 
-
     //填写回库表单
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -433,6 +432,49 @@ public class SpecimenOutboundServiceImpl implements SpecimenOutboundService {
         }
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @LogRecord(type = MUSEUMS_SPECIMEN_TYPE, subType = MUSEUMS_SPECIMEN_REJECT_RETURN_SUB_TYPE,
+            bizNo = "{{#existingSpecimen.id}}", // 使用更新的出库单 ID
+            success = MUSEUMS_SPECIMEN_UPDATE_REJECT_RETURN_SUCCESS , extra = "{{#existingSpecimen.infoId}}") // 定义更新成功的日志消息
+    public void  rejectSpecimenOutbound(SpecimenOutboundRejectReturnReqVO updateReqVO){
+        // 校验存在
+        validateSpecimenOutboundExists(updateReqVO.getId());
+        // 获取当前标本的状态
+        SpecimenOutboundDO existingSpecimen = specimenOutboundMapper.selectById(updateReqVO.getId());
+        Long returnConfirm = existingSpecimen.getReturnConfirm();
+        // 判断状态是否为已出库(3)
+        if (existingSpecimen.getStatus() != 3) {
+            throw exception(ONLY_OUTBOUND_SPECIMEN_CAN_REJECT_RETURNED);
+        }
+        //删除第一回库确认员
+        existingSpecimen.setReturnConfirm(0L).setReturnRejectReason(updateReqVO.getReturnRejectReason());
+
+        System.out.println(existingSpecimen.getReturnConfirm()+"=============================");
+        // 更新数据库
+        specimenOutboundMapper.updateById(existingSpecimen);
+
+        // 记录日志上下文
+        LogRecordContext.putVariable("existingSpecimen", existingSpecimen);
+        LogRecordContext.putVariable("returnRejectReason", updateReqVO.getReturnRejectReason());
+
+        //发送站内信
+        String templateCode = "specimen_return_request_rejected";
+        Map<String, Object> templateParams = new HashMap<>();
+
+        // 定义格式化模板
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        // 转换 LocalDateTime 为字符串
+        String formattedDate = existingSpecimen.getUpdateTime().format(formatter);
+        templateParams.put("updateTime",formattedDate);
+        templateParams.put("returnRejectReason",updateReqVO.getReturnRejectReason());
+        templateParams.put("operator",getLoginUserNickname());
+
+        notifySendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
+                .setUserId(returnConfirm).setTemplateCode(templateCode).setTemplateParams(templateParams));
+    }
+
     @Override
     public void deleteSpecimenOutbound(Long id) {
         // 校验存在