From 69b012a87cc224636a3093123731566e93e66c2e Mon Sep 17 00:00:00 2001 From: "@jyuhsin" <729757837@qq.com> Date: Fri, 6 Jun 2025 16:39:05 +0800 Subject: [PATCH] commit --- .../java/io/v/nutz/base/utils/MsgApi.java | 3 - .../java/io/v/nutz/sys/models/Sys_user.java | 5 + .../constant/TheRapyRecuperationType.java | 2 +- ...RapyRecuperationBaseManagerController.java | 17 +- .../TheRapyRecuperationLineController.java | 14 +- ...RecuperationLineSchoolAuditController.java | 105 + .../TheRapyRecuperationEnrollController.java | 4 +- ...RecuperationLineUnionSelectController.java | 15 +- ...heRapyRecuperationUserQueryController.java | 2 + ...heRapyRecuperationLineQueryController.java | 2 + ...erationSchoolUnionUserQueryController.java | 6 + ...erationSatisfactionEvaluateController.java | 5 +- ...apyRecuperationLineFragmentController.java | 265 ++- ...yRecuperationLineStatisticsController.java | 190 ++ .../model/TheRapyRecuperationConfig.java | 10 + .../model/TheRapyRecuperationEnroll.java | 6 + .../model/TheRapyRecuperationLine.java | 18 +- .../TheRapyRecuperationEnrollService.java | 2 +- .../TheRapyRecuperationEnrollServiceImpl.java | 1736 +++++++++-------- .../TheRapyRecuperationLineServiceImpl.java | 14 + ...pyRecuperationTravelAgencyServiceImpl.java | 2 +- .../theRapyRecuperation/LineAuditInfo.vue | 210 ++ .../theRapyRecuperation/LineInfo.vue | 185 +- .../therapyRecuperation/baseManagement.html | 2 +- .../mobile/therapyRecuperation/index.html | 8 + .../mobile/therapyRecuperation/lineInfo.html | 48 +- .../mobile/therapyRecuperation/lineList.html | 143 +- .../therapyRecuperation/myRecuperation.html | 58 +- .../baseManage/baseManagement.html | 24 +- .../theRapyRecuperation/basicManage/line.html | 160 +- .../basicManage/schoolAudit.html | 269 +++ .../theRapyRecuperation/lineQuery/index.html | 2 +- .../process/lineUnionSelect.html | 65 +- .../statistics/fragment.html | 171 +- .../statistics/lineStatistics.html | 40 +- .../statistics/signUser.js | 13 +- .../theRapyConfig/TheRapyConfig.html | 22 + src/test/java/io/v/nutz/JugTest.java | 19 +- 38 files changed, 2618 insertions(+), 1244 deletions(-) create mode 100644 src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineSchoolAuditController.java create mode 100644 src/main/resources/static/components/theRapyRecuperation/LineAuditInfo.vue create mode 100644 src/main/resources/views/platform/theRapyRecuperation/basicManage/schoolAudit.html diff --git a/src/main/java/io/v/nutz/base/utils/MsgApi.java b/src/main/java/io/v/nutz/base/utils/MsgApi.java index e22cf25..32ee7b1 100644 --- a/src/main/java/io/v/nutz/base/utils/MsgApi.java +++ b/src/main/java/io/v/nutz/base/utils/MsgApi.java @@ -28,12 +28,9 @@ import java.util.List; @Slf4j public class MsgApi { - - @Inject private RedisService redisService; - /** * @param msgTitle 消息标题 * @param msgContent 消息内容 diff --git a/src/main/java/io/v/nutz/sys/models/Sys_user.java b/src/main/java/io/v/nutz/sys/models/Sys_user.java index 33b8e94..bee3917 100644 --- a/src/main/java/io/v/nutz/sys/models/Sys_user.java +++ b/src/main/java/io/v/nutz/sys/models/Sys_user.java @@ -702,6 +702,11 @@ public class Sys_user extends BaseModel implements Serializable { @ColDefine(type = ColType.VARCHAR, width = 50) private String basicDiseaseInfo; + @Column + @Comment("备注") + @ColDefine(type = ColType.VARCHAR, width = 255) + private String remark; + /** * 前端菜单 */ diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/constant/TheRapyRecuperationType.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/constant/TheRapyRecuperationType.java index 50219ed..23c8aa5 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/constant/TheRapyRecuperationType.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/constant/TheRapyRecuperationType.java @@ -36,7 +36,7 @@ public enum TheRapyRecuperationType { /** * 酒店 */ - provinceInHotel("目的地疗休养", 3, TheRapyRecuperationProvinceType.provinceIn.getValue(), "/assets/mobile/img/therapyRecuperation/lxs.png"); + provinceInHotel("分段疗休养", 3, TheRapyRecuperationProvinceType.provinceIn.getValue(), "/assets/mobile/img/therapyRecuperation/lxs.png"); /** * 学校自由组织 diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/baseManage/TheRapyRecuperationBaseManagerController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/baseManage/TheRapyRecuperationBaseManagerController.java index 7502199..8a40952 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/baseManage/TheRapyRecuperationBaseManagerController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/baseManage/TheRapyRecuperationBaseManagerController.java @@ -230,6 +230,7 @@ public class TheRapyRecuperationBaseManagerController { return Result.error("参数错误"); } dao.delete(TheRapyRecuperationBaseManagement.class, id); + dao.clear(TheRapyRecuperationEnroll.class, Cnd.where("takePartInBaseManagementId", "=", id)); return null; } @@ -339,24 +340,10 @@ public class TheRapyRecuperationBaseManagerController { currentDate = currentDate.plusDays(1); } - Sql schoolTimeSql = Sqls.create("select schoolTime from sys_user where id=@id").setParam("id", ShiroUtil.getPlatformUid()); - String schoolTime = (String) Daos.query(dao, schoolTimeSql.toString(), Sqls.callback.str()); - String minDate = DateUtil.formatDate(config.getFragmentPlayStartTime()); - //如果入职日期在活动开始时间之后的 - try { - if (StrUtil.isNotBlank(schoolTime) - && String.valueOf(DateUtil.thisYear() - 1).equals(DateUtil.format(DateUtil.parse(schoolTime), "yyyy")) - && DateUtil.compare(DateUtil.parse(schoolTime), config.getFragmentPlayStartTime(), "MM") > 0) { - minDate = DateUtil.format(DateUtil.offset(DateUtil.parse(schoolTime), DateField.YEAR, 1), "yyyy-MM-dd"); - } - } catch (Exception e) { - e.printStackTrace(); - } - return Map.of("days", resultDates, "holidays", holidays, "lotValue", 0, - "minDate", minDate, + "minDate", DateUtil.formatDate(config.getFragmentPlayStartTime()), "maxDate", DateUtil.formatDate(config.getFragmentPlayEndTime())); } diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineController.java index d1cbdc5..061b62b 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineController.java @@ -10,6 +10,7 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.util.StrUtil; import cn.wizzer.framework.base.Result; import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.model.Audit; import io.v.nutz.base.utils.Vi; import io.v.nutz.base.query.PageForm; import io.v.nutz.sys.models.User; @@ -35,6 +36,7 @@ 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.*; import org.nutz.mvc.upload.TempFile; import org.nutz.mvc.upload.UploadAdaptor; @@ -188,7 +190,17 @@ public class TheRapyRecuperationLineController { @RequiresAuthentication public Object selectLineInfoById(String id) { Assert.notBlank(id); - return lineService.selectLineInfoById(id); + TheRapyRecuperationLine theRapyRecuperationLine = lineService.selectLineInfoById(id); + TheRapyRecuperationLot lot = dao.fetch(TheRapyRecuperationLot.class, theRapyRecuperationLine.getLotId()); + + NutMap nutMap = Lang.obj2map(theRapyRecuperationLine, NutMap.class); + nutMap.put("lotName", lot.getLotName()); + if(StrUtil.isNotBlank(theRapyRecuperationLine.getSchoolAuditId())) { + Audit audit = dao.fetch(Audit.class, theRapyRecuperationLine.getSchoolAuditId()); + nutMap.put("schoolAudit", audit); + } + + return nutMap; } diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineSchoolAuditController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineSchoolAuditController.java new file mode 100644 index 0000000..12ae271 --- /dev/null +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/basicManage/TheRapyRecuperationLineSchoolAuditController.java @@ -0,0 +1,105 @@ +package io.v.nutz.zhgh.therapyRecuperation.controller.basicManage; + +import cn.wizzer.framework.base.Result; +import cn.wizzer.framework.page.Pagination; +import io.v.nutz.base.annontation.ViReturn; +import io.v.nutz.base.model.Audit; +import io.v.nutz.base.query.PageForm; +import io.v.nutz.base.utils.Vi; +import io.v.nutz.web.commons.slog.annotation.SLog; +import io.v.nutz.web.commons.utils.ShiroUtil; +import io.v.nutz.zhgh.loveSubsidy.constant.LoveSubsidyAuditStateConstant; +import io.v.nutz.zhgh.loveSubsidy.model.LoveSubsidy; +import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationLine; +import io.v.nutz.zhgh.therapyRecuperation.service.TheRapyRecuperationLineService; +import lombok.extern.slf4j.Slf4j; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.nutz.aop.interceptor.ioc.TransAop; +import org.nutz.dao.Chain; +import org.nutz.dao.Cnd; +import org.nutz.dao.Dao; +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.mvc.annotation.At; +import org.nutz.mvc.annotation.Ok; +import org.nutz.mvc.annotation.POST; + +import java.util.List; + +/** + * @ClassName TheRapyRecuperationLineSchoolAuditController + * @Author JyuHsin + * @Date 2025/6/4 17:07 + * @Version 1.0 + * @Description TODO + */ +@IocBean +@At("/platform/theRapyRecuperation/line/schoolAudit") +@Ok("json:full") +@Slf4j +public class TheRapyRecuperationLineSchoolAuditController { + + @Inject + private TheRapyRecuperationLineService lineService; + @Inject + private Dao dao; + + @At("") + @Ok("beetl:/platform/theRapyRecuperation/basicManage/schoolAudit.html") + @RequiresPermissions("theRapyRecuperation.line.schoolAudit") + public void index() { + } + + @At + @POST + @Ok("json:full") + @ViReturn + @RequiresPermissions("theRapyRecuperation.line.schoolAudit") + public Object pageData(PageForm pageForm, Integer startYear, Integer endYear, String travelAgencyId, String lineName, String lotId, Integer isAudit) { + Sql sql = Sqls.create(""" + select + line.*, + lot.lotName, + ta.travelAgencyName, + u.username AS createUserName + from + the_rapy_recuperation_line line + LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId + LEFT JOIN the_rapy_recuperation_lot lot on lot.id = line.lotId + LEFT JOIN sys_user u ON u.id = line.opBy + $condition + """); + Cnd cnd = Cnd.NEW(); + if(isAudit == 1) { + cnd.and("line.stateId", ">", 1); + } else if(isAudit == 2) { + cnd.and("line.stateId", "=", 1); + } + cnd.andEX("line.`year`", ">=", startYear); + cnd.andEX("line.`year`", "<=", endYear); + cnd.andEX("line.travelAgencyId", "=", travelAgencyId); + cnd.andEX("line.lotId", "=", lotId); + cnd.and(Cnd.likeEX("line.lineName", lineName)); + cnd.desc("year"); + cnd.desc("regionalNature").asc("serialNumber").asc("line.opBy"); + sql.setCondition(cnd); + return lineService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); + } + + @At + @Aop(TransAop.READ_COMMITTED) + @RequiresPermissions("theRapyRecuperation.line.schoolAudit") + public Result onAudit(Audit audit, String id, Integer auditType) { + dao.insert(audit); + dao.update(TheRapyRecuperationLine.class, + Chain.make("stateId", auditType) + .add("schoolAuditId", audit.getId()), + Cnd.where("id", "=", id)); + return Result.success(); + } +} diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationEnrollController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationEnrollController.java index 391832e..c7817b9 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationEnrollController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationEnrollController.java @@ -85,8 +85,8 @@ public class TheRapyRecuperationEnrollController { @POST @ViReturn @RequiresAuthentication - public Object pageData(PageForm pageForm, Integer year, String unionId, int theRapyRecuperationType, Integer lineUnionType, String routeName, String lotId) { - return enrollService.enrollPageData(pageForm, year, unionId, theRapyRecuperationType, lineUnionType, routeName, lotId); + public Object pageData(PageForm pageForm, Integer year, String unionId, int theRapyRecuperationType, Integer lineUnionType, String routeName, String lotId, String searchKeyword, String playStartTime, String playEndTime) { + return enrollService.enrollPageData(pageForm, year, unionId, theRapyRecuperationType, lineUnionType, routeName, lotId, searchKeyword, playStartTime, playEndTime); } @At diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationLineUnionSelectController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationLineUnionSelectController.java index a880e73..e6014e7 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationLineUnionSelectController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationLineUnionSelectController.java @@ -144,6 +144,7 @@ public class TheRapyRecuperationLineUnionSelectController { } } + cnd.and("line.stateId", "=", 4); cnd.and("line.isDisabled", "=", 0); if (StrUtil.isNotBlank(keywords)) { @@ -285,17 +286,21 @@ public class TheRapyRecuperationLineUnionSelectController { try { Assert.notBlank(lineId); Assert.notBlank(unionId); -// Cnd enrollCnd = Cnd.where("takePartInUnionId", "=", unionId); -// enrollCnd.and("takePartInLineId", "=", lineId); - Cnd enrollCnd = Cnd.where("unionId", "=", unionId); + + List unionSelects = dao.query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "=", lineId)); + List list = unionSelects.stream().map(TheRapyRecuperationLineUnionSelect::getId).toList(); + + dao.clear(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "=", lineId)); + dao.clear(TheRapyRecuperationEnroll.class, Cnd.where("takePartInLineId", "in", list)); + + /*Cnd enrollCnd = Cnd.where("unionId", "=", unionId); enrollCnd.and("lineId", "=", lineId); - unionSelectService.clear(enrollCnd); + unionSelectService.clear(enrollCnd);*/ return Result.success(); } catch (Exception e) { return Result.error(e.getMessage()); } -// unionSelectService.deSelect(usId); } /** diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationUserQueryController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationUserQueryController.java index 11aa402..7a616cc 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationUserQueryController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/process/TheRapyRecuperationUserQueryController.java @@ -293,6 +293,7 @@ public class TheRapyRecuperationUserQueryController { $condition """); Cnd cnd = Cnd.NEW(); + cnd.and("rl.stateId", "=", 4); cnd.and(Cnd.exps("rlus.isOpen","=",1).or("rlus.unionId","=",Vi.getUnionId())); cnd.and("YEAR(rlus.selectTime)","=",DateUtil.thisYear()); // cnd.and("rlus.signUpMode","=",signUpMode); @@ -357,6 +358,7 @@ public class TheRapyRecuperationUserQueryController { LEFT JOIN the_rapy_recuperation_travel_agency lxs ON lxs.id = line.travelAgencyId $condition """); + cnd.and("line.stateId", "=", 4); cnd.andEX("YEAR(enroll.signingUptime)", ">=", startYear); cnd.andEX("YEAR(enroll.signingUptime)", "<=", endYear); cnd.andEX("enroll.selfUnitId", "=", unitId); diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationLineQueryController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationLineQueryController.java index 33b5580..2252205 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationLineQueryController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationLineQueryController.java @@ -59,6 +59,7 @@ public class TheRapyRecuperationLineQueryController { line.regionalNature, line.travelAgencyPlace, lineu.auditState, + lineu.estimatedCost, lineu.lineId, lineu.id as lineUId, lineu.signUpMode, @@ -90,6 +91,7 @@ public class TheRapyRecuperationLineQueryController { $condition """); Cnd cnd = Cnd.NEW(); + cnd.and("line.stateId", "=", 4); cnd.andEX("YEAR(lineu.selectTime)", ">=", startYear); cnd.andEX("YEAR(lineu.selectTime)", "<=", endYear); cnd.andEX("lineu.signUpMode", "=", signUpMode); diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationSchoolUnionUserQueryController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationSchoolUnionUserQueryController.java index c213aec..ea42f62 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationSchoolUnionUserQueryController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/query/TheRapyRecuperationSchoolUnionUserQueryController.java @@ -116,6 +116,9 @@ public class TheRapyRecuperationSchoolUnionUserQueryController { cnd.orderBy(pageForm.getPageOrderName(), pageForm.getPageOrderBy().equalsIgnoreCase("ascending") ? "ASC" : "DESC"); } + cnd.and("line.stateId", "=", 4); + cnd.and("enroll.takePartInLineId", "is not", null); + // 年度 cnd.andEX("YEAR ( enroll.signingUptime )", "=", year); if (StrUtil.isNotBlank(userName)) { @@ -259,6 +262,7 @@ public class TheRapyRecuperationSchoolUnionUserQueryController { $condition """); Cnd cnd = Cnd.NEW(); + cnd.and("t3.stateId", "=", 4); cnd.andEX("t1.selfUnionId", "=", unionId); cnd.andEX("YEAR(t2.selectTime)", "=", year); cnd.andEX("t3.regionalNature", "=", regionalNature); @@ -304,6 +308,8 @@ public class TheRapyRecuperationSchoolUnionUserQueryController { LEFT JOIN audit_state state ON state.stateId = enroll.stateId $condition """); + cnd.and("enroll.takePartInLineId", "is not", null); + cnd.and("line.stateId", "=", 4); // 年度 cnd.andEX("YEAR ( enroll.signingUptime )", "=", year); if (StrUtil.isNotBlank(userName)) { diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/satisfactionEvaluate/TheRapyRecuperationSatisfactionEvaluateController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/satisfactionEvaluate/TheRapyRecuperationSatisfactionEvaluateController.java index f7efc84..215e001 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/satisfactionEvaluate/TheRapyRecuperationSatisfactionEvaluateController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/satisfactionEvaluate/TheRapyRecuperationSatisfactionEvaluateController.java @@ -86,6 +86,7 @@ public class TheRapyRecuperationSatisfactionEvaluateController { $condition """); Cnd cnd = Cnd.NEW(); + cnd.and("t2.stateId", "=", 4); cnd.and("YEAR(t1.selectTime)", "=", year); cnd.andEX("t1.lineId", "=", lineId); sql.setCondition(cnd); @@ -136,7 +137,7 @@ public class TheRapyRecuperationSatisfactionEvaluateController { `the_rapy_recuperation_line_union_select` t1 LEFT JOIN the_rapy_recuperation_line t2 ON t2.id = t1.lineId WHERE - YEAR(selectTime) = @year + YEAR(selectTime) = @year and t2.stateId = 4 GROUP BY t1.id """); @@ -674,7 +675,7 @@ public class TheRapyRecuperationSatisfactionEvaluateController { LEFT JOIN the_rapy_recuperation_line t3 ON t3.id = t2.lineId LEFT JOIN the_rapy_recuperation_travel_agency t4 ON t4.id = t3.travelAgencyId LEFT JOIN the_rapy_recuperation_enroll t5 on t5.id = t1.enrollId - where t1.selectLineId is not null and t1.selectLineId != '' and YEAR(t1.evaluateDate) = @year + where t1.selectLineId is not null and t1.selectLineId != '' and YEAR(t1.evaluateDate) = @year and t3.stateId = 4 """); sql.setParam("year", year); List list = enrollService.listMap(sql); diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineFragmentController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineFragmentController.java index d778416..1a93389 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineFragmentController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineFragmentController.java @@ -5,10 +5,17 @@ import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import cn.wizzer.framework.base.Result; +import com.deepoove.poi.XWPFTemplate; +import com.deepoove.poi.config.Configure; +import com.deepoove.poi.policy.HackLoopTableRenderPolicy; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.query.PageForm; import io.v.nutz.base.utils.MsgApi; +import io.v.nutz.base.utils.OfficeTemplateUtil; +import io.v.nutz.web.commons.base.Globals; +import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.therapyRecuperation.constant.TheRapyRecuperationState; import io.v.nutz.zhgh.therapyRecuperation.model.*; import io.v.nutz.zhgh.therapyRecuperation.service.TheRapyRecuperationEnrollService; @@ -32,11 +39,17 @@ import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Param; import javax.servlet.http.HttpServletResponse; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * @ClassName TheRapyRecuperationLineFragmentController @@ -57,6 +70,8 @@ public class TheRapyRecuperationLineFragmentController { private MsgApi msgApi; @Inject private Dao dao; + @Inject + private OfficeTemplateUtil officeTemplateUtil; @At("") @Ok("beetl:/platform/theRapyRecuperation/statistics/fragment.html") @@ -72,13 +87,15 @@ public class TheRapyRecuperationLineFragmentController { @Param(value = "endYear", required = false) Integer endYear, @Param(value = "baseManagementId") String baseManagementId, @Param(value = "travelAgencyId") String travelAgencyId, + @Param(value = "playStart") String playStart, + @Param(value = "playEnd") String playEnd, @Param(value = "regionalNature", required = false) String regionalNature) { Sql sql = Sqls.create(""" SELECT bm.*, ta.travelAgencyName, - (select COUNT(DISTINCT specificTime) from the_rapy_recuperation_enroll where isNormal = true and takePartInBaseManagementId = bm.id) as groupCount, - (select COUNT(*) from the_rapy_recuperation_enroll where isNormal = true and takePartInBaseManagementId = bm.id) as signCount, + (select COUNT(DISTINCT specificTime, playDay) from the_rapy_recuperation_enroll where isNormal = true and takePartInBaseManagementId = bm.id $signCnd) as groupCount, + (select COUNT(*) from the_rapy_recuperation_enroll where isNormal = true and takePartInBaseManagementId = bm.id $signCnd) as signCount, u.username FROM `the_rapy_recuperation_base_management` bm @@ -86,7 +103,27 @@ public class TheRapyRecuperationLineFragmentController { left join user u on u.id = bm.opBy $condition """); + if (StrUtil.isNotBlank(playStart) && StrUtil.isNotBlank(playEnd)) { + sql.setVar("signCnd", " and REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '') >= '%s' and REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '') <= '%s'".formatted(playStart, playEnd)); + } else if (StrUtil.isNotBlank(playStart)) { + sql.setVar("signCnd", " and REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '') >= '%s'".formatted(playStart)); + } else if (StrUtil.isNotBlank(playEnd)) { + sql.setVar("signCnd", " and REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '') <= '%s'".formatted(playEnd)); + } Cnd cnd = Cnd.NEW(); + if (!ShiroUtil.hasAnyRoles("sysadmin, SchoolUnionAdmin")) { + //如果不是管理员,那么只查自己报名的酒店 + Cnd enrollCnd = Cnd.where("takePartInBaseManagementId", "is not", null) + .and("isNormal", "=", true) + .and("stateId", "=", 2750) + .and("loginName", "=", ShiroUtil.getPlatformLoginname()); + List enrolls = dao.query(TheRapyRecuperationEnroll.class, enrollCnd); + List list = enrolls.stream() + .map(TheRapyRecuperationEnroll::getTakePartInBaseManagementId) + .distinct() + .toList(); + cnd.and("bm.id", "in", list); + } cnd.andEX("bm.year", ">=", startYear); cnd.andEX("bm.year", "<=", endYear); cnd.andEX("bm.id", "=", baseManagementId); @@ -118,12 +155,17 @@ public class TheRapyRecuperationLineFragmentController { @RequiresPermissions("theRapyRecuperation.fragment") public Object getSignUser(PageForm pageForm, @Param(value = "takePartInBaseManagementId", required = false) String takePartInBaseManagementId, - @Param(value = "specificTime", required = false) String specificTime) { + @Param(value = "specificTime", required = false) String specificTime, + @Param(value = "playStart", required = false) String playStart, + @Param(value = "playEnd", required = false) String playEnd, + @Param(value = "playCount", required = false) Integer playCount) { Sql sql = Sqls.create(""" SELECT en.id, en.takePartInBaseManagementId, en.specificTime, + en.playDay, + (en.playDay * 600) as money, u.loginname, u.username, u.sex, @@ -138,6 +180,9 @@ public class TheRapyRecuperationLineFragmentController { Cnd cnd = Cnd.NEW(); cnd.and("en.takePartInBaseManagementId", "is not", null); cnd.andEX("en.specificTime", "=", specificTime); + cnd.andEX("en.playCount", "=", playCount); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", ">=", playStart); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", "<=", playEnd); cnd.andEX("en.takePartInBaseManagementId", "=", takePartInBaseManagementId); cnd.desc("en.specificTime"); sql.setCondition(cnd); @@ -148,12 +193,14 @@ public class TheRapyRecuperationLineFragmentController { @ViReturn @RequiresPermissions("theRapyRecuperation.fragment") public Object getGroupInfo(PageForm pageForm, - @Param(value = "baseId", required = false) String baseId) { - + @Param(value = "baseId", required = false) String baseId, + @Param(value = "playStart") String playStart, + @Param(value = "playEnd") String playEnd) { Sql sql = Sqls.create(""" SELECT en.takePartInBaseManagementId as id, specificTime, + en.playDay, count( specificTime ) as userCount, en.hasLocked FROM @@ -163,7 +210,9 @@ public class TheRapyRecuperationLineFragmentController { Cnd cnd = Cnd.NEW(); cnd.and("en.takePartInBaseManagementId", "=", baseId); cnd.and("en.takePartInBaseManagementId", "is not", null); - cnd.groupBy("en.specificTime"); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", ">=", playStart); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", "<=", playEnd); + cnd.groupBy("en.takePartInBaseManagementId,en.playDay,en.specificTime"); cnd.desc("en.specificTime"); sql.setCondition(cnd); return enrollService.listMap(sql); @@ -173,7 +222,7 @@ public class TheRapyRecuperationLineFragmentController { @ViReturn @Aop(TransAop.READ_COMMITTED) @RequiresPermissions("theRapyRecuperation.fragment") - public Object sendSuccess(String baseId, Boolean type) { + public Object sendSuccess(String baseId, Boolean type, String specificTime, Integer playDay) { TheRapyRecuperationConfig config = dao.fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); if (DateUtil.compare(new Date(), config.getFragmentEndTime()) < 0) { @@ -186,10 +235,12 @@ public class TheRapyRecuperationLineFragmentController { List enrolls = dao.query( TheRapyRecuperationEnroll.class, Cnd.where("takePartInBaseManagementId", "=", baseId) + .and("specificTime", "=", specificTime) + .and("playDay", "=", playDay) .and("isNormal", "=", true).and("year(signingUptime)", "=", DateUtil.thisYear()) .and("stateId", "not in", Lang.array(TheRapyRecuperationState.UNITFAIL, TheRapyRecuperationState.LINEUNITFAIL, TheRapyRecuperationState.SCHOOLFAIL))); - if(enrolls.size() < config.getFragmentCount()) { + if (enrolls.size() < config.getFragmentCount()) { return Result.error("报名人数为%s人,未达到%s人的成团条件".formatted(enrolls.size(), config.getFragmentCount())); } @@ -198,7 +249,7 @@ public class TheRapyRecuperationLineFragmentController { }); dao.update(enrolls); //发短信 - if(type) { + if (type) { enrolls.forEach(item -> { String content = "%s老师,您好!您报名的%s酒店,出行时间为%s,达到成团条件,请准时参加疗休养活动。".formatted( item.getUserName(), @@ -215,7 +266,7 @@ public class TheRapyRecuperationLineFragmentController { @ViReturn @Aop(TransAop.READ_COMMITTED) @RequiresPermissions("theRapyRecuperation.fragment") - public Object sendFail(String baseId, Boolean type) { + public Object sendFail(String baseId, Boolean type, String specificTime, Integer playDay) { TheRapyRecuperationConfig config = dao.fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); @@ -229,6 +280,8 @@ public class TheRapyRecuperationLineFragmentController { List enrolls = dao.query( TheRapyRecuperationEnroll.class, Cnd.where("takePartInBaseManagementId", "=", baseId) + .and("specificTime", "=", specificTime) + .and("playDay", "=", playDay) .and("isNormal", "=", true).and("year(signingUptime)", "=", DateUtil.thisYear()) .and("stateId", "not in", Lang.array(TheRapyRecuperationState.UNITFAIL, TheRapyRecuperationState.LINEUNITFAIL, TheRapyRecuperationState.SCHOOLFAIL))); @@ -242,7 +295,7 @@ public class TheRapyRecuperationLineFragmentController { //msgApi.sendTextMsg(content, item.getLoginName()); }); - if(!type) { + if (!type) { List enrollIds = enrolls.stream().map(TheRapyRecuperationEnroll::getId).collect(Collectors.toList()); List bedIds = enrolls.stream().map(TheRapyRecuperationEnroll::getBedInfoId).collect(Collectors.toList()); dao.clear(TheRapyRecuperationEnroll.class, Cnd.where("takePartInBaseManagementId", "=", baseId)); @@ -255,6 +308,67 @@ public class TheRapyRecuperationLineFragmentController { return null; } + @At + @ViReturn + @Aop(TransAop.READ_COMMITTED) + @RequiresPermissions("theRapyRecuperation.fragment") + public Object oneKeyGroupSuccess(String travelAgencyId, String baseId, String playStart, String playEnd, Boolean type) { + TheRapyRecuperationConfig config = dao.fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); + Integer fragmentCount = config.getFragmentCount(); + + if (DateUtil.compare(new Date(), config.getFragmentEndTime()) < 0) { + return Result.error("报名还未结束"); + } + + List managements = dao.query(TheRapyRecuperationBaseManagement.class, Cnd.NEW()); + Map baseMap = managements.stream().collect(Collectors.toMap(TheRapyRecuperationBaseManagement::getId, TheRapyRecuperationBaseManagement::getBaseName)); + Sql sql = Sqls.create(""" + SELECT + en.takePartInBaseManagementId, + en.specificTime, + en.playDay, + count( specificTime ) as userCount + FROM + the_rapy_recuperation_enroll en + LEFT JOIN the_rapy_recuperation_base_management bm ON en.takePartInBaseManagementId = bm.id + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("takePartInBaseManagementId", "is not", null); + cnd.and("isNormal", "=", true); + cnd.and("stateId", "=", 2750); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", ">=", playStart); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", "<=", playEnd); + cnd.andEX("bm.travelAgencyId", "=", travelAgencyId); + cnd.andEX("en.takePartInBaseManagementId", "=", baseId); + cnd.groupBy("en.takePartInBaseManagementId,en.playDay,en.specificTime"); + cnd.having(Cnd.where("userCount", ">=", fragmentCount)); + sql.setCondition(cnd); + List enrolls = enrollService.listMap(sql); + for (NutMap enroll : enrolls) { + List enrollList = dao.query( + TheRapyRecuperationEnroll.class, + Cnd.where("takePartInBaseManagementId", "=", enroll.getString("takePartInBaseManagementId")) + .and("playDay", "=", enroll.getString("playDay")) + .and("specificTime", "=", enroll.getString("specificTime")) + .and("isNormal", "=", true) + ); + for (TheRapyRecuperationEnroll en : enrollList) { + en.setHasLocked(true); + if (type) { + String content = "%s老师,您好!您报名的%s酒店,出行时间为%s,达到成团条件,请准时参加疗休养活动。".formatted( + en.getUserName(), + baseMap.get(en.getTakePartInBaseManagementId()), + en.getSpecificTime() + ); + //msgApi.sendTextMsg(content, item.getLoginName()); + } + } + dao.update(enrollList); + } + return null; + } + @At @Ok("void") @RequiresPermissions("theRapyRecuperation.fragment") @@ -263,13 +377,17 @@ public class TheRapyRecuperationLineFragmentController { @Param(value = "baseManagementId") String baseManagementId, @Param(value = "travelAgencyId") String travelAgencyId, @Param(value = "regionalNature", required = false) String regionalNature, + @Param(value = "playStart", required = false) String playStart, + @Param(value = "playEnd", required = false) String playEnd, HttpServletResponse response) { Sql sql = Sqls.create(""" SELECT en.*, bm.baseName, ta.travelAgencyName, - u.remark + u.remark, + (en.playDay * 600) as money, + '否' as useNextMoney FROM the_rapy_recuperation_enroll en LEFT JOIN the_rapy_recuperation_base_management bm ON bm.id = en.takePartInBaseManagementId @@ -285,31 +403,136 @@ public class TheRapyRecuperationLineFragmentController { cnd.and("en.isNormal", "=", true); cnd.and("en.stateId", "=", TheRapyRecuperationState.PASS); cnd.and("en.takePartInBaseManagementId", "is not", null); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", ">=", playStart); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", "<=", playEnd); sql.setCondition(cnd); List list = enrollService.listMap(sql); ArrayList exportEntities = new ArrayList<>(); + exportEntities.add(new ExcelExportEntity("部门", "unitName", 40)); exportEntities.add(new ExcelExportEntity("姓名", "userName", 20)); - exportEntities.add(new ExcelExportEntity("工号", "loginName", 20)); exportEntities.add(new ExcelExportEntity("性别", "sex", 10)); - exportEntities.add(new ExcelExportEntity("单位", "unitName", 20)); - exportEntities.add(new ExcelExportEntity("工会", "unionName", 20)); exportEntities.add(new ExcelExportEntity("身份证号", "idCard", 30)); exportEntities.add(new ExcelExportEntity("手机号", "mobile", 15)); - exportEntities.add(new ExcelExportEntity("酒店名称", "baseName", 20)); - exportEntities.add(new ExcelExportEntity("旅行社", "agencyName", 20)); - exportEntities.add(new ExcelExportEntity("报名时间", "signingUptime", 20)); - exportEntities.add(new ExcelExportEntity("出行时间", "specificTime", 50)); + exportEntities.add(new ExcelExportEntity("出行日期", "specificTime", 50)); + exportEntities.add(new ExcelExportEntity("出行天数", "playDay", 10)); + exportEntities.add(new ExcelExportEntity("出行地点", "baseName", 20)); exportEntities.add(new ExcelExportEntity("备注", "remark", 20)); + exportEntities.add(new ExcelExportEntity("旅行社", "travelAgencyName", 20)); + exportEntities.add(new ExcelExportEntity("费用(元)", "money", 20)); + exportEntities.add(new ExcelExportEntity("使用下一年经费", "useNextMoney", 20)); try { + ExportParams exportParams = new ExportParams(); + exportParams.setTitle("分段疗休养报名签到表"); response.setContentType("application/octet-stream"); - response.setHeader("Content-Disposition", "attachment;filename=" + new String(("报名人员.xls").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)); - Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), exportEntities, list); + response.setHeader("Content-Disposition", "attachment;filename=" + new String(("分段疗休养报名签到表.xls").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list); workbook.write(response.getOutputStream()); workbook.close(); } catch (Exception e) { e.printStackTrace(); } } + + @At + @Ok("void") + @RequiresPermissions("theRapyRecuperation.fragment") + public void exportGroup(@Param(value = "startYear", required = false) Integer startYear, + @Param(value = "endYear", required = false) Integer endYear, + @Param(value = "baseManagementId") String baseManagementId, + @Param(value = "travelAgencyId") String travelAgencyId, + @Param(value = "playStart", required = false) String playStart, + @Param(value = "playEnd", required = false) String playEnd, + HttpServletResponse response) throws IOException { + + response.setContentType("application/octet-stream"); + response.setHeader("content-disposition", "attachment;filename=" + + URLEncoder.encode("分段疗休养成团表.zip", StandardCharsets.UTF_8)); + + TheRapyRecuperationConfig rapyConfig = dao.fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); + Integer fragmentCount = rapyConfig.getFragmentCount(); + Sql sql = Sqls.create(""" + SELECT + en.takePartInBaseManagementId as baseId, + specificTime, + en.playDay, + count( specificTime ) as userCount, + en.hasLocked, + bm.baseName, + ta.travelAgencyName + FROM + the_rapy_recuperation_enroll en + left join the_rapy_recuperation_base_management bm on bm.id = en.takePartInBaseManagementId + left join the_rapy_recuperation_travel_agency ta on ta.id = bm.travelAgencyId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.andEX("en.takePartInBaseManagementId", "=", baseManagementId); + cnd.and("en.takePartInBaseManagementId", "is not", null); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", ">=", playStart); + cnd.andEX("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", "<=", playEnd); + cnd.groupBy("en.takePartInBaseManagementId,en.playDay,en.specificTime"); + cnd.having(Cnd.where("userCount", ">=", fragmentCount)); + cnd.desc("en.specificTime"); + sql.setCondition(cnd); + List listMap = enrollService.listMap(sql); + + ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream())); + for (int i = 0; i < listMap.size(); i++) { + NutMap group = listMap.get(i); + Double playDay = group.getDouble("playDay"); + Object dayCount = playDay % 1 == 0 ? String.valueOf(playDay.intValue()) : playDay; + group.put("playDay", dayCount); + Sql userSql = Sqls.create(""" + select + userName as uName, + unitName, + idCard, + mobile + from + the_rapy_recuperation_enroll + $condition + """); + Cnd userCnd = Cnd.NEW(); + userCnd.and("isNormal", "=", true); + userCnd.and("stateId", "=", 2750); + userCnd.and("hasLocked", "=", true); + userCnd.and("specificTime", "=", group.getString("specificTime")); + userCnd.and("playDay", "=", group.getString("playDay")); + userCnd.and("takePartInBaseManagementId", "=", group.getString("baseId")); + userCnd.asc("signingUptime"); + userSql.setCondition(userCnd); + List userList = enrollService.listMap(userSql); + for (int u = 0; u < userList.size(); u++) { + userList.get(u).put("index", (u + 1)); + } + + NutMap data = new NutMap(); + data.put("schoolName", Globals.schoolName); + data.put("address", group.getString("baseName")); + data.put("playTime", group.getString("specificTime")); + data.put("groupType", group.getString("playDay") + "天"); + data.put("travelName", group.getString("travelAgencyName")); + data.put("opinions", "同意"); + data.put("applyTime", DateUtil.now()); + data.put("auditTime", DateUtil.now()); + if(Lang.isNotEmpty(userList)) { + data.put("deptName", userList.get(0).getString("unitName")); + data.put("leader", userList.get(0).getString("uName")); + data.put("mobile", userList.get(0).getString("mobile")); + } + data.put("list", userList); + + HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); + Configure config = Configure.builder().bind("list", policy).build(); + + String fileName = (i + 1) + "." + group.getString("baseName") + "(" + group.getString("specificTime") + ")" + group.getString("playDay") + "天成团表.docx"; + zipOutputStream.putNextEntry(new ZipEntry(fileName)); + XWPFTemplate.compile(officeTemplateUtil.getPath("the_rapy_group"), config).render(data).write(zipOutputStream); + zipOutputStream.closeEntry(); + } + zipOutputStream.flush(); + zipOutputStream.close(); + } } diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineStatisticsController.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineStatisticsController.java index 4300eef..ff37399 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineStatisticsController.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/controller/statistics/TheRapyRecuperationLineStatisticsController.java @@ -1,18 +1,27 @@ package io.v.nutz.zhgh.therapyRecuperation.controller.statistics; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import cn.wizzer.framework.base.Result; +import com.deepoove.poi.XWPFTemplate; +import com.deepoove.poi.config.Configure; +import com.deepoove.poi.policy.HackLoopTableRenderPolicy; import io.v.nutz.base.annontation.ViReturn; import io.v.nutz.base.query.PageForm; import io.v.nutz.base.utils.MsgApi; +import io.v.nutz.base.utils.OfficeTemplateUtil; import io.v.nutz.base.utils.Vi; +import io.v.nutz.web.commons.base.Globals; import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.therapyRecuperation.constant.TheRapyRecuperationState; import io.v.nutz.zhgh.therapyRecuperation.model.*; import io.v.nutz.zhgh.therapyRecuperation.service.TheRapyRecuperationEnrollService; import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.nutz.aop.interceptor.ioc.TransAop; @@ -26,14 +35,23 @@ import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; import org.nutz.lang.Lang; import org.nutz.lang.Strings; +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 javax.servlet.http.HttpServletResponse; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * @version 1.0 @@ -54,6 +72,8 @@ public class TheRapyRecuperationLineStatisticsController { private MsgApi msgApi; @Inject private Dao dao; + @Inject + private OfficeTemplateUtil officeTemplateUtil; @At("") @Ok("beetl:/platform/theRapyRecuperation/statistics/lineStatistics.html") @@ -112,6 +132,7 @@ public class TheRapyRecuperationLineStatisticsController { $condition """); Cnd cnd = Cnd.NEW(); + cnd.and("line.stateId", "=", 4); cnd.andEX("YEAR(lineu.selectTime)", ">=", startYear); cnd.andEX("YEAR(lineu.selectTime)", "<=", endYear); cnd.andEX("lineu.signUpMode","=",signUpMode); @@ -308,4 +329,173 @@ public class TheRapyRecuperationLineStatisticsController { } return null; } + + @At + @Ok("void") + @RequiresPermissions("theRapyRecuperation.statistics") + public void doExport(@Param(value = "startYear", required = false) Integer startYear, + @Param(value = "endYear", required = false) Integer endYear, + @Param(value = "unionId", required = false) String unionId, + @Param(value = "takePartInLineId") String takePartInLineId, + @Param(value = "lotId", required = false) String lotId, + @Param(value = "selectId", required = false) String selectId, + @Param(value = "regionalNature", required = false) String regionalNature, + HttpServletResponse response) { + Sql sql = Sqls.create(""" + SELECT + enroll.*, + line.lineName, + lxs.travelAgencyName, + u.remark, + lot.activityCost as money, + lot.lotValue as playDay, + if(enroll.moneyType = 2, '是' , '否') as useNextMoney, + CONCAT(DATE_FORMAT(lineu.playStartTime, '%m月%d日'), '-', DATE_FORMAT(lineu.playEndTime, '%m月%d日')) as specificTime + FROM + `the_rapy_recuperation_enroll` enroll + LEFT JOIN the_rapy_recuperation_line_union_select lineu ON lineu.id = enroll.takePartInLineId + LEFT JOIN the_rapy_recuperation_line line ON line.id = lineu.lineId + LEFT JOIN the_rapy_recuperation_lot lot ON lot.id = line.lotId + LEFT JOIN the_rapy_recuperation_travel_agency lxs ON line.travelAgencyId = lxs.id + LEFT JOIN sys_user u on u.loginname = enroll.loginName + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("lineu.groupSuccess", "=", true); + cnd.and("line.stateId", "=", 4); + cnd.andEX("YEAR(lineu.selectTime)", ">=", startYear); + cnd.andEX("YEAR(lineu.selectTime)", "<=", endYear); + if (!ShiroUtil.hasAnyRoles("sysadmin, SchoolUnionAdmin")) { + cnd.and("lineu.selectUserId", "=", ShiroUtil.getUserId()); + } + cnd.andEX("line.lotId", "=", lotId); + cnd.andEX("line.id", "=", takePartInLineId); + cnd.andEX("lineu.id", "=", selectId); + cnd.andEX("line.regionalNature", "=", regionalNature); + cnd.asc("enroll.signingUptime"); + sql.setCondition(cnd); + + List list = enrollService.listMap(sql); + ArrayList exportEntities = new ArrayList<>(); + exportEntities.add(new ExcelExportEntity("部门", "unitName", 40)); + exportEntities.add(new ExcelExportEntity("姓名", "userName", 20)); + exportEntities.add(new ExcelExportEntity("性别", "sex", 10)); + exportEntities.add(new ExcelExportEntity("身份证号", "idCard", 30)); + exportEntities.add(new ExcelExportEntity("手机号", "mobile", 15)); + exportEntities.add(new ExcelExportEntity("出行日期", "specificTime", 50)); + exportEntities.add(new ExcelExportEntity("出行天数", "playDay", 10)); + exportEntities.add(new ExcelExportEntity("出行地点", "lineName", 20)); + exportEntities.add(new ExcelExportEntity("备注", "remark", 20)); + exportEntities.add(new ExcelExportEntity("旅行社", "travelAgencyName", 20)); + exportEntities.add(new ExcelExportEntity("费用(元)", "money", 20)); + exportEntities.add(new ExcelExportEntity("使用下一年经费", "useNextMoney", 20)); + + try { + ExportParams exportParams = new ExportParams(); + exportParams.setTitle("集中疗休养报名签到表"); + response.setContentType("application/octet-stream"); + response.setHeader("Content-Disposition", "attachment;filename=" + new String(("集中疗休养报名签到表.xls").getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1)); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, exportEntities, list); + workbook.write(response.getOutputStream()); + workbook.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @At + @Ok("void") + @RequiresPermissions("theRapyRecuperation.statistics") + public void exportGroup(@Param(value = "startYear", required = false) Integer startYear, + @Param(value = "endYear", required = false) Integer endYear, + @Param(value = "unionId", required = false) String unionId, + @Param(value = "takePartInLineId") String takePartInLineId, + @Param(value = "lotId", required = false) String lotId, + @Param(value = "selectId", required = false) String selectId, + @Param(value = "regionalNature", required = false) String regionalNature, + HttpServletResponse response) throws IOException { + response.setContentType("application/octet-stream"); + response.setHeader("content-disposition", "attachment;filename=" + + URLEncoder.encode("集中疗休养成团表.zip", StandardCharsets.UTF_8)); + + Sql sql = Sqls.create(""" + SELECT + us.id, + line.lineName, + CONCAT(DATE_FORMAT(us.playStartTime, '%m月%d日'), '-', DATE_FORMAT(us.playEndTime, '%m月%d日')) as specificTime, + IF + ( line.groupType = 1, '常规团', '精品团' ) AS groupType, + ta.travelAgencyName + FROM + the_rapy_recuperation_line_union_select us + LEFT JOIN the_rapy_recuperation_line line ON us.lineId = line.id + LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId + $condition + """); + Cnd cnd = Cnd.NEW(); + cnd.and("us.groupSuccess", "=", true); + cnd.and("line.stateId", "=", 4); + cnd.andEX("YEAR(us.selectTime)", ">=", startYear); + cnd.andEX("YEAR(us.selectTime)", "<=", endYear); + if (!ShiroUtil.hasAnyRoles("sysadmin, SchoolUnionAdmin")) { + cnd.and("us.selectUserId", "=", ShiroUtil.getUserId()); + } + cnd.andEX("line.lotId", "=", lotId); + cnd.andEX("line.id", "=", takePartInLineId); + cnd.andEX("us.id", "=", selectId); + cnd.andEX("line.regionalNature", "=", regionalNature); + sql.setCondition(cnd); + List listMap = enrollService.listMap(sql); + + ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream())); + + for (int i = 0; i < listMap.size(); i++) { + NutMap group = listMap.get(i); + Sql userSql = Sqls.create(""" + select + userName as uName, + unitName, + idCard, + mobile + from + the_rapy_recuperation_enroll + $condition + """); + Cnd userCnd = Cnd.NEW(); + userCnd.and("isNormal", "=", true); + userCnd.and("stateId", "=", 2750); + userCnd.and("takePartInLineId", "=", group.getString("id")); + userCnd.asc("signingUptime"); + userSql.setCondition(userCnd); + List userList = enrollService.listMap(userSql); + for (int u = 0; u < userList.size(); u++) { + userList.get(u).put("index", (u + 1)); + } + NutMap data = new NutMap(); + data.put("schoolName", Globals.schoolName); + data.put("address", group.getString("lineName")); + data.put("playTime", group.getString("specificTime")); + data.put("groupType", group.getString("groupType")); + data.put("travelName", group.getString("travelAgencyName")); + data.put("opinions", "同意"); + data.put("applyTime", DateUtil.now()); + data.put("auditTime", DateUtil.now()); + if(Lang.isNotEmpty(userList)) { + data.put("deptName", userList.get(0).getString("unitName")); + data.put("leader", userList.get(0).getString("uName")); + data.put("mobile", userList.get(0).getString("mobile")); + } + data.put("list", userList); + + HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); + Configure config = Configure.builder().bind("list", policy).build(); + + String fileName = (i + 1) + "." + group.getString("lineName") + "(" + group.getString("specificTime") + ")" + "成团表.docx"; + zipOutputStream.putNextEntry(new ZipEntry(fileName)); + XWPFTemplate.compile(officeTemplateUtil.getPath("the_rapy_group"), config).render(data).write(zipOutputStream); + zipOutputStream.closeEntry(); + } + zipOutputStream.flush(); + zipOutputStream.close(); + } } diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationConfig.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationConfig.java index 2bc8e13..1016d48 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationConfig.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationConfig.java @@ -130,6 +130,16 @@ public class TheRapyRecuperationConfig { @Comment("分段式最少成团人数") private Integer fragmentCount; + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("精品团创建线路开始日期") + private DateTime createLineStartTime; + + @Column + @ColDefine(type = ColType.DATETIME) + @Comment("精品团创建线路结束日期") + private DateTime createLineEndTime; + @Column @ColDefine(type = ColType.DATETIME) @Comment("集中疗休养报名开始时间") diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationEnroll.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationEnroll.java index 8ebb33b..71d4a25 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationEnroll.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationEnroll.java @@ -223,5 +223,11 @@ public class TheRapyRecuperationEnroll extends BaseModel { @Comment("报酒店时选择的出行天数") private Double playDay; + @Column + @ColDefine(type = ColType.INT) + @Comment("超出费用类型") + @Default("0") + private Integer moneyType; + private String firstLetter; } diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationLine.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationLine.java index 6561644..abefbe3 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationLine.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/model/TheRapyRecuperationLine.java @@ -161,11 +161,27 @@ public class TheRapyRecuperationLine extends BaseModel { @ColDefine(type = ColType.BOOLEAN) @Comment("开放选择") @Default("0") - private boolean openChoose; + private Boolean openChoose; + + @Column + @ColDefine(type = ColType.BOOLEAN) + @Comment("工勤特定线路") + @Default("0") + private Boolean specialLine; @Column @ColDefine(type = ColType.INT) @Comment("成团类型(1.常规团 2.精品团)") private Integer groupType; + @Column + @ColDefine(type = ColType.INT) + @Comment("审核状态(1.待校工会审核,2.校工会退回修改,3.校工会拒绝,4.审核通过)") + private Integer stateId; + + @Column + @ColDefine(type = ColType.VARCHAR, width = 32) + @Comment("校工会审核id") + private String schoolAuditId; + } diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/TheRapyRecuperationEnrollService.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/TheRapyRecuperationEnrollService.java index b0aca58..6bd45ee 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/TheRapyRecuperationEnrollService.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/TheRapyRecuperationEnrollService.java @@ -27,7 +27,7 @@ public interface TheRapyRecuperationEnrollService extends ViService getSelectLineById(String lineId, String unionId, int trrt, Integer lineUnionType); diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationEnrollServiceImpl.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationEnrollServiceImpl.java index 5caf019..10e5dde 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationEnrollServiceImpl.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationEnrollServiceImpl.java @@ -48,263 +48,293 @@ import java.util.stream.Collectors; @IocBean(args = {"refer:dao"}) public class TheRapyRecuperationEnrollServiceImpl extends ViServiceImpl implements TheRapyRecuperationEnrollService { - @Inject - private BaseService baseService; + @Inject + private BaseService baseService; - @Inject - private MsgApi msgApi; + @Inject + private MsgApi msgApi; - public TheRapyRecuperationEnrollServiceImpl(Dao dao) { - super(dao); - } + public TheRapyRecuperationEnrollServiceImpl(Dao dao) { + super(dao); + } - static Map regionTypeLineMap = new HashMap<>() {{ - put(TheRapyRecuperationType.provinceOutLine.getRegionType(), TheRapyRecuperationType.provinceOutLine); - put(TheRapyRecuperationType.provinceInLine.getRegionType(), TheRapyRecuperationType.provinceInLine); - }}; + static Map regionTypeLineMap = new HashMap<>() {{ + put(TheRapyRecuperationType.provinceOutLine.getRegionType(), TheRapyRecuperationType.provinceOutLine); + put(TheRapyRecuperationType.provinceInLine.getRegionType(), TheRapyRecuperationType.provinceInLine); + }}; - @Inject - private TheRapyRecuperationLineService lineService; + @Inject + private TheRapyRecuperationLineService lineService; - @Override - public Pagination enrollPageData(PageForm pageForm, Integer year, String unionId, int trrt, Integer lineUnionType, String routeName, String lotId) { - Cnd cnd = Cnd.NEW(); - if (List.of(TheRapyRecuperationType.provinceInLine.getValue(), TheRapyRecuperationType.provinceOutLine.getValue()).contains(trrt)) { - Sql lineSql = Sqls.create(""" - SELECT - us.id as usId, - line.id as lineId, - line.serialNumber, - line.lineName, - line.regionalNature, - line.travelAgencyPlace, - us.minimumGroupSize, - line.`year`, - us.enable, - us.signUpStartTime, - us.signUpEndTime, - us.changeEndTime, - us.playStartTime, - us.playEndTime, - us.signUpMode, - us.estimatedFamilyNumbers, - line.files, - line.files AS fileId, - usgh.unionname AS usUnionName, - usgh.id AS takePartInUnionId, - u.username AS createUserName, - ta.travelAgencyName, - ta.contact, - ta.contactMobileNumber, - lot.lotName, - lot.lotValue, - lot.activityCost as lotActivityCost, - count(us.id) as playCount, - u1.username as selectUserName, - (select count(1) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as signUpUserNum, - (select count(1) from the_rapy_recuperation_enroll_companion where trreId in (select id from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year)) as signUpUserFamilyNum, - (select ifnull(sum(familyNumber),0) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as familyNumber - FROM - `the_rapy_recuperation_line_union_select` us - LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId - LEFT JOIN the_rapy_recuperation_lot lot on lot.id = line.lotId - LEFT JOIN sys_union usgh ON usgh.id = us.unionId - LEFT JOIN user u ON u.id = line.opBy - LEFT JOIN user u1 ON u1.id = us.selectUserId - LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId - $lineCnd - group by lineId - ORDER BY lotValue desc, us.lineId, playStartTime ASC - """).setParam("year", DateUtil.thisYear()); - Cnd lineCnd = Cnd.NEW(); - lineCnd.and("line.isDisabled", "=", false); - lineCnd.and("us.enable", "=", true); - lineCnd.and("line.regionalNature", "=", TheRapyRecuperationType.typeMap.get(trrt)); - lineCnd.andEX("year(us.selectTime)", "=", year != null ? year : DateUtil.thisYear()); + @Override + public Pagination enrollPageData(PageForm pageForm, Integer year, String unionId, int trrt, Integer lineUnionType, String routeName, String lotId, String searchKeyword, String playStartTime, String playEndTime) { + Cnd cnd = Cnd.NEW(); + if (List.of(TheRapyRecuperationType.provinceInLine.getValue(), TheRapyRecuperationType.provinceOutLine.getValue()).contains(trrt)) { + Sql lineSql = Sqls.create(""" + SELECT + us.id as usId, + line.groupType, + line.id as lineId, + line.serialNumber, + line.lineName, + line.regionalNature, + line.travelAgencyPlace, + us.minimumGroupSize, + line.`year`, + us.enable, + us.signUpStartTime, + us.signUpEndTime, + us.changeEndTime, + us.playStartTime, + us.playEndTime, + us.signUpMode, + us.estimatedFamilyNumbers, + us.estimatedCost, + line.files, + line.files AS fileId, + usgh.unionname AS usUnionName, + usgh.id AS takePartInUnionId, + u.username AS createUserName, + ta.travelAgencyName, + ta.contact, + ta.contactMobileNumber, + lot.lotName, + lot.lotValue, + lot.activityCost as lotActivityCost, + count(us.id) as playCount, + u1.username as selectUserName, + (select count(1) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as signUpUserNum, + (select count(1) from the_rapy_recuperation_enroll_companion where trreId in (select id from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year)) as signUpUserFamilyNum, + (select ifnull(sum(familyNumber),0) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as familyNumber + FROM + `the_rapy_recuperation_line_union_select` us + LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId + LEFT JOIN the_rapy_recuperation_lot lot on lot.id = line.lotId + LEFT JOIN sys_union usgh ON usgh.id = us.unionId + LEFT JOIN user u ON u.id = line.opBy + LEFT JOIN user u1 ON u1.id = us.selectUserId + LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId + $lineCnd + group by lineId + ORDER BY lotValue desc, us.lineId, playStartTime ASC + """).setParam("year", DateUtil.thisYear()); + Cnd lineCnd = Cnd.NEW(); + lineCnd.and("line.stateId", "=", 4); + lineCnd.and("line.isDisabled", "=", false); + lineCnd.and("us.enable", "=", true); + lineCnd.and("line.regionalNature", "=", TheRapyRecuperationType.typeMap.get(trrt)); + lineCnd.andEX("year(us.selectTime)", "=", year != null ? year : DateUtil.thisYear()); - //本分工会的情况 - SqlExpressionGroup selfUnionGroup = new SqlExpressionGroup(); - selfUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); - selfUnionGroup.and("us.unionId", "=", unionId); - //其他分工会 - SqlExpressionGroup otherUnionGroup = new SqlExpressionGroup(); - otherUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); - otherUnionGroup.and("us.isOpen", "=", true); - otherUnionGroup.and("us.unionId", "=", unionId); - //校工会 - SqlExpressionGroup schoolUnionGroup = new SqlExpressionGroup(); - schoolUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.FREE.getValue()); - //个人组织 - SqlExpressionGroup personalGroup = new SqlExpressionGroup(); - personalGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.PERSONAL.getValue()); - //如果是个人组织,报名范围又分3种情况,fuck - SqlExpressionGroup group = new SqlExpressionGroup(); - group.or(new Static("JSON_CONTAINS(us.signScope, '3')"));//面向全校 - group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '2')")).and("u1.unionId", "=", Vi.getUnionId()));//面向本分工会 - group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '1')")).and(new Static("JSON_CONTAINS(us.chooseUserList -> \"$[*].id\", '\"%s\"')".formatted(ShiroUtil.getUserId()))));//面向自己选择的 - personalGroup.and(group); + //本分工会的情况 + SqlExpressionGroup selfUnionGroup = new SqlExpressionGroup(); + selfUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); + selfUnionGroup.and("us.unionId", "=", unionId); + //其他分工会 + SqlExpressionGroup otherUnionGroup = new SqlExpressionGroup(); + otherUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); + otherUnionGroup.and("us.isOpen", "=", true); + //校工会 + SqlExpressionGroup schoolUnionGroup = new SqlExpressionGroup(); + schoolUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.FREE.getValue()); + //个人组织 + SqlExpressionGroup personalGroup = new SqlExpressionGroup(); + personalGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.PERSONAL.getValue()); + //如果是个人组织,报名范围又分3种情况,fuck + SqlExpressionGroup group = new SqlExpressionGroup(); + group.or(new Static("JSON_CONTAINS(us.signScope, '3')"));//面向全校 + group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '2')")).and("u1.unionId", "=", Vi.getUnionId()));//面向本分工会 + group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '1')")).and(new Static("JSON_CONTAINS(us.chooseUserList -> \"$[*].id\", '\"%s\"')".formatted(ShiroUtil.getUserId()))));//面向自己选择的 + personalGroup.and(group); - if(lineUnionType != null) { - switch (lineUnionType) { - case 1 -> lineCnd.and(selfUnionGroup); - case 2 -> lineCnd.and(otherUnionGroup); - case 3 -> lineCnd.and(schoolUnionGroup); - case 4 -> lineCnd.and(personalGroup); - } - } else { - SqlExpressionGroup expressionGroup = new SqlExpressionGroup(); - expressionGroup.or(selfUnionGroup).or(otherUnionGroup).or(schoolUnionGroup).or(personalGroup); - lineCnd.and(expressionGroup); - } - lineSql.setVar("lineCnd", lineCnd); - return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), lineSql); - } else if (TheRapyRecuperationType.provinceInTravelAgency.getValue() == trrt) { - cnd.andEX("year", "=", year != null ? year : DateUtil.thisYear()); - cnd.and("isDisabled", "=", false); - Sql taSql = Sqls.create(""" - select - *, - cast(files ->> '$[0].id' as char) as fileId - from - the_rapy_recuperation_travel_agency $condition - """); - taSql.setCondition(cnd); - return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); - } else if (TheRapyRecuperationType.provinceInHotel.getValue() == trrt) { - cnd.andEX("b.year", "=", year != null ? year : DateUtil.thisYear()); - cnd.and("b.isDisabled", "=", false); - if (StrUtil.isNotBlank(routeName)) { - cnd.and(Cnd.likeEX("b.baseName", routeName)); - } - cnd.andEX("b.lotId", "=", lotId); - Sql taSql = Sqls.create(""" - select - b.*, - b.files as fileId, - l.lotName, - t.travelAgencyName, - ( SELECT COUNT( 1 ) FROM the_rapy_recuperation_enroll WHERE b.id = takePartInBaseManagementId and isNormal=true $yearCnd) agencyNum - from - the_rapy_recuperation_base_management b - left join the_rapy_recuperation_lot l on l.id = b.lotId - left join the_rapy_recuperation_travel_agency t on t.id = b.travelAgencyId - $condition - """); - if (year != null) { - taSql.setVar("yearCnd", "AND YEAR(signingUptime) = '%s' ".formatted(year)); - } - cnd.asc("sortNumber"); - taSql.setCondition(cnd); - return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); - } - return new Pagination(); - } + if (lineUnionType != null) { + switch (lineUnionType) { + case 1 -> lineCnd.and(selfUnionGroup); + case 2 -> lineCnd.and(otherUnionGroup); + case 3 -> lineCnd.and(schoolUnionGroup); + case 4 -> lineCnd.and(personalGroup); + } + } else { + SqlExpressionGroup expressionGroup = new SqlExpressionGroup(); + expressionGroup.or(selfUnionGroup).or(otherUnionGroup).or(schoolUnionGroup).or(personalGroup); + lineCnd.and(expressionGroup); + } + lineSql.setVar("lineCnd", lineCnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), lineSql); + } else if (TheRapyRecuperationType.provinceInTravelAgency.getValue() == trrt) { + cnd.andEX("year", "=", year != null ? year : DateUtil.thisYear()); + cnd.and("isDisabled", "=", false); + Sql taSql = Sqls.create(""" + select + *, + files as fileId + from + the_rapy_recuperation_travel_agency $condition + """); + taSql.setCondition(cnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); + } else if (TheRapyRecuperationType.provinceInHotel.getValue() == trrt) { + cnd.andEX("b.year", "=", year != null ? year : DateUtil.thisYear()); + cnd.and("b.isDisabled", "=", false); + if (StrUtil.isNotBlank(routeName)) { + cnd.and(Cnd.likeEX("b.baseName", routeName)); + } + cnd.andEX("b.lotId", "=", lotId); + Sql taSql = Sqls.create(""" + select + b.*, + b.files as fileId, + l.lotName, + t.travelAgencyName, + ( SELECT COUNT( 1 ) FROM the_rapy_recuperation_enroll WHERE b.id = takePartInBaseManagementId and isNormal=true $yearCnd) agencyNum + from + the_rapy_recuperation_base_management b + left join the_rapy_recuperation_lot l on l.id = b.lotId + left join the_rapy_recuperation_travel_agency t on t.id = b.travelAgencyId + $condition + """); + if (year != null) { + taSql.setVar("yearCnd", "AND YEAR(signingUptime) = '%s' ".formatted(year)); + } - @Override - public List getSelectLineById(String lineId, String unionId, int trrt, Integer lineUnionType) { - Sql lineSql = Sqls.create(""" - SELECT - us.id as usId, - line.id as lineId, - line.serialNumber, - line.lineName, - line.regionalNature, - us.minimumGroupSize, - line.`year`, - us.enable, - us.signUpStartTime, - us.signUpEndTime, - us.changeEndTime, - us.playStartTime, - us.playEndTime, - us.signUpMode, - us.estimatedFamilyNumbers, - line.files, - line.files AS fileId, - usgh.unionname AS usUnionName, - usgh.id AS takePartInUnionId, - u.username AS createUserName, - ta.travelAgencyName, - us.contact, - us.contactPhone, - lot.lotName, - lot.lotValue, - lot.activityCost as lotActivityCost, - (select count(1) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as signUpUserNum, - (select count(1) from the_rapy_recuperation_enroll_companion where trreId in (select id from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year)) as signUpUserFamilyNum, - (select ifnull(sum(familyNumber),0) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as familyNumber - FROM - `the_rapy_recuperation_line_union_select` us - LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId - LEFT JOIN the_rapy_recuperation_lot lot on lot.id = line.lotId - LEFT JOIN sys_union usgh ON usgh.id = us.unionId - LEFT JOIN sys_user u ON u.id = line.opBy - LEFT JOIN user u1 ON u1.id = us.selectUserId - LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId - $lineCnd - ORDER BY us.lineId, playStartTime ASC - """).setParam("lineId", lineId).setParam("year", DateUtil.thisYear()); - Cnd lineCnd = Cnd.NEW(); - lineCnd.and("lineId", "=", lineId); - lineCnd.and("us.enable", "=", true); - lineCnd.and("year(us.selectTime)", "=", DateUtil.thisYear()); - lineCnd.and("line.regionalNature", "=", TheRapyRecuperationType.typeMap.get(trrt)); + // 初始化基础查询条件 + Cnd enrollCnd = Cnd.where("takePartInBaseManagementId", "is not", null) + .and("isNormal", "=", true) + .and("stateId", "=", 2750); + if (StrUtil.isNotBlank(searchKeyword)) { + enrollCnd.and(Cnd.likeEX("userName", searchKeyword)); + } + // 处理时间范围 + if (StrUtil.isNotBlank(playStartTime) && StrUtil.isNotBlank(playEndTime)) { + enrollCnd.and("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", ">=", playStartTime) + .and("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", "<=", playEndTime); + } else if (StrUtil.isNotBlank(playStartTime)) { + enrollCnd.and("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", ">=", playStartTime); + } else if (StrUtil.isNotBlank(playEndTime)) { + enrollCnd.and("REPLACE(REPLACE(SUBSTRING_INDEX(specificTime, '-', 1), '月', '-'), '日', '')", "<=", playEndTime); + } + List enrolls = dao().query(TheRapyRecuperationEnroll.class, enrollCnd); + List list = enrolls.stream() + .map(TheRapyRecuperationEnroll::getTakePartInBaseManagementId) + .distinct() + .toList(); - //本分工会的情况 - SqlExpressionGroup selfUnionGroup = new SqlExpressionGroup(); - selfUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); - selfUnionGroup.and("us.unionId", "=", unionId); - //其他分工会 - SqlExpressionGroup otherUnionGroup = new SqlExpressionGroup(); - otherUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); - otherUnionGroup.and("us.isOpen", "=", true); - otherUnionGroup.and("us.unionId", "=", unionId); - //校工会 - SqlExpressionGroup schoolUnionGroup = new SqlExpressionGroup(); - schoolUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.FREE.getValue()); - //个人组织 - SqlExpressionGroup personalGroup = new SqlExpressionGroup(); - personalGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.PERSONAL.getValue()); - //如果是个人组织,报名范围又分3种情况,fuck - SqlExpressionGroup group = new SqlExpressionGroup(); - group.or(new Static("JSON_CONTAINS(us.signScope, '3')"));//面向全校 - group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '2')")).and("u1.unionId", "=", Vi.getUnionId()));//面向本分工会 - group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '1')")).and(new Static("JSON_CONTAINS(us.chooseUserList -> \"$[*].id\", '\"%s\"')".formatted(ShiroUtil.getUserId()))));//面向自己选择的 - personalGroup.and(group); + // 应用到主查询条件中 + if (StrUtil.isNotBlank(searchKeyword) || StrUtil.isNotBlank(playStartTime) || StrUtil.isNotBlank(playEndTime)) { + cnd.and("b.id", "in", list); + } - if(lineUnionType != null) { - switch (lineUnionType) { - case 1 -> lineCnd.and(selfUnionGroup); - case 2 -> lineCnd.and(otherUnionGroup); - case 3 -> lineCnd.and(schoolUnionGroup); - case 4 -> lineCnd.and(personalGroup); - } - } else { - SqlExpressionGroup expressionGroup = new SqlExpressionGroup(); - expressionGroup.or(selfUnionGroup).or(otherUnionGroup).or(schoolUnionGroup).or(personalGroup); - lineCnd.and(expressionGroup); - } - lineSql.setVar("lineCnd", lineCnd); - return (List) Daos.query(dao(), lineSql.toString(), Sqls.callback.maps()); - } + cnd.asc("sortNumber"); + taSql.setCondition(cnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); + } + return new Pagination(); + } - @Override - public Object openSignUser(String id, String type, String searchKeyWord) { - String column = ""; - switch (type) { - case "line" -> column = "takePartInLineId"; - case "travel" -> column = "takePartInTravelAgencyId"; - case "baseManagement" -> column = "takePartInBaseManagementId"; - } - List enrolls = dao().query( - TheRapyRecuperationEnroll.class, - Cnd.where(column, "=", id) - .and("isNormal", "=", true) - .and("stateId", "=", 2750) - .and(Cnd.likeEX("userName", searchKeyWord)) - .asc("baseManagement".equals(type) ? "specificTime" : "signingUptime") - ); - return enrolls; + @Override + public List getSelectLineById(String lineId, String unionId, int trrt, Integer lineUnionType) { + Sql lineSql = Sqls.create(""" + SELECT + us.id as usId, + line.id as lineId, + line.serialNumber, + line.lineName, + line.regionalNature, + us.minimumGroupSize, + line.`year`, + us.enable, + us.signUpStartTime, + us.signUpEndTime, + us.changeEndTime, + us.playStartTime, + us.playEndTime, + us.signUpMode, + us.estimatedFamilyNumbers, + line.files, + line.files AS fileId, + usgh.unionname AS usUnionName, + usgh.id AS takePartInUnionId, + u.username AS createUserName, + ta.travelAgencyName, + us.contact, + us.contactPhone, + lot.lotName, + lot.lotValue, + lot.activityCost as lotActivityCost, + (select count(1) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as signUpUserNum, + (select count(1) from the_rapy_recuperation_enroll_companion where trreId in (select id from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year)) as signUpUserFamilyNum, + (select ifnull(sum(familyNumber),0) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as familyNumber + FROM + `the_rapy_recuperation_line_union_select` us + LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId + LEFT JOIN the_rapy_recuperation_lot lot on lot.id = line.lotId + LEFT JOIN sys_union usgh ON usgh.id = us.unionId + LEFT JOIN sys_user u ON u.id = line.opBy + LEFT JOIN user u1 ON u1.id = us.selectUserId + LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId + $lineCnd + ORDER BY us.lineId, playStartTime ASC + """).setParam("lineId", lineId).setParam("year", DateUtil.thisYear()); + Cnd lineCnd = Cnd.NEW(); + lineCnd.and("lineId", "=", lineId); + lineCnd.and("us.enable", "=", true); + lineCnd.and("year(us.selectTime)", "=", DateUtil.thisYear()); + lineCnd.and("line.regionalNature", "=", TheRapyRecuperationType.typeMap.get(trrt)); + + //本分工会的情况 + SqlExpressionGroup selfUnionGroup = new SqlExpressionGroup(); + selfUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); + selfUnionGroup.and("us.unionId", "=", unionId); + //其他分工会 + SqlExpressionGroup otherUnionGroup = new SqlExpressionGroup(); + otherUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.UNION.getValue()); + otherUnionGroup.and("us.isOpen", "=", true); + otherUnionGroup.and("us.unionId", "=", unionId); + //校工会 + SqlExpressionGroup schoolUnionGroup = new SqlExpressionGroup(); + schoolUnionGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.FREE.getValue()); + //个人组织 + SqlExpressionGroup personalGroup = new SqlExpressionGroup(); + personalGroup.and("us.signUpMode", "=", TheRapyRecuperationSignUpMode.PERSONAL.getValue()); + //如果是个人组织,报名范围又分3种情况,fuck + SqlExpressionGroup group = new SqlExpressionGroup(); + group.or(new Static("JSON_CONTAINS(us.signScope, '3')"));//面向全校 + group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '2')")).and("u1.unionId", "=", Vi.getUnionId()));//面向本分工会 + group.or(Cnd.exps(new Static("JSON_CONTAINS(us.signScope, '1')")).and(new Static("JSON_CONTAINS(us.chooseUserList -> \"$[*].id\", '\"%s\"')".formatted(ShiroUtil.getUserId()))));//面向自己选择的 + personalGroup.and(group); + + if (lineUnionType != null) { + switch (lineUnionType) { + case 1 -> lineCnd.and(selfUnionGroup); + case 2 -> lineCnd.and(otherUnionGroup); + case 3 -> lineCnd.and(schoolUnionGroup); + case 4 -> lineCnd.and(personalGroup); + } + } else { + SqlExpressionGroup expressionGroup = new SqlExpressionGroup(); + expressionGroup.or(selfUnionGroup).or(otherUnionGroup).or(schoolUnionGroup).or(personalGroup); + lineCnd.and(expressionGroup); + } + lineSql.setVar("lineCnd", lineCnd); + return (List) Daos.query(dao(), lineSql.toString(), Sqls.callback.maps()); + } + + @Override + public Object openSignUser(String id, String type, String searchKeyWord) { + String column = ""; + switch (type) { + case "line" -> column = "takePartInLineId"; + case "travel" -> column = "takePartInTravelAgencyId"; + case "baseManagement" -> column = "takePartInBaseManagementId"; + } + List enrolls = dao().query( + TheRapyRecuperationEnroll.class, + Cnd.where(column, "=", id) + .and("isNormal", "=", true) + .and("stateId", "=", 2750) + .and(Cnd.likeEX("userName", searchKeyWord)) + .asc("baseManagement".equals(type) ? "specificTime" : "signingUptime") + ); + return enrolls; /*enrolls.forEach(item -> { String firstLetter = PinyinUtil.getFirstLetter(StrUtil.sub(item.getUserName(), 0, 1), ""); item.setFirstLetter(firstLetter.toUpperCase()); @@ -317,659 +347,687 @@ public class TheRapyRecuperationEnrollServiceImpl extends ViServiceImpl oldValue, LinkedHashMap::new));*/ - } + } - /** - * 线路报名 - * - * @param enrollInfo 登记信息 - */ - @Override - @Aop(TransAop.READ_COMMITTED) - public void doSignUpForLine(TheRapyRecuperationEnroll enrollInfo) { - TheRapyRecuperationLineUnionSelect lineUnionSelect = dao().fetch(TheRapyRecuperationLineUnionSelect.class, enrollInfo.getTakePartInLineId()); - TheRapyRecuperationLine lineInfo = dao().fetch(TheRapyRecuperationLine.class, lineUnionSelect.getLineId()); + /** + * 线路报名 + * + * @param enrollInfo 登记信息 + */ + @Override + @Aop(TransAop.READ_COMMITTED) + public void doSignUpForLine(TheRapyRecuperationEnroll enrollInfo) { + TheRapyRecuperationLineUnionSelect lineUnionSelect = dao().fetch(TheRapyRecuperationLineUnionSelect.class, enrollInfo.getTakePartInLineId()); + TheRapyRecuperationLine lineInfo = dao().fetch(TheRapyRecuperationLine.class, lineUnionSelect.getLineId()); - Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); + Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); - enrollInfo.setLoginName(user.getLoginname()); - enrollInfo.setUserName(user.getUsername()); - enrollInfo.setSex(user.getSex()); - enrollInfo.setUnitName(user.getUnit().getName()); - enrollInfo.setUnionName(user.getUnion().getUnionname()); - enrollInfo.setSelfUnionId(user.getUnion().getId()); - enrollInfo.setSelfUnitId(user.getUnitid()); - enrollInfo.setSigningUptime(new Date()); - enrollInfo.setTakePartIn(false); - enrollInfo.setNormal(true); + enrollInfo.setLoginName(user.getLoginname()); + enrollInfo.setUserName(user.getUsername()); + enrollInfo.setSex(user.getSex()); + enrollInfo.setUnitName(user.getUnit().getName()); + enrollInfo.setUnionName(user.getUnion().getUnionname()); + enrollInfo.setSelfUnionId(user.getUnion().getId()); + enrollInfo.setSelfUnitId(user.getUnitid()); + enrollInfo.setSigningUptime(new Date()); + enrollInfo.setTakePartIn(false); + enrollInfo.setNormal(true); - if (lineUnionSelect.getSignUpMode() == TheRapyRecuperationSignUpMode.FREE.getValue()) { - enrollInfo.setTakePartInUnionId(null); - } + if (lineUnionSelect.getSignUpMode() == TheRapyRecuperationSignUpMode.FREE.getValue()) { + enrollInfo.setTakePartInUnionId(null); + } - //2023-06-07 省内外线路是否需要审核配置 根据配置来赋报名表的审核状态值☞ - TheRapyRecuperationConfig recuperationConfig = dao().fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); - Boolean isSnLine = recuperationConfig.getIsSnLine(); - Boolean isSwLine = recuperationConfig.getIsSwLine(); + //2023-06-07 省内外线路是否需要审核配置 根据配置来赋报名表的审核状态值☞ + TheRapyRecuperationConfig recuperationConfig = dao().fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); + Boolean isSnLine = recuperationConfig.getIsSnLine(); + Boolean isSwLine = recuperationConfig.getIsSwLine(); - Boolean flag = null; - if (lineInfo.getRegionalNature().equals(TheRapyRecuperationProvinceType.provinceOut.getValue())) { - flag = isSwLine; - } else if (lineInfo.getRegionalNature().equals(TheRapyRecuperationProvinceType.provinceIn.getValue())) { - flag = isSnLine; - } - if (Boolean.TRUE.equals(flag)) { - if (lineUnionSelect.getSignUpMode() == 1) { - if (StrUtil.isNotBlank(enrollInfo.getTakePartInUnionId()) && !enrollInfo.getTakePartInUnionId().equals(enrollInfo.getSelfUnionId())) { - enrollInfo.setStateId(TheRapyRecuperationState.LINEUNIT); - } else { - enrollInfo.setStateId(TheRapyRecuperationState.UNIT); - } - } else { - enrollInfo.setStateId(TheRapyRecuperationState.SCHOOL); - } - } else { - enrollInfo.setStateId(TheRapyRecuperationState.PASS); - } + Boolean flag = null; + if (lineInfo.getRegionalNature().equals(TheRapyRecuperationProvinceType.provinceOut.getValue())) { + flag = isSwLine; + } else if (lineInfo.getRegionalNature().equals(TheRapyRecuperationProvinceType.provinceIn.getValue())) { + flag = isSnLine; + } + if (Boolean.TRUE.equals(flag)) { + if (lineUnionSelect.getSignUpMode() == 1) { + if (StrUtil.isNotBlank(enrollInfo.getTakePartInUnionId()) && !enrollInfo.getTakePartInUnionId().equals(enrollInfo.getSelfUnionId())) { + enrollInfo.setStateId(TheRapyRecuperationState.LINEUNIT); + } else { + enrollInfo.setStateId(TheRapyRecuperationState.UNIT); + } + } else { + enrollInfo.setStateId(TheRapyRecuperationState.SCHOOL); + } + } else { + enrollInfo.setStateId(TheRapyRecuperationState.PASS); + } - if (recuperationConfig.getBedInfo() || recuperationConfig.getFamilyInfo() == 2) { - for (TheRapyRecuperationEnrollCompanion theRapyRecuperationEnrollCompanion : enrollInfo.getCompanionList()) { - insertLinks(theRapyRecuperationEnrollCompanion, "bedInfo"); - } - insertWith(enrollInfo, "companionList|bedInfo"); - } else { - insert(enrollInfo); - } + if (recuperationConfig.getBedInfo() || recuperationConfig.getFamilyInfo() == 2) { + for (TheRapyRecuperationEnrollCompanion theRapyRecuperationEnrollCompanion : enrollInfo.getCompanionList()) { + insertLinks(theRapyRecuperationEnrollCompanion, "bedInfo"); + } + insertWith(enrollInfo, "companionList|bedInfo"); + } else { + insert(enrollInfo); + } - //String content = "【智慧工会】%s老师您好,您已成功报名%s疗休养线路".formatted(user.getUsername(), lineInfo.getLineName()); - //msgApi.sendMsg(content, user.getMobile(), MsgApi.DING_DING_TEMPLATE_ID); - //发短信 + //String content = "【智慧工会】%s老师您好,您已成功报名%s疗休养线路".formatted(user.getUsername(), lineInfo.getLineName()); + //msgApi.sendMsg(content, user.getMobile(), MsgApi.DING_DING_TEMPLATE_ID); + //发短信 // RCSCloudAPI.sendTplSms("81d48e1811144270b838b321575c7199", user.getMobile(), "@1@=" + user.getUsername() + "||@2@=报名||@3@=" + lineInfo.getLineName(), ""); - } + } - /** - * 变更报名 - * - * @param enrollInfo 登记信息 - */ - @Override - @Aop(TransAop.READ_COMMITTED) - public void updateSignUpLine(TheRapyRecuperationEnroll enrollInfo) { - TheRapyRecuperationLineUnionSelect lineUnionSelect = dao().fetch(TheRapyRecuperationLineUnionSelect.class, enrollInfo.getTakePartInLineId()); - TheRapyRecuperationLine lineInfo = dao().fetch(TheRapyRecuperationLine.class, lineUnionSelect.getLineId()); + /** + * 变更报名 + * + * @param enrollInfo 登记信息 + */ + @Override + @Aop(TransAop.READ_COMMITTED) + public void updateSignUpLine(TheRapyRecuperationEnroll enrollInfo) { + TheRapyRecuperationLineUnionSelect lineUnionSelect = dao().fetch(TheRapyRecuperationLineUnionSelect.class, enrollInfo.getTakePartInLineId()); + TheRapyRecuperationLine lineInfo = dao().fetch(TheRapyRecuperationLine.class, lineUnionSelect.getLineId()); - TheRapyRecuperationConfig recuperationConfig = dao().fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); + TheRapyRecuperationConfig recuperationConfig = dao().fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); - if (lineUnionSelect.getSignUpMode() == TheRapyRecuperationSignUpMode.FREE.getValue()) { - enrollInfo.setTakePartInUnionId(null); - } + if (lineUnionSelect.getSignUpMode() == TheRapyRecuperationSignUpMode.FREE.getValue()) { + enrollInfo.setTakePartInUnionId(null); + } - if (recuperationConfig.getBedInfo() || recuperationConfig.getFamilyInfo() == 2) { - dao().clearLinks(enrollInfo, "companionList"); - dao().delete(TheRapyRecuperationEnrollBed.class, enrollInfo.getBedInfoId()); + if (recuperationConfig.getBedInfo() || recuperationConfig.getFamilyInfo() == 2) { + dao().clearLinks(enrollInfo, "companionList"); + dao().delete(TheRapyRecuperationEnrollBed.class, enrollInfo.getBedInfoId()); - dao().insertLinks(enrollInfo, "companionList|bedInfo"); - } + dao().insertLinks(enrollInfo, "companionList|bedInfo"); + } - update(enrollInfo); - //插入变更记录 - TheRapyRecuperationEnrollChangeRecord changeRecord = new TheRapyRecuperationEnrollChangeRecord(); - changeRecord.setEnrollId(enrollInfo.getId()); - changeRecord.setChangeTime(new Date()); - insert(changeRecord); + update(enrollInfo); + //插入变更记录 + TheRapyRecuperationEnrollChangeRecord changeRecord = new TheRapyRecuperationEnrollChangeRecord(); + changeRecord.setEnrollId(enrollInfo.getId()); + changeRecord.setChangeTime(new Date()); + insert(changeRecord); - //发短信 - Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); - //String content = "【智慧工会】%s老师您好,您的疗休养线路已成功修改为%s".formatted(user.getUsername(), lineInfo.getLineName()); - //msgApi.sendMsg(content, user.getMobile(), MsgApi.DING_DING_TEMPLATE_ID); + //发短信 + Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); + //String content = "【智慧工会】%s老师您好,您的疗休养线路已成功修改为%s".formatted(user.getUsername(), lineInfo.getLineName()); + //msgApi.sendMsg(content, user.getMobile(), MsgApi.DING_DING_TEMPLATE_ID); // RCSCloudAPI.sendTplSms("81d48e1811144270b838b321575c7199", user.getMobile(), "@1@=" + user.getUsername() + "||@2@=修改||@3@=" + lineInfo.getLineName(), ""); - } + } - /** - * 报名旅行社 - * - * @param enrollInfo 登记信息 - */ - @Override - public void doSignUpForTravelAgency(TheRapyRecuperationEnroll enrollInfo) { - Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); - enrollInfo.setLoginName(user.getLoginname()); - enrollInfo.setUserName(user.getUsername()); - enrollInfo.setSex(user.getSex()); - enrollInfo.setUnitName(user.getUnit().getName()); - enrollInfo.setUnionName(user.getUnion().getUnionname()); - enrollInfo.setSelfUnionId(user.getUnion().getId()); - enrollInfo.setSelfUnitId(user.getUnitid()); - enrollInfo.setSigningUptime(new Date()); - enrollInfo.setTakePartIn(false); - enrollInfo.setNormal(true); - insert(enrollInfo); - } + /** + * 报名旅行社 + * + * @param enrollInfo 登记信息 + */ + @Override + public void doSignUpForTravelAgency(TheRapyRecuperationEnroll enrollInfo) { + Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); + enrollInfo.setLoginName(user.getLoginname()); + enrollInfo.setUserName(user.getUsername()); + enrollInfo.setSex(user.getSex()); + enrollInfo.setUnitName(user.getUnit().getName()); + enrollInfo.setUnionName(user.getUnion().getUnionname()); + enrollInfo.setSelfUnionId(user.getUnion().getId()); + enrollInfo.setSelfUnitId(user.getUnitid()); + enrollInfo.setSigningUptime(new Date()); + enrollInfo.setTakePartIn(false); + enrollInfo.setNormal(true); + insert(enrollInfo); + } - /** - * 报名酒店 - * - * @param enrollInfo 登记信息 - */ - @Override - public void doSignUpForHotel(TheRapyRecuperationEnroll enrollInfo) { - Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); - enrollInfo.setLoginName(user.getLoginname()); - enrollInfo.setUserName(user.getUsername()); - enrollInfo.setSex(user.getSex()); - enrollInfo.setUnitName(user.getUnit().getName()); - enrollInfo.setUnionName(user.getUnion().getUnionname()); - enrollInfo.setSelfUnionId(user.getUnion().getId()); - enrollInfo.setSelfUnitId(user.getUnitid()); - enrollInfo.setSigningUptime(new Date()); - enrollInfo.setTakePartIn(false); - enrollInfo.setNormal(true); - enrollInfo.setStateId(TheRapyRecuperationState.PASS); + /** + * 报名酒店 + * + * @param enrollInfo 登记信息 + */ + @Override + public void doSignUpForHotel(TheRapyRecuperationEnroll enrollInfo) { + Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); + enrollInfo.setLoginName(user.getLoginname()); + enrollInfo.setUserName(user.getUsername()); + enrollInfo.setSex(user.getSex()); + enrollInfo.setUnitName(user.getUnit().getName()); + enrollInfo.setUnionName(user.getUnion().getUnionname()); + enrollInfo.setSelfUnionId(user.getUnion().getId()); + enrollInfo.setSelfUnitId(user.getUnitid()); + enrollInfo.setSigningUptime(new Date()); + enrollInfo.setTakePartIn(false); + enrollInfo.setNormal(true); + enrollInfo.setStateId(TheRapyRecuperationState.PASS); - for (TheRapyRecuperationEnrollCompanion theRapyRecuperationEnrollCompanion : enrollInfo.getCompanionList()) { - insertLinks(theRapyRecuperationEnrollCompanion, "bedInfo"); - } - insertWith(enrollInfo, "companionList|bedInfo"); - } + for (TheRapyRecuperationEnrollCompanion theRapyRecuperationEnrollCompanion : enrollInfo.getCompanionList()) { + insertLinks(theRapyRecuperationEnrollCompanion, "bedInfo"); + } + insertWith(enrollInfo, "companionList|bedInfo"); + } - /** - * 变更报名 - * - * @param enrollInfo 登记信息 - */ - @Override - @Aop(TransAop.READ_COMMITTED) - public void updateSignUpHotel(TheRapyRecuperationEnroll enrollInfo) { + /** + * 变更报名 + * + * @param enrollInfo 登记信息 + */ + @Override + @Aop(TransAop.READ_COMMITTED) + public void updateSignUpHotel(TheRapyRecuperationEnroll enrollInfo) { - dao().clearLinks(enrollInfo, "companionList"); - dao().delete(TheRapyRecuperationEnrollBed.class, enrollInfo.getBedInfoId()); + dao().clearLinks(enrollInfo, "companionList"); + dao().delete(TheRapyRecuperationEnrollBed.class, enrollInfo.getBedInfoId()); - dao().insertLinks(enrollInfo, "companionList|bedInfo"); + dao().insertLinks(enrollInfo, "companionList|bedInfo"); - update(enrollInfo); - //插入变更记录 - TheRapyRecuperationEnrollChangeRecord changeRecord = new TheRapyRecuperationEnrollChangeRecord(); - changeRecord.setEnrollId(enrollInfo.getId()); - changeRecord.setChangeTime(new Date()); - insert(changeRecord); - } + update(enrollInfo); + //插入变更记录 + TheRapyRecuperationEnrollChangeRecord changeRecord = new TheRapyRecuperationEnrollChangeRecord(); + changeRecord.setEnrollId(enrollInfo.getId()); + changeRecord.setChangeTime(new Date()); + insert(changeRecord); + } - /** - * 变更报名旅行社 - * - * @param enrollInfo 登记信息 - */ - @Override - public void updateSignUpTravelAgency(TheRapyRecuperationEnroll enrollInfo) { - updateIgnoreNull(enrollInfo); - } + /** + * 变更报名旅行社 + * + * @param enrollInfo 登记信息 + */ + @Override + public void updateSignUpTravelAgency(TheRapyRecuperationEnroll enrollInfo) { + updateIgnoreNull(enrollInfo); + } - @Override - public Map validSignUpInfo(String loginName, TheRapyRecuperationEnroll enrollInfo) { + @Override + public Map validSignUpInfo(String loginName, TheRapyRecuperationEnroll enrollInfo) { - //配置信息 - TheRapyRecuperationConfig config = dao().fetch(TheRapyRecuperationConfig.class); + //配置信息 + TheRapyRecuperationConfig config = dao().fetch(TheRapyRecuperationConfig.class); - Sys_user user = dao().fetch(Sys_user.class, Cnd.where("loginname", "=", loginName)); - //判断是否在报名范围内 - int count = dao().count("activity_user_scope", Cnd.NEW().and("groupId", "=", config.getActivityGroupId()) - .and("userId", "=", user.getId() )); - if (count == 0) { - return Map.of(false, "抱歉,您不在报名范围内!"); - } + if(StrUtil.isNotBlank(loginName) && loginName.startsWith("2025")) { + return Map.of(false, "抱歉,您是今年新入职,不能报名!"); + } - //判断报名时间 - Map validTime = this.validSignTime(enrollInfo); - if (validTime != null && validTime.containsKey(false)) { - return validTime; - } + Sys_user user = dao().fetch(Sys_user.class, Cnd.where("loginname", "=", loginName)); + //判断是否在报名范围内 + int count = dao().count("activity_user_scope", Cnd.NEW().and("groupId", "=", config.getActivityGroupId()) + .and("userId", "=", user.getId())); + if (count == 0) { + return Map.of(false, "抱歉,您不在报名范围内!"); + } - //每年旅行频率 - Integer travelFrequency = config.getTravelFrequency(); - //省外几年去一次 - Integer outsideNumber = config.getOutsideNumber(); - //省内起始年份 - Integer provinceStartYear = config.getProvinceStartYear(); + //判断报名时间 + Map validTime = this.validSignTime(enrollInfo); + if (validTime != null && validTime.containsKey(false)) { + return validTime; + } - //如果报酒店,酒店可以一年报2次 - if (StrUtil.isNotBlank(enrollInfo.getTakePartInBaseManagementId())) { - travelFrequency = 2; - Map validResult = this.validBaseManagementCount(loginName, enrollInfo); - if(validResult != null && validResult.containsKey(false)) { - return validResult; - } - } + //每年旅行频率 + Integer travelFrequency = config.getTravelFrequency(); + //省外几年去一次 + Integer outsideNumber = config.getOutsideNumber(); + //省内起始年份 + Integer provinceStartYear = config.getProvinceStartYear(); - //先判断有没有报过 - Map thisYearCount = this.validCountThisYear(loginName, travelFrequency); - if (thisYearCount != null && thisYearCount.containsKey(false) && StrUtil.isBlank(enrollInfo.getId())) { - return thisYearCount; - } + //如果报酒店,酒店可以一年报2次 + if (StrUtil.isNotBlank(enrollInfo.getTakePartInBaseManagementId())) { + //先看有没有报线路,如果报了就不能报酒店 + /*Map thisYearCount = this.validCountThisYear(loginName, travelFrequency, false); + if (thisYearCount != null && thisYearCount.containsKey(false) && StrUtil.isBlank(enrollInfo.getId())) { + return thisYearCount; + }*/ + travelFrequency = 2; + Map validResult = this.validBaseManagementCount(loginName, enrollInfo); + if (validResult != null && validResult.containsKey(false)) { + return validResult; + } + } - if (StrUtil.isNotBlank(enrollInfo.getTakePartInLineId())) { - //线路信息 - TheRapyRecuperationLineUnionSelect lineUnionSelect = dao().fetch(TheRapyRecuperationLineUnionSelect.class, enrollInfo.getTakePartInLineId()); - TheRapyRecuperationLine lineInfo = dao().fetch(TheRapyRecuperationLine.class, lineUnionSelect.getLineId()); + //先判断有没有报过 + Map thisYearCount = this.validCountThisYear(loginName, travelFrequency, true); + if (thisYearCount != null && thisYearCount.containsKey(false) && StrUtil.isBlank(enrollInfo.getId())) { + return thisYearCount; + } - TheRapyRecuperationType trrt = regionTypeLineMap.get(lineInfo.getRegionalNature()); - if (StrUtil.isBlank(enrollInfo.getId()) && StrUtil.isNotBlank(enrollInfo.getTakePartInLineId())) { - //获取标段中的最大费用 - List lotList = dao().query(TheRapyRecuperationLot.class, Cnd.NEW()); - //最大费用 - OptionalInt optionalInt = lotList.stream().mapToInt(TheRapyRecuperationLot::getActivityCost).max(); - int maxCost = optionalInt.isPresent() ? optionalInt.getAsInt() : 0; - //获取当前报名线路对应的标段的费用 - Integer currentLineCost = dao().fetch(TheRapyRecuperationLot.class, lineInfo.getLotId()).getActivityCost(); + if (StrUtil.isNotBlank(enrollInfo.getTakePartInLineId())) { + //线路信息 + TheRapyRecuperationLineUnionSelect lineUnionSelect = dao().fetch(TheRapyRecuperationLineUnionSelect.class, enrollInfo.getTakePartInLineId()); + TheRapyRecuperationLine lineInfo = dao().fetch(TheRapyRecuperationLine.class, lineUnionSelect.getLineId()); - //获取起始年份到当前时间,是否报名 - Sql sql = Sqls.create(""" - SELECT - r.*, - l.regionalNature, - (select activityCost from the_rapy_recuperation_lot where id = l.lotId) as activityCost - FROM - the_rapy_recuperation_enroll r - LEFT JOIN the_rapy_recuperation_line_union_select us on us.id = r.takePartInLineId - LEFT JOIN the_rapy_recuperation_line l ON l.id = us.lineId - $condition - """); - Sql twoYearInSql = sql; - Sql threeYearOutSql = sql; - Sql nowYearSql = sql; + //判断是否工勤线路 + if(lineInfo.getSpecialLine() == true && StrUtil.isNotBlank(user.getRemark()) && !user.getRemark().contains("工勤")) { + return Map.of(false, "不能报名,此路线为工勤特定线路"); + } - Cnd commonCnd = Cnd.NEW(); - commonCnd.and("r.takePartInLineId", "is not", null); - commonCnd.and("loginName", "=", ShiroUtil.getPrincipalProperty("loginname")); - commonCnd.and("r.isNormal", "=", true); - commonCnd.and("stateId", "not in", Lang.array(TheRapyRecuperationState.UNITFAIL, TheRapyRecuperationState.LINEUNITFAIL, TheRapyRecuperationState.SCHOOLFAIL)); - commonCnd.and("signingUptime", "<=", DateUtil.now()); + TheRapyRecuperationType trrt = regionTypeLineMap.get(lineInfo.getRegionalNature()); + if (StrUtil.isBlank(enrollInfo.getId()) && StrUtil.isNotBlank(enrollInfo.getTakePartInLineId())) { + //获取标段中的最大费用 + List lotList = dao().query(TheRapyRecuperationLot.class, Cnd.NEW()); + //最大费用 + OptionalInt optionalInt = lotList.stream().mapToInt(TheRapyRecuperationLot::getActivityCost).max(); + int maxCost = optionalInt.isPresent() ? optionalInt.getAsInt() : 0; + //获取当前报名线路对应的标段的费用 + Integer currentLineCost = dao().fetch(TheRapyRecuperationLot.class, lineInfo.getLotId()).getActivityCost(); - //两年参加省内 - Cnd twoYearInCnd = commonCnd.clone(); - twoYearInCnd.and("signingUptime", ">=", provinceStartYear + "-01-01"); - twoYearInCnd.and("regionalNature", "=", "省内"); - twoYearInCnd.and("isTakePartIn", "=", true); - twoYearInSql.setCondition(twoYearInCnd); - List twoYearInMapList = listMap(twoYearInSql); + //获取起始年份到当前时间,是否报名 + Sql sql = Sqls.create(""" + SELECT + r.*, + l.regionalNature, + (select activityCost from the_rapy_recuperation_lot where id = l.lotId) as activityCost + FROM + the_rapy_recuperation_enroll r + LEFT JOIN the_rapy_recuperation_line_union_select us on us.id = r.takePartInLineId + LEFT JOIN the_rapy_recuperation_line l ON l.id = us.lineId + $condition + """); + Sql twoYearInSql = sql; + Sql threeYearOutSql = sql; + Sql nowYearSql = sql; - //今年是否报名,不管省内省外 - Cnd nowYearCnd = commonCnd.clone(); - nowYearCnd.and("signingUptime", ">=", DateUtil.thisYear() + "-01-01"); - nowYearSql.setCondition(nowYearCnd); - List nowYearMapList = listMap(nowYearSql); + Cnd commonCnd = Cnd.NEW(); + commonCnd.and("r.takePartInLineId", "is not", null); + commonCnd.and("loginName", "=", ShiroUtil.getPrincipalProperty("loginname")); + commonCnd.and("r.isNormal", "=", true); + commonCnd.and("r.stateId", "not in", Lang.array(TheRapyRecuperationState.UNITFAIL, TheRapyRecuperationState.LINEUNITFAIL, TheRapyRecuperationState.SCHOOLFAIL)); + commonCnd.and("signingUptime", "<=", DateUtil.now()); - //三年参加省外 - Cnd threeYearOutCnd = commonCnd.clone(); - threeYearOutCnd.and("signingUptime", ">=", (DateUtil.thisYear() - 3) + "-01-01"); - threeYearOutCnd.and("regionalNature", "=", "省外"); - threeYearOutCnd.and("isTakePartIn", "=", true); - threeYearOutSql.setCondition(threeYearOutCnd); - List threeYearOutMapList = listMap(threeYearOutSql); + //两年参加省内 + Cnd twoYearInCnd = commonCnd.clone(); + twoYearInCnd.and("signingUptime", ">=", provinceStartYear + "-01-01"); + twoYearInCnd.and("regionalNature", "=", "省内"); + twoYearInCnd.and("isTakePartIn", "=", true); + twoYearInSql.setCondition(twoYearInCnd); + List twoYearInMapList = listMap(twoYearInSql); - //今年是否报名,不管报省内还是省外 - if (Lang.isNotEmpty(nowYearMapList)) { - NutMap nowYearMap = nowYearMapList.get(0); - //判断当前报名的线路是否和今年第一次报名的线路重复 - if (nowYearMap.getString("takePartInLineId").equals(lineUnionSelect.getId())) { - return Map.of(false, "您已报名过当前线路,请选择其他线路"); - } - //获取第一次报名线路对应的标段的费用 - int lastLineCost = nowYearMap.getInt("activityCost"); - if ((lastLineCost + currentLineCost) > maxCost) { - return Map.of(false, "您已报名过省内线路"); - } - } - //省内线路判断 - if (trrt.getValue() == TheRapyRecuperationType.provinceInLine.getValue()) { - if (Lang.isEmpty(twoYearInMapList)) { - return Map.of(true, "验证成功"); - } - if (Lang.isNotEmpty(twoYearInMapList)) { - int hasCost = twoYearInMapList.get(0).getInt("activityCost"); - if ((hasCost + currentLineCost) > maxCost) { - return Map.of(false, "您已参加过省内线路"); - } - } - } - //省外线路判断 - if (trrt.getValue() == TheRapyRecuperationType.provinceOutLine.getValue()) { - //三年内有没有参加过省外 - if (Lang.isNotEmpty(threeYearOutMapList)) { - return Map.of(false, "近三年内您已参加过省外线路,不能再次报名"); - } - //获取今年的所有线路 - List lineList = dao().query(TheRapyRecuperationLine.class, Cnd.where("year", "=", DateUtil.thisYear()) - .and("isDisabled", "=", false)); - List lineIds = lineList.stream().map(TheRapyRecuperationLine::getId).collect(Collectors.toList()); - //获取这些线路在选择表中的选择id,因为报名表存的是选择id - List selectList = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "in", lineIds)); - List selectIds = selectList.stream().map(TheRapyRecuperationLineUnionSelect::getId).collect(Collectors.toList()); - //获取这些省外线路的总报名人数 - List enrollList = dao().query(TheRapyRecuperationEnroll.class, Cnd.where("takePartInLineId", "in", selectIds) - .and("isNormal", "=", true).and("signingUptime", "=", DateUtil.thisYear()) - .and("stateId", "not in", Lang.array(TheRapyRecuperationState.UNITFAIL, TheRapyRecuperationState.LINEUNITFAIL, TheRapyRecuperationState.SCHOOLFAIL))); - //活动范围总人数 - List userScopes = dao().query(ActivityUserScope.class, Cnd.where("groupId", "=", config.getActivityGroupId())); - int result = (int) Math.floor((double) userScopes.size() / 3); - if (enrollList.size() >= result) { - return Map.of(false, "已报人数超过三分之一,不能报名"); - } - } - } - } - return Map.of(true, "验证成功"); - } + //今年是否报名,不管省内省外 + Cnd nowYearCnd = commonCnd.clone(); + nowYearCnd.and("signingUptime", ">=", DateUtil.thisYear() + "-01-01"); + nowYearSql.setCondition(nowYearCnd); + List nowYearMapList = listMap(nowYearSql); - public Map validSignTime(TheRapyRecuperationEnroll currentEnroll) { - TheRapyRecuperationConfig config = dao().fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); - DateTime signUpStartTime = null; - DateTime signUpEndTime = null; - if(StrUtil.isNotBlank(currentEnroll.getTakePartInLineId())) { - signUpStartTime = config.getImplodeStartTime(); - signUpEndTime = config.getImplodeEndTime(); - } else if(StrUtil.isNotBlank(currentEnroll.getTakePartInBaseManagementId())) { - signUpStartTime = config.getFragmentStartTime(); - signUpEndTime = config.getFragmentEndTime(); - } - if (DateUtil.compare(new Date(), signUpStartTime) < 0) { - return Map.of(false, "报名未开始,请耐心等待"); - } - if (DateUtil.compare(new Date(), signUpEndTime) > 0) { - return Map.of(false, "报名时间已过,抱歉不能报名"); - } - return null; - } + //三年参加省外 + Cnd threeYearOutCnd = commonCnd.clone(); + threeYearOutCnd.and("signingUptime", ">=", (DateUtil.thisYear() - 3) + "-01-01"); + threeYearOutCnd.and("regionalNature", "=", "省外"); + threeYearOutCnd.and("isTakePartIn", "=", true); + threeYearOutSql.setCondition(threeYearOutCnd); + List threeYearOutMapList = listMap(threeYearOutSql); - public Map validBaseManagementCount(String loginName, TheRapyRecuperationEnroll currentEnroll) { - //酒店可以一年报2次,查询是否有报第一次 - List enrollList = dao().query( - TheRapyRecuperationEnroll.class, - Cnd.where("loginName", "=", loginName) - .and("isNormal", "=", true) - .and("takePartInBaseManagementId", "is not", null) - .and("YEAR(signingUptime)", "=", DateUtil.thisYear()) - .asc("signingUptime") - ); - if(StrUtil.isBlank(currentEnroll.getId()) && enrollList.size() >= 2) { - return Map.of(false, "您已经报名了%s次分段疗休养".formatted(enrollList.size())); - } - //如果报过第一次就要判断 - if(Lang.isNotEmpty(enrollList)) { - TheRapyRecuperationEnroll lastEnroll = enrollList.get(0); - //判断这次报名的旅行社和上次的旅行社是否是一个 - TheRapyRecuperationBaseManagement currentManagement = dao().fetch(TheRapyRecuperationBaseManagement.class, currentEnroll.getTakePartInBaseManagementId()); - TheRapyRecuperationTravelAgency currentTravelAgency = dao().fetch(TheRapyRecuperationTravelAgency.class, currentManagement.getTravelAgencyId()); + //今年是否报名,不管报省内还是省外 + if (Lang.isNotEmpty(nowYearMapList)) { + NutMap nowYearMap = nowYearMapList.get(0); + //判断当前报名的线路是否和今年第一次报名的线路重复 + if (nowYearMap.getString("takePartInLineId").equals(lineUnionSelect.getId())) { + return Map.of(false, "您已报名过当前线路,请选择其他线路"); + } + //获取第一次报名线路对应的标段的费用 + int lastLineCost = nowYearMap.getInt("activityCost"); + if ((lastLineCost + currentLineCost) > maxCost) { + return Map.of(false, "您已报名过省内线路"); + } + } + //省内线路判断 + if (trrt.getValue() == TheRapyRecuperationType.provinceInLine.getValue()) { + if (Lang.isEmpty(twoYearInMapList)) { + return Map.of(true, "验证成功"); + } + if (Lang.isNotEmpty(twoYearInMapList)) { + int hasCost = twoYearInMapList.get(0).getInt("activityCost"); + if ((hasCost + currentLineCost) > maxCost) { + return Map.of(false, "您已参加过省内线路"); + } + } + } + //省外线路判断 + if (trrt.getValue() == TheRapyRecuperationType.provinceOutLine.getValue()) { + //三年内有没有参加过省外 + if (Lang.isNotEmpty(threeYearOutMapList)) { + return Map.of(false, "近三年内您已参加过省外线路,不能再次报名"); + } + //获取今年的所有线路 + List lineList = dao().query(TheRapyRecuperationLine.class, Cnd.where("year", "=", DateUtil.thisYear()) + .and("isDisabled", "=", false)); + List lineIds = lineList.stream().map(TheRapyRecuperationLine::getId).collect(Collectors.toList()); + //获取这些线路在选择表中的选择id,因为报名表存的是选择id + List selectList = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "in", lineIds)); + List selectIds = selectList.stream().map(TheRapyRecuperationLineUnionSelect::getId).collect(Collectors.toList()); + //获取这些省外线路的总报名人数 + List enrollList = dao().query(TheRapyRecuperationEnroll.class, Cnd.where("takePartInLineId", "in", selectIds) + .and("isNormal", "=", true).and("signingUptime", "=", DateUtil.thisYear()) + .and("stateId", "not in", Lang.array(TheRapyRecuperationState.UNITFAIL, TheRapyRecuperationState.LINEUNITFAIL, TheRapyRecuperationState.SCHOOLFAIL))); + //活动范围总人数 + List userScopes = dao().query(ActivityUserScope.class, Cnd.where("groupId", "=", config.getActivityGroupId())); + int result = (int) Math.floor((double) userScopes.size() / 3); + if (enrollList.size() >= result) { + return Map.of(false, "已报人数超过三分之一,不能报名"); + } + } + } + } + return Map.of(true, "验证成功"); + } - TheRapyRecuperationBaseManagement lastManagement = dao().fetch(TheRapyRecuperationBaseManagement.class, lastEnroll.getTakePartInBaseManagementId()); - TheRapyRecuperationTravelAgency lastTravelAgency = dao().fetch(TheRapyRecuperationTravelAgency.class, lastManagement.getTravelAgencyId()); - if(!Objects.equals(currentTravelAgency.getId(), lastTravelAgency.getId())) { - return Map.of(false, "当前报名酒店的旅行社与上次出行不一致"); - } - //如果是一个,再判断天数 - if(currentEnroll.getPlayDay() != null) { - if((currentEnroll.getPlayDay() + lastEnroll.getPlayDay()) != 5) { - Object dayCount = lastEnroll.getPlayDay() % 1 == 0 ? String.valueOf(lastEnroll.getPlayDay().intValue()) : lastEnroll.getPlayDay(); - return Map.of(false, "您选择的出行天数有误,上次出行天数为%s天".formatted(dayCount)); - } - } - } - return null; - } + public Map validSignTime(TheRapyRecuperationEnroll currentEnroll) { + TheRapyRecuperationConfig config = dao().fetch(TheRapyRecuperationConfig.class, Cnd.NEW()); + DateTime signUpStartTime = null; + DateTime signUpEndTime = null; + if (StrUtil.isNotBlank(currentEnroll.getTakePartInLineId())) { + signUpStartTime = config.getImplodeStartTime(); + signUpEndTime = config.getImplodeEndTime(); + } else if (StrUtil.isNotBlank(currentEnroll.getTakePartInBaseManagementId())) { + signUpStartTime = config.getFragmentStartTime(); + signUpEndTime = config.getFragmentEndTime(); + } + if (DateUtil.compare(new Date(), signUpStartTime) < 0) { + return Map.of(false, "报名未开始,请耐心等待"); + } + if (DateUtil.compare(new Date(), signUpEndTime) > 0) { + return Map.of(false, "报名时间已过,抱歉不能报名"); + } + return null; + } - //判断一年报几次 - public Map validCountThisYear(String loginName, int travelFrequency) { - Cnd cnd = Cnd.NEW(); - cnd.and("loginName", "=", loginName); - cnd.and("isNormal", "=", true); - cnd.and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear()); - int joinCount = dao().count(TheRapyRecuperationEnroll.class, cnd); + public Map validBaseManagementCount(String loginName, TheRapyRecuperationEnroll currentEnroll) { + //看有没有报线路 + int count = dao().count(TheRapyRecuperationEnroll.class, Cnd.where("takePartInLineId", "is not", null) + .and("isNormal", "=", true) + .and("stateId", "=", 2750) + .and("YEAR(signingUptime)", "=", DateUtil.thisYear()) + .and("loginName", "=", loginName)); + if(count > 0) { + return Map.of(false, "一年只能报1次,您已报集中疗休养,请先在我的疗休养中删除,方可报名!"); + } + //酒店可以一年报2次,查询是否有报第一次 + List enrollList = dao().query( + TheRapyRecuperationEnroll.class, + Cnd.where("loginName", "=", loginName) + .and("isNormal", "=", true) + .and("takePartInBaseManagementId", "is not", null) + .and("YEAR(signingUptime)", "=", DateUtil.thisYear()) + .asc("signingUptime") + ); + if (StrUtil.isBlank(currentEnroll.getId()) && enrollList.size() >= 2) { + return Map.of(false, "您已经报名了%s次分段疗休养".formatted(enrollList.size())); + } + //如果报过第一次就要判断 + if (Lang.isNotEmpty(enrollList)) { + TheRapyRecuperationEnroll lastEnroll = enrollList.get(0); + //判断这次报名的旅行社和上次的旅行社是否是一个 + TheRapyRecuperationBaseManagement currentManagement = dao().fetch(TheRapyRecuperationBaseManagement.class, currentEnroll.getTakePartInBaseManagementId()); + TheRapyRecuperationTravelAgency currentTravelAgency = dao().fetch(TheRapyRecuperationTravelAgency.class, currentManagement.getTravelAgencyId()); - if (joinCount >= travelFrequency) { - List inList = dao().query(TheRapyRecuperationLine.class, Cnd.where("regionalNature", "=", "省内")); - List unionInSelects = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "in", inList.stream().map(TheRapyRecuperationLine::getId).collect(Collectors.toList()))); - List outList = dao().query(TheRapyRecuperationLine.class, Cnd.where("regionalNature", "=", "省外")); - List unionOutSelects = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "in", outList.stream().map(TheRapyRecuperationLine::getId).collect(Collectors.toList()))); - //是否选择省外 - int inCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) - .and("takePartInLineId", "in", unionInSelects.stream().map(TheRapyRecuperationLineUnionSelect::getId).collect(Collectors.toList())) - .and("isNormal", "=", true) - .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); - //是否报省外 - int outCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) - .and("takePartInLineId", "in", unionOutSelects.stream().map(TheRapyRecuperationLineUnionSelect::getId).collect(Collectors.toList())) - .and("isNormal", "=", true) - .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); - //是否报旅行社 - int travelCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) - .and(Cnd.exps("takePartInLineId", "is", null).or("takePartInLineId", "=", "")) - .and("isNormal", "=", true) - .and("takePartInTravelAgencyId", "is not", null) - .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); - //是否报酒店 - int hotelCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) - .and("takePartInLineId", "is", null).and("isNormal", "=", true) - .and("takePartInBaseManagementId", "is not", null) - .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); - String str = ""; - if (inCount > 0) { - str = "省内线路"; - } else if (outCount > 0) { - str = "省外线路"; - } else if (travelCount > 0) { - str = "旅行社"; - } else if (hotelCount > 0) { - str = "酒店"; - } - return Map.of(false, "一年只能报" + travelFrequency + "次,您已报" + str + ",请先在我的疗休养中删除,方可报名!"); - } - return null; - } + TheRapyRecuperationBaseManagement lastManagement = dao().fetch(TheRapyRecuperationBaseManagement.class, lastEnroll.getTakePartInBaseManagementId()); + TheRapyRecuperationTravelAgency lastTravelAgency = dao().fetch(TheRapyRecuperationTravelAgency.class, lastManagement.getTravelAgencyId()); + if (!Objects.equals(currentTravelAgency.getId(), lastTravelAgency.getId())) { + return Map.of(false, "当前报名酒店的旅行社与上次出行不一致"); + } + //如果是一个,再判断天数 + if (currentEnroll.getPlayDay() != null) { + if ((currentEnroll.getPlayDay() + lastEnroll.getPlayDay()) != 5) { + Object dayCount = lastEnroll.getPlayDay() % 1 == 0 ? String.valueOf(lastEnroll.getPlayDay().intValue()) : lastEnroll.getPlayDay(); + return Map.of(false, "您选择的出行天数有误,上次出行天数为%s天".formatted(dayCount)); + } + } + } + return null; + } - /** - * 我报名的页面数据 - * - * @param pageForm 分页参数 - * @param cnd cnd - * @return {@link Pagination} - */ - @Override - public Pagination mySignUpPageData(PageForm pageForm, Cnd cnd, int trrt, Integer year) { - if (List.of( - TheRapyRecuperationType.provinceInLine.getValue(), - TheRapyRecuperationType.provinceOutLine.getValue() - ).contains(trrt)) { - return this.getDataByInLineAndOutLine(pageForm, cnd, trrt, year); - } else if (trrt == TheRapyRecuperationType.provinceInTravelAgency.getValue()) { - return this.getDataByInTravelAgency(pageForm, cnd, trrt, year); - } else if (trrt == TheRapyRecuperationType.provinceInHotel.getValue()) { - return this.getDataByInHotel(pageForm, cnd, trrt, year); - } - return null; - } + //判断一年报几次 + public Map validCountThisYear(String loginName, int travelFrequency, Boolean validHotel) { + Cnd cnd = Cnd.NEW(); + cnd.and("loginName", "=", loginName); + cnd.and("isNormal", "=", true); + cnd.and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear()); + int joinCount = dao().count(TheRapyRecuperationEnroll.class, cnd); - public Pagination getDataByInLineAndOutLine(PageForm pageForm, Cnd cnd, int trrt, Integer year) { - Sql lineSql = Sqls.create(""" - SELECT - e.*, - line.serialNumber, - line.lineName, - line.regionalNature, - line.YEAR, - us.signUpStartTime, - us.signUpEndTime, - us.changeEndTime, - us.playStartTime, - us.playEndTime, - us.signUpMode, - line.files AS fileId, - gh.unionname AS signUpUnionName, - ta.travelAgencyName, - ta.contact, - ta.contactMobileNumber, - ta.officialWebsite, - GROUP_CONCAT(ec.userName) as companionUserNames, - l.lotName, - au.stateName, - au.stateColor - FROM - the_rapy_recuperation_enroll e - LEFT JOIN sys_union gh ON gh.id = e.takePartInUnionId - LEFT JOIN the_rapy_recuperation_line_union_select us on us.id = e.takePartInLineId - LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId - LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId - left join the_rapy_recuperation_enroll_companion ec on ec.trreId = e.id - left join the_rapy_recuperation_lot l on l.id = line.lotId - left join audit_state au on e.stateId = au.stateId - $condition - GROUP BY e.id - """); - cnd.and("line.regionalNature", "=", TheRapyRecuperationType.typeMap.get(trrt)); - cnd.and("e.isNormal", "=", true); - cnd.andEX("year(e.signingUptime)", "=", year); + if (joinCount >= travelFrequency) { + List inList = dao().query(TheRapyRecuperationLine.class, Cnd.where("regionalNature", "=", "省内")); + List unionInSelects = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "in", inList.stream().map(TheRapyRecuperationLine::getId).collect(Collectors.toList()))); + List outList = dao().query(TheRapyRecuperationLine.class, Cnd.where("regionalNature", "=", "省外")); + List unionOutSelects = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "in", outList.stream().map(TheRapyRecuperationLine::getId).collect(Collectors.toList()))); + //是否选择省外 + int inCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) + .and("takePartInLineId", "in", unionInSelects.stream().map(TheRapyRecuperationLineUnionSelect::getId).collect(Collectors.toList())) + .and("isNormal", "=", true) + .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); + //是否报省外 + int outCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) + .and("takePartInLineId", "in", unionOutSelects.stream().map(TheRapyRecuperationLineUnionSelect::getId).collect(Collectors.toList())) + .and("isNormal", "=", true) + .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); + //是否报旅行社 + int travelCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) + .and(Cnd.exps("takePartInLineId", "is", null).or("takePartInLineId", "=", "")) + .and("isNormal", "=", true) + .and("takePartInTravelAgencyId", "is not", null) + .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); + //是否报酒店 + int hotelCount = dao().count("the_rapy_recuperation_enroll", Cnd.where("loginName", "=", io.v.nutz.web.commons.utils.ShiroUtil.getPrincipalProperty("loginname")) + .and("takePartInLineId", "is", null).and("isNormal", "=", true) + .and("takePartInBaseManagementId", "is not", null) + .and("YEAR(signingUptime)", "=", io.v.nutz.base.utils.DateUtil.getYear())); + String str = ""; + if (inCount > 0) { + str = "省内线路"; + } else if (outCount > 0) { + str = "省外线路"; + } else if (travelCount > 0) { + str = "旅行社"; + } else if (validHotel && hotelCount > 0) { + str = "酒店"; + } + return Map.of(false, "一年只能报" + travelFrequency + "次,您已报" + str + ",请先在我的疗休养中删除,方可报名!"); + } + return null; + } - lineSql.setCondition(cnd); - return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), lineSql); - } + /** + * 我报名的页面数据 + * + * @param pageForm 分页参数 + * @param cnd cnd + * @return {@link Pagination} + */ + @Override + public Pagination mySignUpPageData(PageForm pageForm, Cnd cnd, int trrt, Integer year) { + if (List.of( + TheRapyRecuperationType.provinceInLine.getValue(), + TheRapyRecuperationType.provinceOutLine.getValue() + ).contains(trrt)) { + return this.getDataByInLineAndOutLine(pageForm, cnd, trrt, year); + } else if (trrt == TheRapyRecuperationType.provinceInTravelAgency.getValue()) { + return this.getDataByInTravelAgency(pageForm, cnd, trrt, year); + } else if (trrt == TheRapyRecuperationType.provinceInHotel.getValue()) { + return this.getDataByInHotel(pageForm, cnd, trrt, year); + } + return null; + } - public Pagination getDataByInTravelAgency(PageForm pageForm, Cnd cnd, int trrt, Integer year) { - Sql taSql = Sqls.create(""" - SELECT - e.*, - ta.travelAgencyName, - ta.contact, - ta.contactMobileNumber, - ta.officialWebsite, - cast( ta.files ->> '$[0].id' AS CHAR ) AS fileId - FROM - the_rapy_recuperation_enroll e - LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = e.takePartInTravelAgencyId - $condition - """); - cnd.and("e.takePartInTravelAgencyId", "is not", null); - cnd.and("e.isNormal", "=", true); - cnd.andEX("ta.year", "=", year); - taSql.setCondition(cnd); - return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); - } + public Pagination getDataByInLineAndOutLine(PageForm pageForm, Cnd cnd, int trrt, Integer year) { + Sql lineSql = Sqls.create(""" + SELECT + e.*, + line.groupType, + line.travelAgencyPlace, + line.serialNumber, + line.lineName, + line.regionalNature, + line.YEAR, + us.signUpStartTime, + us.signUpEndTime, + us.changeEndTime, + us.playStartTime, + us.playEndTime, + us.signUpMode, + line.files AS fileId, + gh.unionname AS signUpUnionName, + ta.travelAgencyName, + ta.contact, + ta.contactMobileNumber, + ta.officialWebsite, + GROUP_CONCAT(ec.userName) as companionUserNames, + l.lotName, + au.stateName, + au.stateColor, + u.username as selectUserName + FROM + the_rapy_recuperation_enroll e + LEFT JOIN sys_union gh ON gh.id = e.takePartInUnionId + LEFT JOIN the_rapy_recuperation_line_union_select us on us.id = e.takePartInLineId + LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId + LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = line.travelAgencyId + left join the_rapy_recuperation_enroll_companion ec on ec.trreId = e.id + left join the_rapy_recuperation_lot l on l.id = line.lotId + left join sys_user u on u.id = us.selectUserId + left join audit_state au on e.stateId = au.stateId + $condition + GROUP BY e.id + """); + cnd.and("line.regionalNature", "=", TheRapyRecuperationType.typeMap.get(trrt)); + cnd.and("e.isNormal", "=", true); + cnd.andEX("year(e.signingUptime)", "=", year); - public Pagination getDataByInHotel(PageForm pageForm, Cnd cnd, int trrt, Integer year) { - Sql taSql = Sqls.create(""" - SELECT - e.*, - ta.baseName, - ta.baseContactPerson, - ta.baseContactNumber, - ta.files AS fileId, - l.lotName, - ta.regionalNature, - t.travelAgencyName, - ta.changeEndTime - FROM - the_rapy_recuperation_enroll e - LEFT JOIN the_rapy_recuperation_base_management ta ON ta.id = e.takePartInBaseManagementId - LEFT JOIN the_rapy_recuperation_lot l on l.id = ta.lotId - LEFT JOIN the_rapy_recuperation_travel_agency t on t.id = ta.travelAgencyId - $condition - """); - cnd.and("e.takePartInBaseManagementId", "is not", null); - cnd.and("e.isNormal", "=", true); - cnd.andEX("ta.year", "=", year); - taSql.setCondition(cnd); - return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); - } + lineSql.setCondition(cnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), lineSql); + } - /** - * 找到报名信息通过id - * - * @param id id - * @return {@link TheRapyRecuperationEnroll} - */ - @Override - public TheRapyRecuperationEnroll findSignUpInfoById(String id) { - TheRapyRecuperationEnroll enroll = fetch(id); - return fetchLinks(enroll, "companionList|bedInfo"); - } + public Pagination getDataByInTravelAgency(PageForm pageForm, Cnd cnd, int trrt, Integer year) { + Sql taSql = Sqls.create(""" + SELECT + e.*, + ta.travelAgencyName, + ta.contact, + ta.contactMobileNumber, + ta.officialWebsite, + cast( ta.files ->> '$[0].id' AS CHAR ) AS fileId + FROM + the_rapy_recuperation_enroll e + LEFT JOIN the_rapy_recuperation_travel_agency ta ON ta.id = e.takePartInTravelAgencyId + $condition + """); + cnd.and("e.takePartInTravelAgencyId", "is not", null); + cnd.and("e.isNormal", "=", true); + cnd.andEX("ta.year", "=", year); + taSql.setCondition(cnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); + } - /** - * 删除我的报名信息 - * - * @param id id - */ - @Override - @Aop(TransAop.READ_COMMITTED) - public void deleteMyEnrollInfoById(String id) { - TheRapyRecuperationEnroll enrollInfo = fetch(id); - dao().clearLinks(enrollInfo, "companionList|bedInfo"); - delete(id); - dao().clear(TheRapyRecuperationEnrollChangeRecord.class, Cnd.where("enrollId", "=", id)); + public Pagination getDataByInHotel(PageForm pageForm, Cnd cnd, int trrt, Integer year) { + Sql taSql = Sqls.create(""" + SELECT + e.*, + ta.baseName, + ta.baseContactPerson, + ta.baseContactNumber, + ta.files AS fileId, + l.lotName, + ta.regionalNature, + t.travelAgencyName, + ta.changeEndTime + FROM + the_rapy_recuperation_enroll e + LEFT JOIN the_rapy_recuperation_base_management ta ON ta.id = e.takePartInBaseManagementId + LEFT JOIN the_rapy_recuperation_lot l on l.id = ta.lotId + LEFT JOIN the_rapy_recuperation_travel_agency t on t.id = ta.travelAgencyId + $condition + """); + cnd.and("e.takePartInBaseManagementId", "is not", null); + cnd.and("e.isNormal", "=", true); + cnd.andEX("ta.year", "=", year); + taSql.setCondition(cnd); + return listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), taSql); + } - //发短信 - Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); - //String content = "【智慧工会】%s老师您好,您报名的%s疗休养线路已取消成功".formatted(user.getUsername(), lineInfo.getLineName()); - //msgApi.sendMsg(content, user.getMobile(), MsgApi.DING_DING_TEMPLATE_ID); + /** + * 找到报名信息通过id + * + * @param id id + * @return {@link TheRapyRecuperationEnroll} + */ + @Override + public TheRapyRecuperationEnroll findSignUpInfoById(String id) { + TheRapyRecuperationEnroll enroll = fetch(id); + return fetchLinks(enroll, "companionList|bedInfo"); + } + + /** + * 删除我的报名信息 + * + * @param id id + */ + @Override + @Aop(TransAop.READ_COMMITTED) + public void deleteMyEnrollInfoById(String id) { + TheRapyRecuperationEnroll enrollInfo = fetch(id); + dao().clearLinks(enrollInfo, "companionList|bedInfo"); + delete(id); + dao().clear(TheRapyRecuperationEnrollChangeRecord.class, Cnd.where("enrollId", "=", id)); + + //发短信 + Sys_user user = (Sys_user) ShiroUtil.getPrincipal(); + //String content = "【智慧工会】%s老师您好,您报名的%s疗休养线路已取消成功".formatted(user.getUsername(), lineInfo.getLineName()); + //msgApi.sendMsg(content, user.getMobile(), MsgApi.DING_DING_TEMPLATE_ID); // RCSCloudAPI.sendTplSms("81d48e1811144270b838b321575c7199", user.getMobile(), "@1@=" + user.getUsername() + "||@2@=取消||@3@=" + lineInfo.getLineName(), ""); - } + } - /** - * 手机端线路介绍所有信息 - * - * @param usId usId - * @param usUnionId usUnionId - * @return {@link NutMap} - */ - @Override - public NutMap selectLineAllInfo(String usId, String usUnionId) { + /** + * 手机端线路介绍所有信息 + * + * @param usId usId + * @param usUnionId usUnionId + * @return {@link NutMap} + */ + @Override + public NutMap selectLineAllInfo(String usId, String usUnionId) { - Sql usLineSql = Sqls.create(""" - SELECT - us.id as usId, - line.id as lineId, - line.lineName, - line.regionalNature, - us.playStartTime, - us.playEndTime, - us.signUpStartTime, - us.signUpEndTime, - us.changeEndTime, - us.minimumGroupSize, - us.estimatedFamilyNumbers, - line.content, - l.lotName, - (select COUNT(1) FROM the_rapy_recuperation_enroll en WHERE isNormal=true AND en.loginName=@loginname and YEAR(en.signingUptime)=@year) isNormal, - (select COUNT(1) FROM the_rapy_recuperation_enroll en WHERE isNormal=false AND en.loginName=@loginname and YEAR(en.signingUptime)=@year) isNormalFalse, - (select count(1) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and YEAR(signingUptime)=@year) as signUpUserNum, - (select count(1) from the_rapy_recuperation_enroll_companion where trreId in (select id from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and YEAR(signingUptime)=@year)) as signUpUserFamilyNum, - (select ifnull(sum(familyNumber),0) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as familyNumber, - ta.travelAgencyName, - ta.contactMobileNumber - FROM - `the_rapy_recuperation_line_union_select` us - LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId - LEFT JOIN the_rapy_recuperation_travel_agency ta on ta.id = line.travelAgencyId - LEFT JOIN the_rapy_recuperation_lot l on l.id = line.lotId - WHERE if(us.signUpMode = 1, us.unionId = @usUnionId, 1=1) AND us.id = @id - """); - usLineSql.setParam("loginname", ShiroUtil.getPrincipalProperty("loginname")); - usLineSql.setParam("year", DateUtil.thisYear()); - usLineSql.setParam("usUnionId", usUnionId); - usLineSql.setParam("id", usId); + Sql usLineSql = Sqls.create(""" + SELECT + us.id as usId, + us.estimatedCost, + line.id as lineId, + line.lineName, + line.regionalNature, + us.playStartTime, + us.playEndTime, + us.signUpStartTime, + us.signUpEndTime, + us.changeEndTime, + us.minimumGroupSize, + us.estimatedFamilyNumbers, + line.content, + l.lotName, + (select COUNT(1) FROM the_rapy_recuperation_enroll en WHERE isNormal=true AND en.loginName=@loginname and YEAR(en.signingUptime)=@year) isNormal, + (select COUNT(1) FROM the_rapy_recuperation_enroll en WHERE isNormal=false AND en.loginName=@loginname and YEAR(en.signingUptime)=@year) isNormalFalse, + (select count(1) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and YEAR(signingUptime)=@year) as signUpUserNum, + (select count(1) from the_rapy_recuperation_enroll_companion where trreId in (select id from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and YEAR(signingUptime)=@year)) as signUpUserFamilyNum, + (select ifnull(sum(familyNumber),0) from the_rapy_recuperation_enroll where takePartInLineId = us.id and if(us.signUpMode = 1, takePartInUnionId = us.unionId, 1=1) and isNormal = true and stateId not in (2715,2725,2735) and YEAR(signingUptime)=@year) as familyNumber, + ta.travelAgencyName, + ta.contactMobileNumber + FROM + `the_rapy_recuperation_line_union_select` us + LEFT JOIN the_rapy_recuperation_line line ON line.id = us.lineId + LEFT JOIN the_rapy_recuperation_travel_agency ta on ta.id = line.travelAgencyId + LEFT JOIN the_rapy_recuperation_lot l on l.id = line.lotId + WHERE if(us.signUpMode = 1, us.unionId = @usUnionId, 1=1) AND us.id = @id + """); + usLineSql.setParam("loginname", ShiroUtil.getPrincipalProperty("loginname")); + usLineSql.setParam("year", DateUtil.thisYear()); + usLineSql.setParam("usUnionId", usUnionId); + usLineSql.setParam("id", usId); - return fetch(usLineSql); - } + return fetch(usLineSql); + } - @Override - public List getTheRapyUnions(Integer year) { - //查询某个年份公开线路了的工会 - List openList = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("isOpen", "=", true) - .and("signUpMode", "=", 1).and("year(selectTime)", "=", DateUtil.thisYear()).and("unionId", "!=", Vi.getUnionId())); + @Override + public List getTheRapyUnions(Integer year) { + //查询某个年份公开线路了的工会 + List openList = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("isOpen", "=", true) + .and("signUpMode", "=", 1).and("year(selectTime)", "=", DateUtil.thisYear()).and("unionId", "!=", Vi.getUnionId())); // List openList = dao().query(TheRapyRecuperationLineUnionSelect.class, // Cnd.where("signUpMode", "=", 1).and("year(selectTime)", "=", DateUtil.thisYear())); - if (Lang.isNotEmpty(openList)) { - List unionIds = openList.stream().map(TheRapyRecuperationLineUnionSelect::getUnionId).distinct().collect(Collectors.toList()); - return dao().query(Sys_union.class, Cnd.where("id", "in", unionIds)); - } - return new ArrayList<>(); - } + if (Lang.isNotEmpty(openList)) { + List unionIds = openList.stream().map(TheRapyRecuperationLineUnionSelect::getUnionId).distinct().collect(Collectors.toList()); + return dao().query(Sys_union.class, Cnd.where("id", "in", unionIds)); + } + return new ArrayList<>(); + } } diff --git a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationLineServiceImpl.java b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationLineServiceImpl.java index 69a98d2..8bcfe36 100644 --- a/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationLineServiceImpl.java +++ b/src/main/java/io/v/nutz/zhgh/therapyRecuperation/service/impl/TheRapyRecuperationLineServiceImpl.java @@ -9,6 +9,7 @@ import io.v.nutz.web.commons.utils.ShiroUtil; import io.v.nutz.zhgh.therapyRecuperation.constant.TheRapyRecuperationLineCreateMode; import io.v.nutz.zhgh.therapyRecuperation.constant.TheRapyRecuperationSignUpMode; import io.v.nutz.zhgh.therapyRecuperation.constant.TheRapyRecuperationState; +import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationEnroll; import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationEnrollCompanion; import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationLine; import io.v.nutz.zhgh.therapyRecuperation.model.TheRapyRecuperationLineUnionSelect; @@ -49,8 +50,12 @@ public class TheRapyRecuperationLineServiceImpl extends ViServiceImpl unionSelects = dao().query(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "=", lineId)); + List list = unionSelects.stream().map(TheRapyRecuperationLineUnionSelect::getId).toList(); + delete(lineId); dao().clear(TheRapyRecuperationLineUnionSelect.class, Cnd.where("lineId", "=", lineId)); + dao().clear(TheRapyRecuperationEnroll.class, Cnd.where("takePartInLineId", "in", list)); deleteLineInfoCache(lineId); } @@ -62,9 +67,16 @@ public class TheRapyRecuperationLineServiceImpl extends ViServiceImpl> '$[0].id' as char) as fileId + files as fileId from the_rapy_recuperation_travel_agency $condition """); diff --git a/src/main/resources/static/components/theRapyRecuperation/LineAuditInfo.vue b/src/main/resources/static/components/theRapyRecuperation/LineAuditInfo.vue new file mode 100644 index 0000000..63a1386 --- /dev/null +++ b/src/main/resources/static/components/theRapyRecuperation/LineAuditInfo.vue @@ -0,0 +1,210 @@ + + \ No newline at end of file diff --git a/src/main/resources/static/components/theRapyRecuperation/LineInfo.vue b/src/main/resources/static/components/theRapyRecuperation/LineInfo.vue index fa1d1dd..1774e49 100644 --- a/src/main/resources/static/components/theRapyRecuperation/LineInfo.vue +++ b/src/main/resources/static/components/theRapyRecuperation/LineInfo.vue @@ -1,90 +1,120 @@ diff --git a/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html b/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html index b55e3f1..bf2a67e 100644 --- a/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html +++ b/src/main/resources/views/mobile/therapyRecuperation/baseManagement.html @@ -723,7 +723,7 @@ layout("/mobile/platform.html"){ }), }) if (re.code !== 0) { - vant.Toast(re.msg) + vant.Dialog.alert({title: '温馨提示', message: re.msg}) return } if (this.fromUrlByMy !== 'editDo') { diff --git a/src/main/resources/views/mobile/therapyRecuperation/index.html b/src/main/resources/views/mobile/therapyRecuperation/index.html index 964f570..a6c87e4 100644 --- a/src/main/resources/views/mobile/therapyRecuperation/index.html +++ b/src/main/resources/views/mobile/therapyRecuperation/index.html @@ -71,6 +71,13 @@ layout("/mobile/platform.html"){
+
+ + 疗休养首页 + 线路选择 + 我的报名 + +
+ + diff --git a/src/main/resources/views/platform/theRapyRecuperation/lineQuery/index.html b/src/main/resources/views/platform/theRapyRecuperation/lineQuery/index.html index 2b0dec5..d756aad 100644 --- a/src/main/resources/views/platform/theRapyRecuperation/lineQuery/index.html +++ b/src/main/resources/views/platform/theRapyRecuperation/lineQuery/index.html @@ -263,7 +263,7 @@ layout("/layouts/platform.html"){ {prop: 'regionalNature', label: '线路类型', sortable: true}, {prop: 'username', label: '发起人', sortable: true}, {prop: 'unionname', label: '所属工会', sortable: true}, - {prop: 'estimatedFamilyNumbers', label: '最少成团人数', width: 80}, + {prop: 'minimumGroupSize', label: '最少成团人数', width: 80}, {prop: 'lineNum', label: '报名人数(家属)'}, {prop: 'stateName', label: '审核状态'}, ], diff --git a/src/main/resources/views/platform/theRapyRecuperation/process/lineUnionSelect.html b/src/main/resources/views/platform/theRapyRecuperation/process/lineUnionSelect.html index 3b98b0f..547dfeb 100644 --- a/src/main/resources/views/platform/theRapyRecuperation/process/lineUnionSelect.html +++ b/src/main/resources/views/platform/theRapyRecuperation/process/lineUnionSelect.html @@ -327,8 +327,10 @@ layout("/layouts/platform.html"){ :rules="{required:true,message:'出行开始时间',trigger:['change','blur']}" label-width="0"> @@ -344,8 +346,9 @@ layout("/layouts/platform.html"){ :rules="{required:true,message:'出行结束时间',trigger:['change','blur']}" label-width="0"> @@ -393,19 +396,19 @@ layout("/layouts/platform.html"){ - + - + @@ -451,7 +454,7 @@ layout("/layouts/platform.html"){ ]"> 自己选择 - 本分工会 + 全校 @@ -486,7 +489,7 @@ layout("/layouts/platform.html"){ + width="80%" top="2%">
@@ -495,50 +498,28 @@ layout("/layouts/platform.html"){
- - - {{row.signUpStartTime}} - - - {{row.signUpEndTime}} - - - - {{row.changeEndTime}} - - {{row.playStartTime}} - {{row.playEndTime}} {{row.contact}} - {{row.contactPhone}} - - + {{row.minimumGroupSize}} - {{row.trafficTools}} - {{row.estimatedCost}} - - - {{row.estimatedFamilyNumbers}} - - - - - {{signUpModeName(row.signUpMode)}} - - @@ -787,7 +763,13 @@ layout("/layouts/platform.html"){ } callback() } + const that = this return { + pickerOptions: { + disabledDate(time) { + return that.calPlayTime(time) + } + }, canChooseUserList: [], chooseUserMultiple: [], userDialogVisible: false, @@ -872,6 +854,18 @@ layout("/layouts/platform.html"){ }, }, methods: { + calPlayTime(time) { + const year = new Date().getFullYear() + const lot = this.lotList.find(o => o.id === this.lineData.lotId) + const beforeTime = moment(year + '-10-01').add(-(Number(lot.lotValue)), 'days') + return !(time > new Date(year + '-06-30') && time < beforeTime) + }, + platStartChange(time, row) { + const lot = this.lotList.find(o => o.id === this.lineData.lotId) + const afterTime = moment(time).add(Number(lot.lotValue), 'days') + row.playEndTime = afterTime.format('YYYY-MM-DD HH:mm:ss') + this.$forceUpdate() + }, addRow() { this.formData.times.push({ enable:true, @@ -1120,7 +1114,6 @@ layout("/layouts/platform.html"){ } }, async doEditOpen(row){ - console.log(row) const resp = await $.get(loc() + '/doEditOpen',{id:row.usId}) if (resp.code === 0){ this.$message.success(resp.msg) diff --git a/src/main/resources/views/platform/theRapyRecuperation/statistics/fragment.html b/src/main/resources/views/platform/theRapyRecuperation/statistics/fragment.html index e3420f8..07d52ba 100644 --- a/src/main/resources/views/platform/theRapyRecuperation/statistics/fragment.html +++ b/src/main/resources/views/platform/theRapyRecuperation/statistics/fragment.html @@ -52,10 +52,37 @@ layout("/layouts/platform.html"){ v-model="pageForm.endYear" type="year" value-format="yyyy" - placeholder="选择年" + placeholder="请选择年" style="width: 38%" @change="doSearch"> + + 出行时间: + + + + + + + + + + + + + 酒店名称: - - - - - - - 旅 行 社: - - 路线类型: - - - - - - @@ -110,9 +120,24 @@ layout("/layouts/platform.html"){ ref="table_tool"> - + @@ -180,13 +185,10 @@ layout("/layouts/platform.html"){ - - + 取 消 @@ -195,6 +197,7 @@ layout("/layouts/platform.html"){ + @@ -205,7 +208,7 @@ layout("/layouts/platform.html"){