package com.byh.sys.web.service.impl;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.byh.sys.api.dto.treatmentItem.SysTreatmentChargeDto;
import com.byh.sys.api.dto.treatmentItem.SysTreatmentItemDto;
import com.byh.sys.api.enums.ApplyGenderEnum;
import com.byh.sys.api.enums.ChargeItemSourceEnum;
import com.byh.sys.api.enums.MedicalInsuranceCheckStatusEnum;
import com.byh.sys.api.enums.StatusEnum;
import com.byh.sys.api.excel.CustomMergeStrategy;
import com.byh.sys.api.exception.BusinessException;
import com.byh.sys.api.model.SysCategorySettingEntity;
import com.byh.sys.api.model.chargeCategory.SysChargeCategoryEntity;
import com.byh.sys.api.model.chargeItem.SysChargeItemEntity;
import com.byh.sys.api.model.department.SysDepartmentEntity;
import com.byh.sys.api.model.dict.SysDictValueEntity;
import com.byh.sys.api.model.templateManage.SysTemplateManageDetailEntity;
import com.byh.sys.api.model.templateManage.SysTemplateManageEntity;
import com.byh.sys.api.model.treatmentItem.SysTreatmentChargeEntity;
import com.byh.sys.api.model.treatmentItem.SysTreatmentItemEntity;
import com.byh.sys.api.util.ExceptionUtils;
import com.byh.sys.api.util.StringPinYinUtil;
import com.byh.sys.api.util.StringWubiUtil;
import com.byh.sys.api.util.UUIDUtils;
import com.byh.sys.api.vo.chargeItem.ExportChargeItem;
import com.byh.sys.api.vo.treatmentItem.ExportTreatmentCharge;
import com.byh.sys.api.vo.treatmentItem.ExportTreatmentItem;
import com.byh.sys.api.vo.treatmentItem.SysTreatmentChargeVo;
import com.byh.sys.api.vo.treatmentItem.SysTreatmentItemVo;
import com.byh.sys.data.repository.*;
import com.byh.sys.web.service.SysChargeItemService;
import com.byh.sys.web.service.SysTreatmentItemService;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bouncycastle.jcajce.provider.symmetric.TEA;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 诊疗项目
*
* @author 魏志俊
* @since 2024-01-25
*/
@Service
public class SysTreatmentItemServiceImpl extends ServiceImpl<SysTreatmentItemMapper, SysTreatmentItemEntity> implements SysTreatmentItemService {
@Resource
private SysTreatmentItemMapper sysTreatmentItemMapper;
@Resource
private SysTreatmentChargeMapper sysTreatmentChargeMapper;
@Resource
private SysChargeItemMapper sysChargeItemMapper;
@Resource
private SysTemplateManageMapper sysTemplateManageMapper;
@Resource
private SysTemplateManageDetailMapper sysTemplateManageDetailMapper;
@Resource
private SysDictValueMapper sysDictValueMapper;
@Resource
private SysDepartmentMapper sysDepartmentMapper;
@Resource
private SysCategorySettingMapper sysCategorySettingMapper;
@Autowired
private SysChargeItemService sysChargeItemService;
private Logger logger = LoggerFactory.getLogger(SysTreatmentItemServiceImpl.class);
/**
* 导出诊疗项目、诊疗收费关联
*
* @param response
* @param tenantId
* @author 魏志俊
*/
@Override
public void exportTreatmentItemExcel(HttpServletResponse response, Integer tenantId) {
//导出诊疗项目集合
List<ExportTreatmentItem> exportTreatmentItemList = sysTreatmentItemMapper.selectExportList(tenantId);
//诊疗项目编号集合
List<Integer> treatmentIds = exportTreatmentItemList.stream()
.map(ExportTreatmentItem::getId)
.distinct()
.collect(Collectors.toList());
//根据诊疗项目编号集合查询导出诊疗、收费项目集合
List<ExportTreatmentCharge> exportTreatmentChargeList = sysTreatmentChargeMapper.selectExportList(treatmentIds);
try (OutputStream out = response.getOutputStream()) {
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
//yyyy年MM月dd日HH时mm分ss秒
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日HH时mm分ss秒");
String format = LocalDateTime.now(ZoneOffset.ofHours(8)).format(dateTimeFormatter);
String fileName = URLEncoder.encode("诊疗项目" + format, "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
try (ExcelWriter excelWriter = EasyExcelFactory.write(out).build()) {
//导出诊疗项目sheet操作
WriteSheet writeSheet1 = EasyExcelFactory.writerSheet(0, "诊疗项目").head(ExportTreatmentItem.class)
.build();
excelWriter.write(exportTreatmentItemList, writeSheet1);
//导出诊疗收费关联sheet操作(诊疗项目名称、诊疗项目金额,进行单元格合并)
WriteSheet writeSheet2 = EasyExcelFactory.writerSheet(1, "诊疗收费关联").head(ExportTreatmentCharge.class)
.registerWriteHandler(new CustomMergeStrategy(exportTreatmentChargeList.size(), 0))
.registerWriteHandler(new CustomMergeStrategy(exportTreatmentChargeList.size(), 5))
.build();
excelWriter.write(exportTreatmentChargeList, writeSheet2);
}
out.flush();
} catch (Exception e) {
ExceptionUtils.createException(logger, true, "500", e.getMessage());
}
}
private static List<String> getTypeList() {
List<String> typeList = new ArrayList<>();
//诊疗类别
typeList.add("diagnosis_treatment_type");
//计价单位
typeList.add("charge_unit");
//执行科室标识
typeList.add("execute_dept_flag");
//医保类型编码
typeList.add("medical_insurance_type");
//项目类型
typeList.add("project_type");
//检查类型
typeList.add("examine_type");
//检验类型
typeList.add("inspect_type");
//治疗性质
typeList.add("therapeutic_nature");
//巡诊车(检查类型)
typeList.add("patrol_car_examine_type");
//检查部位
typeList.add("examine_position");
//检验标本
typeList.add("specimen");
//关联巡诊车项目
typeList.add("patrol_car_item");
//收费类别
typeList.add("fee_category");
return typeList;
}
/**
* 导入诊疗项目Excel
*
* @param file
* @param tenantId
* @param userId
* @param userName
* @author 魏志俊
*/
@Transactional(rollbackFor = BusinessException.class)
@Override
public void
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
基于Java语言的zk-sys系统设计源码 (969个子文件)
SysTreatmentItemServiceImpl.java 61KB
SysDrugPharmacyOutServiceImpl.java 54KB
SysDrugInventoryInController.java 35KB
ExtendServiceImpl.java 33KB
SysDrugPharmacyInServiceImpl.java 30KB
SysTemplateManageServiceImpl.java 28KB
SysDrugInventoryOutController.java 25KB
TestController.java 25KB
SysChargeItemServiceImpl.java 24KB
SysMaterialInventoryOutServiceImpl.java 24KB
HsUploadExtend.java 23KB
SysDoctorController.java 22KB
SysDepartmentServiceImpl.java 22KB
StringWubiUtil.java 21KB
SysInvoiceConfigController.java 20KB
SysDrugPharmacyCheckServiceImpl.java 20KB
SysDrugServiceImpl.java 20KB
SysHsInfoContrastServiceImpl.java 18KB
SysMaterialInventoryInServiceImpl.java 16KB
SysDrugInventoryInServiceImpl.java 16KB
SysMaterialInventoryCheckServiceImpl.java 15KB
ReportCountServiceImpl.java 15KB
RedisUtil.java 15KB
SysHospitalServiceImpl.java 15KB
OutPrescription.java 14KB
OSSClientUtil.java 14KB
SysWardServiceImpl.java 14KB
EasyExcelUtil.java 14KB
SysDrugInventoryCheckController.java 14KB
ElasticsearchUtils.java 14KB
LogAspect.java 13KB
SysDrugEntity.java 13KB
SysHisDrugCounterServiceImpl.java 13KB
SysDictServiceImpl.java 12KB
SysUserServiceImpl.java 11KB
SysDrugController.java 11KB
SysUserController.java 10KB
PurchaseOrderServiceImpl.java 10KB
SysDrugEnum.java 10KB
SysDoctorServiceImpl.java 10KB
DateUtils.java 10KB
NuoNuoEntity.java 10KB
HttpUtils.java 10KB
SysDrugOrderVo.java 10KB
SysDrugVo.java 10KB
SysDrugPharmacyOutController.java 9KB
SysInvoiceConfigEntity.java 9KB
SysPriceFloatSettingServiceImpl.java 9KB
SysDrugContrastController.java 9KB
ReportCountController.java 9KB
NuoNuoClientUtils.java 9KB
SysMaterialInventorySimpleServiceImpl.java 8KB
ErrorEnum.java 8KB
SysDrugAdjustParentServiceImpl.java 8KB
ExcelUtils.java 8KB
UserEnums.java 8KB
BeanUtil.java 8KB
SysDrugPharmacyOutRelationExcel.java 8KB
SysDrugClassificationController.java 8KB
SysDrugPharmacySimpleServiceImpl.java 8KB
SysMedicalRecordTemplateEntity.java 8KB
SysMedicalRecordTemplateServiceImpl.java 8KB
UpdateMedicalRecordsTemplate.java 8KB
SysInvoiceServiceImpl.java 7KB
SysUserRoleServiceImpl.java 7KB
ExceptionAdvice.java 7KB
PSInventoryVo.java 7KB
SysMaterialInventoryEnum.java 7KB
CustomMergeStrategy.java 7KB
SysDrugSubstanceServiceImpl.java 7KB
SysChargeItemEntity.java 7KB
SysDrugPharmacyOutRelationServiceImpl.java 6KB
QuerySysMedicalRecordsTemplateVo.java 6KB
SampleXxlJob.java 6KB
SysDrugInventoryController.java 6KB
SysTreatmentItemController.java 6KB
SysPrescriptionDetailVo.java 6KB
SysMaterialEntity.java 6KB
SysChargeCategoryServiceImpl.java 6KB
ResponseData.java 6KB
SysMaterialInventoryServiceImpl.java 6KB
SysDrugPharmacyInController.java 6KB
SelfHelpController.java 6KB
AccountEnums.java 5KB
SysDrugInventoryInPrescriptionEntity.java 5KB
SysChargeItemController.java 5KB
SysCategorySettingController.java 5KB
SysOutPatientGiveDrugDetailVo.java 5KB
SysMaterialVo.java 5KB
SysDrugClassificationServiceImpl.java 5KB
SysDrugPharmacySimpleController.java 5KB
SysDrugPharmacySimpleExcel.java 5KB
SysCnMedicineSaveDto.java 5KB
SysDrugPharmacyCheckController.java 5KB
SysRoleServiceImpl.java 5KB
AESOperator.java 5KB
SysDrugInventoryOutPrescriptionEntity.java 5KB
SysDrugPharmacySimpleVo.java 5KB
SysDrugInventoryOutTempServiceImpl.java 5KB
SysDictController.java 5KB
共 969 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
lsx202406
- 粉丝: 2452
- 资源: 5591
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功