diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/strategy/impl/WarehousingApprovalCallback.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/strategy/impl/WarehousingApprovalCallback.java index 15330b2..7bba296 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/strategy/impl/WarehousingApprovalCallback.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/strategy/impl/WarehousingApprovalCallback.java @@ -1,17 +1,23 @@ package com.bonus.material.approval.strategy.impl; import com.alibaba.fastjson2.JSON; +import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.approval.domain.ApprovalInstance; import com.bonus.material.approval.strategy.IApprovalCallback; +import com.bonus.material.device.domain.vo.DevMergeVo; +import com.bonus.material.device.service.DevMergeService; import com.bonus.material.toolProcess.domain.ToolApplyDetailsEntity; import com.bonus.material.toolProcess.service.ToolApplyService; import com.bonus.material.warehousing.domain.WarehousingEntity; import com.bonus.material.warehousing.mapper.WarehousingMapper; +import org.apache.commons.lang3.ObjectUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; /** * 入库审批回调 @@ -29,38 +35,55 @@ public class WarehousingApprovalCallback implements IApprovalCallback { @Resource private ToolApplyService toolApplyService; + @Resource + private DevMergeService devMergeService; + /** * 审批通过回调 - * 执行入库业务逻辑:更新入库状态、更新工具申请状态等 + * 执行入库业务逻辑:更新入库状态、更新工具申请状态、更新装备状态等 */ @Override public void onApproved(ApprovalInstance instance) { try { log.info("入库审批通过,开始执行入库业务逻辑,业务ID:{}", instance.getBusinessId()); - + // 1. 获取入库ID Integer warehousingId = Integer.valueOf(instance.getBusinessId()); - + // 2. 查询入库记录 WarehousingEntity entity = warehousingMapper.selectById(warehousingId); if (entity == null) { log.error("入库审批通过,但未找到入库记录,业务ID:{}", instance.getBusinessId()); throw new RuntimeException("未找到入库记录"); } - + // 3. 更新入库状态为已通过(状态2) entity.setStatus("2"); warehousingMapper.updateById(entity); - + // 4. 如果有关联的工具申请,更新工具申请详情状态 - if (entity.getApplyId() != null && !entity.getApplyId().isEmpty()) { + if (ObjectUtils.isNotEmpty(entity.getApplyId())) { ToolApplyDetailsEntity toolApplyDetailsEntity = new ToolApplyDetailsEntity(); toolApplyDetailsEntity.setApplyId(Long.valueOf(entity.getApplyId())); toolApplyDetailsEntity.setStatus("2"); toolApplyService.updateAllDetail(toolApplyDetailsEntity); log.info("入库审批通过,已更新工具申请详情状态,申请ID:{}", entity.getApplyId()); } - + + // 5. 如果有关联的装备订单,更新装备状态 + if (ObjectUtils.isNotEmpty(entity.getOrderId())) { + DevMergeVo devMergeVo = new DevMergeVo(); + devMergeVo.setId(entity.getOrderId()); + devMergeVo.setStatus("1"); + List maIdsList = warehousingMapper.getMaIds(entity.getOrderId()); + String maIdsStr = maIdsList.stream() + .filter(str -> str != null && !str.trim().isEmpty()) + .collect(Collectors.joining(",")); + devMergeVo.setDevIds(maIdsStr); + devMergeService.checkDevice(devMergeVo); + log.info("入库审批通过,已更新装备状态,订单ID:{}", entity.getOrderId()); + } + log.info("入库审批通过,业务逻辑执行成功,业务ID:{}", instance.getBusinessId()); } catch (Exception e) { log.error("入库审批通过回调失败", e); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java index 69ec2fb..4215ec8 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/back/service/impl/BackChangeServiceImpl.java @@ -90,15 +90,9 @@ public class BackChangeServiceImpl implements BackChangeService { */ @Override @Transactional(rollbackFor = Exception.class) - @ApprovalRequired( - businessType = "EQUIPMENT_RETURN", - businessIdExpr = "#result['data']", - businessDataExpr = "#csDeviceVo" - ) + @ApprovalRequired(businessType = "EQUIPMENT_RETURN", businessIdExpr = "#result['data']", businessDataExpr = "#csDeviceVo") public AjaxResult addDevDetails(BackCsDeviceVo csDeviceVo) { try { - - if (csDeviceVo == null || csDeviceVo.getDevInfo() == null || CollectionUtils.isEmpty(csDeviceVo.getDevDetailsList())) { return AjaxResult.error("请选择需要添加的设备"); } @@ -205,7 +199,7 @@ public class BackChangeServiceImpl implements BackChangeService { log.error(e.getMessage()); throw new RuntimeException(e.getMessage()); } - return AjaxResult.success("退库申请提交成功,等待审批", AjaxResult.class); + return AjaxResult.success("退库申请提交成功,等待审批", csDeviceVo.getDevInfo().getId()); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java index 2e910c3..90a8f9a 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/service/DevChangeServiceImpl.java @@ -229,9 +229,12 @@ public class DevChangeServiceImpl implements DevChangeService { public List getDevDetailsInfo(CsDeviceDetails dto) { try { Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - dto.setCompanyId(thisLoginUserDeptId); + if (ADMIN_ID.equals(SecurityUtils.getLoginUser().getSysUser().getUserId())) { + dto.setCompanyId(null); + } else { + dto.setCompanyId(thisLoginUserDeptId); + } return mapper.getDevDetailsInfo(dto); - } catch (Exception e) { log.error(e.getMessage()); return new ArrayList<>(); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/service/Impl/WarehousingServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/service/Impl/WarehousingServiceImpl.java index 6a556bb..31a0e9f 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/service/Impl/WarehousingServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/service/Impl/WarehousingServiceImpl.java @@ -141,7 +141,7 @@ public class WarehousingServiceImpl implements WarehousingService { * @return */ @Override - @ApprovalRequired(businessType = "EQUIPMENT_PUT", businessIdExpr = "#ids[0]", businessDataExpr = "#ids") + @ApprovalRequired(businessType = "EQUIPMENT_PUT", businessIdExpr = "#result['data']", businessDataExpr = "#ids") public AjaxResult batchSubmission(Integer[] ids) { try { // 1. 空值/空数组校验:提前终止无效请求 @@ -155,10 +155,11 @@ public class WarehousingServiceImpl implements WarehousingService { } } Integer num = mapper.batchSubmission(ids); - return num > 0 ? AjaxResult.success() : AjaxResult.error(); + // 返回第一个ID作为业务ID(用于审批流) + return num > 0 ? AjaxResult.success("批量提交成功,等待审批", ids[0]) : AjaxResult.error("批量提交失败"); } catch (Exception e) { log.error(e.getMessage()); - return AjaxResult.error(); + return AjaxResult.error("批量提交失败:" + e.getMessage()); } } diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml index b6cd523..fde46c7 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/DevChangeMapper.xml @@ -413,7 +413,14 @@ AND mdi.code LIKE CONCAT('%',#{devCode},'%') - AND mdi.on_company = #{companyId} + AND mdi.on_company + in ( + select dept_id from sys_dept where dept_id= #{companyId} + union + select dept_id from sys_dept where parent_id= #{companyId} + union + select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id= #{companyId}) + ) AND 1=0