体检管理需求整改

This commit is contained in:
2026-04-08 11:44:54 +08:00
parent 32ee62edd4
commit 15cdcb02a2
23 changed files with 1326 additions and 97 deletions
@@ -8,6 +8,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.http.HttpRequest;
@@ -16,11 +17,17 @@ import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.budwk.app.sys.models.*;
import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupProjectSubject;
import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupProjectSubjectMoney;
import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupUserSelection;
import com.budwk.app.zhgh.welfare.model.WelfareList;
import com.budwk.app.zhgh.welfare.model.WelfareProjectSubjectOption;
import com.budwk.app.zhgh.welfare.model.WelfareUserSelection;
import com.budwk.app.zhgh.welfare.service.WelfareProjectService;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +36,9 @@ import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
@@ -36,11 +46,13 @@ import org.nutz.json.Json;
import org.nutz.lang.Lang;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
@@ -55,6 +67,81 @@ public class WelfareTest {
@Inject
private WelfareProjectService welfareService;
@Test
public void importPhysicalExamination() {
Sql sql = Sqls.create("""
select u.*
from temp_user_loginName t
left join sys_user u on t.loginName=u.loginname
where u.id is not null
""");
List<NutMap> nutMaps = welfareService.listMap(sql);
List<HealthCheckupProjectSubject> healthCheckupProjectSubjects = dao.query(HealthCheckupProjectSubject.class,
Cnd.where(HealthCheckupProjectSubject::getProjectId, "=", "ccdc49e3d63b4a8cb89c0af0687bb1bf"));
List<HealthCheckupProjectSubjectMoney> healthCheckupProjectSubjectMoneyList = dao.query(HealthCheckupProjectSubjectMoney.class,
Cnd.where(HealthCheckupProjectSubjectMoney::getProjectId, "=", "ccdc49e3d63b4a8cb89c0af0687bb1bf"));
List<PhysicalExamination> physicalExaminationList = ExcelImportUtil.importExcel(new File("C:\\Users\\mayn\\Desktop\\1.xlsx"), PhysicalExamination.class, new ImportParams());
List<HealthCheckupUserSelection> userSelectionList = physicalExaminationList.stream().map(e -> {
NutMap nutMap = nutMaps.stream().filter(v -> e.getLoginName().equals(v.getString("loginname"))).findFirst().orElse(null);
HealthCheckupUserSelection userSelection = new HealthCheckupUserSelection();
if (ObjectUtil.isNotEmpty(nutMap)) {
userSelection.setSelectUserId(nutMap.getString("id"));
userSelection.setProjectId("ccdc49e3d63b4a8cb89c0af0687bb1bf");
HealthCheckupProjectSubject healthCheckupProjectSubject = healthCheckupProjectSubjects.stream()
.filter(v -> e.getHealthExaminationHospital().equals(v.getOptionName()))
.findFirst().orElse(null);
if(ObjectUtil.isNotEmpty(healthCheckupProjectSubject)) {
userSelection.setSubjectId(healthCheckupProjectSubject.getId());
} else {
userSelection.setBz("医院不存在");
return userSelection;
}
List<HealthCheckupProjectSubjectMoney> healthCheckupProjectSubjectMonies = healthCheckupProjectSubjectMoneyList.stream()
.filter(v -> v.getSubjectId().equals(healthCheckupProjectSubject.getId()))
.collect(Collectors.toList());
healthCheckupProjectSubjectMonies = healthCheckupProjectSubjectMoneyList.stream()
.filter(v -> v.getMoney().compareTo(e.getMoney()) == 0
&& v.getSettlementMoney().compareTo(e.getSettlementMoney()) == 0)
.collect(Collectors.toList());
if(!CollectionUtils.isEmpty(healthCheckupProjectSubjectMonies)){
userSelection.setSubjectMoneyId(healthCheckupProjectSubjectMonies.get(0).getId());
userSelection.setMoney(healthCheckupProjectSubjectMonies.get(0).getMoney());
} else {
userSelection.setSelectUserId(e.getLoginName());
userSelection.setBz("项目不存在");
return userSelection;
}
userSelection.setId(UUID.randomUUID().toString());
userSelection.setCampus("");
userSelection.setSelectTime(new Date());
userSelection.setBz("");
userSelection.setReceiveAddress("");
userSelection.setPostMethod("1");
return userSelection;
} else {
return null;
}
}).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
List<HealthCheckupUserSelection> healthCheckupUserSelections = userSelectionList.stream().filter(e -> StringUtils.isBlank(e.getId())).collect(Collectors.toList());
List<String> collect = healthCheckupUserSelections.stream().map(HealthCheckupUserSelection::getSelectUserId).collect(Collectors.toList());
userSelectionList = userSelectionList.stream().filter(e-> StringUtils.isNotBlank(e.getId())).collect(Collectors.toList());
dao.insert(userSelectionList);
}
@Data
public static class PhysicalExamination {
@Excel(name = "工号")
private String loginName;
@Excel(name = "体检医院")
private String healthExaminationHospital;
@Excel(name = "套餐金额")
private BigDecimal money;
@Excel(name = "结算金额")
private BigDecimal settlementMoney;
}
@Test
public void importSelectUser() {
List<SelectUser> list = ExcelImportUtil.importExcel(new File("C:\\Users\\administrator\\Desktop\\匹配上生日.xlsx"), SelectUser.class, new ImportParams());