| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.system.export.TCrmClinicAuditExport; |
| | | import com.ruoyi.system.export.TSysAppUserClinicExport; |
| | | import com.ruoyi.system.export.TSysAppUserExport; |
| | | import com.ruoyi.system.export.TSysAppUserListExport; |
| | | import com.ruoyi.system.model.TSysAppUser; |
| | | import com.ruoyi.system.model.TSysChronicDisease; |
| | | import com.ruoyi.system.model.TSysInspection; |
| | | import com.ruoyi.system.model.TSysMessageTemplate; |
| | | import com.ruoyi.system.query.TCrmClinicQuery; |
| | | import com.ruoyi.system.query.TSysAppUserQuery; |
| | | import com.ruoyi.system.service.TSysAppUserService; |
| | | import com.ruoyi.system.service.TSysChronicDiseaseService; |
| | | import com.ruoyi.system.service.TSysInspectionService; |
| | | import com.ruoyi.system.service.TSysOrderService; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.TSysAppUserVO; |
| | | import com.ruoyi.system.vo.TSysOrderVO; |
| | | import com.ruoyi.web.controller.tool.MsgUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private final TSysInspectionService sysInspectionService; |
| | | private final TSysOrderService sysOrderService; |
| | | private final TSysChronicDiseaseService sysChronicDiseaseService; |
| | | private final MsgUtils msgUtils; |
| | | private final TSysMessageTemplateService sysMessageTemplateService; |
| | | @Autowired |
| | | public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService) { |
| | | public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService, MsgUtils msgUtils, TSysMessageTemplateService sysMessageTemplateService) { |
| | | this.sysAppUserService = sysAppUserService; |
| | | this.sysInspectionService = sysInspectionService; |
| | | this.sysOrderService = sysOrderService; |
| | | this.sysChronicDiseaseService = sysChronicDiseaseService; |
| | | this.msgUtils = msgUtils; |
| | | this.sysMessageTemplateService = sysMessageTemplateService; |
| | | } |
| | | |
| | | /** |
| | |
| | | @PostMapping(value = "/pageChronicDiseaseUserList") |
| | | public R<PageInfo<TSysAppUserVO>> pageChronicDiseaseUserList(@RequestBody TSysAppUserQuery query) { |
| | | return R.ok(sysAppUserService.pageChronicDiseaseUserList(query)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用药提醒 |
| | | */ |
| | | @ApiOperation(value = "慢性病患者-用药提醒", notes = "userId:患者用户id,templateId:短信模板id") |
| | | @GetMapping(value = "/medicationReminder") |
| | | public R<String> medicationReminder(@RequestParam(value = "userId") String userId, |
| | | @RequestParam(value = "templateId") String templateId) { |
| | | TSysAppUser sysAppUser = sysAppUserService.getById(userId); |
| | | if(StringUtils.isNotBlank(sysAppUser.getPhone())){ |
| | | sysAppUser.setLastReminderTime(LocalDateTime.now()); |
| | | sysAppUserService.updateById(sysAppUser); |
| | | TSysMessageTemplate messageTemplate = sysMessageTemplateService.getById(templateId); |
| | | // 发送短信 |
| | | try { |
| | | Map<String,String> params = new HashMap<>(); |
| | | msgUtils.sendMsg(sysAppUser.getPhone(),params, messageTemplate.getTemplateCode()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Log(title = "用户管理信息-慢性病患者导出-平台", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "慢性病患者导出-平台") |
| | | @PostMapping("/exportList") |
| | | public void exportList(@RequestBody TSysAppUserQuery query){ |
| | | List<TSysAppUserListExport> sysAppUserListExports = sysAppUserService.exportList(query); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TSysAppUserListExport.class, sysAppUserListExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("慢性病患者.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | @Log(title = "用户管理信息-慢性病患者导出-诊所", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "慢性病患者导出-诊所") |
| | | @PostMapping("/exportListClinic") |
| | | public void exportListClinic(@RequestBody TSysAppUserQuery query){ |
| | | List<TSysAppUserClinicExport> sysAppUserClinicExports = sysAppUserService.exportListClinic(query); |
| | | for (TSysAppUserClinicExport sysAppUserClinicExport : sysAppUserClinicExports) { |
| | | String lastReminderTime = sysAppUserClinicExport.getLastReminderTime(); |
| | | lastReminderTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(lastReminderTime); |
| | | sysAppUserClinicExport.setLastReminderTime(lastReminderTime); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TSysAppUserClinicExport.class, sysAppUserClinicExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("慢性病患者.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Log(title = "用户管理信息-用户管理信息导出", businessType = BusinessType.EXPORT) |
| | | @ApiOperation(value = "用户管理信息导出") |
| | | @PostMapping("/exportListAppUser") |
| | | public void exportListAppUser(@RequestBody TSysAppUserQuery query){ |
| | | List<TSysAppUserExport> sysAppUserExports = sysAppUserService.exportListAppUser(query); |
| | | for (TSysAppUserExport sysAppUserExport : sysAppUserExports) { |
| | | String lastInspectionTime = sysAppUserExport.getLastInspectionTime(); |
| | | lastInspectionTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(lastInspectionTime); |
| | | sysAppUserExport.setLastInspectionTime(lastInspectionTime); |
| | | sysAppUserExport.setCreateTimeStr(sysAppUserExport.getCreateTime().toLocalDate().toString()); |
| | | } |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TSysAppUserClinicExport.class, sysAppUserExports); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | assert response != null; |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("用户管理信息.xls", "utf-8"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + fileName); |
| | | response.setContentType("application/vnd.ms-excel;charset=UTF-8"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setHeader("Cache-Control", "no-cache"); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |