体检移动端
This commit is contained in:
+195
@@ -0,0 +1,195 @@
|
||||
package com.budwk.app.zhgh.dayofficework.healthCheckup.h5controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.BaseService;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupCampus;
|
||||
import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupProject;
|
||||
import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupUserSelection;
|
||||
import com.budwk.app.zhgh.dayofficework.healthCheckup.service.HealthCheckupProjectService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
import org.nutz.trans.Trans;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author : hongqiwei
|
||||
* @description :
|
||||
* @createDate : 2025/9/11 14:31
|
||||
*/
|
||||
|
||||
@IocBean
|
||||
@Ok("json:full")
|
||||
@At("/platform/healthCheckup/h5")
|
||||
public class H5HealthCheckupController {
|
||||
|
||||
@Inject
|
||||
private BaseService baseService;
|
||||
|
||||
@Inject
|
||||
private HealthCheckupProjectService healthCheckupProjectService;
|
||||
|
||||
@At("/list")
|
||||
@Ok("beetl:/platform/zhghh5/dayofficework/healthCheckup/list/index.html")
|
||||
@SaCheckPermission("h5.healthCheckup.list")
|
||||
public void list() {
|
||||
}
|
||||
|
||||
@At("/mine")
|
||||
@Ok("beetl:/platform/zhghh5/dayofficework/healthCheckup/mine/index.html")
|
||||
@SaCheckPermission("h5.healthCheckup.mine")
|
||||
public void mine() {
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@ApiOperation("获取项目列表")
|
||||
@SaCheckPermission(value = {"h5.healthCheckup.list", "h5.healthCheckup.mine"}, mode = SaMode.OR)
|
||||
public Object pageData(PageForm pageForm,
|
||||
String status,
|
||||
String name) {
|
||||
Sql sql = Sqls.create("""
|
||||
select
|
||||
*,
|
||||
(select count(*) from health_checkup_user_selection s where s.projectId=p.id and s.selectUserId=@userId) as selectCount
|
||||
from
|
||||
health_checkup_project p
|
||||
$condition
|
||||
""");
|
||||
sql.setParam("userId", SecurityUtil.getUserId());
|
||||
Cnd cnd = Cnd.NEW();
|
||||
// 根据 status 参数筛选进行中或已结束的项目
|
||||
if ("ongoing".equals(status)) {
|
||||
// 进行中的项目:结束时间大于等于当前时间
|
||||
cnd.and("p.choiceTimeEnd", ">=", DateUtil.now());
|
||||
} else if ("finished".equals(status)) {
|
||||
// 已结束的项目:结束时间小于当前时间
|
||||
cnd.and("p.choiceTimeEnd", "<", DateUtil.now());
|
||||
}
|
||||
|
||||
// 只有当name参数不为空时才添加名称查询条件
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
cnd.and("p.name", "like", "%" + name + "%");
|
||||
}
|
||||
cnd.asc("selectCount");
|
||||
sql.setCondition(cnd);
|
||||
return Result.success(healthCheckupProjectService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql));
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission(value = {"h5.healthCheckup.list", "h5.healthCheckup.mine"}, mode = SaMode.OR)
|
||||
public Object mineData(PageForm pageForm, String status) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
us.*,
|
||||
p.name,
|
||||
p.choiceTimeStart,
|
||||
p.choiceTimeEnd,
|
||||
p.cover
|
||||
FROM
|
||||
health_checkup_user_selection us
|
||||
LEFT JOIN health_checkup_project p ON us.projectId = p.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("us.selectUserId", "=", SecurityUtil.getUserId());
|
||||
// 根据 status 参数筛选进行中或已结束的项目
|
||||
if ("ongoing".equals(status)) {
|
||||
// 进行中的项目:结束时间大于等于当前时间
|
||||
cnd.and("p.choiceTimeEnd", ">=", DateUtil.now());
|
||||
} else if ("finished".equals(status)) {
|
||||
// 已结束的项目:结束时间小于当前时间
|
||||
cnd.and("p.choiceTimeEnd", "<", DateUtil.now());
|
||||
}
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission(value = {"h5.healthCheckup.list", "h5.healthCheckup.mine"}, mode = SaMode.OR)
|
||||
public Result doSubmit(@Param("userSelection") HealthCheckupUserSelection userSelection) {
|
||||
if (StrUtil.isNotBlank(userSelection.getId())) {
|
||||
baseService.dao().clearLinks(userSelection, "companionList");
|
||||
baseService.dao().delete(HealthCheckupUserSelection.class, userSelection.getId());
|
||||
userSelection.setId(null);
|
||||
}
|
||||
userSelection.setSelectUserId(SecurityUtil.getUserId());
|
||||
userSelection.setSelectTime(new Date());
|
||||
baseService.dao().insertWith(userSelection, "companionList");
|
||||
return Result.success("提交成功");
|
||||
}
|
||||
|
||||
@At
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
@SaCheckPermission(value = {"h5.healthCheckup.list", "h5.healthCheckup.mine"}, mode = SaMode.OR)
|
||||
public Result cancel(String id, String projectId) {
|
||||
HealthCheckupProject checkupProject = baseService.dao().fetch(HealthCheckupProject.class, projectId);
|
||||
if (DateUtil.compare(new Date(), checkupProject.getChoiceTimeEnd()) > 0) {
|
||||
return Result.error("抱歉,当前时间已经不能取消");
|
||||
}
|
||||
HealthCheckupUserSelection userSelection = baseService.dao().fetch(HealthCheckupUserSelection.class, id);
|
||||
baseService.dao().clearLinks(userSelection, "companionList");
|
||||
baseService.dao().delete(HealthCheckupUserSelection.class, userSelection.getId());
|
||||
return Result.success("取消成功");
|
||||
}
|
||||
|
||||
|
||||
@At
|
||||
@SaCheckPermission(value = {"h5.healthCheckup.list", "h5.healthCheckup.mine"}, mode = SaMode.OR)
|
||||
public Object getCampus() {
|
||||
return Result.success(baseService.dao().query(HealthCheckupCampus.class, Cnd.NEW().asc("campusCode")));
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission(value = {"h5.healthCheckup.list", "h5.healthCheckup.mine"}, mode = SaMode.OR)
|
||||
public Object selectInfo(String projectId) {
|
||||
HealthCheckupUserSelection userSelection = healthCheckupProjectService.dao().fetch(HealthCheckupUserSelection.class,
|
||||
Cnd.where("projectId", "=", projectId).and("selectUserId", "=", SecurityUtil.getUserId()));
|
||||
if (userSelection != null) {
|
||||
baseService.dao().fetchLinks(userSelection, "companionList");
|
||||
NutMap nutMap = Lang.obj2map(userSelection, NutMap.class);
|
||||
if (userSelection.getCompanionList().size() > 0) {
|
||||
nutMap.put("isFamily", "是");
|
||||
} else {
|
||||
nutMap.put("isFamily", "否");
|
||||
}
|
||||
return Result.success(nutMap);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
// @At
|
||||
// public Object validCondition(String cndId) {
|
||||
// if(StrUtil.isBlank(cndId)) {
|
||||
// return Result.success();
|
||||
// }
|
||||
// NutMap nutMap = healthCheckupProjectService.validCondition(cndId);
|
||||
// if(!nutMap.getBoolean("flag")) {
|
||||
// return Result.error("选择条件:" + nutMap.getString("msg"));
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user