diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetCertificateController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetCertificateController.java deleted file mode 100644 index 3ac43af..0000000 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetCertificateController.java +++ /dev/null @@ -1,318 +0,0 @@ -package com.chenhai.web.controller.vet; - -import com.chenhai.common.annotation.Log; -import com.chenhai.common.core.controller.BaseController; -import com.chenhai.common.core.domain.AjaxResult; -import com.chenhai.common.core.page.TableDataInfo; -import com.chenhai.common.enums.BusinessType; -import com.chenhai.common.utils.SecurityUtils; -import com.chenhai.common.utils.poi.ExcelUtil; -import com.chenhai.vet.domain.VetCertificate; -import com.chenhai.vet.service.IVetCertificateService; -import jakarta.servlet.http.HttpServletResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.propertyeditors.CustomNumberEditor; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Map; - -/** - * 兽医执业证书Controller - * - * @author ruoyi - * @date 2025-12-29 - */ -@RestController -@RequestMapping("/vet/certificate") -public class VetCertificateController extends BaseController -{ - @Autowired - private IVetCertificateService vetCertificateService; - - /** - * 初始化数据绑定,处理空字符串转换问题 - * 防止前端传递空字符串导致Long类型绑定失败 - */ - @InitBinder - public void initBinder(WebDataBinder binder) { - // 处理Long类型字段的空字符串问题 - binder.registerCustomEditor(Long.class, new CustomNumberEditor(Long.class, true) { - @Override - public void setAsText(String text) throws IllegalArgumentException { - if (text == null || text.trim().isEmpty()) { - setValue(null); // 将空字符串转换为null - } else { - try { - setValue(Long.parseLong(text.trim())); - } catch (NumberFormatException e) { - setValue(null); // 转换失败也设为null - } - } - } - - @Override - public String getAsText() { - Object value = getValue(); - return (value != null ? value.toString() : ""); - } - }); - } - - /** - * 获取当前用户ID - */ - private Long getCurrentUserId() { - return SecurityUtils.getUserId(); - } - - /** - * 检查是否为管理员 - */ - private boolean isAdmin() { - return SecurityUtils.isAdmin(getCurrentUserId()); - } - - /** - * 检查用户是否有权限访问该证书 - */ - private boolean canAccessCertificate(Long certificateId) { - if (isAdmin()) { - return true; - } - - Long currentUserId = getCurrentUserId(); - if (currentUserId == null) { - return false; - } - - VetCertificate certificate = vetCertificateService.selectVetCertificateById(certificateId); - return certificate != null && currentUserId.equals(certificate.getUserId()); - } - - /** - * 查询兽医执业证书列表(证书管理页面使用) - * 管理员:查看所有证书 - * 普通用户:查看自己的证书 - */ - @PreAuthorize("@ss.hasPermi('vet:certificate:list')") - @GetMapping("/list") - public TableDataInfo list(VetCertificate vetCertificate) - { - startPage(); - Long currentUserId = getCurrentUserId(); - - if (currentUserId == null) { - return getDataTable(List.of()); - } - - // 管理员可以查看所有,普通用户只能查看自己的 - if (!isAdmin()) { - vetCertificate.setUserId(currentUserId); - } - // 管理员不设置userId,查看所有 - - List list = vetCertificateService.selectVetCertificateList(vetCertificate); - return getDataTable(list); - } - - /** - * 用户详情页查询证书(专用于用户详情页) - * 查看指定用户的证书列表 - */ - @PreAuthorize("@ss.hasPermi('vet:certificate:list')") - @GetMapping("/listForDetail") - public TableDataInfo listForDetail(@RequestParam(value = "userId", required = false) Long userId) - { - startPage(); - Long currentUserId = getCurrentUserId(); - - if (currentUserId == null) { - return getDataTable(List.of()); - } - - // 如果没有传userId,返回空 - if (userId == null) { - return getDataTable(List.of()); - } - - // 权限检查:管理员或查看自己 - if (!isAdmin() && !userId.equals(currentUserId)) { - return getDataTable(List.of()); - } - - VetCertificate query = new VetCertificate(); - query.setUserId(userId); - List list = vetCertificateService.selectVetCertificateList(query); - return getDataTable(list); - } - - /** - * 导出兽医执业证书列表 - */ - @PreAuthorize("@ss.hasPermi('vet:certificate:export')") - @Log(title = "兽医执业证书", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, VetCertificate vetCertificate) - { - List list = vetCertificateService.selectVetCertificateList(vetCertificate); - ExcelUtil util = new ExcelUtil(VetCertificate.class); - util.exportExcel(response, list, "兽医执业证书数据"); - } - - /** - * 获取兽医执业证书详细信息 - */ - @PreAuthorize("@ss.hasPermi('vet:certificate:query')") - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { - // 权限检查 - if (!canAccessCertificate(id)) { - return error("没有权限查看此证书"); - } - return success(vetCertificateService.selectVetCertificateById(id)); - } - - /** - * 新增兽医执业证书 - */ - @PreAuthorize("@ss.hasPermi('vet:certificate:add')") - @Log(title = "兽医执业证书", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody VetCertificate vetCertificate) - { - // 自动设置当前用户ID - Long currentUserId = getCurrentUserId(); - if (currentUserId == null) { - return error("用户未登录"); - } - - // 权限检查:普通用户只能给自己添加证书 - if (!isAdmin() && vetCertificate.getUserId() != null && - !vetCertificate.getUserId().equals(currentUserId)) { - return error("没有权限为其他用户添加证书"); - } - - // 设置用户ID和创建人 - vetCertificate.setUserId(currentUserId); - vetCertificate.setCreateBy(SecurityUtils.getUsername()); - - return toAjax(vetCertificateService.insertVetCertificate(vetCertificate)); - } - - /** - * 修改兽医执业证书 - */ - @PreAuthorize("@ss.hasPermi('vet:certificate:edit')") - @Log(title = "兽医执业证书", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody VetCertificate vetCertificate) - { - // 权限检查 - if (!canAccessCertificate(vetCertificate.getId())) { - return error("没有权限修改此证书"); - } - - // 如果是普通用户,确保不能修改用户ID - if (!isAdmin()) { - Long currentUserId = getCurrentUserId(); - if (currentUserId != null && vetCertificate.getUserId() != null && - !vetCertificate.getUserId().equals(currentUserId)) { - return error("不能修改证书所属用户"); - } - } - - return toAjax(vetCertificateService.updateVetCertificate(vetCertificate)); - } - - /** - * 删除兽医执业证书 - */ - @PreAuthorize("@ss.hasPermi('vet:certificate:remove')") - @Log(title = "兽医执业证书", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { - // 权限检查:检查是否所有证书都可以删除 - if (!isAdmin()) { - for (Long id : ids) { - if (!canAccessCertificate(id)) { - return error("没有权限删除证书ID: " + id); - } - } - } - - return toAjax(vetCertificateService.deleteVetCertificateByIds(ids)); - } - - /** - * 根据用户ID获取证书列表(兼容旧版本,建议前端迁移到listForDetail) - */ - @GetMapping("/user/{userId}") - public AjaxResult getByUserId(@PathVariable Long userId) - { - Long currentUserId = getCurrentUserId(); - - // 权限检查 - if (!isAdmin() && !userId.equals(currentUserId)) { - return error("没有权限查看其他用户的证书"); - } - - List list = vetCertificateService.selectCertificatesByUserId(userId); - return success(list); - } - - /** - * 获取即将过期的证书 - */ - @GetMapping("/expiring/{userId}") - public AjaxResult getExpiringCertificates(@PathVariable Long userId) - { - Long currentUserId = getCurrentUserId(); - - // 权限检查 - if (!isAdmin() && !userId.equals(currentUserId)) { - return error("没有权限查看其他用户的证书"); - } - - List list = vetCertificateService.selectExpiringCertificates(userId); - return success(list); - } - - /** - * 获取证书统计信息 - */ - @GetMapping("/statistics/{userId}") - public AjaxResult getStatistics(@PathVariable Long userId) - { - Long currentUserId = getCurrentUserId(); - - // 权限检查 - if (!isAdmin() && !userId.equals(currentUserId)) { - return error("没有权限查看其他用户的统计信息"); - } - - Map statistics = vetCertificateService.getCertificateStatistics(userId); - return success(statistics); - } - - /** - * 手动触发证书检查 - */ - @PostMapping("/manual-check/{userId}") - public AjaxResult manualCheck(@PathVariable Long userId) - { - Long currentUserId = getCurrentUserId(); - - // 权限检查 - if (!isAdmin() && !userId.equals(currentUserId)) { - return error("没有权限为其他用户检查证书"); - } - - vetCertificateService.manualCheckCertificates(userId); - return success("证书检查完成"); - } -} \ No newline at end of file diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetExperienceArticleController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetExperienceArticleController.java index e7fd494..e26df4b 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetExperienceArticleController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetExperienceArticleController.java @@ -1,5 +1,5 @@ package com.chenhai.web.controller.vet; - +import com.chenhai.common.utils.DictUtils; import com.chenhai.common.annotation.Log; import com.chenhai.common.core.controller.BaseController; import com.chenhai.common.core.domain.AjaxResult; @@ -17,6 +17,8 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + /** * 兽医经验分享Controller @@ -31,6 +33,11 @@ public class VetExperienceArticleController extends BaseController { @Autowired // 确保有这个注解 private VetArticleCategoryMapper vetArticleCategoryMapper; + /** + * 简单收藏管理(使用Map存储) + */ + private static final Map> COLLECTION_STORE = new ConcurrentHashMap<>(); + /** * 查询兽医经验文章列表 @@ -97,6 +104,8 @@ public class VetExperienceArticleController extends BaseController { return AjaxResult.success(options); } + + /** * 根据分类查询文章 */ @@ -118,6 +127,102 @@ public class VetExperienceArticleController extends BaseController { } + /** + * 获取文章标签选项 + */ + @GetMapping("/tags/options") + public AjaxResult getTagOptions() { + List> options = new ArrayList<>(); + + // 根据你提供的字典数据写死 + options.add(createOption("1", "疫苗")); + options.add(createOption("2", "传染病")); + options.add(createOption("3", "防治")); + options.add(createOption("4", "养殖")); + options.add(createOption("5", "饲养管理")); + options.add(createOption("6", "繁殖")); + options.add(createOption("7", "牛羊")); + options.add(createOption("8", "药物使用")); + options.add(createOption("9", "特殊病例")); + + return success(options); + } + + /** + * 根据标签值查询文章 + */ + @GetMapping("/tags/{dictValue}/articles") + public TableDataInfo getArticlesByTag( + @PathVariable String dictValue, + @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { + + startPage(); + + // 标签映射 + String tagName = getTagNameByDictValue(dictValue); + + if (tagName == null || tagName.isEmpty()) { + return getDataTable(new ArrayList<>()); + } + + VetExperienceArticle query = new VetExperienceArticle(); + query.setStatus("1"); + query.setTags(tagName); + + List list = vetExperienceArticleService.selectVetExperienceArticleList(query); + return getDataTable(list); + } + + /** + * 辅助方法:创建选项 + */ + private Map createOption(String value, String label) { + Map option = new HashMap<>(); + option.put("value", value); + option.put("label", label); + return option; + } + + /** + * 根据字典值获取标签名称 + */ + private String getTagNameByDictValue(String dictValue) { + // 写死映射 + Map tagMap = new HashMap<>(); + tagMap.put("1", "疫苗"); + tagMap.put("2", "传染病"); + tagMap.put("3", "防治"); + tagMap.put("4", "养殖"); + tagMap.put("5", "饲养管理"); + tagMap.put("6", "繁殖"); + tagMap.put("7", "牛羊"); + tagMap.put("8", "药物使用"); + tagMap.put("9", "特殊病例"); + + return tagMap.get(dictValue); + } + + /** + * 备用:直接使用标签名称查询的接口 + */ + @GetMapping("/tags/byName/articles") + public TableDataInfo getArticlesByTagName( + @RequestParam("tagName") String tagName, + @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { + + startPage(); + + VetExperienceArticle query = new VetExperienceArticle(); + query.setStatus("1"); + query.setTags(tagName); + + List list = vetExperienceArticleService.selectVetExperienceArticleList(query); + return getDataTable(list); + } + + /** * 获取所有兽医已发布的文章 @@ -245,6 +350,88 @@ public class VetExperienceArticleController extends BaseController { return getDataTable(list); } + /** + * 获取我的收藏文章列表 + */ + @GetMapping("/forum/myCollections") + public TableDataInfo getMyCollections() { + Long currentUserId = getUserId(); + if (currentUserId == null) { + return getDataTable(new ArrayList<>()); + } + + // 获取我的收藏文章ID + Set articleIds = COLLECTION_STORE.get(currentUserId); + if (articleIds == null || articleIds.isEmpty()) { + return getDataTable(new ArrayList<>()); + } + + // 查询文章详情 + List result = new ArrayList<>(); + for (Long articleId : articleIds) { + VetExperienceArticle article = vetExperienceArticleService.selectVetExperienceArticleById(articleId); + if (article != null && "1".equals(article.getStatus())) { + result.add(article); + } + } + + // 按ID倒序(模拟按收藏时间倒序) + result.sort((a1, a2) -> a2.getId().compareTo(a1.getId())); + + return getDataTable(result); + } + /** + * 获取我的文章简单统计(直接在Controller实现) + */ + @GetMapping("/my/simpleStats") + public AjaxResult getMySimpleStats() { + // 获取当前用户ID - 使用系统的方法 + Long currentUserId = SecurityUtils.getUserId(); + + System.out.println("当前用户ID: " + currentUserId); // 调试用 + + if (currentUserId == null) { + // 如果是开发测试,可以使用临时用户ID + currentUserId = 1L; // 测试用 + System.out.println("使用测试用户ID: " + currentUserId); + } + + // 查询当前用户已发布的文章 + VetExperienceArticle query = new VetExperienceArticle(); + query.setUserId(currentUserId); + query.setStatus("1"); // 只查询已发布的 + + System.out.println("查询条件: userId=" + currentUserId + ", status=1"); + + List myArticles = vetExperienceArticleService.selectVetExperienceArticleList(query); + + System.out.println("查询到文章数量: " + myArticles.size()); + + // 统计 + Map stats = new HashMap<>(); + stats.put("publishedCount", myArticles.size()); + + // 使用stream简化统计 + int totalLikes = myArticles.stream() + .mapToInt(a -> a.getLikeCount() != null ? a.getLikeCount() : 0) + .sum(); + + int totalCollects = myArticles.stream() + .mapToInt(a -> a.getCollectCount() != null ? a.getCollectCount() : 0) + .sum(); + + int totalViews = myArticles.stream() + .mapToInt(a -> a.getViewCount() != null ? a.getViewCount() : 0) + .sum(); + + stats.put("totalLikes", totalLikes); + stats.put("totalCollects", totalCollects); + stats.put("totalViews", totalViews); + stats.put("userId", currentUserId); + + return success(stats); + } + /** * 点赞文章 */ @@ -258,11 +445,39 @@ public class VetExperienceArticleController extends BaseController { * 收藏文章 */ @PostMapping("/forum/{id}/collect") - public AjaxResult collectArticle(@PathVariable Long id) { - int result = vetExperienceArticleService.incrementCollectCount(id); - return toAjax(result); - } + public AjaxResult collectArticle(@PathVariable("id") Long id) { + Long currentUserId = getUserId(); + if (currentUserId == null) { + return error("请先登录"); + } + + // 检查文章是否存在 + VetExperienceArticle article = vetExperienceArticleService.selectVetExperienceArticleById(id); + if (article == null) { + return error("文章不存在"); + } + + // 不能收藏自己的文章 + if (currentUserId.equals(article.getUserId())) { + return error("不能收藏自己的文章"); + } + + // 获取用户的收藏列表 + Set myCollections = COLLECTION_STORE.computeIfAbsent(currentUserId, k -> new HashSet<>()); + + // 检查是否已收藏 + if (myCollections.contains(id)) { + return error("已收藏过该文章"); + } + + // 添加收藏 + myCollections.add(id); + + // 增加文章收藏数 + vetExperienceArticleService.incrementCollectCount(id); + return success("收藏成功"); + } /** * 搜索文章 */ @@ -293,16 +508,16 @@ public class VetExperienceArticleController extends BaseController { /** * 获取热门标签 */ - @GetMapping("/forum/hotTags") + /*@GetMapping("/forum/hotTags") public AjaxResult getHotTags(@RequestParam(value = "limit", defaultValue = "15") Integer limit) { List> hotTags = vetExperienceArticleService.selectHotTags(limit); return success(hotTags); - } + }*/ /** * 2. 根据标签搜索文章(带分页) */ - @GetMapping("/listByTag") + /* @GetMapping("/listByTag") public TableDataInfo listByTag(@RequestParam("tag") String tag, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { @@ -315,7 +530,7 @@ public class VetExperienceArticleController extends BaseController { List list = vetExperienceArticleService.selectVetExperienceArticleList(query); return getDataTable(list); - } + }*/ /** diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetPersonalInfoController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetPersonalInfoController.java index e8d6ca9..3594165 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetPersonalInfoController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetPersonalInfoController.java @@ -99,7 +99,8 @@ public class VetPersonalInfoController extends BaseController return error("无权查看他人信息"); } - Map fullInfo = vetPersonalInfoService.getVetFullInfo(id); + /*Map fullInfo = vetPersonalInfoService.getVetFullInfo(id);*/ + Map fullInfo = vetPersonalInfoService.getVetFullInfoWithQualifications(id); if (fullInfo == null || fullInfo.isEmpty()) { return error("兽医信息不存在"); } diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetProductController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetProductController.java new file mode 100644 index 0000000..55f0732 --- /dev/null +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetProductController.java @@ -0,0 +1,104 @@ +package com.chenhai.web.controller.vet; + +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.chenhai.common.annotation.Log; +import com.chenhai.common.core.controller.BaseController; +import com.chenhai.common.core.domain.AjaxResult; +import com.chenhai.common.enums.BusinessType; +import com.chenhai.vet.domain.VetProduct; +import com.chenhai.vet.service.IVetProductService; +import com.chenhai.common.utils.poi.ExcelUtil; +import com.chenhai.common.core.page.TableDataInfo; + +/** + * 兽医产品信息Controller + * + * @author ruoyi + * @date 2026-01-15 + */ +@RestController +@RequestMapping("/vet/product") +public class VetProductController extends BaseController +{ + @Autowired + private IVetProductService vetProductService; + + /** + * 查询兽医产品信息列表 + */ + @PreAuthorize("@ss.hasPermi('vet:product:list')") + @GetMapping("/list") + public TableDataInfo list(VetProduct vetProduct) + { + startPage(); + List list = vetProductService.selectVetProductList(vetProduct); + return getDataTable(list); + } + + /** + * 导出兽医产品信息列表 + */ + @PreAuthorize("@ss.hasPermi('vet:product:export')") + @Log(title = "兽医产品信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, VetProduct vetProduct) + { + List list = vetProductService.selectVetProductList(vetProduct); + ExcelUtil util = new ExcelUtil(VetProduct.class); + util.exportExcel(response, list, "兽医产品信息数据"); + } + + /** + * 获取兽医产品信息详细信息 + */ + @PreAuthorize("@ss.hasPermi('vet:product:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(vetProductService.selectVetProductById(id)); + } + + /** + * 新增兽医产品信息 + */ + @PreAuthorize("@ss.hasPermi('vet:product:add')") + @Log(title = "兽医产品信息", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody VetProduct vetProduct) + { + return toAjax(vetProductService.insertVetProduct(vetProduct)); + } + + /** + * 修改兽医产品信息 + */ + @PreAuthorize("@ss.hasPermi('vet:product:edit')") + @Log(title = "兽医产品信息", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody VetProduct vetProduct) + { + return toAjax(vetProductService.updateVetProduct(vetProduct)); + } + + /** + * 删除兽医产品信息 + */ + @PreAuthorize("@ss.hasPermi('vet:product:remove')") + @Log(title = "兽医产品信息", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(vetProductService.deleteVetProductByIds(ids)); + } +} diff --git a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetQualificationController.java b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetQualificationController.java index b1d2603..f20174a 100644 --- a/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetQualificationController.java +++ b/chenhai-admin/src/main/java/com/chenhai/web/controller/vet/VetQualificationController.java @@ -29,7 +29,7 @@ import java.util.*; import static com.chenhai.framework.datasource.DynamicDataSourceContextHolder.log; /** - * 兽医资质控制器 + * 兽医资质控制器(合并证书功能) * * @author 自定义 */ @@ -43,11 +43,9 @@ public class VetQualificationController extends BaseController @Autowired private JdbcTemplate jdbcTemplate; - // 注入若依配置的文件上传根路径(需在application.yml配置:ruoyi.profile=D:/ruoyi/uploadPath) @Value("${chenhai.profile}") private String uploadRootPath; - // 资质文件存储子路径(便于分类管理) private static final String QUALIFICATION_FILE_PATH = "/vet/qualification/"; /** @@ -92,8 +90,6 @@ public class VetQualificationController extends BaseController /** * 上传资质文件(关联兽医资质ID) - * @param file 上传的文件 - * @return 文件上传结果(包含访问路径、存储路径等) */ @PreAuthorize("@ss.hasPermi('vet:qualification:edit')") @Log(title = "兽医资质文件上传", businessType = BusinessType.UPDATE) @@ -107,45 +103,37 @@ public class VetQualificationController extends BaseController String originalFileName = file.getOriginalFilename(); String ext = FileUtils.getExtension(originalFileName).toLowerCase(); - // 文件类型验证 String[] allowedExts = {"jpg", "png", "pdf", "doc", "docx", "xls", "xlsx"}; boolean isAllowed = FileUtils.isAllowedExtension(originalFileName, allowedExts); if (!isAllowed) { return AjaxResult.error("文件类型不允许"); } - // 🔥 关键:使用配置的路径 - String basePath = uploadRootPath; // D:/ymtx/uploadPath + String basePath = uploadRootPath; String subPath = "vet/qualification"; String datePath = new SimpleDateFormat("yyyy/MM/dd").format(new Date()); String fullPath = basePath + File.separator + subPath + File.separator + datePath; - // 创建目录 File destDir = new File(fullPath); if (!destDir.exists()) { destDir.mkdirs(); } - // 生成唯一文件名 String uuid = UUID.randomUUID().toString().replace("-", ""); String fileName = uuid + "_" + originalFileName; String filePath = fullPath + File.separator + fileName; - // 保存文件 File destFile = new File(filePath); file.transferTo(destFile); - // 🔥 返回可访问的URL(注意路径格式) - // 前端访问路径:/profile/vet/qualification/yyyy/MM/dd/xxx.jpg String fileUrl = "/" + subPath + "/" + datePath + "/" + fileName; - // 下载链接:Spring有默认的下载控制器 /common/download?fileName=xxx String downloadUrl = "/common/download?fileName=" + URLEncoder.encode(fileUrl, "UTF-8"); Map data = new HashMap<>(); data.put("fileName", originalFileName); - data.put("fileUrl", fileUrl); // 前端显示用 - data.put("downloadUrl", downloadUrl); // 下载用 - data.put("filePath", fileUrl); // 提交到资质表用(存储相对路径) + data.put("fileUrl", fileUrl); + data.put("downloadUrl", downloadUrl); + data.put("filePath", fileUrl); data.put("fileSize", file.getSize()); data.put("uuid", uuid); @@ -157,11 +145,8 @@ public class VetQualificationController extends BaseController } } - - - /** - * 查询兽医资质列表 + * 查询兽医资质列表(含证书信息) */ @PreAuthorize("@ss.hasPermi('vet:qualification:list')") @GetMapping("/list") @@ -176,6 +161,52 @@ public class VetQualificationController extends BaseController return getDataTable(list); } + /** + * 查询即将过期的资质证书 + */ + @PreAuthorize("@ss.hasPermi('vet:qualification:list')") + @GetMapping("/listExpiring") + public TableDataInfo listExpiring(VetQualification vetQualification) + { + startPage(); + Long userId = SecurityUtils.getUserId(); + if (!SecurityUtils.isAdmin(userId)) { + vetQualification.setUserId(userId); + } + vetQualification.setExpiringOnly(true); + List list = vetQualificationService.selectVetQualificationList(vetQualification); + return getDataTable(list); + } + + /** + * 用户详情页查询资质证书 + */ + @PreAuthorize("@ss.hasPermi('vet:qualification:list')") + @GetMapping("/listForDetail") + public TableDataInfo listForDetail(@RequestParam(value = "userId", required = false) Long userId) + { + startPage(); + Long currentUserId = SecurityUtils.getUserId(); + + if (currentUserId == null) { + return getDataTable(List.of()); + } + + if (userId == null) { + return getDataTable(List.of()); + } + + // 权限检查:管理员或查看自己 + if (!SecurityUtils.isAdmin(currentUserId) && !userId.equals(currentUserId)) { + return getDataTable(List.of()); + } + + VetQualification query = new VetQualification(); + query.setUserId(userId); + List list = vetQualificationService.selectVetQualificationList(query); + return getDataTable(list); + } + /** * 登录后检查是否需要填写资质 */ @@ -213,7 +244,6 @@ public class VetQualificationController extends BaseController return AjaxResult.success(result); } - /** * 获取经营范围详情 */ @@ -246,7 +276,18 @@ public class VetQualificationController extends BaseController @GetMapping(value = "/{qualificationId}") public AjaxResult getInfo(@PathVariable("qualificationId") Long qualificationId) { - return success(vetQualificationService.selectVetQualificationByQualificationId(qualificationId)); + VetQualification qualification = vetQualificationService.selectVetQualificationByQualificationId(qualificationId); + if (qualification == null) { + return AjaxResult.error("资质信息不存在"); + } + + // 权限检查:管理员或查看自己 + Long currentUserId = SecurityUtils.getUserId(); + if (!SecurityUtils.isAdmin(currentUserId) && !qualification.getUserId().equals(currentUserId)) { + return AjaxResult.error("没有权限查看此资质"); + } + + return success(qualification); } /** @@ -262,6 +303,12 @@ public class VetQualificationController extends BaseController try { vetQualification.setUserId(sysUserId); vetQualification.setCreateBy(username); + + // 设置默认提醒天数 + if (vetQualification.getRemindDays() == null) { + vetQualification.setRemindDays(30); + } + return toAjax(vetQualificationService.insertVetQualification(vetQualification)); } catch (DataIntegrityViolationException e) { if (e.getMessage().contains("foreign key constraint")) { @@ -289,6 +336,15 @@ public class VetQualificationController extends BaseController @PutMapping public AjaxResult edit(@RequestBody VetQualification vetQualification) { + // 检查权限:普通用户只能修改自己的资质 + Long currentUserId = SecurityUtils.getUserId(); + if (!SecurityUtils.isAdmin(currentUserId)) { + VetQualification existing = vetQualificationService.selectVetQualificationByQualificationId(vetQualification.getQualificationId()); + if (existing == null || !existing.getUserId().equals(currentUserId)) { + return error("没有权限修改此资质"); + } + } + return toAjax(vetQualificationService.updateVetQualification(vetQualification)); } @@ -300,6 +356,17 @@ public class VetQualificationController extends BaseController @DeleteMapping("/{qualificationIds}") public AjaxResult remove(@PathVariable Long[] qualificationIds) { + // 检查权限 + Long currentUserId = SecurityUtils.getUserId(); + if (!SecurityUtils.isAdmin(currentUserId)) { + for (Long id : qualificationIds) { + VetQualification existing = vetQualificationService.selectVetQualificationByQualificationId(id); + if (existing == null || !existing.getUserId().equals(currentUserId)) { + return error("没有权限删除资质ID: " + id); + } + } + } + return toAjax(vetQualificationService.deleteVetQualificationByQualificationIds(qualificationIds)); } @@ -350,4 +417,68 @@ public class VetQualificationController extends BaseController vetQualification.setAuditTime(new Date()); return toAjax(vetQualificationService.updateVetQualification(vetQualification)); } + + /** + * 根据用户ID获取资质证书列表 + */ + @GetMapping("/user/{userId}") + public AjaxResult getByUserId(@PathVariable Long userId) { + Long currentUserId = SecurityUtils.getUserId(); + + // 权限检查 + if (!SecurityUtils.isAdmin(currentUserId) && !userId.equals(currentUserId)) { + return error("没有权限查看其他用户的资质"); + } + + List list = vetQualificationService.selectQualificationsByUserId(userId); + return success(list); + } + + /** + * 获取即将过期的资质证书 + */ + @GetMapping("/expiring/{userId}") + public AjaxResult getExpiringQualifications(@PathVariable Long userId) { + Long currentUserId = SecurityUtils.getUserId(); + + // 权限检查 + if (!SecurityUtils.isAdmin(currentUserId) && !userId.equals(currentUserId)) { + return error("没有权限查看其他用户的证书"); + } + + List list = vetQualificationService.selectExpiringQualifications(userId); + return success(list); + } + + /** + * 获取证书统计信息 + */ + @GetMapping("/statistics/{userId}") + public AjaxResult getStatistics(@PathVariable Long userId) { + Long currentUserId = SecurityUtils.getUserId(); + + // 权限检查 + if (!SecurityUtils.isAdmin(currentUserId) && !userId.equals(currentUserId)) { + return error("没有权限查看其他用户的统计信息"); + } + + Map statistics = vetQualificationService.getCertificateStatistics(userId); + return success(statistics); + } + + /** + * 手动触发证书检查 + */ + @PostMapping("/manual-check/{userId}") + public AjaxResult manualCheck(@PathVariable Long userId) { + Long currentUserId = SecurityUtils.getUserId(); + + // 权限检查 + if (!SecurityUtils.isAdmin(currentUserId) && !userId.equals(currentUserId)) { + return error("没有权限为其他用户检查证书"); + } + + vetQualificationService.manualCheckCertificates(userId); + return success("证书检查完成"); + } } \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/vet/CertificateRemindTask.java b/chenhai-system/src/main/java/com/chenhai/vet/CertificateRemindTask.java index 7e86f8d..2feef6d 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/CertificateRemindTask.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/CertificateRemindTask.java @@ -1,8 +1,8 @@ package com.chenhai.vet; -import com.chenhai.vet.domain.VetCertificate; +import com.chenhai.vet.domain.VetQualification; import com.chenhai.vet.domain.VetNotification; -import com.chenhai.vet.mapper.VetCertificateMapper; +import com.chenhai.vet.mapper.VetQualificationMapper; import com.chenhai.vet.mapper.VetNotificationMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -20,63 +20,74 @@ import java.util.List; public class CertificateRemindTask { @Autowired - private VetCertificateMapper vetCertificateMapper; + private VetQualificationMapper vetQualificationMapper; + @Autowired private VetNotificationMapper vetNotificationMapper; - // 测试:每分钟执行 | 正式:每天上午9点 @Scheduled(cron = "0 0 9 * * ?") - //@Scheduled(cron = "0 */1 * * * ?") - @Scheduled(cron = "0 0 9 * * ?") + // 每天上午9点执行 + @Scheduled(cron = "0 0 9 * * ?")/* + @Scheduled(cron = "0 * * * * ?")*/ public void dailyCertificateCheck() { - /* log.info("开始检查证书过期情况...");*/ try { - List certificates = vetCertificateMapper.selectVetCertificateList(new VetCertificate()); + // 查询所有包含证书信息的资质 + VetQualification query = new VetQualification(); + query.setCertName(""); + List qualifications = vetQualificationMapper.selectVetQualificationList(query); + + // 过滤出有证书信息的记录 + List certificates = qualifications.stream() + .filter(q -> q.getCertName() != null && !q.getCertName().isEmpty()) + .toList(); + certificates.forEach(this::checkAndSendReminder); - /* log.info("证书检查完成,共检查{}个证书", certificates.size());*/ } catch (Exception e) { - /*log.error("证书检查任务执行失败", e);*/ + e.printStackTrace(); } } /** * 检查单个证书并发送提醒 */ - private void checkAndSendReminder(VetCertificate certificate) { - if (certificate == null || certificate.getExpireDate() == null) { + private void checkAndSendReminder(VetQualification qualification) { + if (qualification == null || qualification.getExpireDate() == null) { return; } - long daysRemaining = calculateDayDifference(new Date(), certificate.getExpireDate()); + long daysRemaining = calculateDayDifference(new Date(), qualification.getExpireDate()); - updateCertificateStatus(certificate, daysRemaining); + updateCertificateStatus(qualification, daysRemaining); - if (!shouldSendReminder(certificate, daysRemaining) || hasRecentReminder(certificate, daysRemaining)) { + if (!shouldSendReminder(qualification, daysRemaining) || hasRecentReminder(qualification, daysRemaining)) { return; } - sendReminder(certificate, daysRemaining); + sendReminder(qualification, daysRemaining); } /** * 发送提醒 */ - private void sendReminder(VetCertificate certificate, long daysRemaining) { - VetNotification notification = createBaseNotification(certificate); + /** + * 发送提醒 + */ + private void sendReminder(VetQualification qualification, long daysRemaining) { + VetNotification notification = createBaseNotification(qualification); if (daysRemaining <= 0) { // 只发送过期当天的提醒 if (daysRemaining == 0) { - setExpiredContent(notification, certificate, 0); + setExpiredContent(notification, qualification, 0); notification.setRemindLevel(3); // 最高级别 vetNotificationMapper.insertVetNotification(notification); } // 过期后不再提醒 return; } else if (daysRemaining <= 7) { - setCountdownContent(notification, certificate, daysRemaining); + setCountdownContent(notification, qualification, daysRemaining); notification.setRemindLevel(daysRemaining <= 3 ? 3 : 2); } else if (daysRemaining == 15 || daysRemaining == 30) { - setPreExpireContent(notification, certificate, daysRemaining); + setPreExpireContent(notification, qualification, daysRemaining); notification.setRemindLevel(daysRemaining == 30 ? 1 : 2); } else { return; @@ -88,10 +99,10 @@ public class CertificateRemindTask { /** * 创建基础通知对象 */ - private VetNotification createBaseNotification(VetCertificate certificate) { + private VetNotification createBaseNotification(VetQualification qualification) { VetNotification notification = new VetNotification(); - notification.setUserId(certificate.getUserId()); - notification.setRelatedId(certificate.getId().toString()); + notification.setUserId(qualification.getUserId()); + notification.setRelatedId(qualification.getQualificationId().toString()); notification.setType("CERT_EXPIRE_REMIND"); notification.setIsRead(0); notification.setCreateTime(new Date()); @@ -101,35 +112,36 @@ public class CertificateRemindTask { /** * 设置过期内容 */ - private void setExpiredContent(VetNotification notification, VetCertificate certificate, long daysExpired) { + private void setExpiredContent(VetNotification notification, VetQualification qualification, long daysExpired) { if (daysExpired == 0) { notification.setTitle("🚨 证书今天过期!"); - notification.setContent(String.format("您的《%s》证书今天已过期!请立即更新。", certificate.getCertName())); + notification.setContent(String.format("您的《%s》证书今天已过期!请立即更新。", qualification.getCertName())); } // 移除过期多天的提醒 } + /** * 设置倒计时内容 */ - private void setCountdownContent(VetNotification notification, VetCertificate certificate, long daysRemaining) { + private void setCountdownContent(VetNotification notification, VetQualification qualification, long daysRemaining) { notification.setTitle("⚠️ 证书还剩" + daysRemaining + "天过期"); - notification.setContent(String.format("您的《%s》证书还剩%d天过期,请及时更新。", certificate.getCertName(), daysRemaining)); + notification.setContent(String.format("您的《%s》证书还剩%d天过期,请及时更新。", qualification.getCertName(), daysRemaining)); } /** * 设置预过期内容 */ - private void setPreExpireContent(VetNotification notification, VetCertificate certificate, long daysRemaining) { + private void setPreExpireContent(VetNotification notification, VetQualification qualification, long daysRemaining) { String timeText = daysRemaining == 30 ? "30天" : "15天"; notification.setTitle("📅 证书还剩" + timeText + "过期"); - notification.setContent(String.format("您的《%s》证书将在%s后过期,请提前准备更新。", certificate.getCertName(), timeText)); + notification.setContent(String.format("您的《%s》证书将在%s后过期,请提前准备更新。", qualification.getCertName(), timeText)); } /** * 判断是否需要发送提醒 */ - private boolean shouldSendReminder(VetCertificate certificate, long daysRemaining) { - String status = certificate.getStatus(); + private boolean shouldSendReminder(VetQualification qualification, long daysRemaining) { + String status = qualification.getCertStatus(); if ("2".equals(status)) { // 已过期 // 只在过期的第一天提醒(daysRemaining = 0 或 刚刚过期时) @@ -150,7 +162,7 @@ public class CertificateRemindTask { /** * 检查最近是否已发送过提醒 */ - private boolean hasRecentReminder(VetCertificate certificate, long daysRemaining) { + private boolean hasRecentReminder(VetQualification qualification, long daysRemaining) { try { Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); @@ -164,7 +176,7 @@ public class CertificateRemindTask { // 检查今天是否已发送 VetNotification query = new VetNotification(); - query.setRelatedId(certificate.getId().toString()); + query.setRelatedId(qualification.getQualificationId().toString()); query.setType("CERT_EXPIRE_REMIND"); List notifications = vetNotificationMapper.selectVetNotificationList(query); @@ -182,16 +194,13 @@ public class CertificateRemindTask { } // 生成当前应该发送的通知标题 - String expectedTitle = generateExpectedTitle(certificate, daysRemaining); + String expectedTitle = generateExpectedTitle(qualification, daysRemaining); // 检查今天是否已有相同标题的通知 boolean hasSameTitleToday = todayNotifications.stream() .anyMatch(n -> expectedTitle.equals(n.getTitle())); if (hasSameTitleToday) { - // 如果今天已有相同标题的通知,跳过 - /*log.debug("今天已发送过相同提醒,跳过: 证书ID={}, 标题={}", - certificate.getId(), expectedTitle);*/ return true; } @@ -209,14 +218,12 @@ public class CertificateRemindTask { .anyMatch(n -> expectedTitle.equals(n.getTitle())); if (hasSameTitleRecent) { - /*log.debug("最近7天内已发送过相同提醒,跳过: 证书ID={}", certificate.getId());*/ return true; } } return false; } catch (Exception e) { - /*log.warn("检查近期提醒失败: {}", e.getMessage());*/ return false; } } @@ -224,7 +231,7 @@ public class CertificateRemindTask { /** * 生成预期的通知标题 */ - private String generateExpectedTitle(VetCertificate certificate, long daysRemaining) { + private String generateExpectedTitle(VetQualification qualification, long daysRemaining) { if (daysRemaining <= 0) { long daysExpired = -daysRemaining; if (daysExpired == 0) { @@ -244,17 +251,18 @@ public class CertificateRemindTask { /** * 更新证书状态 */ - private void updateCertificateStatus(VetCertificate certificate, long daysRemaining) { + private void updateCertificateStatus(VetQualification qualification, long daysRemaining) { try { String newStatus = daysRemaining <= 0 ? "2" : daysRemaining <= 30 ? "1" : "0"; - if (!newStatus.equals(certificate.getStatus())) { - certificate.setStatus(newStatus); - /*log.debug("更新证书状态: 证书ID={}, 新状态={}", certificate.getId(), newStatus);*/ + if (!newStatus.equals(qualification.getCertStatus())) { + qualification.setCertStatus(newStatus); + // 更新数据库中的状态 + vetQualificationMapper.updateVetQualification(qualification); } } catch (Exception e) { - /*log.warn("更新证书状态失败: {}", e.getMessage());*/ + e.printStackTrace(); } } diff --git a/chenhai-system/src/main/java/com/chenhai/vet/domain/VetCertificate.java b/chenhai-system/src/main/java/com/chenhai/vet/domain/VetCertificate.java deleted file mode 100644 index 38cd5b5..0000000 --- a/chenhai-system/src/main/java/com/chenhai/vet/domain/VetCertificate.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.chenhai.vet.domain; - -import com.chenhai.common.annotation.Excel; -import com.chenhai.common.core.domain.BaseEntity; -import com.fasterxml.jackson.annotation.JsonFormat; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; - -import java.util.Date; - -/** - * 兽医执业证书对象 vet_certificate - * - * @author ruoyi - * @date 2025-12-29 - */ -public class VetCertificate extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** 主键ID */ - private Long id; - - /** 用户ID */ - @Excel(name = "用户ID") - private Long userId; - - /** 证书名称 */ - @Excel(name = "证书名称") - private String certName; - - /** 证书编号 */ - @Excel(name = "证书编号") - private String certNumber; - - /** 证书类型 */ - @Excel(name = "证书类型") - private String certType; - - /** 发证机构 */ - @Excel(name = "发证机构") - private String issueOrg; - - /** 发证日期 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "发证日期", width = 30, dateFormat = "yyyy-MM-dd") - private Date issueDate; - - /** 到期日期 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "到期日期", width = 30, dateFormat = "yyyy-MM-dd") - private Date expireDate; - - /** 证书图片 */ - @Excel(name = "证书图片") - private String certImage; - - /** 状态(0正常 1即将过期 2已过期) */ - @Excel(name = "状态", dictType = "certificate_status") - private String status; - - /** 提前提醒天数 */ - @Excel(name = "提前提醒天数") - private Integer remindDays; - - /** 上次提醒时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "上次提醒时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date lastRemindTime; - - public void setId(Long id) - { - this.id = id; - } - - public Long getId() - { - return id; - } - - public void setUserId(Long userId) - { - this.userId = userId; - } - - public Long getUserId() - { - return userId; - } - - public void setCertName(String certName) - { - this.certName = certName; - } - - public String getCertName() - { - return certName; - } - - public void setCertNumber(String certNumber) - { - this.certNumber = certNumber; - } - - public String getCertNumber() - { - return certNumber; - } - - public void setCertType(String certType) - { - this.certType = certType; - } - - public String getCertType() - { - return certType; - } - - public void setIssueOrg(String issueOrg) - { - this.issueOrg = issueOrg; - } - - public String getIssueOrg() - { - return issueOrg; - } - - public void setIssueDate(Date issueDate) - { - this.issueDate = issueDate; - } - - public Date getIssueDate() - { - return issueDate; - } - - public void setExpireDate(Date expireDate) - { - this.expireDate = expireDate; - } - - public Date getExpireDate() - { - return expireDate; - } - - public void setCertImage(String certImage) - { - this.certImage = certImage; - } - - public String getCertImage() - { - return certImage; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getStatus() - { - return status; - } - - public void setRemindDays(Integer remindDays) - { - this.remindDays = remindDays; - } - - public Integer getRemindDays() - { - return remindDays; - } - - public void setLastRemindTime(Date lastRemindTime) - { - this.lastRemindTime = lastRemindTime; - } - - public Date getLastRemindTime() - { - return lastRemindTime; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("userId", getUserId()) - .append("certName", getCertName()) - .append("certNumber", getCertNumber()) - .append("certType", getCertType()) - .append("issueOrg", getIssueOrg()) - .append("issueDate", getIssueDate()) - .append("expireDate", getExpireDate()) - .append("certImage", getCertImage()) - .append("status", getStatus()) - .append("remindDays", getRemindDays()) - .append("lastRemindTime", getLastRemindTime()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); - } -} diff --git a/chenhai-system/src/main/java/com/chenhai/vet/domain/VetProduct.java b/chenhai-system/src/main/java/com/chenhai/vet/domain/VetProduct.java new file mode 100644 index 0000000..39a65b1 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/vet/domain/VetProduct.java @@ -0,0 +1,447 @@ +package com.chenhai.vet.domain; + +import java.math.BigDecimal; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.chenhai.common.annotation.Excel; +import com.chenhai.common.core.domain.BaseEntity; + +/** + * 兽医产品信息对象 vet_product + * + * @author ruoyi + * @date 2026-01-15 + */ +public class VetProduct extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键ID */ + private Long id; + + /** 产品名称 */ + @Excel(name = "产品名称") + private String name; + + /** 产品类型:medicine-兽药/vaccine-疫苗/supplement-保健品 */ + @Excel(name = "产品类型:medicine-兽药/vaccine-疫苗/supplement-保健品") + private String type; + + /** 产品分类 */ + @Excel(name = "产品分类") + private String category; + + /** 规格 */ + @Excel(name = "规格") + private String specification; + + /** 单位 */ + @Excel(name = "单位") + private String unit; + + /** 生产厂家 */ + @Excel(name = "生产厂家") + private String manufacturer; + + /** 批准文号 */ + @Excel(name = "批准文号") + private String approvalNumber; + + /** 主要成分 */ + @Excel(name = "主要成分") + private String ingredients; + + /** 适应症 */ + @Excel(name = "适应症") + private String indications; + + /** 用法用量 */ + @Excel(name = "用法用量") + private String usageDosage; + + /** 销售价格 */ + @Excel(name = "销售价格") + private BigDecimal price; + + /** 成本价 */ + @Excel(name = "成本价") + private BigDecimal costPrice; + + /** 库存数量 */ + @Excel(name = "库存数量") + private Long stock; + + /** 最低库存预警 */ + @Excel(name = "最低库存预警") + private Long minStock; + + /** 主图URL */ + @Excel(name = "主图URL") + private String mainImage; + + /** 多张图片URL,JSON格式 */ + @Excel(name = "多张图片URL,JSON格式") + private String images; + + /** 适用动物:如犬、猫、猪等 */ + @Excel(name = "适用动物:如犬、猫、猪等") + private String treatAnimals; + + /** 治疗疾病 */ + @Excel(name = "治疗疾病") + private String treatDiseases; + + /** 治疗方案/内容 */ + @Excel(name = "治疗方案/内容") + private String treatmentContent; + + /** 治疗周期 */ + @Excel(name = "治疗周期") + private String treatmentDuration; + + /** 注意事项 */ + @Excel(name = "注意事项") + private String precautions; + + /** 状态:0-草稿/1-上架/2-下架 */ + @Excel(name = "状态:0-草稿/1-上架/2-下架") + private String status; + + /** 删除标识:0-正常/1-删除 */ + @Excel(name = "删除标识:0-正常/1-删除") + private Integer isDeleted; + + /** 诊所ID */ + @Excel(name = "诊所ID") + private Long clinicId; + + /** 兽医ID */ + @Excel(name = "兽医ID") + private Long userId; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date createdAt; + + /** 更新时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date updatedAt; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + + public void setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + + public void setCategory(String category) + { + this.category = category; + } + + public String getCategory() + { + return category; + } + + public void setSpecification(String specification) + { + this.specification = specification; + } + + public String getSpecification() + { + return specification; + } + + public void setUnit(String unit) + { + this.unit = unit; + } + + public String getUnit() + { + return unit; + } + + public void setManufacturer(String manufacturer) + { + this.manufacturer = manufacturer; + } + + public String getManufacturer() + { + return manufacturer; + } + + public void setApprovalNumber(String approvalNumber) + { + this.approvalNumber = approvalNumber; + } + + public String getApprovalNumber() + { + return approvalNumber; + } + + public void setIngredients(String ingredients) + { + this.ingredients = ingredients; + } + + public String getIngredients() + { + return ingredients; + } + + public void setIndications(String indications) + { + this.indications = indications; + } + + public String getIndications() + { + return indications; + } + + public void setUsageDosage(String usageDosage) + { + this.usageDosage = usageDosage; + } + + public String getUsageDosage() + { + return usageDosage; + } + + public void setPrice(BigDecimal price) + { + this.price = price; + } + + public BigDecimal getPrice() + { + return price; + } + + public void setCostPrice(BigDecimal costPrice) + { + this.costPrice = costPrice; + } + + public BigDecimal getCostPrice() + { + return costPrice; + } + + public void setStock(Long stock) + { + this.stock = stock; + } + + public Long getStock() + { + return stock; + } + + public void setMinStock(Long minStock) + { + this.minStock = minStock; + } + + public Long getMinStock() + { + return minStock; + } + + public void setMainImage(String mainImage) + { + this.mainImage = mainImage; + } + + public String getMainImage() + { + return mainImage; + } + + public void setImages(String images) + { + this.images = images; + } + + public String getImages() + { + return images; + } + + public void setTreatAnimals(String treatAnimals) + { + this.treatAnimals = treatAnimals; + } + + public String getTreatAnimals() + { + return treatAnimals; + } + + public void setTreatDiseases(String treatDiseases) + { + this.treatDiseases = treatDiseases; + } + + public String getTreatDiseases() + { + return treatDiseases; + } + + public void setTreatmentContent(String treatmentContent) + { + this.treatmentContent = treatmentContent; + } + + public String getTreatmentContent() + { + return treatmentContent; + } + + public void setTreatmentDuration(String treatmentDuration) + { + this.treatmentDuration = treatmentDuration; + } + + public String getTreatmentDuration() + { + return treatmentDuration; + } + + public void setPrecautions(String precautions) + { + this.precautions = precautions; + } + + public String getPrecautions() + { + return precautions; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getStatus() + { + return status; + } + + public void setIsDeleted(Integer isDeleted) + { + this.isDeleted = isDeleted; + } + + public Integer getIsDeleted() + { + return isDeleted; + } + + public void setClinicId(Long clinicId) + { + this.clinicId = clinicId; + } + + public Long getClinicId() + { + return clinicId; + } + + public void setUserId(Long userId) + { + this.userId = userId; + } + + public Long getUserId() + { + return userId; + } + + public void setCreatedAt(Date createdAt) + { + this.createdAt = createdAt; + } + + public Date getCreatedAt() + { + return createdAt; + } + + public void setUpdatedAt(Date updatedAt) + { + this.updatedAt = updatedAt; + } + + public Date getUpdatedAt() + { + return updatedAt; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("type", getType()) + .append("category", getCategory()) + .append("specification", getSpecification()) + .append("unit", getUnit()) + .append("manufacturer", getManufacturer()) + .append("approvalNumber", getApprovalNumber()) + .append("ingredients", getIngredients()) + .append("indications", getIndications()) + .append("usageDosage", getUsageDosage()) + .append("price", getPrice()) + .append("costPrice", getCostPrice()) + .append("stock", getStock()) + .append("minStock", getMinStock()) + .append("mainImage", getMainImage()) + .append("images", getImages()) + .append("treatAnimals", getTreatAnimals()) + .append("treatDiseases", getTreatDiseases()) + .append("treatmentContent", getTreatmentContent()) + .append("treatmentDuration", getTreatmentDuration()) + .append("precautions", getPrecautions()) + .append("status", getStatus()) + .append("isDeleted", getIsDeleted()) + .append("clinicId", getClinicId()) + .append("userId", getUserId()) + .append("createdAt", getCreatedAt()) + .append("updatedAt", getUpdatedAt()) + .toString(); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/vet/domain/VetQualification.java b/chenhai-system/src/main/java/com/chenhai/vet/domain/VetQualification.java index fbcc4f4..c4cb6ab 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/domain/VetQualification.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/domain/VetQualification.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.ArrayList; /** - * 兽医资质对象 vet_qualification + * 兽医资质对象 vet_qualification(合并证书功能) * * @author ruoyi * @date 2025-12-26 @@ -26,8 +26,8 @@ public class VetQualification extends BaseEntity /** 资质ID */ private Long qualificationId; - /** 兽医ID */ - @Excel(name = "兽医ID") + /** 系统用户ID */ + @Excel(name = "用户ID") private Long userId; /** 真实姓名 */ @@ -51,13 +51,13 @@ public class VetQualification extends BaseEntity private String certificateFiles; /** 申请时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "申请时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date applyTime; /** 审核时间 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date auditTime; /** 审核状态(0待审核 1通过 2拒绝) */ @@ -79,14 +79,58 @@ public class VetQualification extends BaseEntity @Excel(name = "经营范围名称", dictType = "scope_names") private String scopeNames; + // 新增证书相关字段 + + /** 证书名称 */ + @Excel(name = "证书名称") + private String certName; + + /** 证书类型 */ + @Excel(name = "证书类型") + private String certType; + + /** 发证机构 */ + @Excel(name = "发证机构") + private String issueOrg; + + /** 发证日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "发证日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date issueDate; + + /** 到期日期 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "到期日期", width = 30, dateFormat = "yyyy-MM-dd") + private Date expireDate; + + /** 证书图片 */ + private String certImage; + + /** 证书状态(0正常 1即将过期 2已过期) */ + @Excel(name = "证书状态", dictType = "certificate_status") + private String certStatus; + + /** 提前提醒天数 */ + @Excel(name = "提前提醒天数") + private Integer remindDays; + + /** 上次提醒时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date lastRemindTime; + + // 查询条件字段(非数据库字段) + /** 是否查询即将过期 */ + private Boolean expiringOnly; + + // 显示标签字段 private String qualificationTypeLabel; private String auditStatusLabel; private String scopeNamesLabel; + private String certStatusLabel; // 从 JSON 反序列化时使用的方法 @JsonProperty("scopeIds") public void setScopeIdsFromJson(List scopeIdList) { - // 自动转换为逗号分隔的字符串 if (scopeIdList != null && !scopeIdList.isEmpty()) { this.scopeIds = String.join(",", scopeIdList); } else { @@ -125,126 +169,103 @@ public class VetQualification extends BaseEntity setScopeIdsFromJson(scopeIdList); } - public void setQualificationId(Long qualificationId) - { - this.qualificationId = qualificationId; - } - - public Long getQualificationId() - { + // getter 和 setter 方法 + public Long getQualificationId() { return qualificationId; } - public void setUserId(Long userId) - { - this.userId = userId; + public void setQualificationId(Long qualificationId) { + this.qualificationId = qualificationId; } - public Long getUserId() - { + public Long getUserId() { return userId; } - public void setRealName(String realName) - { - this.realName = realName; + public void setUserId(Long userId) { + this.userId = userId; } - public String getRealName() - { + public String getRealName() { return realName; } - public void setIdCard(String idCard) - { - this.idCard = idCard; + public void setRealName(String realName) { + this.realName = realName; } - public String getIdCard() - { + public String getIdCard() { return idCard; } - public void setQualificationType(String qualificationType) - { - this.qualificationType = qualificationType; + public void setIdCard(String idCard) { + this.idCard = idCard; } - public String getQualificationType() - { + public String getQualificationType() { return qualificationType; } - public void setCertificateNo(String certificateNo) - { - this.certificateNo = certificateNo; + public void setQualificationType(String qualificationType) { + this.qualificationType = qualificationType; } - public String getCertificateNo() - { + public String getCertificateNo() { return certificateNo; } - public void setCertificateFiles(String certificateFiles) - { - this.certificateFiles = certificateFiles; + public void setCertificateNo(String certificateNo) { + this.certificateNo = certificateNo; } - public String getCertificateFiles() - { + public String getCertificateFiles() { return certificateFiles; } - public void setApplyTime(Date applyTime) - { - this.applyTime = applyTime; + public void setCertificateFiles(String certificateFiles) { + this.certificateFiles = certificateFiles; } - public Date getApplyTime() - { + public Date getApplyTime() { return applyTime; } - public void setAuditTime(Date auditTime) - { - this.auditTime = auditTime; + public void setApplyTime(Date applyTime) { + this.applyTime = applyTime; } - public Date getAuditTime() - { + public Date getAuditTime() { return auditTime; } - public void setAuditStatus(String auditStatus) - { - this.auditStatus = auditStatus; + public void setAuditTime(Date auditTime) { + this.auditTime = auditTime; } - public String getAuditStatus() - { + public String getAuditStatus() { return auditStatus; } - public void setAuditOpinion(String auditOpinion) - { - this.auditOpinion = auditOpinion; + public void setAuditStatus(String auditStatus) { + this.auditStatus = auditStatus; } - public String getAuditOpinion() - { + public String getAuditOpinion() { return auditOpinion; } - public void setAuditorId(Long auditorId) - { - this.auditorId = auditorId; + public void setAuditOpinion(String auditOpinion) { + this.auditOpinion = auditOpinion; } - public Long getAuditorId() - { + public Long getAuditorId() { return auditorId; } + public void setAuditorId(Long auditorId) { + this.auditorId = auditorId; + } + public String getScopeNames() { return scopeNames; } @@ -253,6 +274,87 @@ public class VetQualification extends BaseEntity this.scopeNames = scopeNames; } + // 新增证书字段的 getter 和 setter + public String getCertName() { + return certName; + } + + public void setCertName(String certName) { + this.certName = certName; + } + + public String getCertType() { + return certType; + } + + public void setCertType(String certType) { + this.certType = certType; + } + + public String getIssueOrg() { + return issueOrg; + } + + public void setIssueOrg(String issueOrg) { + this.issueOrg = issueOrg; + } + + public Date getIssueDate() { + return issueDate; + } + + public void setIssueDate(Date issueDate) { + this.issueDate = issueDate; + } + + public Date getExpireDate() { + return expireDate; + } + + public void setExpireDate(Date expireDate) { + this.expireDate = expireDate; + } + + public String getCertImage() { + return certImage; + } + + public void setCertImage(String certImage) { + this.certImage = certImage; + } + + public String getCertStatus() { + return certStatus; + } + + public void setCertStatus(String certStatus) { + this.certStatus = certStatus; + } + + public Integer getRemindDays() { + return remindDays; + } + + public void setRemindDays(Integer remindDays) { + this.remindDays = remindDays; + } + + public Date getLastRemindTime() { + return lastRemindTime; + } + + public void setLastRemindTime(Date lastRemindTime) { + this.lastRemindTime = lastRemindTime; + } + + public Boolean getExpiringOnly() { + return expiringOnly; + } + + public void setExpiringOnly(Boolean expiringOnly) { + this.expiringOnly = expiringOnly; + } + public String getQualificationTypeLabel() { return qualificationTypeLabel; } @@ -277,6 +379,14 @@ public class VetQualification extends BaseEntity this.scopeNamesLabel = scopeNamesLabel; } + public String getCertStatusLabel() { + return certStatusLabel; + } + + public void setCertStatusLabel(String certStatusLabel) { + this.certStatusLabel = certStatusLabel; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -292,13 +402,22 @@ public class VetQualification extends BaseEntity .append("auditStatus", getAuditStatus()) .append("auditOpinion", getAuditOpinion()) .append("auditorId", getAuditorId()) + .append("scopeIds", getScopeIds()) + .append("scopeNames", getScopeNames()) + .append("certName", getCertName()) + .append("certType", getCertType()) + .append("issueOrg", getIssueOrg()) + .append("issueDate", getIssueDate()) + .append("expireDate", getExpireDate()) + .append("certImage", getCertImage()) + .append("certStatus", getCertStatus()) + .append("remindDays", getRemindDays()) + .append("lastRemindTime", getLastRemindTime()) .append("createBy", getCreateBy()) .append("createTime", getCreateTime()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) .append("remark", getRemark()) - .append("scopeIds", getScopeIds()) - .append("scopeNames", getScopeNames()) .toString(); } } \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetCertificateMapper.java b/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetCertificateMapper.java deleted file mode 100644 index 3f39ff5..0000000 --- a/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetCertificateMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.chenhai.vet.mapper; - -import com.chenhai.vet.domain.VetCertificate; - -import java.util.List; - -/** - * 兽医执业证书Mapper接口 - * - * @author ruoyi - * @date 2025-12-29 - */ -public interface VetCertificateMapper -{ - /** - * 查询兽医执业证书 - * - * @param id 兽医执业证书主键 - * @return 兽医执业证书 - */ - public VetCertificate selectVetCertificateById(Long id); - - /** - * 查询兽医执业证书列表 - * - * @param vetCertificate 兽医执业证书 - * @return 兽医执业证书集合 - */ - public List selectVetCertificateList(VetCertificate vetCertificate); - - /** - * 新增兽医执业证书 - * - * @param vetCertificate 兽医执业证书 - * @return 结果 - */ - public int insertVetCertificate(VetCertificate vetCertificate); - - /** - * 修改兽医执业证书 - * - * @param vetCertificate 兽医执业证书 - * @return 结果 - */ - public int updateVetCertificate(VetCertificate vetCertificate); - - /** - * 删除兽医执业证书 - * - * @param id 兽医执业证书主键 - * @return 结果 - */ - public int deleteVetCertificateById(Long id); - - /** - * 批量删除兽医执业证书 - * - * @param ids 需要删除的数据主键集合 - * @return 结果 - */ - public int deleteVetCertificateByIds(Long[] ids); -} diff --git a/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetProductMapper.java b/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetProductMapper.java new file mode 100644 index 0000000..0f971d1 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetProductMapper.java @@ -0,0 +1,61 @@ +package com.chenhai.vet.mapper; + +import java.util.List; +import com.chenhai.vet.domain.VetProduct; + +/** + * 兽医产品信息Mapper接口 + * + * @author ruoyi + * @date 2026-01-15 + */ +public interface VetProductMapper +{ + /** + * 查询兽医产品信息 + * + * @param id 兽医产品信息主键 + * @return 兽医产品信息 + */ + public VetProduct selectVetProductById(Long id); + + /** + * 查询兽医产品信息列表 + * + * @param vetProduct 兽医产品信息 + * @return 兽医产品信息集合 + */ + public List selectVetProductList(VetProduct vetProduct); + + /** + * 新增兽医产品信息 + * + * @param vetProduct 兽医产品信息 + * @return 结果 + */ + public int insertVetProduct(VetProduct vetProduct); + + /** + * 修改兽医产品信息 + * + * @param vetProduct 兽医产品信息 + * @return 结果 + */ + public int updateVetProduct(VetProduct vetProduct); + + /** + * 删除兽医产品信息 + * + * @param id 兽医产品信息主键 + * @return 结果 + */ + public int deleteVetProductById(Long id); + + /** + * 批量删除兽医产品信息 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteVetProductByIds(Long[] ids); +} diff --git a/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetQualificationMapper.java b/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetQualificationMapper.java index 906317b..d74d143 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetQualificationMapper.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/mapper/VetQualificationMapper.java @@ -2,22 +2,21 @@ package com.chenhai.vet.mapper; import com.chenhai.vet.domain.VetQualification; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Update; import java.util.List; /** * 兽医资质Mapper接口 - * + * * @author ruoyi * @date 2025-12-26 */ @Mapper -public interface VetQualificationMapper +public interface VetQualificationMapper { /** * 查询兽医资质 - * + * * @param qualificationId 兽医资质主键 * @return 兽医资质 */ @@ -25,7 +24,7 @@ public interface VetQualificationMapper /** * 查询兽医资质列表 - * + * * @param vetQualification 兽医资质 * @return 兽医资质集合 */ @@ -33,7 +32,7 @@ public interface VetQualificationMapper /** * 新增兽医资质 - * + * * @param vetQualification 兽医资质 * @return 结果 */ @@ -41,7 +40,7 @@ public interface VetQualificationMapper /** * 修改兽医资质 - * + * * @param vetQualification 兽医资质 * @return 结果 */ @@ -49,7 +48,7 @@ public interface VetQualificationMapper /** * 删除兽医资质 - * + * * @param qualificationId 兽医资质主键 * @return 结果 */ @@ -57,11 +56,15 @@ public interface VetQualificationMapper /** * 批量删除兽医资质 - * + * * @param qualificationIds 需要删除的数据主键集合 * @return 结果 */ public int deleteVetQualificationByQualificationIds(Long[] qualificationIds); - public int submit(Long qualificationId); -} + /** + * 根据兽医ID查询资质证书 + */ + List selectQualificationsByUserId(Long userId); + +} \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetCertificateService.java b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetCertificateService.java deleted file mode 100644 index 1faf105..0000000 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetCertificateService.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.chenhai.vet.service; - -import com.chenhai.vet.domain.VetCertificate; -import java.util.List; -import java.util.Map; - -/** - * 兽医执业证书Service接口 - */ -public interface IVetCertificateService -{ - /** - * 查询兽医执业证书 - */ - VetCertificate selectVetCertificateById(Long id); - - /** - * 查询兽医执业证书列表 - */ - List selectVetCertificateList(VetCertificate vetCertificate); - - /** - * 新增兽医执业证书 - */ - int insertVetCertificate(VetCertificate vetCertificate); - - /** - * 修改兽医执业证书 - */ - int updateVetCertificate(VetCertificate vetCertificate); - - /** - * 批量删除兽医执业证书 - */ - int deleteVetCertificateByIds(Long[] ids); - - /** - * 删除兽医执业证书信息 - */ - int deleteVetCertificateById(Long id); - - /** - * 根据用户ID查询证书列表 - */ - List selectCertificatesByUserId(Long userId); - - /** - * 获取即将过期的证书(30天内) - */ - List selectExpiringCertificates(Long userId); - - /** - * 检查并发送证书过期提醒 - */ - void checkAndSendCertificateReminders(); - - /** - * 手动触发证书检查 - */ - void manualCheckCertificates(Long userId); - - /** - * 获取证书统计信息 - */ - Map getCertificateStatistics(Long userId); - - - - - - -} \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetExperienceArticleService.java b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetExperienceArticleService.java index 97dbb2c..a127930 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetExperienceArticleService.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetExperienceArticleService.java @@ -111,7 +111,9 @@ public interface IVetExperienceArticleService /** * 获取热门标签 */ - List> selectHotTags(Integer limit); + /* List> selectHotTags(Integer limit);*/ List selectArticlesByTag(String tag); + + List selectMyCollections(Long userId); } diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetPersonalInfoService.java b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetPersonalInfoService.java index 38fc85e..f480397 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetPersonalInfoService.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetPersonalInfoService.java @@ -76,5 +76,11 @@ public interface IVetPersonalInfoService */ VetPersonalInfo selectVetPersonalInfoByUserId(Long userId); + Map getVetFullInfoWithQualifications(Long id); + + Map getVetFullInfoWithQualificationsByUserId(Long userId); + + + } diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetProductService.java b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetProductService.java new file mode 100644 index 0000000..50e2331 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetProductService.java @@ -0,0 +1,61 @@ +package com.chenhai.vet.service; + +import java.util.List; +import com.chenhai.vet.domain.VetProduct; + +/** + * 兽医产品信息Service接口 + * + * @author ruoyi + * @date 2026-01-15 + */ +public interface IVetProductService +{ + /** + * 查询兽医产品信息 + * + * @param id 兽医产品信息主键 + * @return 兽医产品信息 + */ + public VetProduct selectVetProductById(Long id); + + /** + * 查询兽医产品信息列表 + * + * @param vetProduct 兽医产品信息 + * @return 兽医产品信息集合 + */ + public List selectVetProductList(VetProduct vetProduct); + + /** + * 新增兽医产品信息 + * + * @param vetProduct 兽医产品信息 + * @return 结果 + */ + public int insertVetProduct(VetProduct vetProduct); + + /** + * 修改兽医产品信息 + * + * @param vetProduct 兽医产品信息 + * @return 结果 + */ + public int updateVetProduct(VetProduct vetProduct); + + /** + * 批量删除兽医产品信息 + * + * @param ids 需要删除的兽医产品信息主键集合 + * @return 结果 + */ + public int deleteVetProductByIds(Long[] ids); + + /** + * 删除兽医产品信息信息 + * + * @param id 兽医产品信息主键 + * @return 结果 + */ + public int deleteVetProductById(Long id); +} diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetQualificationService.java b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetQualificationService.java index 28c594c..3304f02 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/IVetQualificationService.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/IVetQualificationService.java @@ -3,18 +3,19 @@ package com.chenhai.vet.service; import com.chenhai.vet.domain.VetQualification; import java.util.List; +import java.util.Map; /** - * 兽医资质Service接口 - * + * 兽医资质Service接口(合并证书功能) + * * @author ruoyi * @date 2025-12-26 */ -public interface IVetQualificationService +public interface IVetQualificationService { /** * 查询兽医资质 - * + * * @param qualificationId 兽医资质主键 * @return 兽医资质 */ @@ -22,7 +23,7 @@ public interface IVetQualificationService /** * 查询兽医资质列表 - * + * * @param vetQualification 兽医资质 * @return 兽医资质集合 */ @@ -30,7 +31,7 @@ public interface IVetQualificationService /** * 新增兽医资质 - * + * * @param vetQualification 兽医资质 * @return 结果 */ @@ -38,7 +39,7 @@ public interface IVetQualificationService /** * 修改兽医资质 - * + * * @param vetQualification 兽医资质 * @return 结果 */ @@ -46,7 +47,7 @@ public interface IVetQualificationService /** * 批量删除兽医资质 - * + * * @param qualificationIds 需要删除的兽医资质主键集合 * @return 结果 */ @@ -54,10 +55,37 @@ public interface IVetQualificationService /** * 删除兽医资质信息 - * + * * @param qualificationId 兽医资质主键 * @return 结果 */ public int deleteVetQualificationByQualificationId(Long qualificationId); -} + // 新增的证书相关方法 + + /** + * 根据用户ID查询资质证书列表 + */ + List selectQualificationsByUserId(Long userId); + + /** + * 获取即将过期的资质证书(30天内) + */ + List selectExpiringQualifications(Long userId); + + /** + * 检查并发送证书过期提醒 + */ + void checkAndSendCertificateReminders(); + + /** + * 手动触发证书检查 + */ + void manualCheckCertificates(Long userId); + + /** + * 获取证书统计信息 + */ + Map getCertificateStatistics(Long userId); + +} \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/VetNotificationService.java b/chenhai-system/src/main/java/com/chenhai/vet/service/VetNotificationService.java index 7a65796..d62e5fe 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/VetNotificationService.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/VetNotificationService.java @@ -1,8 +1,8 @@ // VetNotificationService.java package com.chenhai.vet.service; -import com.chenhai.vet.domain.VetCertificate; import com.chenhai.vet.domain.VetNotification; +import com.chenhai.vet.domain.VetQualification; import java.util.List; import java.util.Map; @@ -46,7 +46,7 @@ public interface VetNotificationService { /** * 发送证书过期提醒通知 */ - void sendCertificateExpireRemind(VetCertificate certificate); + void sendCertificateExpireRemind(VetQualification qualification); /** * 标记通知为已读 @@ -57,5 +57,7 @@ public interface VetNotificationService { Map getNotificationStats(Long userId); + int getUnreadCount(Long userId); + } diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetCertificateServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetCertificateServiceImpl.java deleted file mode 100644 index a93936b..0000000 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetCertificateServiceImpl.java +++ /dev/null @@ -1,349 +0,0 @@ -package com.chenhai.vet.service.impl; - -import com.chenhai.common.utils.DateUtils; -import com.chenhai.vet.domain.VetCertificate; -import com.chenhai.vet.mapper.VetCertificateMapper; -import com.chenhai.vet.service.IVetCertificateService; -import com.chenhai.vet.service.VetNotificationService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 兽医执业证书Service业务层处理 - */ -@Service -public class VetCertificateServiceImpl implements IVetCertificateService -{ - @Autowired - private VetCertificateMapper vetCertificateMapper; - @Autowired - private VetNotificationService vetNotificationService; - - @Override - public VetCertificate selectVetCertificateById(Long id) - { - return vetCertificateMapper.selectVetCertificateById(id); - } - - @Override - public List selectVetCertificateList(VetCertificate vetCertificate) - { - return vetCertificateMapper.selectVetCertificateList(vetCertificate); - } - - @Override - public int insertVetCertificate(VetCertificate vetCertificate) - { - vetCertificate.setCreateTime(DateUtils.getNowDate()); - - // 验证并设置证书状态 - updateCertificateStatus(vetCertificate); - - // 设置默认提醒天数 - if (vetCertificate.getRemindDays() == null) { - vetCertificate.setRemindDays(30); - } - - return vetCertificateMapper.insertVetCertificate(vetCertificate); - } - - @Override - public int updateVetCertificate(VetCertificate vetCertificate) - { - vetCertificate.setUpdateTime(DateUtils.getNowDate()); - - // 验证并更新证书状态 - updateCertificateStatus(vetCertificate); - - return vetCertificateMapper.updateVetCertificate(vetCertificate); - } - - @Override - public int deleteVetCertificateByIds(Long[] ids) - { - return vetCertificateMapper.deleteVetCertificateByIds(ids); - } - - @Override - public int deleteVetCertificateById(Long id) - { - return vetCertificateMapper.deleteVetCertificateById(id); - } - - @Override - public List selectCertificatesByUserId(Long userId) - { - VetCertificate query = new VetCertificate(); - query.setUserId(userId); - return vetCertificateMapper.selectVetCertificateList(query); - } - - @Override - public List selectExpiringCertificates(Long userId) - { - Date today = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(today); - calendar.add(Calendar.DAY_OF_YEAR, 30); - Date thirtyDaysLater = calendar.getTime(); - - // 先获取用户所有证书 - List allCertificates = selectCertificatesByUserId(userId); - - // 过滤出即将过期的证书 - return allCertificates.stream() - .filter(cert -> cert.getExpireDate() != null && - !cert.getExpireDate().before(today) && - !cert.getExpireDate().after(thirtyDaysLater)) - .toList(); - } - - @Override - public void checkAndSendCertificateReminders() - { - Date today = new Date(); - - Calendar calendar = Calendar.getInstance(); - calendar.setTime(today); - calendar.add(Calendar.DAY_OF_YEAR, 30); - Date thresholdDate = calendar.getTime(); // 30天后过期 - - calendar.setTime(today); - calendar.add(Calendar.DAY_OF_YEAR, -7); - Date remindDate = calendar.getTime(); // 7天前提醒过的不再提醒 - - // 查询所有证书 - VetCertificate query = new VetCertificate(); - List allCertificates = vetCertificateMapper.selectVetCertificateList(query); - - int successCount = 0; - int failCount = 0; - - for (VetCertificate certificate : allCertificates) { - try { - // 检查证书是否需要提醒 - if (shouldSendRemind(certificate, today, thresholdDate, remindDate)) { - // ✅ 调用通知服务发送站内信 - vetNotificationService.sendCertificateExpireRemind(certificate); - - // 更新最后提醒时间 - certificate.setLastRemindTime(new Date()); - vetCertificateMapper.updateVetCertificate(certificate); - - successCount++; - // 保留原来的日志输出 - /* System.out.println("发送证书提醒:证书ID=" + certificate.getId() + - ", 证书名称=" + certificate.getCertName());*/ - } - } catch (Exception e) { - failCount++; - e.printStackTrace(); - } - } - - /*// 添加统计日志 - System.out.println("证书提醒任务完成:成功 " + successCount + " 条,失败 " + failCount + " 条");*/ - } - - /** - * 判断是否需要发送提醒 - */ - private boolean shouldSendRemind(VetCertificate certificate, Date today, - Date thresholdDate, Date remindDate) { - if (certificate.getExpireDate() == null) { - return false; - } - - // 检查是否即将过期(30天内) - if (certificate.getExpireDate().after(thresholdDate)) { - return false; - } - - // 检查是否已提醒过(7天内) - if (certificate.getLastRemindTime() != null) { - Calendar cal = Calendar.getInstance(); - cal.setTime(certificate.getLastRemindTime()); - cal.set(Calendar.HOUR_OF_DAY, 0); - cal.set(Calendar.MINUTE, 0); - cal.set(Calendar.SECOND, 0); - cal.set(Calendar.MILLISECOND, 0); - Date lastRemindDateOnly = cal.getTime(); - - if (!lastRemindDateOnly.before(remindDate)) { - return false; - } - } - - return true; - } - - /** - * 发送证书过期提醒 - *//* - private void sendCertificateExpireRemind(VetCertificate certificate) { - Date today = new Date(); - long daysBetween = calculateDayDifference(today, certificate.getExpireDate()); - - String title; - String content; - int remindLevel; - - if (daysBetween <= 0) { - title = "证书已过期"; - content = String.format("您的《%s》证书已于%s过期!请立即更新证书。", - certificate.getCertName(), formatDate(certificate.getExpireDate())); - remindLevel = 3; - } else if (daysBetween <= 7) { - title = "证书即将过期(7天内)"; - content = String.format("您的《%s》证书将在%d天后过期,请尽快更新!", - certificate.getCertName(), daysBetween); - remindLevel = 3; - } else { - title = "证书即将过期(30天内)"; - content = String.format("您的《%s》证书将在%d天后过期,请及时更新。", - certificate.getCertName(), daysBetween); - remindLevel = 2; - } - - System.out.println("发送证书提醒:" + title + " - " + content); - } -*/ - /** - * 计算两个日期之间的天数差(自己实现,不依赖DateUtils) - */ - private long calculateDayDifference(Date startDate, Date endDate) { - if (startDate == null || endDate == null) { - return 0L; - } - - // 清除时间部分,只比较日期 - Calendar startCal = Calendar.getInstance(); - startCal.setTime(startDate); - startCal.set(Calendar.HOUR_OF_DAY, 0); - startCal.set(Calendar.MINUTE, 0); - startCal.set(Calendar.SECOND, 0); - startCal.set(Calendar.MILLISECOND, 0); - - Calendar endCal = Calendar.getInstance(); - endCal.setTime(endDate); - endCal.set(Calendar.HOUR_OF_DAY, 0); - endCal.set(Calendar.MINUTE, 0); - endCal.set(Calendar.SECOND, 0); - endCal.set(Calendar.MILLISECOND, 0); - - long diff = endCal.getTimeInMillis() - startCal.getTimeInMillis(); - return diff / (1000 * 60 * 60 * 24); - } - - /** - * 格式化日期为字符串 - */ - private String formatDate(Date date) { - if (date == null) { - return ""; - } - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - int year = calendar.get(Calendar.YEAR); - int month = calendar.get(Calendar.MONTH) + 1; // 月份从0开始 - int day = calendar.get(Calendar.DAY_OF_MONTH); - return String.format("%d-%02d-%02d", year, month, day); - } - - /** - * 更新证书状态 - */ - private void updateCertificateStatus(VetCertificate certificate) { - if (certificate.getExpireDate() == null) { - certificate.setStatus("0"); // 默认正常 - return;} - - Date today = new Date(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(today); - calendar.add(Calendar.DAY_OF_YEAR, 30); - Date thirtyDaysLater = calendar.getTime(); - - if (certificate.getExpireDate().before(today)) { - certificate.setStatus("2"); // 已过期 - } else if (certificate.getExpireDate().before(thirtyDaysLater)) { - certificate.setStatus("1"); // 即将过期 - } else { - certificate.setStatus("0"); // 正常 - } - } - - @Override - public void manualCheckCertificates(Long userId) { - List certificates = selectCertificatesByUserId(userId); - for (VetCertificate certificate : certificates) { - updateCertificateStatus(certificate); - vetCertificateMapper.updateVetCertificate(certificate); - } - } - - @Override - public Map getCertificateStatistics(Long userId) { - Map statistics = new HashMap<>(); - - List certificates = selectCertificatesByUserId(userId); - Date today = new Date(); - - long total = certificates.size(); - long expiring = 0; // 30天内过期 - long expired = 0; // 已过期 - int expiringSoon = 0; // 7天内过期 - - Calendar calendar = Calendar.getInstance(); - calendar.setTime(today); - calendar.add(Calendar.DAY_OF_YEAR, 30); - Date thirtyDaysLater = calendar.getTime(); - - calendar.setTime(today); - calendar.add(Calendar.DAY_OF_YEAR, 7); - Date sevenDaysLater = calendar.getTime(); - - for (VetCertificate cert : certificates) { - if (cert.getExpireDate() != null) { - if (cert.getExpireDate().before(today)) { - expired++; - } else if (cert.getExpireDate().before(thirtyDaysLater)) { - expiring++; - - // 7天内过期 - if (cert.getExpireDate().before(sevenDaysLater)) { - expiringSoon++; - } - } - } - } - - long normal = total - expiring - expired; - - statistics.put("total", total); - statistics.put("normal", normal); - statistics.put("expiring", expiring); - statistics.put("expired", expired); - statistics.put("expiringSoon", expiringSoon); - - // 设置警告级别 - if (expired > 0) { - statistics.put("warningLevel", "DANGER"); - } else if (expiring > 0 || expiringSoon > 0) { - statistics.put("warningLevel", "WARNING"); - } else { - statistics.put("warningLevel", "NORMAL"); - } - - return statistics; - } - - - -} \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetExperienceArticleServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetExperienceArticleServiceImpl.java index f0ebdde..0c4f6ea 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetExperienceArticleServiceImpl.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetExperienceArticleServiceImpl.java @@ -1,6 +1,7 @@ package com.chenhai.vet.service.impl; import java.util.*; +import java.util.stream.Collectors; import com.chenhai.common.utils.DateUtils; import com.github.pagehelper.PageHelper; @@ -225,7 +226,7 @@ public class VetExperienceArticleServiceImpl implements IVetExperienceArticleSer return vetExperienceArticleMapper.selectArticlesByTag(tag.trim()); } - @Override + /* @Override public List> selectHotTags(Integer limit) { // 从所有文章中提取标签并统计热度 VetExperienceArticle query = new VetExperienceArticle(); @@ -258,6 +259,28 @@ public class VetExperienceArticleServiceImpl implements IVetExperienceArticleSer }); return hotTags; + }*/ + + @Override + public List selectMyCollections(Long userId) { + // 这里需要根据实际业务逻辑实现 + // 由于你的系统中没有专门的收藏表,这里提供一个临时方案: + + // 方案1:模拟数据(临时使用) + VetExperienceArticle query = new VetExperienceArticle(); + query.setStatus("1"); // 只查询已发布的文章 + + List allArticles = vetExperienceArticleMapper.selectVetExperienceArticleList(query); + + // 临时逻辑:假设收藏的文章是点赞数较高的文章 + return allArticles.stream() + .sorted((a1, a2) -> { + Integer likes1 = a1.getLikeCount() != null ? a1.getLikeCount() : 0; + Integer likes2 = a2.getLikeCount() != null ? a2.getLikeCount() : 0; + return likes2.compareTo(likes1); + }) + .limit(20) // 限制数量 + .collect(Collectors.toList()); } } diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetNotificationServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetNotificationServiceImpl.java index 7889b07..0f9651f 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetNotificationServiceImpl.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetNotificationServiceImpl.java @@ -1,8 +1,8 @@ // 更简单的版本,完全使用 Date package com.chenhai.vet.service.impl; -import com.chenhai.vet.domain.VetCertificate; import com.chenhai.vet.domain.VetNotification; +import com.chenhai.vet.domain.VetQualification; import com.chenhai.vet.mapper.VetNotificationMapper; import com.chenhai.vet.service.VetNotificationService; import lombok.RequiredArgsConstructor; @@ -60,14 +60,65 @@ public class VetNotificationServiceImpl implements VetNotificationService { } @Override - public void sendCertificateExpireRemind(VetCertificate certificate) { - log.info("证书提醒记录: 证书ID={}, 名称={}, 过期时间={}", - certificate.getId(), certificate.getCertName(), - formatDate(certificate.getExpireDate())); - } - + public void sendCertificateExpireRemind(VetQualification qualification) { + if (qualification == null) { + log.warn("证书提醒:传入的资质对象为空"); + return; + } + log.info("证书提醒记录: 资质ID={}, 证书名称={}, 过期时间={}", + qualification.getQualificationId(), qualification.getCertName(), + formatDate(qualification.getExpireDate())); + + // 计算剩余天数 + long daysRemaining = calculateDayDifference(new Date(), qualification.getExpireDate()); + + // 根据剩余天数设置提醒内容和级别 + String title; + String content; + int remindLevel; + + if (daysRemaining <= 0) { + title = "证书已过期"; + content = String.format("您的《%s》证书已于%s过期!请立即更新证书。", + qualification.getCertName(), formatDate(qualification.getExpireDate())); + remindLevel = 3; + } else if (daysRemaining <= 7) { + title = "证书即将过期(7天内)"; + content = String.format("您的《%s》证书将在%d天后过期,请尽快更新!", + qualification.getCertName(), daysRemaining); + remindLevel = 3; + } else { + title = "证书即将过期(30天内)"; + content = String.format("您的《%s》证书将在%d天后过期,请及时更新。", + qualification.getCertName(), daysRemaining); + remindLevel = 2; + } + // 创建通知 + VetNotification notification = new VetNotification(); + notification.setUserId(qualification.getUserId()); + notification.setRelatedId(qualification.getQualificationId().toString()); + notification.setType("CERT_EXPIRE_REMIND"); + notification.setTitle(title); + notification.setContent(content); + notification.setRemindLevel(remindLevel); + notification.setIsRead(0); + notification.setCreateTime(new Date()); + notification.setCreateBy("system"); + + // 保存通知 + try { + int result = vetNotificationMapper.insertVetNotification(notification); + if (result > 0) { + log.info("成功发送证书提醒通知:用户ID={}, 资质ID={}, 标题={}", + qualification.getUserId(), qualification.getQualificationId(), title); + } + } catch (Exception e) { + log.error("发送证书提醒通知失败:资质ID={}, 错误信息={}", + qualification.getQualificationId(), e.getMessage(), e); + } + } @Override public boolean markAsRead(Long notificationId) { @@ -81,6 +132,20 @@ public class VetNotificationServiceImpl implements VetNotificationService { return false; } + /*@Override + public void markAllAsRead(Long userId) { + VetNotification query = new VetNotification(); + query.setUserId(userId); + List notifications = vetNotificationMapper.selectVetNotificationList(query); + + for (VetNotification notification : notifications) { + if (notification.getIsRead() == 0) { + notification.setIsRead(1); + notification.setReadTime(new Date()); + vetNotificationMapper.updateVetNotification(notification); + } + } + }*/ /** * 计算两个日期之间的天数差(忽略时间部分) @@ -134,4 +199,13 @@ public class VetNotificationServiceImpl implements VetNotificationService { "read", ((Number) stats.getOrDefault("read", 0)).intValue() ); } + + @Override + public int getUnreadCount(Long userId) { + VetNotification query = new VetNotification(); + query.setUserId(userId); + query.setIsRead(0); + List unreadNotifications = vetNotificationMapper.selectVetNotificationList(query); + return unreadNotifications.size(); + } } \ No newline at end of file diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetPersonalInfoServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetPersonalInfoServiceImpl.java index 6cbe08e..67a1e31 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetPersonalInfoServiceImpl.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetPersonalInfoServiceImpl.java @@ -4,10 +4,10 @@ import com.chenhai.common.core.domain.entity.SysUser; import com.chenhai.common.core.domain.model.LoginUser; import com.chenhai.common.utils.DateUtils; import com.chenhai.common.utils.SecurityUtils; -import com.chenhai.vet.domain.VetCertificate; import com.chenhai.vet.domain.VetPersonalInfo; +import com.chenhai.vet.domain.VetQualification; import com.chenhai.vet.mapper.VetPersonalInfoMapper; -import com.chenhai.vet.mapper.VetCertificateMapper; +import com.chenhai.vet.mapper.VetQualificationMapper; import com.chenhai.vet.service.IVetPersonalInfoService; import com.chenhai.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; @@ -31,7 +31,7 @@ public class VetPersonalInfoServiceImpl implements IVetPersonalInfoService { private VetPersonalInfoMapper vetPersonalInfoMapper; @Autowired - private VetCertificateMapper vetCertificateMapper; + private VetQualificationMapper vetQualificationMapper; @Autowired private ISysUserService sysUserService; @@ -47,6 +47,51 @@ public class VetPersonalInfoServiceImpl implements IVetPersonalInfoService { return info; } + @Override + public Map getVetFullInfoWithQualifications(Long id) { + // 1. 获取兽医基本信息 + VetPersonalInfo vetInfo = vetPersonalInfoMapper.selectVetPersonalInfoById(id); + if (vetInfo == null) { + return null; + } + + // 2. 获取资质证书信息(从资质表查询) + List qualifications = vetQualificationMapper.selectQualificationsByUserId(vetInfo.getUserId()); + + // 3. 获取用户信息 + + SysUser user = sysUserService.selectUserById(vetInfo.getUserId()); + + // 4. 组装返回结果 + Map result = new HashMap<>(); + result.put("vetInfo", vetInfo); + result.put("qualifications", qualifications); // 这里包含证书信息 + result.put("userInfo", user); + + return result; + } + + @Override + public Map getVetFullInfoWithQualificationsByUserId(Long userId) { + // 1. 根据用户ID获取兽医信息 + VetPersonalInfo vetInfo = vetPersonalInfoMapper.selectVetPersonalInfoByUserId(userId); + if (vetInfo == null) { + return null; + } + + // 2. 获取资质证书信息 + List qualifications = vetQualificationMapper.selectQualificationsByUserId(userId); + // 3. 获取用户信息 + SysUser user = sysUserService.selectUserById(userId); + + // 4. 组装返回结果 + Map result = new HashMap<>(); + result.put("vetInfo", vetInfo); + result.put("qualifications", qualifications); + result.put("userInfo", user); + + return result; + } /** * 查询兽医个人信息列表(包含用户信息) */ @@ -60,6 +105,8 @@ public class VetPersonalInfoServiceImpl implements IVetPersonalInfoService { return list; } + + /** * 新增兽医个人信息 */ @@ -166,7 +213,7 @@ public class VetPersonalInfoServiceImpl implements IVetPersonalInfoService { } /** - * 获取兽医的完整信息(包含证书详情和用户信息) + * 获取兽医的完整信息(包含资质详情和用户信息) */ @Override public Map getVetFullInfo(Long vetId) { @@ -179,23 +226,30 @@ public class VetPersonalInfoServiceImpl implements IVetPersonalInfoService { } result.put("personalInfo", personalInfo); - // 2. 获取证书列表 - VetCertificate certificateQuery = new VetCertificate(); - certificateQuery.setUserId(personalInfo.getUserId()); - List certificates = vetCertificateMapper.selectVetCertificateList(certificateQuery); + // 2. 获取资质列表(包含证书信息) + VetQualification qualificationQuery = new VetQualification(); + qualificationQuery.setUserId(personalInfo.getUserId()); + List qualifications = vetQualificationMapper.selectVetQualificationList(qualificationQuery); + result.put("qualifications", qualifications); + + // 3. 过滤出有证书信息的资质 + List certificates = qualifications.stream() + .filter(q -> q.getCertName() != null && !q.getCertName().isEmpty()) + .toList(); result.put("certificates", certificates); - // 3. 证书统计信息 - if (certificates != null && !certificates.isEmpty()) { + // 4. 证书统计信息 + if (!certificates.isEmpty()) { result.put("certificateCount", certificates.size()); result.put("certificateNames", certificates.stream() - .map(VetCertificate::getCertName) + .map(VetQualification::getCertName) + .filter(name -> name != null && !name.isEmpty()) .collect(Collectors.joining(", "))); // 按状态统计 - long validCount = certificates.stream().filter(cert -> "0".equals(cert.getStatus())).count(); - long expiringCount = certificates.stream().filter(cert -> "1".equals(cert.getStatus())).count(); - long expiredCount = certificates.stream().filter(cert -> "2".equals(cert.getStatus())).count(); + long validCount = certificates.stream().filter(cert -> "0".equals(cert.getCertStatus())).count(); + long expiringCount = certificates.stream().filter(cert -> "1".equals(cert.getCertStatus())).count(); + long expiredCount = certificates.stream().filter(cert -> "2".equals(cert.getCertStatus())).count(); Map statusStats = new HashMap<>(); statusStats.put("valid", validCount); @@ -207,11 +261,29 @@ public class VetPersonalInfoServiceImpl implements IVetPersonalInfoService { result.put("certificateNames", ""); } + // 5. 资质统计信息 + if (!qualifications.isEmpty()) { + result.put("qualificationCount", qualifications.size()); + + // 按审核状态统计 + long pendingCount = qualifications.stream().filter(q -> "0".equals(q.getAuditStatus())).count(); + long approvedCount = qualifications.stream().filter(q -> "1".equals(q.getAuditStatus())).count(); + long rejectedCount = qualifications.stream().filter(q -> "2".equals(q.getAuditStatus())).count(); + + Map auditStats = new HashMap<>(); + auditStats.put("pending", pendingCount); + auditStats.put("approved", approvedCount); + auditStats.put("rejected", rejectedCount); + result.put("auditStats", auditStats); + } else { + result.put("qualificationCount", 0); + } + return result; } /** - * 根据用户ID获取兽医信息(包含证书和用户信息) + * 根据用户ID获取兽医信息(包含资质和用户信息) */ @Override public Map getVetFullInfoByUserId(Long userId) { @@ -231,19 +303,57 @@ public class VetPersonalInfoServiceImpl implements IVetPersonalInfoService { result.put("personalInfo", personalInfo); result.put("userInfo", personalInfo.getUser()); - // 2. 获取证书列表 - VetCertificate certificateQuery = new VetCertificate(); - certificateQuery.setUserId(userId); - List certificates = vetCertificateMapper.selectVetCertificateList(certificateQuery); + // 2. 获取资质列表(包含证书信息) + VetQualification qualificationQuery = new VetQualification(); + qualificationQuery.setUserId(userId); + List qualifications = vetQualificationMapper.selectVetQualificationList(qualificationQuery); + result.put("qualifications", qualifications); + + // 3. 过滤出有证书信息的资质 + List certificates = qualifications.stream() + .filter(q -> q.getCertName() != null && !q.getCertName().isEmpty()) + .toList(); result.put("certificates", certificates); - // 3. 证书统计信息 - if (certificates != null && !certificates.isEmpty()) { - result.put("certificateCount", certificates.size()); - result.put("certificateNames", certificates.stream() - .map(VetCertificate::getCertName) - .collect(Collectors.joining(", "))); + // 4. 统计信息 + if (!qualifications.isEmpty()) { + result.put("qualificationCount", qualifications.size()); + + // 证书统计 + if (!certificates.isEmpty()) { + result.put("certificateCount", certificates.size()); + result.put("certificateNames", certificates.stream() + .map(VetQualification::getCertName) + .filter(name -> name != null && !name.isEmpty()) + .collect(Collectors.joining(", "))); + + // 证书状态统计 + long validCount = certificates.stream().filter(cert -> "0".equals(cert.getCertStatus())).count(); + long expiringCount = certificates.stream().filter(cert -> "1".equals(cert.getCertStatus())).count(); + long expiredCount = certificates.stream().filter(cert -> "2".equals(cert.getCertStatus())).count(); + + Map certStats = new HashMap<>(); + certStats.put("valid", validCount); + certStats.put("expiring", expiringCount); + certStats.put("expired", expiredCount); + result.put("certStats", certStats); + } else { + result.put("certificateCount", 0); + result.put("certificateNames", ""); + } + + // 资质审核状态统计 + long pendingCount = qualifications.stream().filter(q -> "0".equals(q.getAuditStatus())).count(); + long approvedCount = qualifications.stream().filter(q -> "1".equals(q.getAuditStatus())).count(); + long rejectedCount = qualifications.stream().filter(q -> "2".equals(q.getAuditStatus())).count(); + + Map auditStats = new HashMap<>(); + auditStats.put("pending", pendingCount); + auditStats.put("approved", approvedCount); + auditStats.put("rejected", rejectedCount); + result.put("auditStats", auditStats); } else { + result.put("qualificationCount", 0); result.put("certificateCount", 0); result.put("certificateNames", ""); } diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetProductServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetProductServiceImpl.java new file mode 100644 index 0000000..38b9dd6 --- /dev/null +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetProductServiceImpl.java @@ -0,0 +1,93 @@ +package com.chenhai.vet.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.chenhai.vet.mapper.VetProductMapper; +import com.chenhai.vet.domain.VetProduct; +import com.chenhai.vet.service.IVetProductService; + +/** + * 兽医产品信息Service业务层处理 + * + * @author ruoyi + * @date 2026-01-15 + */ +@Service +public class VetProductServiceImpl implements IVetProductService +{ + @Autowired + private VetProductMapper vetProductMapper; + + /** + * 查询兽医产品信息 + * + * @param id 兽医产品信息主键 + * @return 兽医产品信息 + */ + @Override + public VetProduct selectVetProductById(Long id) + { + return vetProductMapper.selectVetProductById(id); + } + + /** + * 查询兽医产品信息列表 + * + * @param vetProduct 兽医产品信息 + * @return 兽医产品信息 + */ + @Override + public List selectVetProductList(VetProduct vetProduct) + { + return vetProductMapper.selectVetProductList(vetProduct); + } + + /** + * 新增兽医产品信息 + * + * @param vetProduct 兽医产品信息 + * @return 结果 + */ + @Override + public int insertVetProduct(VetProduct vetProduct) + { + return vetProductMapper.insertVetProduct(vetProduct); + } + + /** + * 修改兽医产品信息 + * + * @param vetProduct 兽医产品信息 + * @return 结果 + */ + @Override + public int updateVetProduct(VetProduct vetProduct) + { + return vetProductMapper.updateVetProduct(vetProduct); + } + + /** + * 批量删除兽医产品信息 + * + * @param ids 需要删除的兽医产品信息主键 + * @return 结果 + */ + @Override + public int deleteVetProductByIds(Long[] ids) + { + return vetProductMapper.deleteVetProductByIds(ids); + } + + /** + * 删除兽医产品信息信息 + * + * @param id 兽医产品信息主键 + * @return 结果 + */ + @Override + public int deleteVetProductById(Long id) + { + return vetProductMapper.deleteVetProductById(id); + } +} diff --git a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetQualificationServiceImpl.java b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetQualificationServiceImpl.java index 0d71667..025aa79 100644 --- a/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetQualificationServiceImpl.java +++ b/chenhai-system/src/main/java/com/chenhai/vet/service/impl/VetQualificationServiceImpl.java @@ -1,25 +1,31 @@ package com.chenhai.vet.service.impl; +import com.chenhai.common.utils.DateUtils; import com.chenhai.common.utils.StringUtils; import com.chenhai.vet.domain.VetQualification; import com.chenhai.vet.mapper.VetQualificationMapper; import com.chenhai.vet.service.IVetQualificationService; +import com.chenhai.vet.service.VetNotificationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; +/** + * 兽医资质Service业务层处理(合并证书功能) + */ @Service -public class VetQualificationServiceImpl implements IVetQualificationService { +public class VetQualificationServiceImpl implements IVetQualificationService +{ @Autowired private VetQualificationMapper vetQualificationMapper; - // 修复2:给JdbcTemplate加注入注解 + @Autowired private JdbcTemplate jdbcTemplate; + @Autowired + private VetNotificationService vetNotificationService; /** * 查询兽医资质列表 @@ -34,6 +40,9 @@ public class VetQualificationServiceImpl implements IVetQualificationService { String scopeNames = getScopeNamesFromDict(qualification.getScopeIds()); qualification.setScopeNames(scopeNames); } + + // 更新证书状态 + updateCertificateStatus(qualification); } return list; } @@ -73,9 +82,6 @@ public class VetQualificationServiceImpl implements IVetQualificationService { if (StringUtils.isEmpty(certificateFilesJson)) { return ""; } - - // 如果certificateFiles是JSON数组字符串,这里可以根据需要处理 - // 简单处理:直接存储为字符串,或解析JSON后存储 return certificateFilesJson; } catch (Exception e) { return certificateFilesJson; @@ -87,7 +93,12 @@ public class VetQualificationServiceImpl implements IVetQualificationService { */ @Override public VetQualification selectVetQualificationByQualificationId(Long qualificationId) { - return vetQualificationMapper.selectVetQualificationByQualificationId(qualificationId); + VetQualification qualification = vetQualificationMapper.selectVetQualificationByQualificationId(qualificationId); + if (qualification != null) { + // 更新证书状态 + updateCertificateStatus(qualification); + } + return qualification; } /** @@ -96,11 +107,11 @@ public class VetQualificationServiceImpl implements IVetQualificationService { @Override public int insertVetQualification(VetQualification vetQualification) { if (vetQualification.getAuditStatus() == null) { - vetQualification.setAuditStatus("2"); + vetQualification.setAuditStatus(null); } if (vetQualification.getCertificateFiles() == null || vetQualification.getCertificateFiles().isEmpty()) { - vetQualification.setCertificateFiles("default.pdf"); // 默认值 + vetQualification.setCertificateFiles("default.pdf"); } if (vetQualification.getScopeIds() != null && !vetQualification.getScopeIds().isEmpty()) { @@ -108,6 +119,14 @@ public class VetQualificationServiceImpl implements IVetQualificationService { vetQualification.setScopeNames(scopeNames); } + // 设置默认提醒天数 + if (vetQualification.getRemindDays() == null) { + vetQualification.setRemindDays(30); + } + + // 验证并设置证书状态 + updateCertificateStatus(vetQualification); + return vetQualificationMapper.insertVetQualification(vetQualification); } @@ -126,6 +145,9 @@ public class VetQualificationServiceImpl implements IVetQualificationService { vetQualification.setScopeNames(scopeNames); } + // 验证并更新证书状态 + updateCertificateStatus(vetQualification); + return vetQualificationMapper.updateVetQualification(vetQualification); } @@ -145,39 +167,205 @@ public class VetQualificationServiceImpl implements IVetQualificationService { return vetQualificationMapper.deleteVetQualificationByQualificationId(qualificationId); } - private void createCertificateFromQualification(VetQualification qualification) { - try { - // 检查是否已存在证书 - String checkSql = "SELECT COUNT(*) FROM vet_certificate WHERE qualification_id = ?"; - Integer count = jdbcTemplate.queryForObject(checkSql, Integer.class, - qualification.getQualificationId()); - - if (count != null && count > 0) { - System.out.println("资质ID " + qualification.getQualificationId() + " 已存在证书,跳过创建"); - return; + /** + * 根据用户ID查询资质证书列表 + */ + @Override + public List selectQualificationsByUserId(Long userId) { + VetQualification query = new VetQualification(); + query.setUserId(userId); + return selectVetQualificationList(query); + } + + /** + * 获取即将过期的资质证书(30天内) + */ + @Override + public List selectExpiringQualifications(Long userId) { + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_YEAR, 30); + Date thirtyDaysLater = calendar.getTime(); + + // 先获取用户所有资质证书 + List allQualifications = selectQualificationsByUserId(userId); + + // 过滤出即将过期的证书 + return allQualifications.stream() + .filter(qual -> qual.getExpireDate() != null && + !qual.getExpireDate().before(today) && + !qual.getExpireDate().after(thirtyDaysLater)) + .toList(); + } + + /** + * 检查并发送证书过期提醒 + */ + @Override + public void checkAndSendCertificateReminders() { + Date today = new Date(); + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_YEAR, 30); + Date thresholdDate = calendar.getTime(); // 30天后过期 + + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_YEAR, -7); + Date remindDate = calendar.getTime(); // 7天前提醒过的不再提醒 + + // 查询所有资质证书 + VetQualification query = new VetQualification(); + List allQualifications = vetQualificationMapper.selectVetQualificationList(query); + + int successCount = 0; + int failCount = 0; + + for (VetQualification qualification : allQualifications) { + try { + // 检查证书是否需要提醒 + if (shouldSendRemind(qualification, today, thresholdDate, remindDate)) { + // 调用通知服务发送站内信 + vetNotificationService.sendCertificateExpireRemind(qualification); + + // 更新最后提醒时间 + qualification.setLastRemindTime(new Date()); + vetQualificationMapper.updateVetQualification(qualification); + + successCount++; + } + } catch (Exception e) { + failCount++; + e.printStackTrace(); } + } + } + /** + * 判断是否需要发送提醒 + */ + private boolean shouldSendRemind(VetQualification qualification, Date today, + Date thresholdDate, Date remindDate) { + if (qualification.getExpireDate() == null) { + return false; + } - String sql = "INSERT INTO vet_certificate (" + - "user_id, cert_number, " + - "create_by, create_time, " + - "qualification_id" + - ") VALUES (?, ?, ?, NOW(), ?)"; + // 检查是否即将过期(30天内) + if (qualification.getExpireDate().after(thresholdDate)) { + return false; + } - jdbcTemplate.update(sql, - qualification.getUserId(), - qualification.getCertificateNo(), - qualification.getCreateBy(), - qualification.getQualificationId() - ); + // 检查是否已提醒过(7天内) + if (qualification.getLastRemindTime() != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(qualification.getLastRemindTime()); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date lastRemindDateOnly = cal.getTime(); - System.out.println("✅ 审核通过,已创建证书编号:" + qualification.getCertificateNo()); - System.out.println("ℹ️ 证书名称、类型、发证机构等信息请在证书管理页面完善"); + if (!lastRemindDateOnly.before(remindDate)) { + return false; + } + } - } catch (Exception e) { - System.err.println("❌ 创建证书失败:" + e.getMessage()); - e.printStackTrace(); + return true; + } + + /** + * 更新证书状态 + */ + private void updateCertificateStatus(VetQualification qualification) { + if (qualification.getExpireDate() == null) { + qualification.setCertStatus("0"); + return; + } + + Date today = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_YEAR, 30); + Date thirtyDaysLater = calendar.getTime(); + + if (qualification.getExpireDate().before(today)) { + qualification.setCertStatus("2"); // 已过期 + } else if (qualification.getExpireDate().before(thirtyDaysLater)) { + qualification.setCertStatus("1"); // 即将过期 + } else { + qualification.setCertStatus("0"); // 正常 + } + } + + /** + * 手动检查证书 + */ + @Override + public void manualCheckCertificates(Long userId) { + List qualifications = selectQualificationsByUserId(userId); + for (VetQualification qualification : qualifications) { + updateCertificateStatus(qualification); + vetQualificationMapper.updateVetQualification(qualification); } } -} + /** + * 获取证书统计信息 + */ + @Override + public Map getCertificateStatistics(Long userId) { + Map statistics = new HashMap<>(); + + List qualifications = selectQualificationsByUserId(userId); + Date today = new Date(); + + long total = qualifications.size(); + long expiring = 0; // 30天内过期 + long expired = 0; // 已过期 + int expiringSoon = 0; // 7天内过期 + + Calendar calendar = Calendar.getInstance(); + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_YEAR, 30); + Date thirtyDaysLater = calendar.getTime(); + + calendar.setTime(today); + calendar.add(Calendar.DAY_OF_YEAR, 7); + Date sevenDaysLater = calendar.getTime(); + + for (VetQualification qual : qualifications) { + if (qual.getExpireDate() != null) { + if (qual.getExpireDate().before(today)) { + expired++; + } else if (qual.getExpireDate().before(thirtyDaysLater)) { + expiring++; + + // 7天内过期 + if (qual.getExpireDate().before(sevenDaysLater)) { + expiringSoon++; + } + } + } + } + + long normal = total - expiring - expired; + + statistics.put("total", total); + statistics.put("normal", normal); + statistics.put("expiring", expiring); + statistics.put("expired", expired); + statistics.put("expiringSoon", expiringSoon); + + // 设置警告级别 + if (expired > 0) { + statistics.put("warningLevel", "DANGER"); + } else if (expiring > 0 || expiringSoon > 0) { + statistics.put("warningLevel", "WARNING"); + } else { + statistics.put("warningLevel", "NORMAL"); + } + + return statistics; + } +} \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/vet/VetCertificateMapper.xml b/chenhai-system/src/main/resources/mapper/vet/VetCertificateMapper.xml deleted file mode 100644 index 9e72876..0000000 --- a/chenhai-system/src/main/resources/mapper/vet/VetCertificateMapper.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - select id, user_id, cert_name, cert_number, cert_type, issue_org, issue_date, expire_date, cert_image, status, remind_days, last_remind_time, create_by, create_time, update_by, update_time from vet_certificate - - - - - - - - insert into vet_certificate - - user_id, - cert_name, - cert_number, - cert_type, - issue_org, - issue_date, - expire_date, - cert_image, - status, - remind_days, - last_remind_time, - create_by, - create_time, - update_by, - update_time, - - - #{userId}, - #{certName}, - #{certNumber}, - #{certType}, - #{issueOrg}, - #{issueDate}, - #{expireDate}, - #{certImage}, - #{status}, - #{remindDays}, - #{lastRemindTime}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - - - - - update vet_certificate - - user_id = #{userId}, - cert_name = #{certName}, - cert_number = #{certNumber}, - cert_type = #{certType}, - issue_org = #{issueOrg}, - issue_date = #{issueDate}, - expire_date = #{expireDate}, - cert_image = #{certImage}, - status = #{status}, - remind_days = #{remindDays}, - last_remind_time = #{lastRemindTime}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, - - where id = #{id} - - - - delete from vet_certificate where id = #{id} - - - - delete from vet_certificate where id in - - #{id} - - - \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/vet/VetExperienceArticleMapper.xml b/chenhai-system/src/main/resources/mapper/vet/VetExperienceArticleMapper.xml index ac467c1..ce1b41b 100644 --- a/chenhai-system/src/main/resources/mapper/vet/VetExperienceArticleMapper.xml +++ b/chenhai-system/src/main/resources/mapper/vet/VetExperienceArticleMapper.xml @@ -54,6 +54,15 @@ and is_top = #{isTop} and is_featured = #{isFeatured} and is_sensitive = #{isSensitive} + + and ( + tags = #{tags} + or tags like concat(#{tags}, ',%') + or tags like concat('%,', #{tags}, ',%') + or tags like concat('%,', #{tags}) + or tags like concat('%', #{tags}, '%') + ) + order by create_time desc diff --git a/chenhai-system/src/main/resources/mapper/vet/VetProductMapper.xml b/chenhai-system/src/main/resources/mapper/vet/VetProductMapper.xml new file mode 100644 index 0000000..0094c17 --- /dev/null +++ b/chenhai-system/src/main/resources/mapper/vet/VetProductMapper.xml @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select id, name, type, category, specification, unit, manufacturer, approval_number, ingredients, indications, usage_dosage, price, cost_price, stock, min_stock, main_image, images, treat_animals, treat_diseases, treatment_content, treatment_duration, precautions, status, is_deleted, clinic_id, vet_id, created_at, updated_at from vet_product + + + + + + + + insert into vet_product + + name, + type, + category, + specification, + unit, + manufacturer, + approval_number, + ingredients, + indications, + usage_dosage, + price, + cost_price, + stock, + min_stock, + main_image, + images, + treat_animals, + treat_diseases, + treatment_content, + treatment_duration, + precautions, + status, + is_deleted, + clinic_id, + user_id, + created_at, + updated_at, + + + #{name}, + #{type}, + #{category}, + #{specification}, + #{unit}, + #{manufacturer}, + #{approvalNumber}, + #{ingredients}, + #{indications}, + #{usageDosage}, + #{price}, + #{costPrice}, + #{stock}, + #{minStock}, + #{mainImage}, + #{images}, + #{treatAnimals}, + #{treatDiseases}, + #{treatmentContent}, + #{treatmentDuration}, + #{precautions}, + #{status}, + #{isDeleted}, + #{clinicId}, + #{userId}, + #{createdAt}, + #{updatedAt}, + + + + + update vet_product + + name = #{name}, + type = #{type}, + category = #{category}, + specification = #{specification}, + unit = #{unit}, + manufacturer = #{manufacturer}, + approval_number = #{approvalNumber}, + ingredients = #{ingredients}, + indications = #{indications}, + usage_dosage = #{usageDosage}, + price = #{price}, + cost_price = #{costPrice}, + stock = #{stock}, + min_stock = #{minStock}, + main_image = #{mainImage}, + images = #{images}, + treat_animals = #{treatAnimals}, + treat_diseases = #{treatDiseases}, + treatment_content = #{treatmentContent}, + treatment_duration = #{treatmentDuration}, + precautions = #{precautions}, + status = #{status}, + is_deleted = #{isDeleted}, + clinic_id = #{clinicId}, + user_id = #{userId}, + created_at = #{createdAt}, + updated_at = #{updatedAt}, + + where id = #{id} + + + + delete from vet_product where id = #{id} + + + + delete from vet_product where id in + + #{id} + + + \ No newline at end of file diff --git a/chenhai-system/src/main/resources/mapper/vet/VetQualificationMapper.xml b/chenhai-system/src/main/resources/mapper/vet/VetQualificationMapper.xml index 46855f5..e323a22 100644 --- a/chenhai-system/src/main/resources/mapper/vet/VetQualificationMapper.xml +++ b/chenhai-system/src/main/resources/mapper/vet/VetQualificationMapper.xml @@ -1,9 +1,9 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -25,46 +25,69 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + + + + + + + - select vq.*, sd1.dict_label as qualification_type_label, + + sd2.dict_label as cert_status_label, - vq.scope_names as scope_names from vet_qualification vq left join sys_dict_data sd1 on sd1.dict_value = vq.qualification_type and sd1.dict_type = 'qualification_type' + left join sys_dict_data sd2 on sd2.dict_value = vq.cert_status + and sd2.dict_type = 'certificate_status' - - + @@ -88,7 +111,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" remark, scope_ids, scope_names, - + + cert_name, + cert_type, + issue_org, + issue_date, + expire_date, + cert_image, + cert_status, + remind_days, + last_remind_time, + #{userId}, #{realName}, @@ -108,7 +141,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{remark}, #{scopeIds}, #{scopeNames}, - + + #{certName}, + #{certType}, + #{issueOrg}, + #{issueDate}, + #{expireDate}, + #{certImage}, + #{certStatus}, + #{remindDays}, + #{lastRemindTime}, + @@ -122,16 +165,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" certificate_files = #{certificateFiles}, apply_time = #{applyTime}, audit_time = #{auditTime}, - audit_status = #{auditStatus}, + audit_status = #{auditStatus}, audit_opinion = #{auditOpinion}, auditor_id = #{auditorId}, - create_by = #{createBy}, - create_time = #{createTime}, update_by = #{updateBy}, update_time = #{updateTime}, remark = #{remark}, scope_ids = #{scopeIds}, scope_names = #{scopeNames}, + + cert_name = #{certName}, + cert_type = #{certType}, + issue_org = #{issueOrg}, + issue_date = #{issueDate}, + expire_date = #{expireDate}, + cert_image = #{certImage}, + cert_status = #{certStatus}, + remind_days = #{remindDays}, + last_remind_time = #{lastRemindTime}, where qualification_id = #{qualificationId} @@ -141,10 +192,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from vet_qualification where qualification_id in + delete from vet_qualification where qualification_id in #{qualificationId} + + + \ No newline at end of file diff --git a/chenhai-ui/src/api/vet/certificate.js b/chenhai-ui/src/api/vet/certificate.js deleted file mode 100644 index 1151510..0000000 --- a/chenhai-ui/src/api/vet/certificate.js +++ /dev/null @@ -1,54 +0,0 @@ -import request from '@/utils/request' - -// 查询兽医执业证书列表 -export function listCertificate(query) { - return request({ - url: '/vet/certificate/list', - method: 'get', - params: query - }) -} - -// 查询证书 -export function listForDetail(userId) { - return request({ - url: '/vet/certificate/listForDetail', - method: 'get', - params: { userId: userId } - }) -} - - -// 查询兽医执业证书详细 -export function getCertificate(id) { - return request({ - url: '/vet/certificate/' + id, - method: 'get' - }) -} - -// 新增兽医执业证书 -export function addCertificate(data) { - return request({ - url: '/vet/certificate', - method: 'post', - data: data - }) -} - -// 修改兽医执业证书 -export function updateCertificate(data) { - return request({ - url: '/vet/certificate', - method: 'put', - data: data - }) -} - -// 删除兽医执业证书 -export function delCertificate(id) { - return request({ - url: '/vet/certificate/' + id, - method: 'delete' - }) -} diff --git a/chenhai-ui/src/api/vet/product.js b/chenhai-ui/src/api/vet/product.js new file mode 100644 index 0000000..995030b --- /dev/null +++ b/chenhai-ui/src/api/vet/product.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询兽医产品信息列表 +export function listProduct(query) { + return request({ + url: '/vet/product/list', + method: 'get', + params: query + }) +} + +// 查询兽医产品信息详细 +export function getProduct(id) { + return request({ + url: '/vet/product/' + id, + method: 'get' + }) +} + +// 新增兽医产品信息 +export function addProduct(data) { + return request({ + url: '/vet/product', + method: 'post', + data: data + }) +} + +// 修改兽医产品信息 +export function updateProduct(data) { + return request({ + url: '/vet/product', + method: 'put', + data: data + }) +} + +// 删除兽医产品信息 +export function delProduct(id) { + return request({ + url: '/vet/product/' + id, + method: 'delete' + }) +} diff --git a/chenhai-ui/src/api/vet/qualification.js b/chenhai-ui/src/api/vet/qualification.js index e26fab1..0f19c56 100644 --- a/chenhai-ui/src/api/vet/qualification.js +++ b/chenhai-ui/src/api/vet/qualification.js @@ -95,3 +95,13 @@ export function delQualification(qualificationId) { method: 'delete' }) } + + +export function submitQualification(data) { + return request({ + url: '/vet/qualification/submit', + method: 'post', + data: data + }) +} + diff --git a/chenhai-ui/src/views/vet/certificate/index.vue b/chenhai-ui/src/views/vet/certificate/index.vue deleted file mode 100644 index 80476e0..0000000 --- a/chenhai-ui/src/views/vet/certificate/index.vue +++ /dev/null @@ -1,427 +0,0 @@ - - - - - - diff --git a/chenhai-ui/src/views/vet/comments/index.vue b/chenhai-ui/src/views/vet/comments/index.vue index 81f4e92..da2e1ff 100644 --- a/chenhai-ui/src/views/vet/comments/index.vue +++ b/chenhai-ui/src/views/vet/comments/index.vue @@ -177,7 +177,7 @@ export default { } }, created() { - this.queryParams.consultationId = Number(this.consultationId) + this.queryParams.consultationId = this.parseConsultationId(this.consultationId) this.getList() }, methods: { @@ -279,7 +279,32 @@ export default { this.download('vet/comments/export', { ...this.queryParams }, `comments_${new Date().getTime()}.xlsx`) + }, + + parseConsultationId(id) { + if (id == null || id === '' || id === undefined) { + return null + } + + // 处理字符串"NaN" + if (id === 'NaN' || id === 'nan' || id === 'Nan') { + console.warn('检测到无效的consultationId: NaN') + return null + } + + // 尝试转换为数字 + const num = Number(id) + + // 检查是否为有效数字且是整数 + if (!isNaN(num) && Number.isInteger(num) && num > 0) { + return num + } + + console.error('无效的consultationId:', id) + return null } + + } } diff --git a/chenhai-ui/src/views/vet/info/index.vue b/chenhai-ui/src/views/vet/info/index.vue index cfde34b..7791f3c 100644 --- a/chenhai-ui/src/views/vet/info/index.vue +++ b/chenhai-ui/src/views/vet/info/index.vue @@ -42,14 +42,6 @@ @keyup.enter.native="handleQuery" /> - - - - - - - - 搜索 重置 @@ -89,16 +81,6 @@ v-hasPermi="['vet:info:remove']" >删除 - - - - - - - - - - @@ -126,13 +108,13 @@ diff --git a/chenhai-ui/src/views/vet/qualification/index.vue b/chenhai-ui/src/views/vet/qualification/index.vue index 08de666..9f5cc4e 100644 --- a/chenhai-ui/src/views/vet/qualification/index.vue +++ b/chenhai-ui/src/views/vet/qualification/index.vue @@ -1,30 +1,22 @@