新增了结算导出
This commit is contained in:
parent
f55d3a07f5
commit
8a99d31e33
@ -11,6 +11,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import net.lab1024.sa.admin.module.app.medicalrecord.service.MedicalRecordService;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.CaseplatformCaseQueryForm;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.EasyExcelCaseDetailVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.ExportExpertCaseExcelVo;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.service.CaseplatformCaseService;
|
||||
import net.lab1024.sa.common.module.support.operatelog.annoation.OperateLog;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
@ -18,10 +19,13 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -38,6 +42,7 @@ public class CaseplatformCaseExcelController {
|
||||
@Autowired
|
||||
private CaseplatformCaseService caseplatformCaseService;
|
||||
|
||||
// 病例管理导出
|
||||
@GetMapping("/caseplatformCase/exportEasyExcel")
|
||||
public void exportEasyExcel(HttpServletResponse response, @Valid CaseplatformCaseQueryForm queryForm) {
|
||||
try {
|
||||
@ -82,4 +87,66 @@ public class CaseplatformCaseExcelController {
|
||||
}
|
||||
}
|
||||
|
||||
// 结算导出
|
||||
@GetMapping("/caseplatformCase/exportExpertCaseExcel")
|
||||
public void exportExpertCaseExcel(HttpServletResponse response, @Valid CaseplatformCaseQueryForm queryForm) {
|
||||
try {
|
||||
List<ExportExpertCaseExcelVo> list = caseplatformCaseService.exportExpertCaseExcel(queryForm);
|
||||
|
||||
// 处理数据
|
||||
List<ExportExpertCaseExcelVo> processedList = caseplatformCaseService.exportExpertCaseExcelProcess(list);
|
||||
|
||||
// 1. 构建合并的第一行标题
|
||||
List<List<String>> head = new ArrayList<>();
|
||||
List<String> titleRow = new ArrayList<>();
|
||||
titleRow.add("人工肝诊疗病例征集项目专家劳务费表");
|
||||
for (int i = 0; i < 12; i++) { // 假设你总共有 13 列(从"序号"到"身份证号")
|
||||
if (i > 0) titleRow.add("");
|
||||
}
|
||||
head.add(titleRow);
|
||||
|
||||
// 2. 添加第二行字段标题(正常列头)
|
||||
List<String> headerRow = Arrays.asList(
|
||||
"序号", "银行", "账号所在省份", "账户所在地市",
|
||||
"卡号", "姓名", "实发", "备注", "个税", "应发", "单位", "电话", "身份证号"
|
||||
);
|
||||
head.add(headerRow);
|
||||
|
||||
// 1设置表头样式
|
||||
WriteCellStyle headStyle = new WriteCellStyle();
|
||||
// 1.1设置表头数据居中
|
||||
headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
||||
|
||||
// 2设置表格内容样式
|
||||
WriteCellStyle bodyStyle = new WriteCellStyle();
|
||||
// 2.1设置表格内容水平居中
|
||||
bodyStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
|
||||
// 2.2设置表格内容垂直居中
|
||||
bodyStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
WriteCellStyle contentStyle = new WriteCellStyle();
|
||||
contentStyle.setHorizontalAlignment(org.apache.poi.ss.usermodel.HorizontalAlignment.CENTER);
|
||||
|
||||
// 4拿到表格处理对象
|
||||
ExcelWriter writer = EasyExcel.write(response.getOutputStream())
|
||||
.head(head)
|
||||
.excelType(ExcelTypeEnum.XLSX)
|
||||
.registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, contentStyle))
|
||||
.build();
|
||||
|
||||
WriteSheet writeSheet = EasyExcel.writerSheet("劳务费明细").needHead(true).build();
|
||||
|
||||
// 5写入excel数据
|
||||
writer.write(processedList, writeSheet);
|
||||
|
||||
// 6通知浏览器以附件的形式下载处理,设置返回头要注意文件名有中文
|
||||
String fileName = URLEncoder.encode("人工肝专家劳务费明细表", "UTF-8").replaceAll("\\+", "%20");
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
response.setContentType("multipart/form-data");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
writer.finish();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseDetailVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.EasyExcelCaseDetailVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.ExportExpertCaseExcelVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
@ -39,6 +40,8 @@ public interface CaseplatformCaseDao extends BaseMapper<CaseplatformCaseEntity>
|
||||
|
||||
List<EasyExcelCaseDetailVO> excelList(@Param("queryForm") CaseplatformCaseQueryForm queryForm, @Param("provList")List<ProvVO> provList);
|
||||
|
||||
List<ExportExpertCaseExcelVo> getExportExpertCaseExcelList(@Param("queryForm") CaseplatformCaseQueryForm queryForm, @Param("provList")List<ProvVO> provList);
|
||||
|
||||
/**
|
||||
* 获取详情
|
||||
* @param case_id
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
package net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@EqualsAndHashCode
|
||||
public class ExportExpertCaseExcelVo {
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("专家id")
|
||||
private Long expertId;
|
||||
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("病例id")
|
||||
private Long caseId;
|
||||
|
||||
@ExcelProperty("序号")
|
||||
private Integer index;
|
||||
|
||||
@ExcelProperty("银行")
|
||||
private String bankName;
|
||||
|
||||
@ExcelProperty("账号所在省份")
|
||||
private String prov;
|
||||
|
||||
@ExcelProperty("账户所在地市")
|
||||
private String city;
|
||||
|
||||
@ExcelProperty("卡号")
|
||||
private String bankCardNo;
|
||||
|
||||
@ExcelProperty("姓名")
|
||||
private String idCardName;
|
||||
|
||||
@ExcelProperty("实发")
|
||||
private Double actualAmount = 0.00;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("个税")
|
||||
private Double taxAmount = 0.00;
|
||||
|
||||
@ExcelProperty("应发")
|
||||
private Double totalAmount = 0.00;
|
||||
|
||||
@ExcelProperty("单位")
|
||||
private String hospitalName;
|
||||
|
||||
@ExcelProperty("电话")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty("身份证号")
|
||||
private String idCardNo;
|
||||
|
||||
@ExcelProperty("关联病例")
|
||||
private String relatedCaseId;
|
||||
}
|
||||
@ -20,6 +20,7 @@ import net.lab1024.sa.admin.module.business.caseplatformcase.domain.form.Casepla
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseDetailVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.CaseplatformCaseVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.EasyExcelCaseDetailVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.ExportExpertCaseExcelVo;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcaseabstrac.domain.vo.CaseplatformCaseAbstracVO;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcaseabstrac.service.CaseplatformCaseAbstracService;
|
||||
import net.lab1024.sa.admin.module.business.caseplatformcasecheckdata.domain.vo.CaseplatformCaseCheckdataVO;
|
||||
@ -136,6 +137,92 @@ public class CaseplatformCaseService {
|
||||
return list;
|
||||
}
|
||||
|
||||
// 结算导出
|
||||
public List<ExportExpertCaseExcelVo> exportExpertCaseExcel(CaseplatformCaseQueryForm queryForm) {
|
||||
LoginEmployeeDetail requestUser = (LoginEmployeeDetail)SmartRequestUtil.getRequestUser();
|
||||
List<ProvVO> provList = requestUser.getProvList();
|
||||
Long provId = queryForm.getProvId();
|
||||
if(provId != null){
|
||||
boolean match = provList.stream().anyMatch(item -> item.getId().equals(provId));
|
||||
if(!match){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
List<ExportExpertCaseExcelVo> list = caseplatformCaseDao.getExportExpertCaseExcelList(queryForm, provList);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ExportExpertCaseExcelVo> exportExpertCaseExcelProcess(List<ExportExpertCaseExcelVo> list) {
|
||||
// 存放 expertId -> ExportExpertCaseExcelVo 列表
|
||||
Map<Long, List<ExportExpertCaseExcelVo>> expertMap = new HashMap<>();
|
||||
|
||||
// 第一次遍历:按 expertId 分组
|
||||
for (ExportExpertCaseExcelVo vo : list) {
|
||||
Long expertId = vo.getExpertId();
|
||||
if (!expertMap.containsKey(expertId)) {
|
||||
expertMap.put(expertId, new ArrayList<>());
|
||||
}
|
||||
expertMap.get(expertId).add(vo);
|
||||
}
|
||||
|
||||
// 最终结果列表
|
||||
List<ExportExpertCaseExcelVo> result = new ArrayList<>();
|
||||
|
||||
// 第二次遍历:处理每组数据
|
||||
Integer index = 1;
|
||||
for (List<ExportExpertCaseExcelVo> group : expertMap.values()) {
|
||||
// 构建一个新的 ExportExpertCaseExcelVo 对象
|
||||
ExportExpertCaseExcelVo newItem = new ExportExpertCaseExcelVo();
|
||||
|
||||
// 取第一个对象的基础信息(假设同一个人信息一致)
|
||||
ExportExpertCaseExcelVo first = group.get(0);
|
||||
|
||||
newItem.setIndex(index);
|
||||
newItem.setExpertId(first.getExpertId());
|
||||
newItem.setBankName(first.getBankName());
|
||||
newItem.setProv(first.getProv());
|
||||
newItem.setCity(first.getCity());
|
||||
newItem.setBankCardNo(first.getBankCardNo());
|
||||
newItem.setIdCardName(first.getIdCardName());
|
||||
newItem.setRemark(first.getRemark());
|
||||
newItem.setHospitalName(first.getHospitalName());
|
||||
newItem.setMobile(first.getMobile());
|
||||
newItem.setIdCardNo(first.getIdCardNo());
|
||||
|
||||
// 病例数量
|
||||
int caseCount = group.size();
|
||||
|
||||
// relatedCaseId 拼接
|
||||
StringBuilder relatedCaseIds = new StringBuilder();
|
||||
for (ExportExpertCaseExcelVo vo : group) {
|
||||
if (relatedCaseIds.length() > 0) {
|
||||
relatedCaseIds.append(",");
|
||||
}
|
||||
relatedCaseIds.append(vo.getCaseId());
|
||||
}
|
||||
|
||||
// 应发金额 = 数量 × 500
|
||||
double totalAmount = caseCount * 500.0;
|
||||
|
||||
// 实发金额 = 应发 − 个税(暂时用10元代替)
|
||||
double taxAmount = computeIndividualIncomeTax(totalAmount);
|
||||
double actualAmount = totalAmount - taxAmount;
|
||||
|
||||
// 设置金额字段
|
||||
newItem.setRelatedCaseId(relatedCaseIds.toString());
|
||||
newItem.setTotalAmount(totalAmount);
|
||||
newItem.setTaxAmount(taxAmount);
|
||||
newItem.setActualAmount(actualAmount);
|
||||
|
||||
// 加入最终结果
|
||||
result.add(newItem);
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
@ -233,6 +320,36 @@ public class CaseplatformCaseService {
|
||||
}
|
||||
}
|
||||
|
||||
// 计算个税
|
||||
public double computeIndividualIncomeTax(double income) {
|
||||
if (income <= 800) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (income <= 4000) {
|
||||
income -= 800;
|
||||
} else {
|
||||
income *= 0.8;
|
||||
}
|
||||
|
||||
double taxRate;
|
||||
double quickDeduction;
|
||||
|
||||
if (income <= 20000) {
|
||||
taxRate = 0.2;
|
||||
quickDeduction = 0;
|
||||
} else if (income <= 50000) {
|
||||
taxRate = 0.3;
|
||||
quickDeduction = 2000;
|
||||
} else {
|
||||
taxRate = 0.4;
|
||||
quickDeduction = 7000;
|
||||
}
|
||||
|
||||
double incomeTax = income * taxRate - quickDeduction;
|
||||
|
||||
return Math.max(incomeTax, 0); // 防止负值
|
||||
}
|
||||
|
||||
/**
|
||||
* 白名单专家导入
|
||||
|
||||
@ -110,7 +110,6 @@ public class CaseplatformExpertWhiteService {
|
||||
expertWhite.setCreateTime(LocalDateTime.now());
|
||||
expertWhiteEntityDao.insert(expertWhite);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException("文件读取失败: " + e.getMessage());
|
||||
}
|
||||
|
||||
@ -127,4 +127,63 @@
|
||||
where t_caseplatform_case.id=#{case_id}
|
||||
</select>
|
||||
|
||||
<select id="getExportExpertCaseExcelList" resultType="net.lab1024.sa.admin.module.business.caseplatformcase.domain.vo.ExportExpertCaseExcelVo">
|
||||
SELECT
|
||||
t_caseplatform_case.id caseId,
|
||||
(select name from t_area where id=t_caseplatform_bank.prov_id) prov,
|
||||
(select name from t_area where id=t_caseplatform_bank.city_id) city,
|
||||
t_caseplatform_expert.id expertId,
|
||||
t_caseplatform_expert.mobile mobile,
|
||||
t_caseplatform_expert.hospital_name hospitalName,
|
||||
t_caseplatform_bank.id_card_name idCardName,
|
||||
t_caseplatform_bank.id_card_no idCardNo,
|
||||
t_caseplatform_bank.bank_card_no bankCardNo,
|
||||
t_caseplatform_bank.bank_name bankName
|
||||
FROM t_caseplatform_case
|
||||
inner join t_caseplatform_expert on t_caseplatform_case.expert_id = t_caseplatform_expert.id
|
||||
inner join t_caseplatform_bank on t_caseplatform_bank.expert_id = t_caseplatform_expert.id
|
||||
|
||||
<where>
|
||||
<!--name-->
|
||||
<if test="queryForm.name != null and queryForm.name != ''">
|
||||
AND ( INSTR(t_caseplatform_case.user_id,#{queryForm.name})
|
||||
OR INSTR(t_caseplatform_case.expert_name,#{queryForm.name})
|
||||
)
|
||||
</if>
|
||||
<!--0待审核 1审核通过 2审核不通过-->
|
||||
<if test="queryForm.status != null">
|
||||
AND t_caseplatform_case.status = 1
|
||||
</if>
|
||||
<if test="queryForm.settlementFlag != null">
|
||||
AND t_caseplatform_case.settlement_flag = #{queryForm.settlementFlag}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="queryForm.provId != null and queryForm.provId != ''">
|
||||
AND t_caseplatform_expert.prov_id =#{queryForm.provId}
|
||||
</when>
|
||||
<when test="provList != null and provList.size > 0">
|
||||
and
|
||||
t_caseplatform_expert.prov_id
|
||||
in
|
||||
<foreach collection="provList" open="(" close=")" separator="," item="item">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1=2
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="queryForm.cityId != null and queryForm.cityId != ''">
|
||||
AND t_caseplatform_expert.city_id =#{queryForm.cityId}
|
||||
</if>
|
||||
<if test="queryForm.hospitalUuid != null and queryForm.hospitalUuid != ''">
|
||||
AND t_caseplatform_expert.hospital_uuid =#{queryForm.hospitalUuid}
|
||||
</if>
|
||||
<!-- 审核时间区间 -->
|
||||
<if test="queryForm.examineTime != null and queryForm.examineTime.size == 2">
|
||||
AND t_caseplatform_case.examine_time BETWEEN #{queryForm.examineTime[0]} AND #{queryForm.examineTime[1]}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user