diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java b/dl-module-company/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java index 3895eebf..a01c2a4f 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java @@ -72,4 +72,34 @@ public class SendSmsUtil { } } + + public static void sendMsgCommonByPhoneNums(String[] templateParamSet,String[] phoneNums,String sdkAppId,String signName,String templateId){ + + try{ + Credential cred = new Credential("AKIDQlz4xdAaypV0MYkv1AMRRKSdw350qW2x", "oRv221ymOsBMOMBwAHF4f2GJC6tX6Wnv"); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("sms.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + SendSmsRequest req = new SendSmsRequest(); + req.setPhoneNumberSet(phoneNums); + + req.setSmsSdkAppId(sdkAppId); + req.setSignName(signName); + req.setTemplateId(templateId); + req.setTemplateParamSet(templateParamSet); + // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 + SendSmsResponse resp = client.SendSms(req); + // 输出json格式的字符串回包 + System.out.println(SendSmsResponse.toJsonString(resp)); + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + } + + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java index 7195fa74..a2271842 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/InspectionNoticeService.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.common.service; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; + public interface InspectionNoticeService { /** @@ -16,5 +18,6 @@ public interface InspectionNoticeService { * @param userId 用户id * @param text 消息通知内容 **/ - void sentMessage(Long userId, String text, Long tenantId); + @TenantIgnore + void sentMessageToMember(Long userId, String text, Long tenantId); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java index 76d4fbed..26668eee 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/common/service/impl/InspectionNoticeServiceImpl.java @@ -46,13 +46,13 @@ public class InspectionNoticeServiceImpl implements InspectionNoticeService { * @param text 消息通知内容 **/ @Override - public void sentMessage(Long userId, String text, Long tenantId) { + public void sentMessageToMember(Long userId, String text, Long tenantId) { // 准备发送参数 Map templateParams = new HashMap<>(); // 发送模版内容 templateParams.put("text", text); // 发送站内信 - sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO() + sendApi.sendSingleMessageToMember(new NotifySendSingleToUserReqDTO() .setUserId(userId) .setTemplateCode(TICKET_EMPLOY) .setSystemCode(SystemEnum.INSPECTION.getCode()) diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionConstants.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionConstants.java index 697e8a23..2f39fa00 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionConstants.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionConstants.java @@ -112,6 +112,31 @@ public class InspectionConstants { */ public static final String INSPECTION_NOTICE_TEMPLATE_BUSINESS_MANAGER_MEET_CAR_ORDER_UNQUALIFIED = "%s的工单不合格,详细信息请前往列表查看"; + /** + * 检测站内信模板-提示经办人 用户车辆年审即将到期 + */ + public static final String INSPECTION_NOTICE_TEMPLATE_USER_CAR_YEAR_EXPIRE = "用户车辆%s年审将与%s到期 用户联系方式:%s"; + + /** + * 检测站内信模板-提示经办人 用户车辆保险即将到期 + */ + public static final String INSPECTION_NOTICE_TEMPLATE_USER_CAR_INSURANCE_EXPIRE = "用户车辆%s保险将于%s到期 用户联系方式:%s"; + + /** + * 检测站内信模板-提示用户 用户车辆保险即将到期 + */ + public static final String INSPECTION_NOTICE_TEMPLATE_USER_CAR_INSURANCE_EXPIRE_USER = "您的车辆%s保险将于%s到期"; + + /** + * 检测站内信模板-提示用户 车辆年审即将到期 + */ + public static final String INSPECTION_NOTICE_TEMPLATE_USER_CAR_YEAR_EXPIRE_USER = "您的车辆%s年审将于%s到期"; + + /** + * 检测站内信模板-提示用户 上传的资料即将到期 + */ + public static final String INSPECTION_NOTICE_TEMPLATE_USER_FILE_EXPIRE = "您上传的资料%s即将到期"; + // =======================================打印模板======================================= /** * 检测打印模板-订单结算 @@ -255,4 +280,6 @@ public class InspectionConstants { " \n" + " \n" + ""; + public static final String INSPECTION_CUSTOMER_FILE_FOLDER = "small_inspection_member_folder"; + public static final String INSPECTION_CUSTOMER_FILE_FOLDER_NAME = "检测客户资料夹"; } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionFileEnum.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionFileEnum.java index 5e14e475..7aa8f1cc 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionFileEnum.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/constant/InspectionFileEnum.java @@ -13,7 +13,9 @@ public enum InspectionFileEnum { FOLDER("staff", "员工文件夹"), FILE("equipment", "设备文件夹"), COACH("coach", "驾校员工文件夹"), - student("student","驾校学员文件夹"); + student("student","驾校学员文件夹"), + INSPECTION_CUSTOMER("small_inspection_member_folder", "检测客户资料夹"), + ; private final String type; diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallInspectionFileController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallInspectionFileController.java new file mode 100644 index 00000000..0293719d --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallInspectionFileController.java @@ -0,0 +1,230 @@ +package cn.iocoder.yudao.module.inspection.controller.app; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.common.SystemEnum; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.constant.InspectionConstants; +import cn.iocoder.yudao.module.core.controller.BaseController; +import cn.iocoder.yudao.module.inspection.entity.InspectionFile; +import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService; +import cn.iocoder.yudao.module.inspection.service.IInspectionFileService; +import cn.iocoder.yudao.module.inspection.vo.AssignAuthorityVo; +import cn.iocoder.yudao.module.shop.entity.ShopMallPartners; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; +import cn.iocoder.yudao.module.system.service.permission.PermissionServiceImpl; +import cn.iocoder.yudao.util.ExcelUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * inspectionFileController + * + * @author zcy + * @date 2023-10-13 + */ +@RestController +@RequestMapping("/inspectionFile") +public class SmallInspectionFileController extends BaseController { + @Autowired + private IInspectionFileService inspectionFileService; + @Autowired + private AppInspectionPartnerService partnerService; + + @Autowired + private PermissionServiceImpl roleService; + @Resource + private DictDataApi dictDataApi; + @Resource + private PermissionApi permissionApi; + + + /** + * 获取检测资料夹 + * + * @return inspectionFile + */ + @GetMapping("/getFirstFolder") + public CommonResult getFirstFolder() { + // 查询检测 并且 文件夹 是检测客户资料夹的文件夹 + InspectionFile folder = inspectionFileService.getOne(Wrappers.lambdaQuery() + .eq(InspectionFile::getType, InspectionConstants.INSPECTION_FOLDER) + .eq(InspectionFile::getServicePackageId, SystemEnum.INSPECTION.getCode()) + .eq(InspectionFile::getDefaultKey, InspectionConstants.INSPECTION_CUSTOMER_FILE_FOLDER)); + if (folder == null) { + // 新增一个这个文件夹 + folder = new InspectionFile(); + folder.setFileName(InspectionConstants.INSPECTION_CUSTOMER_FILE_FOLDER_NAME); + folder.setServicePackageId(SystemEnum.INSPECTION.getCode()); + folder.setDefaultKey(InspectionConstants.INSPECTION_CUSTOMER_FILE_FOLDER); + folder.setType(InspectionConstants.INSPECTION_FOLDER); + folder.setTenantId(180L); + + inspectionFileService.insertInspectionFile(folder); + } + return success(folder); + } + + /** + * 查询inspectionFile列表 + */ + @GetMapping("/list") + @TenantIgnore + public CommonResult list( InspectionFile inspectionFile) throws Exception { + Long loginUserId = SecurityFrameworkUtils.getLoginUserId(); + inspectionFile.setCreator(String.valueOf(loginUserId)); + if (ObjectUtil.isEmpty(inspectionFile.getFatherId())) { + + // 查询检测 并且 文件夹 是检测客户资料夹的文件夹 + InspectionFile folder = inspectionFileService.getOne(Wrappers.lambdaQuery() + .eq(InspectionFile::getType, InspectionConstants.INSPECTION_FOLDER) + .eq(InspectionFile::getServicePackageId, SystemEnum.INSPECTION.getCode()) + .eq(InspectionFile::getDefaultKey, InspectionConstants.INSPECTION_CUSTOMER_FILE_FOLDER)); + if (folder == null) { + // 新增一个这个文件夹 + folder = new InspectionFile(); + folder.setFileName(InspectionConstants.INSPECTION_CUSTOMER_FILE_FOLDER_NAME); + folder.setServicePackageId(SystemEnum.INSPECTION.getCode()); + folder.setDefaultKey(InspectionConstants.INSPECTION_CUSTOMER_FILE_FOLDER); + folder.setType(InspectionConstants.INSPECTION_FOLDER); + folder.setTenantId(180L); + + inspectionFileService.insertInspectionFile(folder); + } + inspectionFile.setFatherId(folder.getId()); + } + + List list = inspectionFileService.selectInspectionFileList(inspectionFile); + + return success(list); + } + + /** + * 获取inspectionFile详细信息 + */ + @GetMapping(value = "/{id}") + @TenantIgnore + public CommonResult getInfo(@PathVariable("id") Long id) { + return success(inspectionFileService.selectInspectionFileById(id)); + } + + /** + * 新增inspectionFile + */ + @PostMapping("/add") + @TenantIgnore + public CommonResult add(@RequestBody InspectionFile inspectionFile) throws Exception { + inspectionFile.setTenantId(180L); + return success(inspectionFileService.insertInspectionFile(inspectionFile)); + } + + /** + * 修改inspectionFile + */ + @PostMapping("/edit") + @TenantIgnore + public CommonResult edit(@RequestBody InspectionFile inspectionFile) throws Exception { +// if (!partners.getPartnerId().equals(file.getPartnerId())) { +// return null; +// } + return toAjax(inspectionFileService.updateInspectionFile(inspectionFile)); + } + + /** + * 删除inspectionFile + */ + @PostMapping("/del/{id}") + @TenantIgnore + public CommonResult remove(@PathVariable Long id) throws Exception { +// ShopMallPartners partners = partnerService.shopInfo(); +// InspectionFile file = inspectionFileService.selectInspectionFileById(id); +// if (!partners.getPartnerId().equals(file.getPartnerId())) { +// return null; +// } + return toAjax(inspectionFileService.deleteInspectionFileById(id)); + } + + /** + * 根据id统计数量 + * + * @param ids ids + * @author 小李 + * @date 14:30 2024/12/14 + **/ + @GetMapping("/getCountByIds") + public CommonResult getCountByIds(@RequestParam(value = "ids", required = false) List ids) { + if (CollUtil.isEmpty(ids)) { + return null; + } + return success(inspectionFileService.getCountByIds(ids)); + } + + /** + * 得到使用说明 + * + * @author 小李 + * @date 12:31 2024/12/17 + **/ + @GetMapping("/getPresent") + public CommonResult getPresent() { + List files = inspectionFileService.list(new LambdaQueryWrapper().eq(InspectionFile::getFileName, "使用说明")); + if (CollUtil.isEmpty(files)) { + return null; + } + InspectionFile inspectionFile = files.get(0); + return success(inspectionFile); + + } + + /** + * 分配权限 + * + * @param assignAuthorityVo + * @return + */ + @PostMapping("/assignAuthority") + public CommonResult assignAuthority(@RequestBody AssignAuthorityVo assignAuthorityVo) { + return success(inspectionFileService.assignAuthority(assignAuthorityVo.getUserIds(), assignAuthorityVo.getFileId())); + } + + /** + * 根据文件id获取有权限的用户id + * + * @param fileId + * @return + */ + @GetMapping("/getUserIdsByFileId") + public CommonResult getUserIdsByFileId(Integer fileId) { + List userIds = inspectionFileService.getUserIdsByFileId(fileId); + return success(userIds); + } + + /** + * 查询文件夹树 + * + * @return + */ + @GetMapping("/queryTreeFolder") + public CommonResult queryTreeFolder() { + return success(inspectionFileService.queryTreeFolder()); + } + + /** + * 查询文件夹树 + * + * @return + */ + @GetMapping("/queryTreeFolderForJx") + public CommonResult queryTreeFolderForJx() { + return success(inspectionFileService.queryTreeFolderForJx()); + } +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallInspectionFileRecordController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallInspectionFileRecordController.java new file mode 100644 index 00000000..c27c7648 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallInspectionFileRecordController.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.inspection.controller.app; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.core.controller.BaseController; +import cn.iocoder.yudao.module.inspection.entity.InspectionFileRecord; +import cn.iocoder.yudao.module.inspection.service.InspectionFileRecordService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @Description: 文档记录 + * @Author: 86187 + * @Date: 2025/02/08 13:53 + * @Version: 1.0 + */ +@RestController +@RequestMapping("/system/fileRecord") +public class SmallInspectionFileRecordController extends BaseController { + + @Autowired + private InspectionFileRecordService inspectionFileRecordService; + + /** + * 根据文件id查询修改记录 + * + * @param id + * @return + */ + @GetMapping("/get/{id}") + public CommonResult getByFileId(@PathVariable Long id) { + List list = inspectionFileRecordService.getRecordList(id); + + return CommonResult.success(list); + } +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallNewsController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallNewsController.java new file mode 100644 index 00000000..fde45a17 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/app/SmallNewsController.java @@ -0,0 +1,321 @@ +package cn.iocoder.yudao.module.inspection.controller.app; + +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import cn.iocoder.yudao.module.core.controller.BaseController; +import cn.iocoder.yudao.module.inspection.entity.InspectionNews; +import cn.iocoder.yudao.module.inspection.entity.InspectionNewsComment; +import cn.iocoder.yudao.module.inspection.service.IInspectionNewsCommentService; +import cn.iocoder.yudao.module.inspection.service.IInspectionNewsService; +import cn.iocoder.yudao.module.shop.entity.ShopMallPartners; +import cn.iocoder.yudao.module.shop.service.IShopMallPartnersService; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; +import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; +import cn.iocoder.yudao.module.system.service.dict.DictDataService; +import cn.iocoder.yudao.module.system.service.permission.RoleService; +import cn.iocoder.yudao.util.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/appInspection/news") +public class SmallNewsController extends BaseController { + @Autowired + private IInspectionNewsService inspectionNewsService; + @Autowired + private IInspectionNewsCommentService commentService; + @Autowired + private AdminUserApi sysUserService; + @Autowired + private DeptApi deptService; + @Autowired + private IShopMallPartnersService partnersService; + @Autowired + private DictDataService dictTypeService; + @Resource + private RoleService roleService; + @Resource + private PermissionApi permissionApi; + + /** + * 根据字典类型查询字典数据信息 + */ + @GetMapping(value = "/editType") + public CommonResult editType() + { + List data = dictTypeService.getDictDataListByDictType("inspection_hygg"); + if (StringUtils.isNull(data)) + { + data = new ArrayList(); + } + //获取当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + List roleIds = permissionApi.getRoleIdsByUserId(loginUser.getId()); + List roleList = roleService.getRoleList(roleIds); + List roleKeys = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList()); + if (roleKeys.contains("jcgf")){ + data = data.stream().filter(it->{ + return it.getValue().equals("zflm")||it.getValue().equals("jcztz"); + }).collect(Collectors.toList()); + }else if (roleKeys.contains("jcshop")){ + data = data.stream().filter(it->{ + return it.getValue().equals("jczgg"); + }).collect(Collectors.toList()); + } + return success(data); + } + /** + * 根据字典类型查询字典数据信息 + */ + @GetMapping(value = "/listType") + public CommonResult listType() + { + List data = dictTypeService.getDictDataListByDictType("inspection_hygg"); + if (StringUtils.isNull(data)) + { + data = new ArrayList(); + } + data = data.stream().filter(it->{ + return !it.getValue().equals("jcztz"); + }).collect(Collectors.toList()); + + return success(data); + } + @GetMapping("/listGfClass") + public CommonResult listGfClass() + { + List list = inspectionNewsService.listGfClass("zflm"); + return success(list); + } + @GetMapping("/list") + public CommonResult list(InspectionNews inspectionNews, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) + { + Page page = new Page<>(pageNum, pageSize); + IPage list = inspectionNewsService.selectInspectionNewsList(page,inspectionNews); + return success(list); + } + + @GetMapping("/ownList") + public CommonResult ownList(InspectionNews inspectionNews,@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize") Integer pageSize) + { + //当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + inspectionNews.setCreator(loginUser.getId().toString()); + Page page = new Page<>(pageNum, pageSize); + IPage list = inspectionNewsService.selectInspectionNewsList(page,inspectionNews); + return success(list); + } + @PostMapping("/add") + public CommonResult add(@RequestBody InspectionNews inspectionNews) throws Exception { + //获取当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); +// AdminUserRespDTO user = sysUserService.getUser(loginUser.getId()); + List roleIds = permissionApi.getRoleIdsByUserId(loginUser.getId()); + List roleList = roleService.getRoleList(roleIds); + + List roleKeys = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList()); + + if (roleKeys.contains("jcgf")) { + if (StringUtils.isEmpty(inspectionNews.getCategory())) { + //检测官方 + inspectionNews.setCategory("zflm"); + } else { + if (!inspectionNews.getCategory().equals("zflm") && !inspectionNews.getCategory().equals("jcztz")) { + throw new Exception("权限不足"); + } + } + //根据部门获取发布单位 + AdminUserRespDTO user = sysUserService.getUser(loginUser.getId()); + DeptRespDTO sysDept = deptService.getDept(user.getDeptId()); + inspectionNews.setPublishUnit(ObjectUtil.isEmpty(sysDept) ? "检测官方" : sysDept.getName()); +// if (inspectionNews.getCategory().equals("jcztz")){ +// //如果是内部通知 进行websocket通知 +// try { +// msgSocket.sendToAll("newMsg"); +// }catch (Exception e){ +// logger.error(e.getMessage()); +// } +// +// } + } else if (roleKeys.contains("jcshop")) { + //检测站 + inspectionNews.setCategory("jczgg"); + ShopMallPartners partners = partnersService.selectShopMallPartnersByUserId(loginUser.getId(), "jc"); + inspectionNews.setPublishUnit(partners.getPartnerName()); + } + + if (ObjectUtil.isEmpty(inspectionNews.getType()) || inspectionNews.getType().equals("null")){ + if (ObjectUtil.isNotEmpty(inspectionNews.getIfShow())){ + inspectionNews.setType(inspectionNews.getIfShow().equals("01") ? "staff" : "user"); + } + } + + //判断是否为当前登录用户创建的 + return toAjax(inspectionNewsService.insertInspectionNews(inspectionNews)); + } + + @PostMapping("/edit") + public CommonResult edit(@RequestBody InspectionNews inspectionNews) + { + //判断是否为当前登录用户创建的 + //当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + InspectionNews inspectionNews1 = inspectionNewsService.selectInspectionNewsById(inspectionNews.getId()); + if (!inspectionNews1.getCreator().equals(loginUser.getId().toString())){ + return error("禁止编辑"); + } + inspectionNews.setPublishUnit(null); + inspectionNews.setCategory(null); + return toAjax(inspectionNewsService.updateInspectionNews(inspectionNews)); + } + + /** + * 删除【请填写功能名称】 + */ + @PostMapping("/del") + public CommonResult remove(@RequestParam("id") Long id) + { + //判断是否为当前登录用户创建的 + //当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + InspectionNews inspectionNews1 = inspectionNewsService.selectInspectionNewsById(id); + if (!inspectionNews1.getCreator().equals(loginUser.getId().toString())){ + return error("禁止删除"); + } + return toAjax(inspectionNewsService.deleteInspectionNewsById(id)); + } + //获取 详细信息 + @GetMapping("/getDetail") + public CommonResult getDetail(Long newsId) + { + return success(inspectionNewsService.getDetail(newsId)); + } + + /** + * 新增阅读数量 + * @param newsId + * @return + */ + @PostMapping("/addReadNum") + public CommonResult addReadNum(@RequestParam("newsId") Long newsId,Long objectId) + { + inspectionNewsService.addReadNum(newsId,objectId); + return CommonResult.ok(); + } + + /** + * 点赞/收藏 + * @param newsId + * @param type + * @return + */ + @PostMapping("/likeOrCollect") + public CommonResult likeOrCollect(@RequestParam("newsId") Long newsId,@RequestParam("type") String type) + { + inspectionNewsService.likeOrCollect(newsId,type); + return CommonResult.ok(); + } + + + + /** + * 新增评论 + * @param inspectionNewsComment + * @return + */ + @PostMapping("/addInspectionNewsComment") + public CommonResult addInspectionNewsComment(@RequestBody InspectionNewsComment inspectionNewsComment) + { + inspectionNewsService.addInspectionNewsComment(inspectionNewsComment); + return CommonResult.ok(); + } + + /** + * 删除评论 + * @param commentId + * @return + */ + @PostMapping("/delNewsComment") + public CommonResult delNewsComment(Long commentId) + { + //判断是否为当前登录用户创建的 + //当前登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + InspectionNewsComment comment = commentService.getById(commentId); + if (!comment.getCreator().equals(loginUser.getId().toString())){ + return error("禁止删除"); + } + return toAjax(commentService.removeById(commentId)); + } + /** + * 获取评论列表 + * @return + */ + @GetMapping("/getCommentList") + public CommonResult getCommentList(Long newsId, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) + { + + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectionNewsComment::getNewsId,newsId).orderByDesc(TenantBaseDO::getCreateTime); + IPage commentList = commentService.page(page,queryWrapper); + return success(commentList); + } + /** + * 我的收藏 + * @return + */ + @GetMapping("/collectionNews") + public CommonResult collectionNews(String newsName, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) + { + Page page = new Page<>(pageNum, pageSize); + IPage newsList = inspectionNewsService.collectionNews(page,newsName); + return success(newsList); + } + + /** + * 获取未读消息数量 + * @return + */ + @GetMapping("/newMsgNum") + public CommonResult newMsgNum(Long partnerId) + { + return success(inspectionNewsService.newMsgNum(partnerId)); + } + + /** + * 获取未读消息列表 + * @return + */ + @GetMapping("/msgList") + public CommonResult msgList(Long partnerId, + @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, + @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) + { + Page page = new Page<>(pageNum, pageSize); + IPage news = inspectionNewsService.msgList(page,partnerId); + return success(news); + } +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java index ee9bc8a8..a0c3d7a8 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionInfoMapper.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; import java.util.Map; @@ -103,4 +104,8 @@ public interface InspectionInfoMapper extends BaseMapper List selectMeetCarList(@Param("datetimeRange") List datetimeRange); Map workOrderDataNew(@Param("query") OrderTableQuery query); + + List selectLatestByCarNums(@Param("carNos") Collection carNos); + + Map selectBuyUserIdsByInfoIds(Collection ids); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionFileService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionFileService.java index 2090d7e8..a5d41746 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionFileService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionFileService.java @@ -123,4 +123,9 @@ public interface IInspectionFileService extends IService { */ List queryTreeFolder(); List queryTreeFolderForJx(); + + /** + * 文件提醒 + */ + void warnReminder(); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java index 98c467f7..deda7d8c 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java @@ -11,8 +11,10 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionInfo; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; /** * 【请填写功能名称】Service接口 @@ -180,4 +182,8 @@ public interface IInspectionInfoService extends IService Map getBusinessCountByType(Integer partnerId); List selectMeetCarList(List datetimeRange); + + List selectLatestByCarNums(Collection carNos); + + Map selectBuyUserIdsByInfoIds(Collection ids); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java index 6710edb7..18e1f9d6 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionAppointmentServiceImpl.java @@ -249,7 +249,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl fileList = this.list(queryWrapper); //判断文件是否是图片 @@ -586,6 +589,27 @@ public class InspectionFileServiceImpl extends ServiceImpl().eq(InspectionFile::getDefaultKey, InspectionFileEnum.INSPECTION_CUSTOMER.getType())); + if (inspectionFile != null) { + // 查询出code中所有带这个文件夹id的文件 + List inspectionFiles = baseMapper.selectList(new LambdaQueryWrapper().like(InspectionFile::getFileCode, inspectionFile.getId()).eq(InspectionFile::getFileType, InspectionConstants.INSPECTION_FILE)); + // 判断获取提醒时间判断是否有过期的 + inspectionFiles.forEach(file -> { + if (file.getWarnTime() != null && file.getWarnTime().before(new Date())) { + String message = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_FILE_EXPIRE, file.getFileName()); + // 提醒 + noticeService.sentMessage(Long.valueOf(file.getCreator()), message); + } + }); + } + } + /** * 构建树形结构 * diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java index 819dff03..2680ad01 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java @@ -1095,6 +1095,24 @@ public class InspectionInfoServiceImpl extends ServiceImpl selectLatestByCarNums(Collection carNos) { + return baseMapper.selectLatestByCarNums(carNos); + } + + /** + * @param ids + * @return + */ + @Override + public Map selectBuyUserIdsByInfoIds(Collection ids) { + return baseMapper.selectBuyUserIdsByInfoIds(ids); + } + /** * 保存引车员记录 * diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/job/job/ExpirationReminderJob.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/job/job/ExpirationReminderJob.java new file mode 100644 index 00000000..f85c64be --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/job/job/ExpirationReminderJob.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.job.job; + +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; +import cn.iocoder.yudao.module.infra.service.job.JobLogService; +import cn.iocoder.yudao.module.reminder.service.IInspectionReminderConfigService; +import cn.iocoder.yudao.module.shop.service.IShopUserCarService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 定时执行提醒 + * + * @author j-sentinel + */ +@Slf4j +@Component +public class ExpirationReminderJob implements JobHandler { + + @Resource + private IInspectionReminderConfigService inspectionReminderConfigService; + + @Override + @TenantJob + public String execute(String param) { + inspectionReminderConfigService.expireInspectionReminder(); + log.info("定时提醒开启"); + return String.format("定时执行清理定时任务日志数量 %s 个"); + } + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/job/job/FileWarnJob.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/job/job/FileWarnJob.java new file mode 100644 index 00000000..35b2a088 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/job/job/FileWarnJob.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.job.job; + +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; +import cn.iocoder.yudao.module.inspection.service.IInspectionFileService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +@RequiredArgsConstructor +public class FileWarnJob implements JobHandler { + + private final IInspectionFileService inspectionFileService; + + /** + * 执行任务 + * + * @param param 参数 + * @return 结果 + * @throws Exception 异常 + */ + @Override + @TenantJob + public String execute(String param) throws Exception { + inspectionFileService.warnReminder(); + log.info("执行了文件提醒"); + return String.format("定时执行清理定时任务日志数量 %s 个"); + } +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/controller/admin/InspectionReminderConfigController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/controller/admin/InspectionReminderConfigController.java new file mode 100644 index 00000000..529f430b --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/controller/admin/InspectionReminderConfigController.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.reminder.controller.admin; + + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderConfig; +import cn.iocoder.yudao.module.reminder.service.IInspectionReminderConfigService; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +/** + *

+ * 年审和年检提醒配置表 前端控制器 + *

+ * + * @author lighting + * @since 2025-07-21 + */ +@RestController +@RequestMapping("/inspection-reminder-config") +@RequiredArgsConstructor +public class InspectionReminderConfigController { + + private final IInspectionReminderConfigService inspectionReminderConfigService; + + /** + * 年审和年检提醒 + */ + @RequestMapping("/expireInspectionReminder") + public void expireInspectionReminder() { + inspectionReminderConfigService.expireInspectionReminder(); + } + + /** + * 获取信息 + * + * @return InspectionReminderConfig + */ + @GetMapping + public CommonResult getInfo() { + return CommonResult.success(inspectionReminderConfigService.getOne(Wrappers.lambdaQuery())); + } + + /** + * 添加信息 + * + * @param inspectionReminderConfig + * @return InspectionReminderConfig + */ + @PostMapping + public CommonResult addInfo(@RequestBody InspectionReminderConfig inspectionReminderConfig) { + return CommonResult.success(inspectionReminderConfigService.save(inspectionReminderConfig)); + } + + /** + * 修改信息 + * + * @param inspectionReminderConfig + * @return InspectionReminderConfig + */ + @PutMapping + public CommonResult updateInfo(@RequestBody InspectionReminderConfig inspectionReminderConfig) { + return CommonResult.success(inspectionReminderConfigService.updateById(inspectionReminderConfig)); + } +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/entity/InspectionReminderConfig.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/entity/InspectionReminderConfig.java new file mode 100644 index 00000000..6596da93 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/entity/InspectionReminderConfig.java @@ -0,0 +1,69 @@ +package cn.iocoder.yudao.module.reminder.entity; + +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 年审和年检提醒配置表 + *

+ * + * @author lighting + * @since 2025-07-21 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("inspection_reminder_config") +public class InspectionReminderConfig extends TenantBaseDO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 年审提前 天数提醒 + */ + private Integer annualEviewDay; + + /** + * 保险提前申请天数 + */ + private Integer insuranceDay; + + /** + * 状态(0-正常1-开启) + */ + private Integer status; + + /** + * 提醒对象(0-车主 1-经办人 2-都提醒) + */ + private Integer reminderPeople; + + /** + * 短信appid + */ + private String sdkAppId; + + /** + * 短信模板ID + */ + private String templateId; + + /** + * 签名 + */ + private String signName; +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/entity/InspectionReminderRecord.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/entity/InspectionReminderRecord.java new file mode 100644 index 00000000..97be4619 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/entity/InspectionReminderRecord.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.reminder.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; +import java.time.LocalDate; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 车辆提醒记录表 + *

+ * + * @author lighting + * @since 2025-07-22 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("inspection_reminder_record") +public class InspectionReminderRecord implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private Long id; + + /** + * 车牌号 + */ + private String carNum; + + /** + * 提醒类型(0-年审,1-保险) + */ + private Integer reminderType; + + /** + * 提醒日期 + */ + private Date remindDate; + + /** + * 当时记录的到期日 + */ + private Date actualDueDate; + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/mapper/InspectionReminderConfigMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/mapper/InspectionReminderConfigMapper.java new file mode 100644 index 00000000..7404dc8a --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/mapper/InspectionReminderConfigMapper.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.reminder.mapper; + +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderConfig; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 年审和年检提醒配置表 Mapper 接口 + *

+ * + * @author lighting + * @since 2025-07-21 + */ +@Mapper +public interface InspectionReminderConfigMapper extends BaseMapper { + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/mapper/InspectionReminderRecordMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/mapper/InspectionReminderRecordMapper.java new file mode 100644 index 00000000..bf83c4c2 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/mapper/InspectionReminderRecordMapper.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.reminder.mapper; + +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 车辆提醒记录表 Mapper 接口 + *

+ * + * @author lighting + * @since 2025-07-22 + */ +@Mapper +public interface InspectionReminderRecordMapper extends BaseMapper { + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/IInspectionReminderConfigService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/IInspectionReminderConfigService.java new file mode 100644 index 00000000..36543024 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/IInspectionReminderConfigService.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.reminder.service; + +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderConfig; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 年审和年检提醒配置表 服务类 + *

+ * + * @author lighting + * @since 2025-07-21 + */ +public interface IInspectionReminderConfigService extends IService { + + void expireInspectionReminder(); +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/IInspectionReminderRecordService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/IInspectionReminderRecordService.java new file mode 100644 index 00000000..ed124190 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/IInspectionReminderRecordService.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.reminder.service; + +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 车辆提醒记录表 服务类 + *

+ * + * @author lighting + * @since 2025-07-22 + */ +public interface IInspectionReminderRecordService extends IService { + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/impl/InspectionReminderConfigServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/impl/InspectionReminderConfigServiceImpl.java new file mode 100644 index 00000000..def9d574 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/impl/InspectionReminderConfigServiceImpl.java @@ -0,0 +1,252 @@ +package cn.iocoder.yudao.module.reminder.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.common.service.InspectionNoticeService; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import cn.iocoder.yudao.module.constant.InspectionConstants; +import cn.iocoder.yudao.module.inspection.entity.InspectionInfo; +import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService; +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderConfig; +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderRecord; +import cn.iocoder.yudao.module.reminder.mapper.InspectionReminderConfigMapper; +import cn.iocoder.yudao.module.reminder.service.IInspectionReminderConfigService; +import cn.iocoder.yudao.module.reminder.service.IInspectionReminderRecordService; +import cn.iocoder.yudao.module.shop.entity.ShopUserCar; +import cn.iocoder.yudao.module.shop.service.IShopUserCarService; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.service.user.AdminUserService; +import cn.iocoder.yudao.util.SendSmsUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.omg.PortableInterceptor.USER_EXCEPTION; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + *

+ * 年审和年检提醒配置表 服务实现类 + *

+ * + * @author lighting + * @since 2025-07-21 + */ +@Service +@RequiredArgsConstructor +public class InspectionReminderConfigServiceImpl extends ServiceImpl implements IInspectionReminderConfigService { + + private final IShopUserCarService shopUserCarService; + private final IInspectionInfoService inspectionInfoService; + private final InspectionNoticeService inspectionNoticeService; + private final AdminUserService adminUserService; + private final IInspectionReminderRecordService reminderRecordService; + + + @Override + public void expireInspectionReminder() { + // TODO 有可能每天都会给同一辆车发送信息 只需要发送一次 + InspectionReminderConfig config = this.getOne(Wrappers.lambdaQuery()); + if (ObjectUtil.isNotEmpty(config) && config.getStatus() == 0) { + DateTime now = DateUtil.date(); + reminderNextInspection(config.getAnnualEviewDay(), now, config); + reminderInsurance(config.getInsuranceDay(), now, config); + } + } + + private void reminderInsurance(Integer insuranceDay, DateTime now, InspectionReminderConfig config) { + DateTime insuranceTime = DateUtil.offsetDay(now, insuranceDay); + List insuranceReminders = shopUserCarService.list(Wrappers.lambdaQuery() + .between(ShopUserCar::getInsuranceDate, DateUtil.beginOfDay(now), DateUtil.endOfDay(insuranceTime)) + .or() + .between(ShopUserCar::getVehicleInsuranceExpiryDate, DateUtil.beginOfDay(now), DateUtil.endOfDay(insuranceTime))); + + Set carNos = insuranceReminders.stream().map(ShopUserCar::getCarNo).collect(Collectors.toSet()); + if (carNos.isEmpty()) return; + + List inspectionInfos = inspectionInfoService.selectLatestByCarNums(carNos); + Map othersInfo = getOthersInfo(config, inspectionInfos); + + List ownerPhones = inspectionInfos.stream() + .map(InspectionInfo::getBuyPhone) + .filter(ObjectUtil::isNotEmpty) + .collect(Collectors.toList()); + + + + // 发送站内信 + for (InspectionInfo inspectionInfo : inspectionInfos) { + Date minDate = Stream.of(inspectionInfo.getInsuranceExpiryDate(), inspectionInfo.getVehicleInsuranceExpiryDate()) + .filter(Objects::nonNull) + .min(Date::compareTo) + .orElse(null); + String formattedDate = DateUtil.format(minDate, "yyyy年MM月dd日"); + + // 查询是否已有提醒记录 + Long count = reminderRecordService.count(Wrappers.lambdaQuery() + .eq(InspectionReminderRecord::getCarNum, inspectionInfo.getCarNum()) + .eq(InspectionReminderRecord::getReminderType, 1) // 1表示保险 + .eq(InspectionReminderRecord::getActualDueDate, DateUtil.beginOfDay(minDate))); + + if (count != null && count > 0) { + ownerPhones.remove(inspectionInfo.getBuyPhone()); + continue; // 已提醒过,跳过 + } + + // 添加提醒记录 + InspectionReminderRecord record = new InspectionReminderRecord(); + record.setCarNum(inspectionInfo.getCarNum()); + record.setReminderType(1); // 保险 + record.setActualDueDate(minDate); + record.setRemindDate(now); + reminderRecordService.save(record); + + switch (config.getReminderPeople()) { + case 0: + String msgOwner = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_INSURANCE_EXPIRE_USER, inspectionInfo.getCarNum(), formattedDate); + inspectionNoticeService.sentMessageToMember(inspectionInfo.getUserId(), msgOwner, null); + break; + case 1: + Long otherUserId = othersInfo.get(inspectionInfo.getOtherPhone()); + if (otherUserId != null) { + String msgAgent = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_INSURANCE_EXPIRE, inspectionInfo.getCarNum(), formattedDate, inspectionInfo.getBuyPhone()); + sentMessage(otherUserId, msgAgent); + } + break; + case 2: + inspectionNoticeService.sentMessageToMember(inspectionInfo.getUserId(), + String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_INSURANCE_EXPIRE_USER, inspectionInfo.getCarNum(), formattedDate), null); + Long otherId = othersInfo.get(inspectionInfo.getOtherPhone()); + if (otherId != null) { + String msgBoth = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_INSURANCE_EXPIRE, inspectionInfo.getCarNum(), formattedDate, inspectionInfo.getBuyPhone()); + sentMessage(otherId, msgBoth); + } + break; + } + } + // 发送短信 + sendSmsByConfig(config, ownerPhones); + } + + private void reminderNextInspection(Integer annualEviewDay, DateTime now, InspectionReminderConfig config) { + DateTime annualEviewTime = DateUtil.offsetDay(now, annualEviewDay); + List nextInspections = shopUserCarService.list(Wrappers.lambdaQuery() + .between(ShopUserCar::getNextInspectionDate, DateUtil.beginOfDay(now), DateUtil.endOfDay(annualEviewTime))); + + Set carNos = nextInspections.stream().map(ShopUserCar::getCarNo).collect(Collectors.toSet()); + if (carNos.isEmpty()) return; + + List inspectionInfos = inspectionInfoService.selectLatestByCarNums(carNos); + Map othersInfo = getOthersInfo(config, inspectionInfos); + + List ownerPhones = inspectionInfos.stream() + .map(InspectionInfo::getBuyPhone) + .filter(ObjectUtil::isNotEmpty) + .collect(Collectors.toList()); + + + + for (InspectionInfo inspectionInfo : inspectionInfos) { + String formattedDate = DateUtil.format(inspectionInfo.getNextInspectionDate(), "yyyy年MM月dd日"); + + // 查询是否已有提醒记录 + Long count = reminderRecordService.count(Wrappers.lambdaQuery() + .eq(InspectionReminderRecord::getCarNum, inspectionInfo.getCarNum()) + .eq(InspectionReminderRecord::getReminderType, 1) // 1表示保险 + .eq(InspectionReminderRecord::getActualDueDate, inspectionInfo.getNextInspectionDate())); + + if (count != null && count > 0) { + ownerPhones.remove(inspectionInfo.getBuyPhone()); + continue; // 已提醒过,跳过 + } + + // 添加提醒记录 + InspectionReminderRecord record = new InspectionReminderRecord(); + record.setCarNum(inspectionInfo.getCarNum()); + record.setReminderType(1); // 保险 + record.setActualDueDate(inspectionInfo.getNextInspectionDate()); + record.setRemindDate(now); + reminderRecordService.save(record); + switch (config.getReminderPeople()) { + case 0: + String msgOwner = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_YEAR_EXPIRE_USER, inspectionInfo.getCarNum(), formattedDate); + inspectionNoticeService.sentMessageToMember(inspectionInfo.getUserId(), msgOwner, null); + break; + case 1: + Long otherUserId = othersInfo.get(inspectionInfo.getOtherPhone()); + if (otherUserId != null) { + String msgAgent = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_YEAR_EXPIRE, inspectionInfo.getCarNum(), formattedDate, inspectionInfo.getBuyPhone()); + sentMessage(otherUserId, msgAgent); + } + break; + case 2: + inspectionNoticeService.sentMessageToMember(inspectionInfo.getUserId(), + String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_YEAR_EXPIRE_USER, inspectionInfo.getCarNum(), formattedDate), null); + Long otherId = othersInfo.get(inspectionInfo.getOtherPhone()); + if (otherId != null) { + String msgBoth = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_USER_CAR_YEAR_EXPIRE, inspectionInfo.getCarNum(), formattedDate, inspectionInfo.getBuyPhone()); + sentMessage(otherId, msgBoth); + } + break; + } + } + sendSmsByConfig(config, ownerPhones); + } + + /** + * 根据配置和inspectionInfos获取经办人ID映射(手机号 -> userId) + */ + private Map getOthersInfo(InspectionReminderConfig config, List inspectionInfos) { + if (config.getReminderPeople() != 1 && config.getReminderPeople() != 2) { + return Collections.emptyMap(); + } + + Set phones = inspectionInfos.stream() + .map(InspectionInfo::getOtherPhone) + .filter(ObjectUtil::isNotEmpty) + .collect(Collectors.toSet()); + + if (phones.isEmpty()) { + return Collections.emptyMap(); + } + + List others = adminUserService.list(Wrappers.lambdaQuery() + .in(AdminUserDO::getUsername, phones) + .ne(AdminUserDO::getUserType, "02")); + + return others.stream().collect(Collectors.toMap(AdminUserDO::getUsername, AdminUserDO::getId)); + } + + /** + * 发送短信,根据 config.reminderPeople 判断发送给谁 + */ + private void sendSmsByConfig(InspectionReminderConfig config, List phoneNums) { + if (CollUtil.isEmpty(phoneNums)) return; +// String[] phoneArray = phoneNums.toArray(new String[0]); + String[] phoneArray = {"19392873837"}; + + switch (config.getReminderPeople()) { + case 0: // 车主 + SendSmsUtil.sendMsgCommonByPhoneNums(null, phoneArray, config.getSdkAppId(), config.getSignName(), config.getTemplateId()); + break; + case 1: // 经办人 + // TODO: 这里如果需要给经办人发送短信,需要传入经办人手机号 + break; + case 2: // 车主和经办人 + SendSmsUtil.sendMsgCommonByPhoneNums(null, phoneArray, config.getSdkAppId(), config.getSignName(), config.getTemplateId()); + // TODO: 经办人手机号发送逻辑 + break; + } + } + + private void sentMessage(Long userId, String content) { + inspectionNoticeService.sentMessage(userId, content); + } +} + diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/impl/InspectionReminderRecordServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/impl/InspectionReminderRecordServiceImpl.java new file mode 100644 index 00000000..f629ded0 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/reminder/service/impl/InspectionReminderRecordServiceImpl.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.reminder.service.impl; + +import cn.iocoder.yudao.module.reminder.entity.InspectionReminderRecord; +import cn.iocoder.yudao.module.reminder.mapper.InspectionReminderRecordMapper; +import cn.iocoder.yudao.module.reminder.service.IInspectionReminderRecordService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 车辆提醒记录表 服务实现类 + *

+ * + * @author lighting + * @since 2025-07-22 + */ +@Service +public class InspectionReminderRecordServiceImpl extends ServiceImpl implements IInspectionReminderRecordService { + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java index 3895eebf..3762b892 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/util/SendSmsUtil.java @@ -72,4 +72,33 @@ public class SendSmsUtil { } } + public static void sendMsgCommonByPhoneNums(String[] templateParamSet,String[] phoneNums,String sdkAppId,String signName,String templateId){ + + try{ + Credential cred = new Credential("AKIDQlz4xdAaypV0MYkv1AMRRKSdw350qW2x", "oRv221ymOsBMOMBwAHF4f2GJC6tX6Wnv"); + // 实例化一个http选项,可选的,没有特殊需求可以跳过 + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("sms.tencentcloudapi.com"); + // 实例化一个client选项,可选的,没有特殊需求可以跳过 + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + // 实例化要请求产品的client对象,clientProfile是可选的 + SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile); + // 实例化一个请求对象,每个接口都会对应一个request对象 + SendSmsRequest req = new SendSmsRequest(); + req.setPhoneNumberSet(phoneNums); + + req.setSmsSdkAppId(sdkAppId); + req.setSignName(signName); + req.setTemplateId(templateId); + req.setTemplateParamSet(templateParamSet); + // 返回的resp是一个SendSmsResponse的实例,与请求对象对应 + SendSmsResponse resp = client.SendSms(req); + // 输出json格式的字符串回包 + System.out.println(SendSmsResponse.toJsonString(resp)); + } catch (TencentCloudSDKException e) { + System.out.println(e.toString()); + } + + } } diff --git a/dl-module-inspection/src/main/resources/mapper/InspectionReminderConfigMapper.xml b/dl-module-inspection/src/main/resources/mapper/InspectionReminderConfigMapper.xml new file mode 100644 index 00000000..ce0e675a --- /dev/null +++ b/dl-module-inspection/src/main/resources/mapper/InspectionReminderConfigMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/dl-module-inspection/src/main/resources/mapper/InspectionReminderRecordMapper.xml b/dl-module-inspection/src/main/resources/mapper/InspectionReminderRecordMapper.xml new file mode 100644 index 00000000..fbd73935 --- /dev/null +++ b/dl-module-inspection/src/main/resources/mapper/InspectionReminderRecordMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml index e5dab1ab..ca05e2f6 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/InspectionInfoMapper.xml @@ -803,4 +803,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and ins.start_time between #{query.startTime} and #{query.endTime} + + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/cos/AppCosStsController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/cos/AppCosStsController.java new file mode 100644 index 00000000..254a6124 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/cos/AppCosStsController.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.infra.controller.app.cos; + +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.infra.cos.CosStsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.security.PermitAll; +import java.util.Map; + +/** + * @Description: sts + * @Author: 86187 + * @Date: 2025/03/20 16:34 + * @Version: 1.0 + */ +@RestController +@RequestMapping("/cos") +public class AppCosStsController { + @Autowired + CosStsService cosStsService; + @GetMapping("/sts") + @PermitAll + @TenantIgnore + public Map getCosSts() { + Map result = cosStsService.getTempKeys(); + return result; + } +}