ltkj-admin/src/main/java/com/ltkj/web/config/task/MallOrderTask.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ltkj-admin/src/main/java/com/ltkj/web/config/task/TjReservationTask.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ltkj-admin/src/main/java/com/ltkj/web/controller/mall/WxMallOrderController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjReservationController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ltkj-admin/src/test/java/zjhTest.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ltkj-common/src/main/java/com/ltkj/common/utils/bean/BeanUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ltkj-admin/src/main/java/com/ltkj/web/config/task/MallOrderTask.java
New file @@ -0,0 +1,86 @@ package com.ltkj.web.config.task; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.common.task.Task; import com.ltkj.common.utils.bean.BeanUtil; import com.ltkj.hosp.domain.TjCustomer; import com.ltkj.hosp.domain.TjReservation; import com.ltkj.hosp.service.ITbTransitionService; import com.ltkj.hosp.service.ITjCustomerService; import com.ltkj.hosp.service.ITjReservationService; import com.ltkj.mall.domain.MallOrder; import com.ltkj.mall.domain.MallTimeConfig; import com.ltkj.mall.mallOrderUtils.OrderHandleOption; import com.ltkj.mall.mallOrderUtils.OrderUtil; import com.ltkj.mall.service.IMallOrderService; import com.ltkj.mall.service.IMallTimeConfigService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.Date; /** * @Company: 西安路泰科技有限公司 * @Author: zjh * @Date: 2024/1/11 0011 16:19 */ public class MallOrderTask extends Task { private final Log log = LogFactory.getLog(MallOrderTask.class); private String orderId = "-1"; public MallOrderTask(String orderId, long delayInMilliseconds) { super("MallOrderTask-" + orderId, delayInMilliseconds); this.orderId = orderId; } public MallOrderTask(String orderId) { super("MallOrderTask-" + orderId, 30 * 60 * 1000); this.orderId = orderId; } @Override public void run() { IMallOrderService orderService = BeanUtil.getBean(IMallOrderService.class); ITjReservationService reservationService = BeanUtil.getBean(ITjReservationService.class); ITbTransitionService transitionService = BeanUtil.getBean(ITbTransitionService.class); IMallTimeConfigService mallTimeConfigService = BeanUtil.getBean(IMallTimeConfigService.class); ITjCustomerService tjCustomerService = BeanUtil.getBean(ITjCustomerService.class); MallOrder order = orderService.getById(orderId); //这里根据orderSerialNo去检查用户是否完成了订单支付 //如果用户没有支付订单,去执行订单关闭的操作 if (order == null) { log.info("订单" + orderId + "不存在 被自动关闭"); }else { // 检测是否能够取消 OrderHandleOption handleOption = OrderUtil.build(order); if (!handleOption.isCancel()) { log.info("订单" + orderId + "不能取消 被自动关闭"); }else { // 设置订单已取消状态 order.setOrderStatus(OrderUtil.STATUS_CANCEL.longValue()); order.setCloseTime(new Date()); order.setUpdateTime(new Date()); orderService.updateById(order); //对应预约时间数量+1 final TjReservation byId = reservationService.getById(order.getReservationId()); final Date reservationTime = byId.getReservationTime(); LambdaQueryWrapper<MallTimeConfig> wq=new LambdaQueryWrapper<>(); wq.eq(MallTimeConfig::getTime,reservationTime); final MallTimeConfig one = mallTimeConfigService.getOne(wq); one.setNowNum(one.getNowNum()+1); mallTimeConfigService.updateById(one); byId.setIsExpire(1); reservationService.updateById(byId); TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(byId.getIdCard()); String cardId ="0"; if(null !=tjCustomer){ cardId = tjCustomer.getCardId(); } transitionService.deletedTbTransitionListByCusIdAndTjNum(byId.getIdCard(),cardId); } } } } ltkj-admin/src/main/java/com/ltkj/web/config/task/TjReservationTask.java
New file @@ -0,0 +1,58 @@ package com.ltkj.web.config.task; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.common.task.Task; import com.ltkj.common.utils.bean.BeanUtil; import com.ltkj.hosp.domain.TjCustomer; import com.ltkj.hosp.domain.TjReservation; import com.ltkj.hosp.service.ITbTransitionService; import com.ltkj.hosp.service.ITjCustomerService; import com.ltkj.hosp.service.ITjReservationService; import com.ltkj.mall.domain.MallTimeConfig; import com.ltkj.mall.service.IMallTimeConfigService; public class TjReservationTask extends Task { private String reservationId = "-1"; public TjReservationTask(String cusRegisterId, long delayInMilliseconds) { super("TjReservationTask-" + cusRegisterId, delayInMilliseconds); this.reservationId = cusRegisterId; } public TjReservationTask(String cusRegisterId) { super("TjReservationTask-" + cusRegisterId, 60 * 1000 * 60 * 24); // super("TjReservationTask-" + cusRegisterId, 60 * 1000 *3); this.reservationId = cusRegisterId; } @Override public void run() { ITjReservationService reservationService = BeanUtil.getBean(ITjReservationService.class); ITbTransitionService transitionService = BeanUtil.getBean(ITbTransitionService.class); IMallTimeConfigService mallTimeConfigService = BeanUtil.getBean(IMallTimeConfigService.class); ITjCustomerService tjCustomerService = BeanUtil.getBean(ITjCustomerService.class); TjReservation tjReservation = reservationService.getById(reservationId); if(null!=tjReservation){ TjCustomer tjCustomer = tjCustomerService.getTjCustomerByCusIdCard(tjReservation.getIdCard()); String cardId ="0"; if(null !=tjCustomer){ cardId = tjCustomer.getCardId(); } if(tjReservation.getIsExpire()==2){ //对应预约时间数量+1 LambdaQueryWrapper<MallTimeConfig> wq=new LambdaQueryWrapper<>(); wq.eq(MallTimeConfig::getTime,tjReservation.getReservationTime()); final MallTimeConfig one = mallTimeConfigService.getOne(wq); one.setNowNum(one.getNowNum()+1); mallTimeConfigService.updateById(one); tjReservation.setIsExpire(1); reservationService.updateById(tjReservation); transitionService.deletedTbTransitionListByCusIdAndTjNum(tjReservation.getIdCard(),cardId); } } } } ltkj-admin/src/main/java/com/ltkj/web/controller/app/ReservationController.java
@@ -1,5 +1,6 @@ package com.ltkj.web.controller.app; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson2.JSON; @@ -7,6 +8,7 @@ import com.google.common.base.Joiner; import com.ltkj.common.core.controller.BaseController; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.task.TaskService; import com.ltkj.common.utils.StringUtils; import com.ltkj.framework.config.MatchUtils; import com.ltkj.framework.config.UserHoder; @@ -16,6 +18,7 @@ import com.ltkj.mall.service.IMallTimeConfigService; import com.ltkj.system.service.ISysConfigService; import com.ltkj.web.config.redis.OrderDelayService; import com.ltkj.web.config.task.TjReservationTask; import com.ltkj.web.wxUtils.WxUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -55,8 +58,10 @@ private IMallTimeConfigService mallTimeConfigService; @Resource private ISysConfigService configService; @Resource private OrderDelayService delayService; // @Resource // private OrderDelayService delayService; @Autowired private TaskService taskService; @PostMapping @ApiOperation(value = "个人预约") @@ -105,7 +110,9 @@ tjReservation.setProIds(join); } if (reservationService.save(tjReservation)) { delayService.reservation(tjReservation.getId()); taskService.addTask(new TjReservationTask(tjReservation.getId(), DateUtil.between(new Date(),DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS))); TjCustomer one = customerService.getOne(new LambdaQueryWrapper<TjCustomer>().eq(TjCustomer::getCusIdcard,tjReservation.getIdCard())); if(null !=one){ @@ -210,6 +217,7 @@ if (reservation.getId()==null){ return AjaxResult.success("出错了,请联系工作人员!"); } taskService.removeTask(new TjReservationTask(reservation.getId())); TjReservation one = reservationService.getById(reservation.getId()); if (null != one) { String isPays = configService.selectConfigByKey("isPay"); @@ -226,6 +234,7 @@ transitionService.deletedTbTransitionByCusId(reservation.getIdCard()); reservationService.removeById(one); //发订单信息给wx订阅服务消息————————————————start———————————————————————————————————————— Map<String, Object> res = new HashMap<>(); @@ -333,7 +342,12 @@ mallTimeConfigService.updateById(config1); one.setReservationTime(tjReservation.getReservationTime()); reservationService.updateById(one); if (reservationService.updateById(one)) { taskService.removeTask(new TjReservationTask(tjReservation.getId())); taskService.addTask(new TjReservationTask(tjReservation.getId(), DateUtil.between(new Date(),DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS))); } return AjaxResult.success("操作成功"); } return AjaxResult.error("预约不存在或已超时 不可修改!"); ltkj-admin/src/main/java/com/ltkj/web/controller/mall/WxMallOrderController.java
@@ -19,6 +19,7 @@ import com.google.common.base.Joiner; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.common.exception.user.DataNotFoundException; import com.ltkj.common.task.TaskService; import com.ltkj.common.utils.IpUtil; import com.ltkj.common.utils.JacksonUtil; import com.ltkj.framework.config.UserHoder; @@ -84,7 +85,8 @@ private WxPayService wxPayService; @Resource private ITbTransitionService transitionService; @Autowired private TaskService taskService; @Resource private OrderDelayService delayService; ltkj-admin/src/main/java/com/ltkj/web/controller/system/SysDeptController.java
@@ -599,26 +599,17 @@ return AjaxResult.success("暂无数据"); } } List<TjCustomer> customerLists = new ArrayList<>(); List<TjCustomer> customerLists = null; if (type == 0) { customerLists = redisCache.getCacheMapValue(ksId + "ks", "wj"); // customerLists = redisCache.getCacheMapValue(ksId + "ks", "wj"); } if (type == 1) { customerLists = redisCache.getCacheMapValue(ksId + "ks", "yj"); // customerLists = redisCache.getCacheMapValue(ksId + "ks", "yj"); } asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId)); if (customerLists != null && customerLists.size() > 0) { Collections.reverse(customerLists); List<TjCustomer> customerList = customerLists.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); Map<String, Object> map = new HashMap<>(); map.put("date", customerList); map.put("total", customerLists.size()); return AjaxResult.success(map); } else { AjaxResult map = getAjaxResult(type, page, pageSize, ksproList, customerLis); if (map != null) return map; return AjaxResult.success("暂时没有数据"); } AjaxResult map = getAjaxResult(type, page, pageSize, ksproList, customerLis); if (map != null) return map; return AjaxResult.success("暂时没有数据"); } @@ -680,7 +671,7 @@ ) .collect(Collectors.toList()); if (ksproList == null || ksproList.size() == 0) { if (ksproList.size() == 0) { return AjaxResult.error("请完善科室项目信息"); } List<TjCustomer> customerLis = new ArrayList<>(); @@ -821,15 +812,15 @@ return AjaxResult.success("暂无数据"); } } List<TjCustomer> customerLists = new ArrayList<>(); List<TjCustomer> customerLists = null; if (type == 0) { customerLists = redisCache.getCacheMapValue(ksId + "ks", "wj"); // customerLists = redisCache.getCacheMapValue(ksId + "ks", "wj"); } if (type == 1) { customerLists = redisCache.getCacheMapValue(ksId + "ks", "yj"); // customerLists = redisCache.getCacheMapValue(ksId + "ks", "yj"); } asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId)); if (customerLists != null && customerLists.size() > 0) { // asyncService.dockerSetCustomerLisByRedis(ksproList, String.valueOf(ksId)); if (customerLists.size() > 0) { Collections.reverse(customerLists); List<TjCustomer> customerList = customerLists.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); Map<String, Object> map = new HashMap<>(); ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjReservationController.java
@@ -9,6 +9,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.extra.pinyin.PinyinUtil; @@ -18,6 +19,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.base.Joiner; import com.ltkj.common.excelConfig.ExcelUtils; import com.ltkj.common.task.TaskService; import com.ltkj.common.utils.SecurityUtils; import com.ltkj.common.utils.StringUtils; import com.ltkj.framework.config.MatchUtils; @@ -28,6 +30,7 @@ import com.ltkj.mall.mallOrderUtils.TjConstants; import com.ltkj.web.config.pdfutils.PDFBinaryUtil; import com.ltkj.web.config.redis.OrderDelayService; import com.ltkj.web.config.task.TjReservationTask; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -76,8 +79,10 @@ private ITjGroupingProService groupingProService; @Resource private TjAsyncService asyncService; @Resource private OrderDelayService delayService; // @Resource // private OrderDelayService delayService; @Autowired private TaskService taskService; @Resource private ITjReportTemplateService reportTemplateService; @@ -88,71 +93,54 @@ @ApiOperation(value = "导出excel表模板") public void importTemplate(HttpServletResponse response) { //原来的下载模板调用接口 // ExcelUtils.exportTemplate(response, "体检预约Excel模板", TjReservation.class); String base64String = PDFBinaryUtil.getPDFBinary("D:\\Tjreport\\西安路泰机电科技有限公司.xls"); // TjReportTemplate tem = new TjReportTemplate(); // tem.setName("团体预约Excel模版"); // tem.setRemark("团体预约Excel模版"); // tem.setTemplate(base64String); // tem.setFlag("1"); // tem.setOpen("0"); // reportTemplateService.save(tem); if(null !=base64String){ PDFBinaryUtil.base64StringToPDF(base64String, FileUtil.mkdir(value).getPath() + "\\" + "团体预约Excel模版.xls"); String filePath = value + "\\" + "团体预约Excel模版.xls"; File f = new File(filePath); BufferedInputStream br = null; OutputStream out = null; FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(f); br = new BufferedInputStream(fileInputStream); byte[] bs = new byte[1024]; int len = 0; response.reset(); // 非常重要 if (true) { // 在线打开方式 URL u = new URL("file:///" + filePath); //System.out.println(u); String contentType = u.openConnection().getContentType(); response.setContentType(contentType); response.setHeader("Content-Disposition", "inline;filename=团体预约Excel模版.xls"); } else { // 纯下载方式 response.setContentType("application/x-msdownload"); response.setContentType("application/pdf;charset=utf-8"); response.setHeader("Content-Disposition", "attachment;filename=团体预约Excel模版.xls"); } out = response.getOutputStream(); while ((len = br.read(bs)) > 0) { out.write(bs, 0, len); } out.flush(); out.close(); br.close(); fileInputStream.close(); } catch (IOException e) { e.printStackTrace(); //System.out.println("pdf处理文件异常" + e); } finally { if (out != null) { try { out.close(); br.close(); fileInputStream.close(); // LambdaQueryWrapper<TjReportTemplate> wq = new LambdaQueryWrapper<>(); // wq.eq(TjReportTemplate::getFlag, 4); // wq.eq(TjReportTemplate::getName, ""); // wq.eq(TjReportTemplate::getOpen, 0); // reportTemplateService.getOne(wq); PDFBinaryUtil.base64StringToPDF(base64String, FileUtil.mkdir(value).getPath() + "\\" + "团体预约Excel模版.xls"); String filePath = value + "\\" + "团体预约Excel模版.xls"; File f = new File(filePath); if (filePath.isEmpty()) { System.out.println("文件不存在!"); return; } BufferedInputStream br = null; OutputStream out = null; FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(f); br = new BufferedInputStream(fileInputStream); byte[] bs = new byte[1024]; int len = 0; response.reset(); // 非常重要 if (true) { // 在线打开方式 URL u = new URL("file:///" + filePath); //System.out.println(u); String contentType = u.openConnection().getContentType(); response.setContentType(contentType); response.setHeader("Content-Disposition", "inline;filename=团体预约Excel模版.xls"); } else { // 纯下载方式 response.setContentType("application/x-msdownload"); response.setContentType("application/pdf;charset=utf-8"); response.setHeader("Content-Disposition", "attachment;filename=团体预约Excel模版.xls"); } out = response.getOutputStream(); while ((len = br.read(bs)) > 0) { out.write(bs, 0, len); } out.flush(); out.close(); br.close(); fileInputStream.close(); } catch (IOException e) { e.printStackTrace(); //System.out.println("pdf处理文件异常" + e); } finally { if (out != null) { try { out.close(); br.close(); fileInputStream.close(); } catch (IOException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } } @@ -250,6 +238,7 @@ */ @PostMapping("/newExcelImport") @ApiOperation(value = "团体导入 (新版本)") @Transactional public AjaxResult newExcelImport(@RequestPart(value = "file") @ApiParam(value = "Excel文件") MultipartFile file, @RequestParam @ApiParam(value = "单位id") String dwId, @RequestParam @ApiParam(value = "单位部门id") String dwDeptId) { @@ -402,7 +391,7 @@ reservation.setTjType(String.valueOf(1)); reservation.setTeamNo(teamNo); tjReservationService.save(reservation); delayService.reservation(reservation.getId()); // delayService.reservation(reservation.getId()); } LambdaQueryWrapper<TjCompPay> wq0 = new LambdaQueryWrapper<>(); wq0.eq(TjCompPay::getCompId, compId); @@ -489,7 +478,9 @@ tjReservation.setIsExpire(2); tjReservation.setTjType(String.valueOf(2)); if (tjReservationService.save(tjReservation)) { delayService.reservation(tjReservation.getId()); // delayService.reservation(tjReservation.getId()); taskService.addTask(new TjReservationTask(tjReservation.getId(), DateUtil.between(new Date(),DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS))); return AjaxResult.success("预约成功!!!"); } LambdaQueryWrapper<TbTransition> remove=new LambdaQueryWrapper<>(); @@ -546,6 +537,7 @@ if (null != reservation && reservation.getIsExpire() == 2) { if (tjReservationService.removeById(id)) { transitionService.remove(new LambdaQueryWrapper<TbTransition>().eq(TbTransition::getCusId, reservation.getIdCard())); taskService.removeTask(new TjReservationTask(id)); return AjaxResult.success("撤销成功"); } return AjaxResult.error("撤销失败"); @@ -566,6 +558,7 @@ if (null != reservation && reservation.getIsExpire() == 2) { if (tjReservationService.removeById(id)) { transitionService.remove(new LambdaQueryWrapper<TbTransition>().eq(TbTransition::getCusId, reservation.getIdCard())); taskService.removeTask(new TjReservationTask(id)); } } } @@ -590,6 +583,9 @@ tjReservation.setPhoe(reservation.getPhoe()); tjReservation.setName(reservation.getName()); if (tjReservationService.updateById(tjReservation)) { taskService.removeTask(new TjReservationTask(tjReservation.getId())); taskService.addTask(new TjReservationTask(tjReservation.getId(), DateUtil.between(new Date(),DateUtil.endOfDay(tjReservation.getReservationTime()), DateUnit.MS))); return AjaxResult.success("操作成功"); } return AjaxResult.error("操作失败"); @@ -628,8 +624,6 @@ public AjaxResult newReservationConfirm(@RequestBody ConfirmDto dto) { //预约的所有人 List<TjReservation> rightList = dto.getReservations(); //预约时间 String reservationTime = dto.getReservationTime(); @@ -670,16 +664,20 @@ reservation.setCompany(dwGrouping.getDwName()); reservation.setPayType(Long.valueOf(dwGrouping.getPayType())); reservation.setPacId(dwDept.getId()); if(dwGrouping.getPayType().equals("1")){ compPay=compPay.add(dwGrouping.getYsPrice()); tramNum+=1; reservation.setTjType(String.valueOf(1)); reservation.setTeamNo(teamNo); }else { reservation.setTjType(String.valueOf(2)); } // if(dwGrouping.getPayType().equals("1")){ // compPay=compPay.add(dwGrouping.getYsPrice()); // tramNum+=1; // reservation.setTjType(String.valueOf(1)); // reservation.setTeamNo(teamNo); // }else { // reservation.setTjType(String.valueOf(2)); // } compPay=compPay.add(dwGrouping.getYsPrice()); tramNum+=1; reservation.setTjType(String.valueOf(1)); reservation.setTeamNo(teamNo); tjReservationService.save(reservation); delayService.reservation(reservation.getId()); taskService.addTask(new TjReservationTask(reservation.getId(),DateUtil.between(new Date(),DateUtil.endOfDay(reservation.getReservationTime()), DateUnit.MS))); } LambdaQueryWrapper<TjCompPay> wq0 = new LambdaQueryWrapper<>(); wq0.eq(TjCompPay::getCompId, dwDept.getDwId()); ltkj-admin/src/test/java/zjhTest.java
@@ -1,5 +1,6 @@ import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.LtkjApplication; @@ -80,19 +81,14 @@ public static void main(String[] args) { // lat 39.97646 //log 116.3039 // String add = getAdd("116.3039", "39.97646"); // JSONObject jsonObject = JSONObject.parseObject(add); // JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("addrList")); // JSONObject j_2 = JSONObject.parseObject(String.valueOf(jsonArray.get(0))); // String allAdd = j_2.getString("admName"); // String arr[] = allAdd.split(","); // System.out.println("省:"+arr[0]+"\n市:"+arr[1]+"\n区:"+arr[2]); // String a ="你好哈哈哈哈哈哈"; // String s = a.toUpperCase(Locale.ROOT); // System.out.println(s); // String dateStr1 = "2024-03-01 22:33:23"; // Date date1 = DateUtil.parse(dateStr1); // ////相差一个月,31天 // long betweenDay = DateUtil.between(new Date(),date1, DateUnit.DAY); // System.out.println(betweenDay); // System.out.println(DateUtil.between(new Date(),date1, DateUnit.MS)); // System.out.println(DateUtil.between(new Date(),date1, DateUnit.SECOND)); } // // public static String getAdd(String log, String lat ){ ltkj-common/src/main/java/com/ltkj/common/utils/bean/BeanUtil.java
New file @@ -0,0 +1,24 @@ package com.ltkj.common.utils.bean; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component public class BeanUtil implements ApplicationContextAware { protected static ApplicationContext context; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { context = applicationContext; } public static Object getBean(String name) { return context.getBean(name); } public static <T> T getBean(Class<T> c){ return context.getBean(c); } }