diff --git a/admin/src/api/pmcomplaintsuggestion.js b/admin/src/api/pmcomplaintsuggestion.js index 6b7b785..de10e74 100644 --- a/admin/src/api/pmcomplaintsuggestion.js +++ b/admin/src/api/pmcomplaintsuggestion.js @@ -61,3 +61,15 @@ export function pmcomplaintsuggestionListApi(params) { }) } +/** + * 祈愿菜单列表(csType=99) + * @param params + */ +export function wishMenuListApi(params) { + return request({ + url: `autogencode/pmcomplaintsuggestion/wishMenuList`, + method: 'GET', + params + }) +} + diff --git a/admin/src/api/pmdailymenudtllike.js b/admin/src/api/pmdailymenudtllike.js new file mode 100644 index 0000000..b573d04 --- /dev/null +++ b/admin/src/api/pmdailymenudtllike.js @@ -0,0 +1,95 @@ + +import request from '@/utils/request' + +/** + * 新增pmdailymenudtllike + * @param pram + */ +export function pmdailymenudtllikeCreateApi(data) { + return request({ + url: `autogencode/pmdailymenudtllike/save`, + method: 'POST', + data + }) +} + +/** + * pmdailymenudtllike更新 + * @param pram + */ +export function pmdailymenudtllikeUpdateApi(data) { + return request({ + url: `autogencode/pmdailymenudtllike/update`, + method: 'POST', + data + }) +} + +/** + * pmdailymenudtllike详情 + * @param pram + */ +export function pmdailymenudtllikeDetailApi(id) { + return request({ + url: `autogencode/pmdailymenudtllike/info/${id}`, + method: 'GET' + }) +} + +/** + * pmdailymenudtllike批量删除 + * @param ids + */ +export function pmdailymenudtllikeDeleteApi(ids) { + return request({ + url: `autogencode/pmdailymenudtllike/delete`, + method: 'POST', + data: ids + }) +} + + +/** + * pmdailymenudtllike列表 + * @param pram + */ +export function pmdailymenudtllikeListApi(params) { + return request({ + url: `autogencode/pmdailymenudtllike/list`, + method: 'GET', + params + }) +} + +/** + * 对菜单明细进行点赞/点踩 + * @param menuDtlId 菜单明细ID + * @param likeType 评价类型:1-点赞,2-点踩 + */ +export function pmdailymenudtllikeLikeApi(menuDtlId, likeType) { + return request({ + url: `autogencode/pmdailymenudtllike/like`, + method: 'POST', + params: { + menuDtlId, + likeType + } + }) +} + +/** + * 查询菜品点赞和点踩排行 + * @param params 查询参数 + * @param params.limit 返回数量限制 + * @param params.rankingType 排行类型:like-点赞排行,dislike-点踩排行 + * @param params.itemType 菜品类型 + * @param params.date 日期 + */ +export function pmdailymenudtllikeRankingApi(params) { + return request({ + url: `autogencode/pmdailymenudtllike/ranking`, + method: 'GET', + params + }) +} + diff --git a/admin/src/views/cm/cust/cmcust-add-and-update.vue b/admin/src/views/cm/cust/cmcust-add-and-update.vue index 97d3b97..7a7dea3 100644 --- a/admin/src/views/cm/cust/cmcust-add-and-update.vue +++ b/admin/src/views/cm/cust/cmcust-add-and-update.vue @@ -19,7 +19,14 @@ - + + + + @@ -37,10 +44,12 @@ diff --git a/admin/src/views/pm/daily/menu/dtl/index-like.vue b/admin/src/views/pm/daily/menu/dtl/index-like.vue new file mode 100644 index 0000000..f8a3035 --- /dev/null +++ b/admin/src/views/pm/daily/menu/dtl/index-like.vue @@ -0,0 +1,201 @@ + + + + 菜品评价排行 + + 点赞排行 + 点踩排行 + + + + + + + + + + + + + + 查询 + 重置 + + + + + + + + + + + + + + + {{ rankingType === 'like' ? scope.row.likeCount : scope.row.dislikeCount }} + + + + + + + + + + + diff --git a/admin/src/views/pm/daily/menu/suggestion/index.vue b/admin/src/views/pm/daily/menu/suggestion/index.vue new file mode 100644 index 0000000..93cb398 --- /dev/null +++ b/admin/src/views/pm/daily/menu/suggestion/index.vue @@ -0,0 +1,311 @@ + + + + + + + + + + + + + 查询 + 重置 + 新增祈愿 + 批量删除 + + + + + + + + + + + + + + + + + + + + + + + + + + {{ '修改' }} + {{ '处理' }} + 删除 + + + + + + + + + + + diff --git a/admin/src/views/pm/daily/menu/suggestion/pmcomplaintsuggestion-add-and-update.vue b/admin/src/views/pm/daily/menu/suggestion/pmcomplaintsuggestion-add-and-update.vue new file mode 100644 index 0000000..0b83d4b --- /dev/null +++ b/admin/src/views/pm/daily/menu/suggestion/pmcomplaintsuggestion-add-and-update.vue @@ -0,0 +1,471 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 取消 + 确定 + + + + + diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CmCustController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CmCustController.java index 256fc75..cc16f5d 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CmCustController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/CmCustController.java @@ -186,6 +186,18 @@ public class CmCustController { } supplier.setQualifyStatus(qualifyStatus); + + // 设置资质状态的虚拟字段,根据supplier关联的所有CmCustQualifyFile的status,是否都是status为1 + String allStatusPassed = "0"; + List allCustFiles = allFilesMap.getOrDefault(supplier.getId(), Collections.emptyList()); + if (!allCustFiles.isEmpty()) { + boolean isAllStatusOne = allCustFiles.stream().allMatch(file -> "1".equals(file.getStatus())); + if (isAllStatusOne) { + allStatusPassed = "1"; + } + } + supplier.setAllStatusPassed(allStatusPassed); + } return CommonResult.success(page); @@ -235,6 +247,19 @@ public class CmCustController { // 设置供应商的资质列表 cmCust.setCmCustQualifyList(qualifyList); + + // 设置资质状态的虚拟字段,根据supplier关联的所有CmCustQualifyFile的status,是否都是status为1 + String allStatusPassed = "0"; + List allCustFiles = cmCustQualifyFileService.list(new LambdaQueryWrapper() + .eq(CmCustQualifyFile::getCustId, id) + .eq(CmCustQualifyFile::getDelFlag, "0")); + if (!allCustFiles.isEmpty()) { + boolean isAllStatusOne = allCustFiles.stream().allMatch(file -> "1".equals(file.getStatus())); + if (isAllStatusOne) { + allStatusPassed = "1"; + } + } + cmCust.setAllStatusPassed(allStatusPassed); } return CommonResult.success(cmCust); diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmComplaintSuggestionController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmComplaintSuggestionController.java index 17c9c2a..f866ab6 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmComplaintSuggestionController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmComplaintSuggestionController.java @@ -194,6 +194,11 @@ public class PmComplaintSuggestionController { queryWrapper.eq(PmComplaintSuggestion::getOwnerId, request.getOwnerId()); } + // 业主名称 + if (StrUtil.isNotBlank(request.getOwnerName())) { + queryWrapper.like(PmComplaintSuggestion::getOwnerName, request.getOwnerName()); + } + // 房屋id if (request.getHouseId() != null) { queryWrapper.eq(PmComplaintSuggestion::getHouseId, request.getHouseId()); @@ -241,6 +246,9 @@ public class PmComplaintSuggestionController { // 应用搜索条件 condition(queryWrapper, request); + // 过滤掉csType=99的数据(祈愿菜单) + queryWrapper.ne(PmComplaintSuggestion::getCsType, "99"); + List list = pmComplaintSuggestionService.pageList(queryWrapper, pageParamRequest); // 为每个投诉建议添加处理人名称、业主名称和房屋名称 @@ -327,6 +335,108 @@ public class PmComplaintSuggestionController { } + /** + * 分页显示祈愿菜单(默认csType=99) + * @param request 搜索条件 + * @param pageParamRequest 分页参数 + */ + @ApiOperation(value = "祈愿菜单列表") + @RequestMapping(value = "/wishMenuList", method = RequestMethod.GET) + public CommonResult> getWishMenuList(@Validated PmComplaintSuggestion request, @Validated PageParamRequest pageParamRequest) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + + // 强制设置csType为99(祈愿菜单类型) + request.setCsType("99"); + + // 应用搜索条件 + condition(queryWrapper, request); + + List list = pmComplaintSuggestionService.pageList(queryWrapper, pageParamRequest); + + // 为每个祈愿菜单添加处理人名称、业主名称和房屋名称 + for (PmComplaintSuggestion item : list) { + // 添加处理人名称 + if (item.getHandlerId() != null) { + try { + // 将Long类型的handlerId转换为Integer + Integer adminId = item.getHandlerId().intValue(); + com.zbkj.common.model.system.SystemAdmin admin = systemAdminService.getDetail(adminId); + if (admin != null) { + item.setHandlerName(admin.getRealName()); + } else { + item.setHandlerName(""); + } + } catch (Exception e) { + item.setHandlerName(""); + } + } else { + item.setHandlerName(""); + } + + // 添加业主名称 + if (item.getOwnerId() != null) { + if ("1".equals(item.getOwnerType())) { + PmOwner owner = pmOwnerService.getById(item.getOwnerId()); + item.setOwnerName(owner != null ? owner.getOwnerName() : ""); + } else if ("2".equals(item.getOwnerType())) { + PmTenant tenant = pmTenantService.getById(item.getOwnerId()); + item.setOwnerName(tenant != null ? tenant.getTenantName() : ""); + } + } + + // 添加房屋名称 + if (item.getHouseId() != null) { + PmHouse house = pmHouseService.getById(item.getHouseId()); + if (house != null) { + StringBuilder houseName = new StringBuilder(); + if (house.getUnitNo() != null) { + houseName.append(house.getUnitNo()).append("单元 "); + } + if (house.getFloorNo() != null) { + houseName.append(house.getFloorNo()).append("层 "); + } + if (house.getHouseNo() != null) { + houseName.append(house.getHouseNo()).append("室"); + } + item.setHouseName(houseName.toString()); + } + } + + // 添加被投诉房屋名称 + if (item.getComplainedHouseId() != null) { + PmHouse complainedHouse = pmHouseService.getById(item.getComplainedHouseId()); + if (complainedHouse != null) { + StringBuilder complainedHouseName = new StringBuilder(); + if (complainedHouse.getUnitNo() != null) { + complainedHouseName.append(complainedHouse.getUnitNo()).append("单元 "); + } + if (complainedHouse.getFloorNo() != null) { + complainedHouseName.append(complainedHouse.getFloorNo()).append("层 "); + } + if (complainedHouse.getHouseNo() != null) { + complainedHouseName.append(complainedHouse.getHouseNo()).append("室"); + } + item.setComplainedHouseName(complainedHouseName.toString()); + } + } + + // 添加业主所属部门名称 + if (item.getOwnerCompany() != null) { + SysDept dept = sysDeptService.getById(item.getOwnerCompany()); + if (dept != null) { + item.setOwnerDeptName(dept.getDeptName()); + } + } + + // 设置文件列表 + setFile(item); + } + + CommonPage page = CommonPage.restPage(list); + return CommonResult.success(page); + } + + /** * 详情数据 */ @@ -421,6 +531,25 @@ public class PmComplaintSuggestionController { @RequestMapping(value = "/save", method = RequestMethod.POST) public CommonResult save(@RequestBody PmComplaintSuggestion pmComplaintSuggestion){ + // 检查是否是祈愿菜单(csType=99) + if ("99".equals(pmComplaintSuggestion.getCsType())) { + // 检查用户是否已有未答复的祈愿 + if (pmComplaintSuggestion.getOwnerId() != null) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmComplaintSuggestion::getCsType, "99"); // 祈愿菜单类型 + queryWrapper.eq(PmComplaintSuggestion::getOwnerId, pmComplaintSuggestion.getOwnerId()); // 同一用户 + queryWrapper.ne(PmComplaintSuggestion::getStatus, "3"); // 状态不是已处理 + queryWrapper.eq(PmComplaintSuggestion::getDelFlag, "0"); // 未删除 + + long count = pmComplaintSuggestionService.count(queryWrapper); + if (count > 0) { + return CommonResult.failed("您有未答复的祈愿,请等待处理完成后再提交新的祈愿"); + } + } else { + return CommonResult.failed("请先选择祈愿人"); + } + } + // 获取当前用户信息(如果没有通过 uid 设置 create_by) Long currentUserId = null; if (pmComplaintSuggestion.getCreateBy() == null) { diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuDtlController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuDtlController.java index 0e00ce9..55d9ebf 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuDtlController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuDtlController.java @@ -27,6 +27,8 @@ import com.zbkj.modules.autogencode.entity.PmDailyMenu; import com.zbkj.modules.autogencode.entity.PmDailyMenuDtl; import com.zbkj.modules.autogencode.service.PmDailyMenuDtlService; import com.zbkj.modules.autogencode.service.PmDailyMenuService; +import com.zbkj.modules.autogencode.entity.PmDailyMenuDtlLike; +import com.zbkj.modules.autogencode.service.PmDailyMenuDtlLikeService; @@ -42,6 +44,9 @@ public class PmDailyMenuDtlController { @Autowired private PmDailyMenuService pmDailyMenuService; + + @Autowired + private PmDailyMenuDtlLikeService pmDailyMenuDtlLikeService; @@ -215,8 +220,24 @@ public class PmDailyMenuDtlController { dtl.setMealType(menu.getMealType()); } } + + // 计算点赞数量 + LambdaQueryWrapper likeQueryWrapper = new LambdaQueryWrapper<>(); + likeQueryWrapper.eq(PmDailyMenuDtlLike::getMenuDtlId, dtl.getId()); + likeQueryWrapper.eq(PmDailyMenuDtlLike::getLikeType, "1"); + likeQueryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, "0"); + int likeCount = pmDailyMenuDtlLikeService.count(likeQueryWrapper); + dtl.setLikeCount(likeCount); + + // 计算点踩数量 + LambdaQueryWrapper dislikeQueryWrapper = new LambdaQueryWrapper<>(); + dislikeQueryWrapper.eq(PmDailyMenuDtlLike::getMenuDtlId, dtl.getId()); + dislikeQueryWrapper.eq(PmDailyMenuDtlLike::getLikeType, "2"); + dislikeQueryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, "0"); + int dislikeCount = pmDailyMenuDtlLikeService.count(dislikeQueryWrapper); + dtl.setDislikeCount(dislikeCount); } - + CommonPage page = CommonPage.restPage(pmDailyMenuDtls); return CommonResult.success(page); } @@ -270,6 +291,22 @@ public class PmDailyMenuDtlController { dtl.setMealType(menu.getMealType()); } } + + // 计算点赞数量 + LambdaQueryWrapper likeQueryWrapper = new LambdaQueryWrapper<>(); + likeQueryWrapper.eq(PmDailyMenuDtlLike::getMenuDtlId, dtl.getId()); + likeQueryWrapper.eq(PmDailyMenuDtlLike::getLikeType, "1"); + likeQueryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, "0"); + int likeCount = pmDailyMenuDtlLikeService.count(likeQueryWrapper); + dtl.setLikeCount(likeCount); + + // 计算点踩数量 + LambdaQueryWrapper dislikeQueryWrapper = new LambdaQueryWrapper<>(); + dislikeQueryWrapper.eq(PmDailyMenuDtlLike::getMenuDtlId, dtl.getId()); + dislikeQueryWrapper.eq(PmDailyMenuDtlLike::getLikeType, "2"); + dislikeQueryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, "0"); + int dislikeCount = pmDailyMenuDtlLikeService.count(dislikeQueryWrapper); + dtl.setDislikeCount(dislikeCount); } return CommonResult.success(pmDailyMenuDtls); @@ -327,6 +364,3 @@ public class PmDailyMenuDtlController { - - - diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuDtlLikeController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuDtlLikeController.java new file mode 100644 index 0000000..c7b4841 --- /dev/null +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmDailyMenuDtlLikeController.java @@ -0,0 +1,371 @@ +package com.zbkj.modules.autogencode.controller; + +import java.util.Arrays; +import java.util.Map; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zbkj.common.request.PageParamRequest; +import com.zbkj.common.response.CommonResult; +import com.zbkj.common.page.CommonPage; +import com.zbkj.common.utils.SecurityUtil; +import com.zbkj.common.vo.LoginUserVo; +import com.zbkj.modules.autogencode.entity.PmDailyMenu; +import com.zbkj.modules.autogencode.service.PmDailyMenuService; +import com.zbkj.modules.autogencode.entity.PmDailyMenuDtl; +import com.zbkj.modules.autogencode.service.PmDailyMenuDtlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.ApiOperation; +import org.springframework.security.access.prepost.PreAuthorize; + + + + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zbkj.modules.autogencode.entity.PmDailyMenuDtlLike; +import com.zbkj.modules.autogencode.service.PmDailyMenuDtlLikeService; + + + + +/** + * 食堂菜单明细点赞/点踩关联表 控制器 + */ +@RestController +@RequestMapping("api/autogencode/pmdailymenudtllike") +public class PmDailyMenuDtlLikeController { + @Autowired + private PmDailyMenuDtlLikeService pmDailyMenuDtlLikeService; + + @Autowired + private PmDailyMenuDtlService pmDailyMenuDtlService; + + @Autowired + private PmDailyMenuService pmDailyMenuService; + + + + /** + * 条件设置 + * 根据实体类字段自动生成查询条件 + */ + private void condition(LambdaQueryWrapper queryWrapper, PmDailyMenuDtlLike request) { + if (request == null) { + return; + } + + // 根据实体类字段自动生成查询条件 + + // 主键ID + if (request.getId() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getId, request.getId()); + } + + // 菜单明细ID(关联pm_daily_menu_dtl.id) + if (request.getMenuDtlId() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getMenuDtlId, request.getMenuDtlId()); + } + + // 评价用户ID + if (request.getUserId() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getUserId, request.getUserId()); + } + + // 菜单日期(冗余字段,方便按日统计) + if (request.getMenuDate() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getMenuDate, request.getMenuDate()); + } + + // 评价类型:1-点赞,2-点踩 + if (StrUtil.isNotBlank(request.getLikeType())) { + queryWrapper.eq(PmDailyMenuDtlLike::getLikeType, request.getLikeType()); + } + + // 删除标志(0存在 2删除) + if (StrUtil.isNotBlank(request.getDelFlag())) { + queryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, request.getDelFlag()); + } + + // 创建人 + if (request.getCreateBy() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getCreateBy, request.getCreateBy()); + } + + // 创建时间 + if (request.getCreateTime() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getCreateTime, request.getCreateTime()); + } + + // 修改人 + if (request.getUpdateBy() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getUpdateBy, request.getUpdateBy()); + } + + // 修改时间 + if (request.getUpdateTime() != null) { + queryWrapper.eq(PmDailyMenuDtlLike::getUpdateTime, request.getUpdateTime()); + } + + // 租户ID + if (StrUtil.isNotBlank(request.getTenantId())) { + queryWrapper.eq(PmDailyMenuDtlLike::getTenantId, request.getTenantId()); + } + + } + + + /** + * 分页显示食堂菜单明细点赞/点踩关联表 + * @param request 搜索条件 + * @param pageParamRequest 分页参数 + */ + @ApiOperation(value = "分页列表") + @RequestMapping(value = "/list", method = RequestMethod.GET) + public CommonResult> getList(@Validated PmDailyMenuDtlLike request, @Validated PageParamRequest pageParamRequest) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper(); + + // 应用搜索条件 + condition(queryWrapper, request); + + CommonPage page = CommonPage.restPage(pmDailyMenuDtlLikeService.pageList(queryWrapper, pageParamRequest)); + return CommonResult.success(page); + } + + + /** + * 详情数据 + */ + @RequestMapping(value = "/info/{id}", method = RequestMethod.GET) + public CommonResult info(@PathVariable("id") Long id){ + PmDailyMenuDtlLike pmDailyMenuDtlLike = pmDailyMenuDtlLikeService.getById(id); + + return CommonResult.success(pmDailyMenuDtlLike); + } + + /** + * 新增数据 + */ + @RequestMapping(value = "/save", method = RequestMethod.POST) + public CommonResult save(@RequestBody PmDailyMenuDtlLike pmDailyMenuDtlLike){ + if (pmDailyMenuDtlLikeService.save(pmDailyMenuDtlLike)) { + return CommonResult.success(); + } + return CommonResult.failed(); + } + + /** + * 修改数据 + */ + @RequestMapping(value = "/update", method = RequestMethod.POST) + public CommonResult update(@RequestBody PmDailyMenuDtlLike pmDailyMenuDtlLike){ + if (pmDailyMenuDtlLikeService.updateById(pmDailyMenuDtlLike)) { + return CommonResult.success(); + } + return CommonResult.failed(); + } + + /** + * 删除:根据id集合 + */ + @RequestMapping(value = "/delete", method = RequestMethod.POST) + public CommonResult delete(@RequestBody Long[] ids){ + if (pmDailyMenuDtlLikeService.removeByIds(Arrays.asList(ids))) { + return CommonResult.success(); + } + return CommonResult.failed(); + } + + /** + * 对菜单明细进行点赞/点踩 + * @param menuDtlId 菜单明细ID + * @param likeType 评价类型:1-点赞,2-点踩 + */ + @ApiOperation(value = "对菜单明细进行点赞/点踩") + @RequestMapping(value = "/like", method = RequestMethod.POST) + public CommonResult likeOrDislike(@RequestParam Long menuDtlId, @RequestParam String likeType) { + try { + // 获取当前登录用户ID + LoginUserVo loginUserVo = SecurityUtil.getLoginUserVo(); + if (loginUserVo == null || loginUserVo.getUser() == null) { + return CommonResult.failed("用户未登录"); + } + Long userId = Long.valueOf(loginUserVo.getUser().getId()); + + // 获取菜单明细信息 + PmDailyMenuDtl menuDtl = pmDailyMenuDtlService.getById(menuDtlId); + if (menuDtl == null) { + return CommonResult.failed("菜单明细不存在"); + } + + // 通过PmDailyMenu 获取菜单日期 + PmDailyMenu menu = pmDailyMenuService.getById(menuDtl.getMenuId()); + if (menu == null) { + return CommonResult.failed("菜单不存在"); + } + + Date menuDate = menu.getMenuDate(); + if (menuDate == null) { + return CommonResult.failed("菜单日期不存在"); + } + + // 检查用户在该日期的评价次数 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmDailyMenuDtlLike::getUserId, userId); + queryWrapper.eq(PmDailyMenuDtlLike::getMenuDate, menuDate); + queryWrapper.eq(PmDailyMenuDtlLike::getLikeType, likeType); + queryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, "0"); + + int count = pmDailyMenuDtlLikeService.count(queryWrapper); + if (count >= 3) { + return CommonResult.failed("同一日期内" + ("1".equals(likeType) ? "点赞" : "点踩") + "次数已达上限(3次)"); + } + + // 检查是否已经对该菜单明细进行过评价 + LambdaQueryWrapper existQueryWrapper = new LambdaQueryWrapper<>(); + existQueryWrapper.eq(PmDailyMenuDtlLike::getUserId, userId); + existQueryWrapper.eq(PmDailyMenuDtlLike::getMenuDtlId, menuDtlId); + existQueryWrapper.eq(PmDailyMenuDtlLike::getLikeType, likeType); + existQueryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, "0"); + + PmDailyMenuDtlLike existingLike = pmDailyMenuDtlLikeService.getOne(existQueryWrapper); + if (existingLike != null) { + return CommonResult.failed("已经对该菜品进行过" + ("1".equals(likeType) ? "点赞" : "点踩")); + } + + // 保存点赞/点踩记录 + PmDailyMenuDtlLike like = new PmDailyMenuDtlLike(); + like.setMenuDtlId(menuDtlId); + like.setUserId(userId); + like.setMenuDate(menuDate); + like.setLikeType(likeType); + like.setDelFlag("0"); + like.setCreateBy(userId); + like.setCreateTime(new Date()); + + if (pmDailyMenuDtlLikeService.save(like)) { + return CommonResult.success("操作成功"); + } else { + return CommonResult.failed("操作失败"); + } + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("操作失败:" + e.getMessage()); + } + } + + /** + * 查询菜品点赞和点踩排行 + * @param limit 返回数量限制 + * @param rankingType 排行类型:like-点赞排行,dislike-点踩排行 + * @param itemType 菜品类型 + * @param startDate 开始日期 + * @param endDate 结束日期 + */ + @ApiOperation(value = "查询菜品点赞和点踩排行") + @RequestMapping(value = "/ranking", method = RequestMethod.GET) + public CommonResult> getRanking(@RequestParam(defaultValue = "10") Integer limit, + @RequestParam(defaultValue = "like") String rankingType, + @RequestParam(required = false) String itemType, + @RequestParam(required = false) String startDate, + @RequestParam(required = false) String endDate) { + try { + // 构建查询条件 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PmDailyMenuDtlLike::getDelFlag, "0"); + + // 如果有日期范围条件,添加日期过滤 + if (StrUtil.isNotBlank(startDate)) { + queryWrapper.ge(PmDailyMenuDtlLike::getMenuDate, startDate); + } + if (StrUtil.isNotBlank(endDate)) { + queryWrapper.le(PmDailyMenuDtlLike::getMenuDate, endDate); + } + + // 获取点赞/点踩记录 + List likeList = pmDailyMenuDtlLikeService.list(queryWrapper); + + // 统计每个菜品的点赞和点踩数量 + Map> itemStats = new HashMap<>(); + + for (PmDailyMenuDtlLike like : likeList) { + // 获取菜单明细信息 + PmDailyMenuDtl menuDtl = pmDailyMenuDtlService.getById(like.getMenuDtlId()); + if (menuDtl != null && StrUtil.isNotBlank(menuDtl.getItemName())) { + // 如果有菜品类型条件,过滤不符合的菜品 + if (StrUtil.isNotBlank(itemType) && !itemType.equals(menuDtl.getItemType())) { + continue; + } + + Long menuDtlId = menuDtl.getId(); + + // 初始化菜品统计信息 + if (!itemStats.containsKey(menuDtlId)) { + Map stats = new HashMap<>(); + stats.put("likeCount", 0); + stats.put("dislikeCount", 0); + stats.put("menuDtl", menuDtl); + itemStats.put(menuDtlId, stats); + } + + // 更新统计信息 + Map stats = itemStats.get(menuDtlId); + if ("1".equals(like.getLikeType())) { + stats.put("likeCount", (Integer) stats.get("likeCount") + 1); + } else if ("2".equals(like.getLikeType())) { + stats.put("dislikeCount", (Integer) stats.get("dislikeCount") + 1); + } + } + } + + // 转换为排行列表 + List rankingList = new ArrayList<>(); + for (Map.Entry> entry : itemStats.entrySet()) { + PmDailyMenuDtl menuDtl = (PmDailyMenuDtl) entry.getValue().get("menuDtl"); + + // 创建PmDailyMenuDtlLike对象用于返回 + PmDailyMenuDtlLike rankingItem = new PmDailyMenuDtlLike(); + rankingItem.setId(menuDtl.getId()); + rankingItem.setItemName(menuDtl.getItemName()); + rankingItem.setItemType(menuDtl.getItemType()); + rankingItem.setItemPrice(menuDtl.getItemPrice()); + rankingItem.setLikeCount((Integer) entry.getValue().get("likeCount")); + rankingItem.setDislikeCount((Integer) entry.getValue().get("dislikeCount")); + rankingItem.setTotalCount((Integer) entry.getValue().get("likeCount") + (Integer) entry.getValue().get("dislikeCount")); + + rankingList.add(rankingItem); + } + + // 根据排行类型排序 + if ("like".equals(rankingType)) { + // 按照点赞数量排序 + rankingList.sort((a, b) -> { + return Integer.compare(b.getLikeCount(), a.getLikeCount()); + }); + } else if ("dislike".equals(rankingType)) { + // 按照点踩数量排序 + rankingList.sort((a, b) -> { + return Integer.compare(b.getDislikeCount(), a.getDislikeCount()); + }); + } + + // 限制返回数量 + if (rankingList.size() > limit) { + rankingList = rankingList.subList(0, limit); + } + CommonPage page = CommonPage.restPage(rankingList); + return CommonResult.success(page); + } catch (Exception e) { + e.printStackTrace(); + return CommonResult.failed("查询失败:" + e.getMessage()); + } + } + +} + + diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmMaintenanceOrderController.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmMaintenanceOrderController.java index 54ec869..39506b9 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmMaintenanceOrderController.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/controller/PmMaintenanceOrderController.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Random; import java.util.ArrayList; import java.util.HashMap; +import java.util.Date; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -218,7 +219,7 @@ public class PmMaintenanceOrderController { // 应用搜索条件 condition(queryWrapper, request); - + queryWrapper.orderByDesc(PmMaintenanceOrder::getCreateTime); CommonPage page = CommonPage.restPage(pmMaintenanceOrderService.pageList(queryWrapper, pageParamRequest)); // 收集所有需要查询的ID @@ -409,6 +410,11 @@ public class PmMaintenanceOrderController { currentUserId = pmMaintenanceOrder.getCreateBy(); } + // 设置创建时间 + if (pmMaintenanceOrder.getCreateTime() == null) { + pmMaintenanceOrder.setCreateTime(new Date()); + } + // 如果有传uid,根据eb_user中的字段查询对应的业主、租户、部门 if (pmMaintenanceOrder.getUid() != null) { User user = userService.getOne(Wrappers.lambdaQuery() diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/dao/PmDailyMenuDtlLikeDao.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/dao/PmDailyMenuDtlLikeDao.java new file mode 100644 index 0000000..d5bf6a1 --- /dev/null +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/dao/PmDailyMenuDtlLikeDao.java @@ -0,0 +1,13 @@ +package com.zbkj.modules.autogencode.dao; + +import com.zbkj.modules.autogencode.entity.PmDailyMenuDtlLike; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 食堂菜单明细点赞/点踩关联表 DAO 映射层 + */ +@Mapper +public interface PmDailyMenuDtlLikeDao extends BaseMapper { + +} diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CmCust.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CmCust.java index 0c371b1..36581f2 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CmCust.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/CmCust.java @@ -115,4 +115,11 @@ public class CmCust implements Serializable { @TableField(exist = false) private List supplierType; + /** + * 资质状态(虚拟字段:0为存在未通过的资质,1为所有资质都通过) + */ + @ApiModelProperty(value = "资质状态(0为存在未通过的资质,1为所有资质都通过)") + @TableField(exist = false) + private String allStatusPassed; + } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.java index b4763f9..d443157 100644 --- a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.java +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtl.java @@ -8,107 +8,122 @@ import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import org.springframework.format.annotation.DateTimeFormat; - import java.math.BigDecimal; - import java.io.Serializable; +import java.math.BigDecimal; +import java.io.Serializable; import java.util.Date; + import lombok.Data; @Data @TableName("pm_daily_menu_dtl") public class PmDailyMenuDtl implements Serializable { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + + /** + * id + */ + @ApiModelProperty(value = "id") + @TableId + private Long id; + /** + * 菜单id + */ + @ApiModelProperty(value = "菜单id") + private Long menuId; + /** + * 菜品名称 + */ + @ApiModelProperty(value = "菜品名称") + private String itemName; + /** + * 菜品类型 + */ + @ApiModelProperty(value = "菜品类型") + private String itemType; + /** + * 菜品价格 + */ + @ApiModelProperty(value = "菜品价格") + private BigDecimal itemPrice; + /** + * 备注 + */ + @ApiModelProperty(value = "备注") + private String remark; + /** + * 删除标志(0代表存在 2代表删除) + */ + @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)") + private String delFlag; + /** + * 创建部门 + */ + @ApiModelProperty(value = "创建部门") + private Long createDept; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private Long createBy; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + /** + * 修改人 + */ + @ApiModelProperty(value = "修改人") + private Long updateBy; + /** + * 修改时间 + */ + @ApiModelProperty(value = "修改时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + /** + * 租户ID + */ + @ApiModelProperty(value = "租户ID") + private String tenantId; + + /** + * 日期 + */ + @ApiModelProperty(value = "日期") + @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @TableField(exist = false) + private Date menuDate; - /** - * id - */ - @ApiModelProperty(value = "id") - @TableId - private Long id; - /** - * 菜单id - */ - @ApiModelProperty(value = "菜单id") - private Long menuId; - /** - * 菜品名称 - */ - @ApiModelProperty(value = "菜品名称") - private String itemName; - /** - * 菜品类型 - */ - @ApiModelProperty(value = "菜品类型") - private String itemType; - /** - * 菜品价格 - */ - @ApiModelProperty(value = "菜品价格") - private BigDecimal itemPrice; - /** - * 备注 - */ - @ApiModelProperty(value = "备注") - private String remark; - /** - * 删除标志(0代表存在 2代表删除) - */ - @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)") - private String delFlag; - /** - * 创建部门 - */ - @ApiModelProperty(value = "创建部门") - private Long createDept; - /** - * 创建人 - */ - @ApiModelProperty(value = "创建人") - private Long createBy; - /** - * 创建时间 - */ - @ApiModelProperty(value = "创建时间") - @TableField(fill = FieldFill.INSERT) - private Date createTime; - /** - * 修改人 - */ - @ApiModelProperty(value = "修改人") - private Long updateBy; - /** - * 修改时间 - */ - @ApiModelProperty(value = "修改时间") - @TableField(fill = FieldFill.INSERT_UPDATE) - private Date updateTime; - /** - * 租户ID - */ - @ApiModelProperty(value = "租户ID") - private String tenantId; + /** + * 食堂名称 + */ + @ApiModelProperty(value = "食堂名称") + @TableField(exist = false) + private String canteenName; - /** - * 日期 - */ - @ApiModelProperty(value = "日期") - @JsonFormat(pattern = "yyyy-MM-dd") - @DateTimeFormat(pattern = "yyyy-MM-dd") - @TableField(exist = false) - private Date menuDate; + /** + * 餐别 + */ + @ApiModelProperty(value = "餐别") + @TableField(exist = false) + private String mealType; - /** - * 食堂名称 - */ - @ApiModelProperty(value = "食堂名称") - @TableField(exist = false) - private String canteenName; + /** + * 点赞数量 + */ + @ApiModelProperty(value = "点赞数量") + @TableField(exist = false) + private Integer likeCount; - /** - * 餐别 - */ - @ApiModelProperty(value = "餐别") - @TableField(exist = false) - private String mealType; + /** + * 点踩数量 + */ + @ApiModelProperty(value = "点踩数量") + @TableField(exist = false) + private Integer dislikeCount; } diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtlLike.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtlLike.java new file mode 100644 index 0000000..ad313e5 --- /dev/null +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/entity/PmDailyMenuDtlLike.java @@ -0,0 +1,117 @@ +package com.zbkj.modules.autogencode.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModelProperty; + + import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +@Data +@TableName("pm_daily_menu_dtl_like") +public class PmDailyMenuDtlLike implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 主键ID + */ + @ApiModelProperty(value = "主键ID") + @TableId + private Long id; + /** + * 菜单明细ID(关联pm_daily_menu_dtl.id) + */ + @ApiModelProperty(value = "菜单明细ID(关联pm_daily_menu_dtl.id)") + private Long menuDtlId; + /** + * 评价用户ID + */ + @ApiModelProperty(value = "评价用户ID") + private Long userId; + /** + * 菜单日期(冗余字段,方便按日统计) + */ + @ApiModelProperty(value = "菜单日期(冗余字段,方便按日统计)") + private Date menuDate; + /** + * 评价类型:1-点赞,2-点踩 + */ + @ApiModelProperty(value = "评价类型:1-点赞,2-点踩") + private String likeType; + /** + * 删除标志(0存在 2删除) + */ + @ApiModelProperty(value = "删除标志(0存在 2删除)") + private String delFlag; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private Long createBy; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 修改人 + */ + @ApiModelProperty(value = "修改人") + private Long updateBy; + /** + * 修改时间 + */ + @ApiModelProperty(value = "修改时间") + private Date updateTime; + /** + * 租户ID + */ + @ApiModelProperty(value = "租户ID") + private String tenantId; + + /** + * 菜品名称(虚拟字段) + */ + @ApiModelProperty(value = "菜品名称") + @TableField(exist = false) + private String itemName; + + /** + * 菜品类型(虚拟字段) + */ + @ApiModelProperty(value = "菜品类型") + @TableField(exist = false) + private String itemType; + + /** + * 菜品价格(虚拟字段) + */ + @ApiModelProperty(value = "菜品价格") + @TableField(exist = false) + private java.math.BigDecimal itemPrice; + + /** + * 点赞数量(虚拟字段) + */ + @ApiModelProperty(value = "点赞数量") + @TableField(exist = false) + private Integer likeCount; + + /** + * 点踩数量(虚拟字段) + */ + @ApiModelProperty(value = "点踩数量") + @TableField(exist = false) + private Integer dislikeCount; + + /** + * 总数量(虚拟字段) + */ + @ApiModelProperty(value = "总数量") + @TableField(exist = false) + private Integer totalCount; + +} diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/PmDailyMenuDtlLikeService.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/PmDailyMenuDtlLikeService.java new file mode 100644 index 0000000..4371547 --- /dev/null +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/PmDailyMenuDtlLikeService.java @@ -0,0 +1,25 @@ +package com.zbkj.modules.autogencode.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.zbkj.modules.autogencode.entity.PmDailyMenuDtlLike; +import com.zbkj.common.request.PageParamRequest; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; + + +import java.util.List; +import java.util.Map; + +/** + * 食堂菜单明细点赞/点踩关联表 业务接口 + * +---------------------------------------------------------------------- + */ +public interface PmDailyMenuDtlLikeService extends IService { + + /** + * PmDailyMenuDtlLike 列表查询 + * @param pageParamRequest 分页参数对象 + * @return + */ + List pageList(LambdaQueryWrapper queryWrapper, PageParamRequest pageParamRequest); +} + diff --git a/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/PmDailyMenuDtlLikeServiceImpl.java b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/PmDailyMenuDtlLikeServiceImpl.java new file mode 100644 index 0000000..847362e --- /dev/null +++ b/crmeb/crmeb-admin/src/main/java/com/zbkj/modules/autogencode/service/impl/PmDailyMenuDtlLikeServiceImpl.java @@ -0,0 +1,42 @@ +package com.zbkj.modules.autogencode.service.impl; + +import com.github.pagehelper.PageHelper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +import com.zbkj.modules.autogencode.dao.PmDailyMenuDtlLikeDao; +import com.zbkj.modules.autogencode.entity.PmDailyMenuDtlLike; +import com.zbkj.modules.autogencode.service.PmDailyMenuDtlLikeService; +import com.zbkj.common.page.CommonPage; +import com.zbkj.common.request.PageParamRequest; + +import javax.annotation.Resource; +import java.util.Map; +import java.util.Arrays; +import java.util.List; + + +@Service("pmDailyMenuDtlLikeService") +public class PmDailyMenuDtlLikeServiceImpl extends ServiceImpl implements PmDailyMenuDtlLikeService { + + + @Resource + private PmDailyMenuDtlLikeDao dao; + + + /** + * 带分页参数的列表查询实现 + */ + @Override + public List pageList(LambdaQueryWrapper queryWrapper, PageParamRequest pageParamRequest) { + + PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit()); + + return dao.selectList(queryWrapper); + } + + +} diff --git a/crmeb/crmeb-admin/src/main/resources/mapper/autogencode/PmDailyMenuDtlLikeDao.xml b/crmeb/crmeb-admin/src/main/resources/mapper/autogencode/PmDailyMenuDtlLikeDao.xml new file mode 100644 index 0000000..b2b0a66 --- /dev/null +++ b/crmeb/crmeb-admin/src/main/resources/mapper/autogencode/PmDailyMenuDtlLikeDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/crmeb/crmeb-service/src/main/java/com/zbkj/service/service/impl/SystemAdminServiceImpl.java b/crmeb/crmeb-service/src/main/java/com/zbkj/service/service/impl/SystemAdminServiceImpl.java index 129c835..911eb5c 100644 --- a/crmeb/crmeb-service/src/main/java/com/zbkj/service/service/impl/SystemAdminServiceImpl.java +++ b/crmeb/crmeb-service/src/main/java/com/zbkj/service/service/impl/SystemAdminServiceImpl.java @@ -198,6 +198,9 @@ public class SystemAdminServiceImpl extends ServiceImpl