活动场地预约-预约审核:修复多个场地管理员审核同时审核相同一页数据时,后端异常报错的问题;
This commit is contained in:
@@ -7,6 +7,7 @@ import io.v.nutz.activity.services.ActivityCommonService;
|
|||||||
import io.v.nutz.activity.services.SiteInfoService;
|
import io.v.nutz.activity.services.SiteInfoService;
|
||||||
import io.v.nutz.activity.services.SiteReserveService;
|
import io.v.nutz.activity.services.SiteReserveService;
|
||||||
import io.v.nutz.annontation.ViReturn;
|
import io.v.nutz.annontation.ViReturn;
|
||||||
|
import io.v.nutz.base.result.Result;
|
||||||
import io.v.nutz.base.utils.MsgApi;
|
import io.v.nutz.base.utils.MsgApi;
|
||||||
import io.v.nutz.base.utils.PageUtil;
|
import io.v.nutz.base.utils.PageUtil;
|
||||||
import io.v.nutz.base.utils.SendMsg;
|
import io.v.nutz.base.utils.SendMsg;
|
||||||
@@ -34,6 +35,7 @@ import org.nutz.mvc.annotation.Ok;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,14 +150,39 @@ public class SiteReviewController {
|
|||||||
|
|
||||||
@At
|
@At
|
||||||
@ViReturn
|
@ViReturn
|
||||||
public Object doReview(String[] id, Audit audit, Boolean isPass) {
|
public Object doReview(String[] id, Integer[] reserveState, Audit audit, Boolean isPass) {
|
||||||
|
if (id == null || reserveState == null || id.length == 0 || id.length != reserveState.length || isPass == null) {
|
||||||
|
return Result.error("审核参数错误,请刷新页面后重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ActivitySiteReserve> reviewList = new ArrayList<>();
|
||||||
|
List<Integer> afterStateList = new ArrayList<>();
|
||||||
|
int skippedCount = 0;
|
||||||
|
for (int i = 0; i < id.length; i++) {
|
||||||
|
ActivitySiteReserve reserve = siteReserveService.fetch(id[i]);
|
||||||
|
if (reserve == null || !Objects.equals(reserve.getReserve_state(), reserveState[i])) {
|
||||||
|
skippedCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Integer afterStateCode = activityCommonService.findAfterStateCode(reserve.getReserve_state(), isPass);
|
||||||
|
if (afterStateCode == null) {
|
||||||
|
return Result.error("当前预约已完成审核或审核流程配置异常,请刷新页面后重试");
|
||||||
|
}
|
||||||
|
reviewList.add(reserve);
|
||||||
|
afterStateList.add(afterStateCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reviewList.isEmpty()) {
|
||||||
|
return Result.success("所选预约已被其他人审核,无需重复处理")
|
||||||
|
.addData(NutMap.NEW().setv("skippedCount", skippedCount));
|
||||||
|
}
|
||||||
|
|
||||||
siteReserveService.insert(audit);
|
siteReserveService.insert(audit);
|
||||||
|
|
||||||
for (String s : id) {
|
for (int i = 0; i < reviewList.size(); i++) {
|
||||||
ActivitySiteReserve fetch = siteReserveService.fetch(s);
|
ActivitySiteReserve fetch = reviewList.get(i);
|
||||||
|
|
||||||
Integer stateCode = fetch.getReserve_state();
|
Integer stateCode = fetch.getReserve_state();
|
||||||
Integer afterStateCode = activityCommonService.findAfterStateCode(stateCode, isPass);
|
Integer afterStateCode = afterStateList.get(i);
|
||||||
|
|
||||||
List<ActivitySiteReserve> reserves = siteReserveService.query(Cnd.NEW().and("sqid", "=", fetch.getSqid()));
|
List<ActivitySiteReserve> reserves = siteReserveService.query(Cnd.NEW().and("sqid", "=", fetch.getSqid()));
|
||||||
String days = "";
|
String days = "";
|
||||||
@@ -217,6 +244,10 @@ public class SiteReviewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
if (skippedCount > 0) {
|
||||||
|
return Result.success("审核完成,成功处理" + reviewList.size() + "条,跳过" + skippedCount + "条状态已变化的预约")
|
||||||
|
.addData(NutMap.NEW().setv("skippedCount", skippedCount));
|
||||||
|
}
|
||||||
|
return Result.success("审核成功");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,22 +279,25 @@ layout("/layouts/platform.html"){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).then(async ({value}) => {
|
}).then(async ({value}) => {
|
||||||
let id = ''
|
const reviewList = type === 'one' ? [that.reserveViewData] : this.selectTable
|
||||||
if (type === 'one') {
|
|
||||||
id = JSON.stringify([that.formData.id])
|
|
||||||
} else {
|
|
||||||
id = JSON.stringify(this.selectTable.map(x => x.id))
|
|
||||||
}
|
|
||||||
$.post(location.href + "/doReview", {
|
$.post(location.href + "/doReview", {
|
||||||
id: id,
|
id: JSON.stringify(reviewList.map(x => x.id)),
|
||||||
|
reserveState: JSON.stringify(reviewList.map(x => x.reserve_state)),
|
||||||
auditOpinion: value,
|
auditOpinion: value,
|
||||||
isPass: state
|
isPass: state
|
||||||
}, (res) => {
|
}, (res) => {
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
that.$message.success(res.msg)
|
|
||||||
this.selectTable = []
|
this.selectTable = []
|
||||||
that.pageData();
|
that.pageData();
|
||||||
that.$refs.guava.index()
|
that.$refs.guava.index()
|
||||||
|
if (res.data && res.data.skippedCount > 0) {
|
||||||
|
that.$alert(res.msg, '审核提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
type: 'warning'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
that.$message.success(res.msg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, "json");
|
}, "json");
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user