体检管理bug调整
This commit is contained in:
+40
-34
@@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.budwk.app.base.annotation.SLog;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.param.PageForm;
|
||||
@@ -24,6 +25,7 @@ import com.budwk.app.zhgh.dayofficework.healthCheckup.model.HealthCheckupUserSel
|
||||
import com.budwk.app.zhgh.dayofficework.healthCheckup.service.HealthCheckupSingleService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
@@ -299,11 +301,11 @@ public class HealthCheckupSingleController {
|
||||
@Ok("json:full")
|
||||
@SaCheckPermission("healthCheckup.statisticsSingle")
|
||||
@SLog(type = "healthCheckup", tag = "体检管理", msg = "管理员给没选的人统一选择去年的数据")
|
||||
public Result selectOptionByLastYear(String projectId) {
|
||||
public Result selectOptionByLastYear(String projectId, String lastYearProjectId) {
|
||||
|
||||
Dao dao = healthCheckupSingleService.dao();
|
||||
//获取去年项目
|
||||
HealthCheckupProject lastYearProject = dao.fetch(HealthCheckupProject.class, Cnd.where("YEAR(year)", "=", DateUtil.thisYear() - 1));
|
||||
HealthCheckupProject lastYearProject = dao.fetch(HealthCheckupProject.class, Cnd.where("id", "=", lastYearProjectId));
|
||||
if (lastYearProject == null) {
|
||||
return Result.error("请先创建去年的体检项目");
|
||||
}
|
||||
@@ -317,10 +319,12 @@ public class HealthCheckupSingleController {
|
||||
$projectCnd $condition
|
||||
""");
|
||||
cnd.and("hcu.projectId", "=", projectId);
|
||||
sql.setVar("projectCnd", "AND u.id NOT IN ( SELECT selectUserId FROM `health_checkup_user_selection` WHERE projectId = '" + projectId + "' AND selectUserId IS NOT NULL )");
|
||||
sql.setVar("projectCnd",
|
||||
"AND u.id NOT IN ( SELECT selectUserId FROM `health_checkup_user_selection` WHERE projectId = '" + projectId + "' AND selectUserId IS NOT NULL )");
|
||||
cnd.groupBy("u.loginname");
|
||||
sql.setCondition(cnd);
|
||||
List<NutMap> mapList = healthCheckupSingleService.listMap(sql);
|
||||
if(CollectionUtil.isEmpty(mapList)) return Result.success();
|
||||
|
||||
List<String> userIds = mapList.stream().map(v -> v.getString("id")).toList();
|
||||
|
||||
@@ -340,41 +344,43 @@ public class HealthCheckupSingleController {
|
||||
userIds.forEach(v -> {
|
||||
//获取去年这个人选择的记录
|
||||
HealthCheckupUserSelection userSelection = lastYearSelectionList.stream().filter(item -> item.getSelectUserId().equals(v)).findFirst().orElse(null);
|
||||
//去年这个人选择的选项是什么
|
||||
HealthCheckupProjectSubject lastYearSubject = lastYearSubjectList.stream().filter(last -> last.getId().equals(userSelection.getSubjectId())).findFirst().orElse(null);
|
||||
//今年项目下的选项
|
||||
HealthCheckupProjectSubject thisYearSubject = thisYearSubjectList.stream().filter(thisYear -> thisYear.getOptionName().equals(lastYearSubject.getOptionName())).findFirst().orElse(null);
|
||||
if (userSelection != null && thisYearSubject != null) {
|
||||
//获取今年这个选项的收费
|
||||
List<HealthCheckupProjectSubjectMoney> list = dao.query(HealthCheckupProjectSubjectMoney.class,
|
||||
Cnd.where(HealthCheckupProjectSubjectMoney::getSubjectId, "=", thisYearSubject.getId()));
|
||||
BigDecimal money = BigDecimal.valueOf(0.00);
|
||||
String subjectMoneyId = null;
|
||||
for (HealthCheckupProjectSubjectMoney subject : list) {
|
||||
//找出这个人符合哪个项目
|
||||
Cnd cndUser = Cnd.where("id", "=", v);
|
||||
ConditionGroupUtil.applyConditionGroup(cndUser, subject.getMatchCnd());
|
||||
int count = dao.count(View_user.class, cndUser);
|
||||
if (count > 0) {
|
||||
money = subject.getMoney();
|
||||
subjectMoneyId = subject.getId();
|
||||
break;
|
||||
if(ObjectUtil.isNotEmpty(userSelection)){
|
||||
//去年这个人选择的选项是什么
|
||||
HealthCheckupProjectSubject lastYearSubject = lastYearSubjectList.stream().filter(last -> last.getId().equals(userSelection.getSubjectId())).findFirst().orElse(null);
|
||||
//今年项目下的选项
|
||||
HealthCheckupProjectSubject thisYearSubject = thisYearSubjectList.stream().filter(thisYear -> thisYear.getOptionName().equals(lastYearSubject.getOptionName())).findFirst().orElse(null);
|
||||
if (userSelection != null && thisYearSubject != null) {
|
||||
//获取今年这个选项的收费
|
||||
List<HealthCheckupProjectSubjectMoney> list = dao.query(HealthCheckupProjectSubjectMoney.class,
|
||||
Cnd.where(HealthCheckupProjectSubjectMoney::getSubjectId, "=", thisYearSubject.getId()));
|
||||
BigDecimal money = BigDecimal.valueOf(0.00);
|
||||
String subjectMoneyId = null;
|
||||
for (HealthCheckupProjectSubjectMoney subject : list) {
|
||||
//找出这个人符合哪个项目
|
||||
Cnd cndUser = Cnd.where("id", "=", v);
|
||||
ConditionGroupUtil.applyConditionGroup(cndUser, subject.getMatchCnd());
|
||||
int count = dao.count(View_user.class, cndUser);
|
||||
if (count > 0) {
|
||||
money = subject.getMoney();
|
||||
subjectMoneyId = subject.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
//如果有符合的就添加
|
||||
if (subjectMoneyId != null) {
|
||||
HealthCheckupUserSelection selection = new HealthCheckupUserSelection();
|
||||
selection.setProjectId(projectId);
|
||||
selection.setSelectUserId(v);
|
||||
selection.setSubjectId(thisYearSubject.getId());
|
||||
selection.setSubjectMoneyId(subjectMoneyId);
|
||||
selection.setMoney(money);
|
||||
selection.setSelectTime(new Date());
|
||||
selections.add(selection);
|
||||
}
|
||||
}
|
||||
//如果有符合的就添加
|
||||
if (subjectMoneyId != null) {
|
||||
HealthCheckupUserSelection selection = new HealthCheckupUserSelection();
|
||||
selection.setProjectId(projectId);
|
||||
selection.setSelectUserId(v);
|
||||
selection.setSubjectId(thisYearSubject.getId());
|
||||
selection.setSubjectMoneyId(subjectMoneyId);
|
||||
selection.setMoney(money);
|
||||
selection.setSelectTime(new Date());
|
||||
selections.add(selection);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
dao.insert(selections);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user