diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/service/impl/ApprovalEngineServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/service/impl/ApprovalEngineServiceImpl.java index 1346ef8..a5ffd0e 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/service/impl/ApprovalEngineServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/service/impl/ApprovalEngineServiceImpl.java @@ -351,13 +351,22 @@ public class ApprovalEngineServiceImpl implements IApprovalEngineService { */ private void executeCallback(ApprovalInstance instance, String status) { try { + log.info("开始执行审批回调,业务类型:{},审批状态:{}", instance.getBusinessType(), status); + log.info("当前注册的回调处理器:{}", callbackMap.keySet()); + IApprovalCallback callback = callbackMap.get(instance.getBusinessType()); if (callback != null) { + log.info("找到回调处理器,开始执行,业务类型:{}", instance.getBusinessType()); if (ApprovalStatusEnum.APPROVED.getCode().equals(status)) { + log.info("执行审批通过回调"); callback.onApproved(instance); } else if (ApprovalStatusEnum.REJECTED.getCode().equals(status)) { + log.info("执行审批驳回回调"); callback.onRejected(instance); } + log.info("审批回调执行成功,业务类型:{}", instance.getBusinessType()); + } else { + log.warn("未找到业务类型[{}]的回调处理器", instance.getBusinessType()); } } catch (Exception e) { log.error("执行审批回调失败,实例编号:{},业务类型:{}", instance.getInstanceCode(), instance.getBusinessType(), e); 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 new file mode 100644 index 0000000..7bba296 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/approval/strategy/impl/WarehousingApprovalCallback.java @@ -0,0 +1,124 @@ +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; + +/** + * 入库审批回调 + * + * @author syruan + */ +@Component("EQUIPMENT_PUT") +public class WarehousingApprovalCallback implements IApprovalCallback { + + private static final Logger log = LoggerFactory.getLogger(WarehousingApprovalCallback.class); + + @Resource + private WarehousingMapper warehousingMapper; + + @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 (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); + throw new RuntimeException("入库审批通过回调失败:" + e.getMessage(), e); + } + } + + /** + * 审批驳回回调 + * 更新入库状态为"已驳回" + */ + @Override + public void onRejected(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. 更新入库状态为已驳回(状态3) + entity.setStatus("3"); + warehousingMapper.updateById(entity); + + log.info("入库审批驳回,业务逻辑执行成功,业务ID:{}", instance.getBusinessId()); + } catch (Exception e) { + log.error("入库审批驳回回调失败", e); + throw new RuntimeException("入库审批驳回回调失败:" + e.getMessage(), 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 a59a029..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("请选择需要添加的设备"); } @@ -608,6 +602,7 @@ public class BackChangeServiceImpl implements BackChangeService { deviceInfo.setReviewStatus("5"); deviceInfo.setCreateUser(username); deviceInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getDeptId()); + deviceInfo.setSource("0"); int result = repairMapper.addDeviceChange(deviceInfo); if (result < 1) { throw new Exception("添加任务失败"); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceInfo.java index a71c337..4c972c5 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceInfo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/CsDeviceInfo.java @@ -103,4 +103,9 @@ public class CsDeviceInfo { @ApiModelProperty(value = "所属公司id") private Long companyId; + + /** + * 来源(维修:0-退料,1-在库) + */ + private String source; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/MaDevFile.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/MaDevFile.java index 56a7cb1..49db52f 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/MaDevFile.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/devchange/domain/MaDevFile.java @@ -50,6 +50,8 @@ public class MaDevFile { */ private String fileUrl; + private String url; + /** * 创建人ID * 数据库字段:creator 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 b8510ce..b6f4969 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/device/controller/DevMergeController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevMergeController.java index 0c6324d..d9de9b2 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevMergeController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevMergeController.java @@ -213,6 +213,17 @@ public class DevMergeController extends BaseController { } } + @ApiOperation(value = "装备台账-删除增单个设备草稿") + @PostMapping("/delDeviceByMaIds") + public AjaxResult delDeviceByMaIds(@RequestBody Long[] maIds) { + try { + return toAjax(service.deleteDevInfoByMaIds(maIds)); + } catch (Exception e) { + logger.error("报错啦", e); + return AjaxResult.error("调用异常,请联系管理员"); + } + } + /** * 提交设备台账 diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java index 2433c5d..746b98e 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java @@ -325,5 +325,7 @@ public interface DevInfoMapper { DevInfoVo selectToolByMaId(Long maId); DevInfo getMaStatusByToolId(@Param("id") Long id, @Param("num") Integer num); + + int delMaApplyDetails(@Param("maIds") Long[] maIds); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevMergeService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevMergeService.java index 3eff0a8..87f1229 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevMergeService.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/DevMergeService.java @@ -88,4 +88,12 @@ public interface DevMergeService { * @return Map<装备类型名称, 特征项列表> */ Map> getAllTypePropertiesMap(); + + /** + * 批量删除设备信息 + * + * @param maIds 需要删除的设备信息主键集合 + * @return 结果 + */ + int deleteDevInfoByMaIds(Long[] maIds); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java index 7996f5d..e917a1f 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevMergeServiceImpl.java @@ -492,13 +492,45 @@ public class DevMergeServiceImpl implements DevMergeService { // 4.4 校验日期格式(若框架未自动处理,可添加) // 示例:校验productionDate是否为有效日期(根据实际需求调整) - LocalDate productionDate = item.getProductionDate().toInstant() - .atZone(ZoneId.systemDefault()).toLocalDate(); - LocalDate purchaseDate = item.getPurchaseDate().toInstant() - .atZone(ZoneId.systemDefault()).toLocalDate(); - if (productionDate.isAfter(purchaseDate)) { - rowError.append("生产日期不能晚于采购日期;"); + Date prodDate = item.getProductionDate(); + Date purDate = item.getPurchaseDate(); + + if (prodDate != null && purDate != null) { + LocalDate productionDate = prodDate.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + LocalDate purchaseDate = purDate.toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + + if (productionDate.isAfter(purchaseDate)) { + rowError.append("生产日期不能晚于采购日期;"); + } } + + //校验装备名称、规格型号、资产原值、生产厂家、下次维保日期、最大使用年限、计数单位等字段必填 + if (StringUtils.isBlank(item.getEquipmentName())){ + rowError.append("装备名称不能为空;"); + } + if (StringUtils.isBlank(item.getSpecification())){ + rowError.append("规格型号不能为空;"); + } + if (ObjectUtil.isEmpty(item.getOriginalValue())){ + rowError.append("资产原值不能为空;"); + } + if (StringUtils.isBlank(item.getManufacturer())){ + rowError.append("生产厂家不能为空;"); + } + if (item.getNextMaintenanceDate() == null) { + rowError.append("下次维保日期不能为空;"); + } + if (StringUtils.isBlank(item.getUnit())){ + rowError.append("计数单位不能为空;"); + } + if (ObjectUtil.isEmpty(item.getMaxServiceYears())){ + rowError.append("最大使用年限不能为空;"); + } + Integer typeId = devMergeMapper.getTypeId(item.getProfession()); if (ObjectUtil.isEmpty(typeId)) { rowError.append("请选择类别"); @@ -1163,6 +1195,20 @@ public class DevMergeServiceImpl implements DevMergeService { return typePropertiesMap; } + /** + * 批量删除设备信息 + * + * @param maIds 需要删除的设备信息主键 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int deleteDevInfoByMaIds(Long[] maIds) { + devInfoMapper.batchDeleteDevInfoProperties(maIds); + devInfoMapper.deleteDevInfoByMaIds(maIds); + return devInfoMapper.delMaApplyDetails(maIds); + } + private boolean isCoreFieldHasValue(EquipmentImportDTO item) { return StringUtils.hasText(item.getEquipmentName()) || StringUtils.hasText(item.getSpecification()) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java index d522f77..29dd418 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/domain/Project.java @@ -21,7 +21,7 @@ public class Project { int sequence; //工程id 主键 - private Integer id; + private String id; //工程编号 @Excel(name = "项目编号", width = 25, sort = 2) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/mapper/ProjectMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/mapper/ProjectMapper.java index df55e16..9dbec92 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/mapper/ProjectMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/project/mapper/ProjectMapper.java @@ -62,5 +62,5 @@ public interface ProjectMapper { int countByProjectCode(String proCode); - int countByProjectNameById(@Param("proName")String proName, @Param("id") Integer id); + int countByProjectNameById(@Param("proName")String proName, @Param("id") String id); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/controller/RepairController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/controller/RepairController.java index 7b49f29..a839af8 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/controller/RepairController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/controller/RepairController.java @@ -2,6 +2,7 @@ package com.bonus.material.repair.controller; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; import com.bonus.material.devchange.domain.CsDeviceInfo; import com.bonus.material.devchange.domain.CsDeviceVo; import com.bonus.material.repair.domain.ToBeRepair; @@ -33,10 +34,11 @@ public class RepairController extends BaseController { */ @ApiOperation(value = "获取待修工具和装备列表") @GetMapping("/getToBeRepairList") - public AjaxResult list(ToBeRepair bean) + public TableDataInfo list(ToBeRepair bean) { + startPage(); List list = service.getToBeRepairList(bean); - return AjaxResult.success(list); + return getDataTable(list); } /** diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/domain/ToBeRepair.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/domain/ToBeRepair.java index be77aee..6ef5505 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/domain/ToBeRepair.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/domain/ToBeRepair.java @@ -150,4 +150,9 @@ public class ToBeRepair { @ApiModelProperty(value = "是否是审核") private int isAudit; + + /** + * 来源(维修:0-退料,1-在库) + */ + private String source; } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java index 8010716..2953bc5 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/repair/service/impl/RepairServiceImpl.java @@ -458,6 +458,7 @@ public class RepairServiceImpl implements RepairService { deviceInfo.setReviewStatus("0"); deviceInfo.setCreateUser(username); deviceInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getDeptId()); + deviceInfo.setSource("1"); int result = mapper.addDeviceChange(deviceInfo); if (result < 1) { throw new Exception("添加任务失败"); diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/scrap/service/impl/ToBeScrapServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/scrap/service/impl/ToBeScrapServiceImpl.java index 3572483..d9b2169 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/scrap/service/impl/ToBeScrapServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/scrap/service/impl/ToBeScrapServiceImpl.java @@ -230,7 +230,7 @@ public class ToBeScrapServiceImpl implements ToBeScrapService { toBeScrap.setCreateUser(username); if (CollectionUtils.isNotEmpty(toBeScrap.getBmFileInfos())) { - toBeScrap.setScrapUrl(toBeScrap.getBmFileInfos().get(0).getFileUrl()); + toBeScrap.setScrapUrl(toBeScrap.getBmFileInfos().get(0).getUrl()); } int res = scrapMapper.addScrapChangeApplyDetails(toBeScrap); if (res <= 0) { diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/controller/WarehousingController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/controller/WarehousingController.java index d75c321..6ec9f47 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/controller/WarehousingController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/warehousing/controller/WarehousingController.java @@ -5,6 +5,9 @@ import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.page.TableDataInfo; import com.bonus.common.log.annotation.SysLog; import com.bonus.common.log.enums.OperaType; +import com.bonus.material.approval.domain.ApprovalInstance; +import com.bonus.material.approval.mapper.ApprovalInstanceMapper; +import com.bonus.material.approval.service.IApprovalEngineService; import com.bonus.material.warehousing.domain.WarehousingEntity; import com.bonus.material.warehousing.service.WarehousingService; import io.swagger.annotations.Api; @@ -22,6 +25,12 @@ public class WarehousingController extends BaseController { @Resource private WarehousingService service; + @Resource + private IApprovalEngineService approvalEngineService; + + @Resource + private ApprovalInstanceMapper approvalInstanceMapper; + /** * 工具类型表格 * @@ -98,25 +107,75 @@ public class WarehousingController extends BaseController { /** - * 批量提交 + * 批量审批通过 + * 通过审批引擎处理审批操作 * - * @param ids - * @return + * @param ids 入库ID列表 + * @return 审批结果 */ @PostMapping("/batchApproval/{ids}") public AjaxResult batchApproval(@PathVariable("ids") Integer[] ids) { - return service.batchApproval(ids); + try { + if (ids == null || ids.length == 0) { + return AjaxResult.error("未选择数据"); + } + + // 对每个入库ID进行审批 + for (Integer id : ids) { + // 查询该入库对应的审批实例 + ApprovalInstance instance = approvalInstanceMapper.selectInstanceByBusiness("EQUIPMENT_PUT", String.valueOf(id)); + if (instance == null) { + return AjaxResult.error("入库ID:" + id + " 对应的审批实例不存在"); + } + + // 调用审批引擎进行审批通过(1表示通过) + AjaxResult result = approvalEngineService.doApprove(instance.getId(), "1", ""); + if (!result.isSuccess()) { + return result; + } + } + + return AjaxResult.success("审批通过"); + } catch (Exception e) { + logger.error("批量审批失败", e); + return AjaxResult.error("批量审批失败:" + e.getMessage()); + } } /** - * 批量提交 + * 批量审批驳回 + * 通过审批引擎处理驳回操作 * - * @param ids - * @return + * @param ids 入库ID列表 + * @return 驳回结果 */ @PostMapping("/batchRejection/{ids}") public AjaxResult batchRejection(@PathVariable("ids") Integer[] ids) { - return service.batchRejection(ids); + try { + if (ids == null || ids.length == 0) { + return AjaxResult.error("未选择数据"); + } + + // 对每个入库ID进行驳回 + for (Integer id : ids) { + // 查询该入库对应的审批实例 + ApprovalInstance instance = approvalInstanceMapper.selectInstanceByBusiness("EQUIPMENT_PUT", String.valueOf(id)); + if (instance == null) { + return AjaxResult.error("入库ID:" + id + " 对应的审批实例不存在"); + } + + // 调用审批引擎进行驳回(2表示驳回) + AjaxResult result = approvalEngineService.doApprove(instance.getId(), "2", ""); + if (!result.isSuccess()) { + return result; + } + } + + return AjaxResult.success("审批驳回"); + } catch (Exception e) { + logger.error("批量驳回失败", e); + return AjaxResult.error("批量驳回失败:" + e.getMessage()); + } } 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 927a29b..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 @@ -2,6 +2,7 @@ package com.bonus.material.warehousing.service.Impl; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.approval.annotation.ApprovalRequired; import com.bonus.material.devchange.domain.MapBean; import com.bonus.material.device.domain.vo.DevMergeVo; import com.bonus.material.device.service.DevMergeService; @@ -120,7 +121,7 @@ public class WarehousingServiceImpl implements WarehousingService { // warehousing.setCompanyId(deptId); // } if(ADMIN_ID.equals(userId)){ - warehousing.setCompanyId(1L); + warehousing.setCompanyId(null); }else{ warehousing.setCompanyId(deptId); } @@ -128,17 +129,19 @@ public class WarehousingServiceImpl implements WarehousingService { return ObjectUtils.isNotEmpty(warehousingEntities) ? warehousingEntities : new ArrayList(); } catch (Exception e) { log.error(e.getMessage()); - return new ArrayList(); + return new ArrayList<>(); } } /** * 批量提交 + * 提交后会自动创建审批流实例 * * @param ids * @return */ @Override + @ApprovalRequired(businessType = "EQUIPMENT_PUT", businessIdExpr = "#result['data']", businessDataExpr = "#ids") public AjaxResult batchSubmission(Integer[] ids) { try { // 1. 空值/空数组校验:提前终止无效请求 @@ -152,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 251c9da..f52356d 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 @@ -272,6 +272,7 @@ WHERE is_active = 1 AND dcd.change_id = #{id} + and dcd.del_flag='0' AND dcd.real_num is NOT null @@ -327,6 +328,7 @@ WHERE dcd.change_id = #{id} and dcd.dev_type='2' + and dcd.del_flag='0' AND dcd.real_num is NOT null @@ -411,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 diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index 5d1e095..babd88f 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -698,6 +698,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{maId} + + delete from ma_apply_details where dev_id in + + #{maId} + + insert into diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/index/IndexMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/index/IndexMapper.xml index 33eb69e..47b8c34 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/index/IndexMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/index/IndexMapper.xml @@ -71,6 +71,7 @@ WHEN 'EQUIPMENT_REPAIR' THEN '设备维修' WHEN 'EQUIPMENT_RETURN' THEN '设备退库' WHEN 'EQUIPMENT_OUT' THEN '设备出库' + WHEN 'EQUIPMENT_PUT' THEN '设备入库' ELSE '未知业务类型' END AS businessName, '申请' AS statusType, @@ -93,6 +94,7 @@ WHEN 'EQUIPMENT_REPAIR' THEN '设备维修' WHEN 'EQUIPMENT_RETURN' THEN '设备退库' WHEN 'EQUIPMENT_OUT' THEN '设备出库' + WHEN 'EQUIPMENT_PUT' THEN '设备入库' ELSE '未知业务类型' END AS businessName, '审核' AS statusType, @@ -110,7 +112,7 @@