guoyuji
2024-08-28 1ba66049a45dc180940be8da94d125f36205ae39
提交报工时接口数据错误不保存在数据库,重新进行回滚问题
2个文件已修改
18 ■■■■■ 已修改文件
north-glass-erp/src/main/java/com/example/erp/controller/pp/ReportingWorkController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportingWorkService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/controller/pp/ReportingWorkController.java
@@ -144,7 +144,13 @@
    @ApiOperation("mes报工接口")
    @PostMapping  ("/mesReportingWork")
    public Result mesReportingWork(@RequestBody Map<String,Object> reportingWork){
        return Result.seccess(reportingWorkService.mesReportingWorkSv(reportingWork));
        Boolean aBoolean = reportingWorkService.mesReportingWorkSv(reportingWork);
        if(aBoolean){
            return Result.seccess(reportingWorkService.mesReportingWorkSv(reportingWork));
        }else{
            throw new ServiceException(Constants.Code_600, "上工序已完工数量小于本工序报工数量,请检查");
        }
    }
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportingWorkService.java
@@ -617,7 +617,7 @@
        String count=reportingWorkMapper.getPatchConditionMp(reportingWorkId);
        return count;
    }
    @Transactional(rollbackFor = Exception.class , noRollbackFor = Error.class)
    @Transactional(rollbackFor = Exception.class , noRollbackFor = ServiceException.class)
    public Boolean mesReportingWorkSv(Map<String,Object> reportingWorkMap) {
        //设置回滚点
        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
@@ -635,8 +635,7 @@
            );
            //判断是否大于当前数量并且抛出异常
            if (processNum < (reportingWorkDetail.getBreakageQuantity() + reportingWorkDetail.getCompletedQuantity())) {
                TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
                throw new ServiceException(Constants.Code_600, "上工序已完工数量小于本工序报工数量,请检查");
                return false;
            }
@@ -677,11 +676,10 @@
            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
            //将异常传入数据库
            SysError sysError = new SysError();
            sysError.setError(e +"\n"+Arrays.toString(e.getStackTrace()));
            sysError.setError(e +Arrays.toString(e.getStackTrace()));
            sysError.setFunc("saveOrder");
            sysErrorService.insert(sysError);
            //throw new ServiceException(Constants.Code_500, "数据请求异常,请检查");
            throw new Error();
            throw new ServiceException(Constants.Code_500, "数据请求异常,请检查");
        }
    }