| | |
| | | package com.ltkj.web.controller.system; |
| | | |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.net.URL; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | 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; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.google.common.base.Joiner; |
| | | import com.ltkj.common.annotation.RepeatSubmit; |
| | | 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; |
| | |
| | | import com.ltkj.hosp.dto.ConfirmDto; |
| | | import com.ltkj.hosp.dto.ExcelImportDto; |
| | | import com.ltkj.hosp.service.*; |
| | | 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; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ltkj.common.core.controller.BaseController; |
| | | import com.ltkj.common.core.domain.AjaxResult; |
| | |
| | | private ITjGroupingProService groupingProService; |
| | | @Resource |
| | | private TjAsyncService asyncService; |
| | | // @Resource |
| | | // private OrderDelayService delayService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Resource |
| | | private OrderDelayService delayService; |
| | | private ITjReportTemplateService reportTemplateService; |
| | | |
| | | @Value("${path.filePath}") |
| | | private String value; |
| | | |
| | | @PostMapping("/importTemplate") |
| | | @ApiOperation(value = "导出excel表模板") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtils.exportTemplate(response, "体检预约Excel模板", TjReservation.class); |
| | | //原来的下载模板调用接口 |
| | | String base64String = PDFBinaryUtil.getPDFBinary("D:\\Tjreport\\西安路泰机电科技有限公司.xls"); |
| | | 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(); |
| | | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询体检预约列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('reservation:reservation:list')") |
| | | //@PreAuthorize("@ss.hasPermi('reservation:reservation:list')") |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "查询体检预约列表接口(默认)") |
| | | public TableDataInfo list(TjReservation tjReservation) { |
| | |
| | | */ |
| | | @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) { |
| | |
| | | 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); |
| | |
| | | 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<>(); |
| | | remove.between(TbTransition::getCreateTime,DateUtil.offsetMinute(transitionService.getTbTransitionCreateTimeByCusId(tjReservation.getIdCard()),-1),new Date()); |
| | | remove.eq(TbTransition::getCusId,tjReservation.getIdCard()); |
| | | transitionService.remove(remove); |
| | | return AjaxResult.error("预约失败"); |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping(value = "/{id}") |
| | | @ApiOperation(value = "根据预约id获取预约详情") |
| | | public AjaxResult getInfo(@PathVariable("id") @ApiParam(value = "预约id") Integer id) { |
| | | public AjaxResult getInfo(@PathVariable("id") @ApiParam(value = "预约id") String id) { |
| | | TjReservation tjReservation = tjReservationService.selectTjReservationById(id); |
| | | if (null != tjReservation) { |
| | | if (null != tjReservation.getPacId()) { |
| | | tjReservation.setPacName(packageService.getById(tjReservation.getPacId()).getPacName()); |
| | | TjPackage aPackage = packageService.getById(tjReservation.getPacId()); |
| | | if(null !=aPackage){ |
| | | tjReservation.setPacName(aPackage.getPacName()); |
| | | } |
| | | TjDwDept dwDept = dwDeptService.getById(tjReservation.getPacId()); |
| | | |
| | | if(null !=dwDept){ |
| | | tjReservation.setPacName(dwDept.getDwName()); |
| | | } |
| | | |
| | | } |
| | | if (null != tjReservation.getProIds()) { |
| | | List<String> proNames = new ArrayList<>(); |
| | |
| | | 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("撤销失败"); |
| | |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | |
| | | @PostMapping("/tjReappoint") |
| | | @ApiOperation(value = "体检预约修改接口") |
| | | public AjaxResult tjReappoint(@RequestBody TjReservation tjReservation) { |
| | | TjReservation reservation = tjReservationService.getById(tjReservation.getId()); |
| | | |
| | | if (tjReservation.getIsExpire() == 1) { |
| | | return AjaxResult.error("预约已过期不可修改"); |
| | | } |
| | | tjReservation.setIdCard(reservation.getIdCard()); |
| | | 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("操作失败"); |
| | |
| | | |
| | | @PostMapping("/newReservationConfirm") |
| | | @ApiOperation(value = "团体预约确认接口 (新版本)") |
| | | @Transactional |
| | | @RepeatSubmit |
| | | public AjaxResult newReservationConfirm(@RequestBody ConfirmDto dto) { |
| | | //预约的所有人 |
| | | List<TjReservation> rightList = dto.getReservations(); |
| | | |
| | | |
| | | |
| | | //预约时间 |
| | | String reservationTime = dto.getReservationTime(); |
| | |
| | | TjDwDept dwDept = dwDeptService.getById(dto.getDwDeptId()); |
| | | |
| | | //异步数据 |
| | | asyncService.addNewReservationConfirm(rightList); |
| | | // asyncService.addNewReservationConfirm(rightList); |
| | | asyncService.saveNewReservationConfirm(rightList); |
| | | |
| | | //团体人数合计价格 |
| | | BigDecimal compPay=new BigDecimal("0.00"); |
| | |
| | | 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()); |