体检统计报错

This commit is contained in:
2026-10-14 09:26:37 +08:00
parent 79ce184be3
commit 4c05dc8311
3 changed files with 70 additions and 36 deletions
@@ -20,6 +20,7 @@ import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.stream.Collectors;
@@ -48,7 +49,16 @@ public class HealthCheckupProjectServiceImpl extends BaseServiceImpl<HealthCheck
if (Strings.isBlank(id)){
return null;
}
HealthCheckupProject project = fetchLinks(fetch(id), "healthCheckupProjectSubjects", Cnd.NEW().asc("optionSort"));
HealthCheckupProject project = fetch(id);
// 项目可能已被删除,详情查询保持与空 ID 相同的返回约定。
if (project == null) {
return null;
}
project = fetchLinks(project, "healthCheckupProjectSubjects", Cnd.NEW().asc("optionSort"));
// 尚未配置套餐的项目仍可查看详情和统计基础人数。
if (project.getHealthCheckupProjectSubjects() == null) {
project.setHealthCheckupProjectSubjects(new ArrayList<>());
}
project.getHealthCheckupProjectSubjects().forEach(v -> {
v.setSubjectMoneys(dao().query(HealthCheckupProjectSubjectMoney.class, Cnd.where("subjectId", "=", v.getId())));
});
@@ -29,9 +29,17 @@ public class HealthCheckupSingleServiceImpl extends BaseServiceImpl<HealthChecku
@Inject
private HealthCheckupProjectService healthCheckupProjectService;
/**
* 按体检项目和可选分工会统计人数;projectId 为项目 ID,unionId 为空时统计所有工会。
* 返回 tableList 统计行、tableColumn 动态列;未指定项目或项目已删除时两者为空列表。
*/
@Override
public NutMap pageData(String projectId, String unionId) {
HealthCheckupProject project = healthCheckupProjectService.findOne(projectId);
// 无有效项目时不执行统计 SQL,避免空指针及无项目条件的查询。
if (project == null) {
return NutMap.NEW().addv("tableList", new ArrayList<>()).addv("tableColumn", new ArrayList<>());
}
Sql sql = Sqls.create("""
SELECT
su.id,
@@ -341,32 +341,42 @@ layout("/layouts/platform.html"){
this.noSelectOptionId = null
this.selectByAdminDialogVisible = true
},
async yearChange() {
const resp = await this.$axios.post("/platform/healthCheckup/project/mange/getHealthCheckupProject", {year: this.pageForm.year})
if (resp.code === 0) {
this.projectOptions = resp.data
if (resp.data && resp.data.length > 0) {
this.$set(this.pageForm, "projectId", resp.data[0].id)
} else {
this.$set(this.pageForm, "projectId", null)
yearChange() {
// 年度切换时先清理旧项目,避免无项目年度继续显示上一年度的数据。
this.$set(this.pageForm, "projectId", null)
this.$set(this, "projectOptions", [])
this.getHealthCheckupSubject()
return this.$axios.post("/platform/healthCheckup/project/mange/getHealthCheckupProject", {year: this.pageForm.year}).then((resp) => {
if (resp.code === 0) {
this.$set(this, "projectOptions", resp.data || [])
if (this.projectOptions.length > 0) {
this.$set(this.pageForm, "projectId", this.projectOptions[0].id)
}
return this.getHealthCheckupSubject()
}
await this.getHealthCheckupSubject()
} else {
this.notifyError(resp.msg)
}
})
},
async getHealthCheckupSubject() {
this.projectSubjectOptions = []
const resp = await this.$axios.post("/platform/healthCheckup/project/mange/findOne", {id: this.pageForm.projectId})
if (resp.code === 0) {
if (resp.data) {
this.projectInfo = resp.data
this.projectSubjectOptions = resp.data.healthCheckupProjectSubjects
}
} else {
this.notifyError(resp.msg)
getHealthCheckupSubject() {
this.$set(this, "projectInfo", {})
this.$set(this, "projectSubjectOptions", [])
this.$set(this, "tableData", [])
// 未选项目时只刷新空表结构,不请求项目详情或人数统计。
if (!this.pageForm.projectId) {
return this.pageData()
}
this.doSearch()
return this.$axios.post("/platform/healthCheckup/project/mange/findOne", {id: this.pageForm.projectId}).then((resp) => {
if (resp.code === 0) {
if (resp.data) {
this.$set(this, "projectInfo", resp.data)
this.$set(this, "projectSubjectOptions", resp.data.healthCheckupProjectSubjects || [])
} else {
this.$set(this.pageForm, "projectId", null)
}
return this.pageData()
}
this.notifyError(resp.msg)
})
},
async queryCampus() {
const resp = await this.$axios.post("/platform/healthCheckup/campus/queryCampus")
@@ -377,14 +387,8 @@ layout("/layouts/platform.html"){
}
},
async pageData() {
pageData() {
this.tableColumns = []
const loading = this.$loading({
lock: true,
text: '努力加载中。。。',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
this.tableColumns.push(
{prop: 'unionName', label: '所属工会'},
@@ -400,14 +404,26 @@ layout("/layouts/platform.html"){
{prop: "unselectedTeacherSum", label: "未选人数"}
)
if (!this.pageForm.projectId) {
this.tableData = []
this.$set(this, "tableData", [])
return
}
const resp = await this.$axios.post(loc() + '/pageData', this.pageForm)
if (resp.code === 0) {
this.tableData = resp.data.tableList
}
loading.close()
this.tableLoading = true
const loading = this.$loading({
lock: true,
text: '努力加载中。。。',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
return this.$axios.post(loc() + '/pageData', this.pageForm).then((resp) => {
if (resp.code === 0) {
this.$set(this, "tableData", resp.data.tableList)
}
}).finally(() => {
// 业务错误或网络异常也必须释放遮罩,保证页面可以重新查询。
this.tableLoading = false
loading.close()
})
},
pageNumberChange(val) {
this.pageFormUnion.pageNumber = val;