退料入库修改

This commit is contained in:
syruan 2026-01-06 20:27:38 +08:00
parent 03e4848b35
commit 07c15e1f2f
5 changed files with 49 additions and 21 deletions

View File

@ -1,17 +1,23 @@
package com.bonus.material.approval.strategy.impl; package com.bonus.material.approval.strategy.impl;
import com.alibaba.fastjson2.JSON; 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.domain.ApprovalInstance;
import com.bonus.material.approval.strategy.IApprovalCallback; 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.domain.ToolApplyDetailsEntity;
import com.bonus.material.toolProcess.service.ToolApplyService; import com.bonus.material.toolProcess.service.ToolApplyService;
import com.bonus.material.warehousing.domain.WarehousingEntity; import com.bonus.material.warehousing.domain.WarehousingEntity;
import com.bonus.material.warehousing.mapper.WarehousingMapper; import com.bonus.material.warehousing.mapper.WarehousingMapper;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 入库审批回调 * 入库审批回调
@ -29,38 +35,55 @@ public class WarehousingApprovalCallback implements IApprovalCallback {
@Resource @Resource
private ToolApplyService toolApplyService; private ToolApplyService toolApplyService;
@Resource
private DevMergeService devMergeService;
/** /**
* 审批通过回调 * 审批通过回调
* 执行入库业务逻辑更新入库状态更新工具申请状态等 * 执行入库业务逻辑更新入库状态更新工具申请状态更新装备状态
*/ */
@Override @Override
public void onApproved(ApprovalInstance instance) { public void onApproved(ApprovalInstance instance) {
try { try {
log.info("入库审批通过开始执行入库业务逻辑业务ID{}", instance.getBusinessId()); log.info("入库审批通过开始执行入库业务逻辑业务ID{}", instance.getBusinessId());
// 1. 获取入库ID // 1. 获取入库ID
Integer warehousingId = Integer.valueOf(instance.getBusinessId()); Integer warehousingId = Integer.valueOf(instance.getBusinessId());
// 2. 查询入库记录 // 2. 查询入库记录
WarehousingEntity entity = warehousingMapper.selectById(warehousingId); WarehousingEntity entity = warehousingMapper.selectById(warehousingId);
if (entity == null) { if (entity == null) {
log.error("入库审批通过但未找到入库记录业务ID{}", instance.getBusinessId()); log.error("入库审批通过但未找到入库记录业务ID{}", instance.getBusinessId());
throw new RuntimeException("未找到入库记录"); throw new RuntimeException("未找到入库记录");
} }
// 3. 更新入库状态为已通过状态2 // 3. 更新入库状态为已通过状态2
entity.setStatus("2"); entity.setStatus("2");
warehousingMapper.updateById(entity); warehousingMapper.updateById(entity);
// 4. 如果有关联的工具申请更新工具申请详情状态 // 4. 如果有关联的工具申请更新工具申请详情状态
if (entity.getApplyId() != null && !entity.getApplyId().isEmpty()) { if (ObjectUtils.isNotEmpty(entity.getApplyId())) {
ToolApplyDetailsEntity toolApplyDetailsEntity = new ToolApplyDetailsEntity(); ToolApplyDetailsEntity toolApplyDetailsEntity = new ToolApplyDetailsEntity();
toolApplyDetailsEntity.setApplyId(Long.valueOf(entity.getApplyId())); toolApplyDetailsEntity.setApplyId(Long.valueOf(entity.getApplyId()));
toolApplyDetailsEntity.setStatus("2"); toolApplyDetailsEntity.setStatus("2");
toolApplyService.updateAllDetail(toolApplyDetailsEntity); toolApplyService.updateAllDetail(toolApplyDetailsEntity);
log.info("入库审批通过已更新工具申请详情状态申请ID{}", entity.getApplyId()); log.info("入库审批通过已更新工具申请详情状态申请ID{}", entity.getApplyId());
} }
// 5. 如果有关联的装备订单更新装备状态
if (ObjectUtils.isNotEmpty(entity.getOrderId())) {
DevMergeVo devMergeVo = new DevMergeVo();
devMergeVo.setId(entity.getOrderId());
devMergeVo.setStatus("1");
List<String> 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()); log.info("入库审批通过业务逻辑执行成功业务ID{}", instance.getBusinessId());
} catch (Exception e) { } catch (Exception e) {
log.error("入库审批通过回调失败", e); log.error("入库审批通过回调失败", e);

View File

@ -90,15 +90,9 @@ public class BackChangeServiceImpl implements BackChangeService {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ApprovalRequired( @ApprovalRequired(businessType = "EQUIPMENT_RETURN", businessIdExpr = "#result['data']", businessDataExpr = "#csDeviceVo")
businessType = "EQUIPMENT_RETURN",
businessIdExpr = "#result['data']",
businessDataExpr = "#csDeviceVo"
)
public AjaxResult addDevDetails(BackCsDeviceVo csDeviceVo) { public AjaxResult addDevDetails(BackCsDeviceVo csDeviceVo) {
try { try {
if (csDeviceVo == null || csDeviceVo.getDevInfo() == null || CollectionUtils.isEmpty(csDeviceVo.getDevDetailsList())) { if (csDeviceVo == null || csDeviceVo.getDevInfo() == null || CollectionUtils.isEmpty(csDeviceVo.getDevDetailsList())) {
return AjaxResult.error("请选择需要添加的设备"); return AjaxResult.error("请选择需要添加的设备");
} }
@ -205,7 +199,7 @@ public class BackChangeServiceImpl implements BackChangeService {
log.error(e.getMessage()); log.error(e.getMessage());
throw new RuntimeException(e.getMessage()); throw new RuntimeException(e.getMessage());
} }
return AjaxResult.success("退库申请提交成功,等待审批", AjaxResult.class); return AjaxResult.success("退库申请提交成功,等待审批", csDeviceVo.getDevInfo().getId());
} }

View File

@ -229,9 +229,12 @@ public class DevChangeServiceImpl implements DevChangeService {
public List<CsDeviceDetails> getDevDetailsInfo(CsDeviceDetails dto) { public List<CsDeviceDetails> getDevDetailsInfo(CsDeviceDetails dto) {
try { try {
Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); 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); return mapper.getDevDetailsInfo(dto);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return new ArrayList<>(); return new ArrayList<>();

View File

@ -141,7 +141,7 @@ public class WarehousingServiceImpl implements WarehousingService {
* @return * @return
*/ */
@Override @Override
@ApprovalRequired(businessType = "EQUIPMENT_PUT", businessIdExpr = "#ids[0]", businessDataExpr = "#ids") @ApprovalRequired(businessType = "EQUIPMENT_PUT", businessIdExpr = "#result['data']", businessDataExpr = "#ids")
public AjaxResult batchSubmission(Integer[] ids) { public AjaxResult batchSubmission(Integer[] ids) {
try { try {
// 1. 空值/空数组校验提前终止无效请求 // 1. 空值/空数组校验提前终止无效请求
@ -155,10 +155,11 @@ public class WarehousingServiceImpl implements WarehousingService {
} }
} }
Integer num = mapper.batchSubmission(ids); 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) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return AjaxResult.error(); return AjaxResult.error("批量提交失败:" + e.getMessage());
} }
} }

View File

@ -413,7 +413,14 @@
AND mdi.code LIKE CONCAT('%',#{devCode},'%') AND mdi.code LIKE CONCAT('%',#{devCode},'%')
</if> </if>
<if test="companyId!=null"> <if test="companyId!=null">
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})
)
</if> </if>
<if test='devType == "2"'> <if test='devType == "2"'>
AND 1=0 AND 1=0