This commit is contained in:
mashuai 2025-02-27 15:37:11 +08:00
parent 5c481ee8b4
commit 11d3ac48c4
1 changed files with 37 additions and 1 deletions

View File

@ -710,7 +710,43 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
@Override
public AjaxResult delete(ScrapApplyDetails scrapApplyDetails) {
try {
int result = scrapApplyDetailsMapper.delete(scrapApplyDetails);
int result = 0;
// 先根据taskId进行查询
List<ScrapApplyDetails> list = scrapApplyDetailsMapper.getDetailsList(scrapApplyDetails);
// 恢复设备库存及设备状态
for (ScrapApplyDetails details : list) {
result = scrapApplyDetailsMapper.updateStorageNumAdd(details);
if (result == 0) {
return AjaxResult.error("库存回滚失败");
}
if (StringUtils.isNotBlank(details.getMaIds())) {
String[] maIds = details.getMaIds().split(",");
// 转换为long类型
for (String maId : maIds) {
Long maIdLong = Long.parseLong(maId);
// 更新设备状态
ScrapApplyDetails applyDetails = new ScrapApplyDetails();
applyDetails.setMaId(maIdLong);
applyDetails.setStatus(MaMachineStatusEnum.IN_STORE.getStatus().toString());
scrapApplyDetailsMapper.updateMaStatus(applyDetails);
}
}
}
result = scrapApplyDetailsMapper.delete(scrapApplyDetails);
if (result == 0) {
return AjaxResult.error("删除主任务失败");
}
// 删除任务表
result = taskMapper.deleteTmTaskByTaskId(scrapApplyDetails.getTaskId());
if (result == 0) {
return AjaxResult.error("删除任务信息失败");
}
// 删除文件信息
BmFileInfo fileInfo = new BmFileInfo();
fileInfo.setTaskType(TmTaskTypeEnum.TM_TASK_PART_SCRAP.getTaskTypeId());
fileInfo.setFileType(6L);
fileInfo.setTaskId(scrapApplyDetails.getTaskId());
result += fileInfoMapper.deleteBmFileInfoByBizInfo(fileInfo);
if (result > 0) {
return AjaxResult.success("删除成功");
}