|  |  |  | 
|---|
|  |  |  | import com.ruoyi.common.utils.DateUtils; | 
|---|
|  |  |  | import com.ruoyi.common.utils.StringUtils; | 
|---|
|  |  |  | import com.ruoyi.common.utils.WebUtils; | 
|---|
|  |  |  | import com.ruoyi.framework.web.service.TokenService; | 
|---|
|  |  |  | 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.model.*; | 
|---|
|  |  |  | import com.ruoyi.system.query.TCrmClinicQuery; | 
|---|
|  |  |  | import com.ruoyi.system.query.TSysAppUserQuery; | 
|---|
|  |  |  | import com.ruoyi.system.service.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.apache.poi.ss.usermodel.Workbook; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.time.LocalDateTime; | 
|---|
|  |  |  | import java.time.temporal.ChronoUnit; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | 
|---|
|  |  |  | private final TSysChronicDiseaseService sysChronicDiseaseService; | 
|---|
|  |  |  | private final MsgUtils msgUtils; | 
|---|
|  |  |  | private final TSysMessageTemplateService sysMessageTemplateService; | 
|---|
|  |  |  | private final TCrmClinicService crmClinicService; | 
|---|
|  |  |  | private final TokenService tokenService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService, MsgUtils msgUtils, TSysMessageTemplateService sysMessageTemplateService) { | 
|---|
|  |  |  | public TSysAppUserController(TSysAppUserService sysAppUserService, TSysInspectionService sysInspectionService, TSysOrderService sysOrderService, TSysChronicDiseaseService sysChronicDiseaseService, MsgUtils msgUtils, TSysMessageTemplateService sysMessageTemplateService, TCrmClinicService crmClinicService, TokenService tokenService) { | 
|---|
|  |  |  | this.sysAppUserService = sysAppUserService; | 
|---|
|  |  |  | this.sysInspectionService = sysInspectionService; | 
|---|
|  |  |  | this.sysOrderService = sysOrderService; | 
|---|
|  |  |  | this.sysChronicDiseaseService = sysChronicDiseaseService; | 
|---|
|  |  |  | this.msgUtils = msgUtils; | 
|---|
|  |  |  | this.sysMessageTemplateService = sysMessageTemplateService; | 
|---|
|  |  |  | this.crmClinicService = crmClinicService; | 
|---|
|  |  |  | this.tokenService = tokenService; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | if (sysAppUserService.isExit(dto)) { | 
|---|
|  |  |  | return R.fail("用户管理信息已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long userId = tokenService.getLoginUser().getUserId(); | 
|---|
|  |  |  | TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) | 
|---|
|  |  |  | .eq(TCrmClinic::getUserId, userId)); | 
|---|
|  |  |  | dto.setClinicId(crmClinic.getId()); | 
|---|
|  |  |  | return R.ok(sysAppUserService.save(dto)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 查询检测信息 | 
|---|
|  |  |  | List<TSysInspection> sysInspections = sysInspectionService.list(Wrappers.lambdaQuery(TSysInspection.class).eq(TSysInspection::getAppUserId, id)); | 
|---|
|  |  |  | if(!CollectionUtils.isEmpty(sysInspections)){ | 
|---|
|  |  |  | List<String> clinicIds = sysInspections.stream().map(TSysInspection::getClinicId).collect(Collectors.toList()); | 
|---|
|  |  |  | List<TCrmClinic> clinicList = crmClinicService.list(Wrappers.lambdaQuery(TCrmClinic.class).in(TCrmClinic::getId, clinicIds)); | 
|---|
|  |  |  | List<TSysOrder> sysOrderList = sysOrderService.list(Wrappers.lambdaQuery(TSysOrder.class).in(TSysOrder::getClinicId, clinicIds)); | 
|---|
|  |  |  | for (TSysInspection sysInspection : sysInspections) { | 
|---|
|  |  |  | TCrmClinic clinic = clinicList.stream().filter(c -> c.getId().equals(sysInspection.getClinicId())).findFirst().orElse(null); | 
|---|
|  |  |  | if(clinic != null){ | 
|---|
|  |  |  | sysInspection.setClinicName(clinic.getClinicName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<TSysOrder> sysOrders = sysOrderList.stream().filter(c -> sysInspection.getId().equals(c.getInspectionId())).collect(Collectors.toList()); | 
|---|
|  |  |  | if(CollectionUtils.isEmpty(sysOrders)){ | 
|---|
|  |  |  | sysInspection.setIsPrescribeMedicine(0); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | sysInspection.setIsPrescribeMedicine(1); | 
|---|
|  |  |  | sysInspection.setOrderId(sysOrders.get(0).getId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | sysAppUserVO.setSysInspections(sysInspections); | 
|---|
|  |  |  | // 订单信息 | 
|---|
|  |  |  | List<TSysOrderVO> sysOrders = sysOrderService.queryListByAppUserId(id); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改用户慢性病 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Log(title = "用户管理信息-修改用户慢性病", businessType = BusinessType.UPDATE) | 
|---|
|  |  |  | @ApiOperation(value = "修改用户慢性病") | 
|---|
|  |  |  | @PostMapping(value = "/updateDisease") | 
|---|
|  |  |  | public R<Boolean> updateDisease(@RequestParam(value = "id") String id, | 
|---|
|  |  |  | @RequestParam(value = "chronicDiseaseId") String chronicDiseaseId) { | 
|---|
|  |  |  | TSysAppUser sysAppUser = new TSysAppUser(); | 
|---|
|  |  |  | sysAppUser.setId(id); | 
|---|
|  |  |  | sysAppUser.setChronicDiseaseId(chronicDiseaseId); | 
|---|
|  |  |  | return R.ok(sysAppUserService.updateById(sysAppUser)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Log(title = "用户管理信息-慢性病患者导出-平台", businessType = BusinessType.EXPORT) | 
|---|
|  |  |  | @ApiOperation(value = "慢性病患者导出-平台") | 
|---|
|  |  |  | @PostMapping("/exportList") | 
|---|