commit
This commit is contained in:
+17
-2
@@ -84,6 +84,9 @@ public class DifficultHelpApplyController {
|
||||
public Result getIsCanPlay() {
|
||||
//获取申请次数,不想再写一个接口, are you ok? .and("zt", "=", 600)
|
||||
int applyCount = dao.count(DifficultHelpInfo.class, Cnd.where("proxyUserId", "=", SecurityUtil.getUserId()));
|
||||
// 页面初始化时需要先判断当前登录人本年度是否已经申请过,避免重复进入新增申请。
|
||||
boolean hasCurrentYearApply = dao.count(DifficultHelpInfo.class, Cnd.where("userId", "=", SecurityUtil.getUserId())
|
||||
.and("YEAR(applyTime)", "=", DateUtil.getYear())) > 0;
|
||||
Sys_config startConfig = dao.fetch(Sys_config.class, Cnd.where("configKey", "=", "DifficultyApplyStartTime"));
|
||||
Sys_config endConfig = dao.fetch(Sys_config.class, Cnd.where("configKey", "=", "DifficultyApplyEndTime"));
|
||||
if(startConfig != null && endConfig != null) {
|
||||
@@ -98,9 +101,9 @@ public class DifficultHelpApplyController {
|
||||
int endResult = cn.hutool.core.date.DateUtil.compare(cn.hutool.core.date.DateUtil.parse(today), cn.hutool.core.date.DateUtil.parse(end));
|
||||
|
||||
String time = startConfig.getConfigValue().replace("-", "月") + "日-" + endConfig.getConfigValue().replace("-", "月") + "日";
|
||||
return Result.success(Map.of("applyCount", applyCount,"time", time, "result", startResult >=0 && endResult <= 0));
|
||||
return Result.success(Map.of("applyCount", applyCount,"time", time, "result", startResult >=0 && endResult <= 0, "hasCurrentYearApply", hasCurrentYearApply));
|
||||
} else {
|
||||
return Result.success(Map.of("applyCount", applyCount,"time", "", "result", false));
|
||||
return Result.success(Map.of("applyCount", applyCount,"time", "", "result", false, "hasCurrentYearApply", hasCurrentYearApply));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +113,10 @@ public class DifficultHelpApplyController {
|
||||
@SLog(tag = "困难补助申请", msg = "保存申请,填写人: ${args[0].proxyUserName}")
|
||||
public Result save(@Param("data") DifficultHelpInfo difficultHelpInfo) {
|
||||
difficultHelpInfo.setApplyTime(ObjectUtil.defaultIfNull(difficultHelpInfo.getApplyTime(), new Date()));
|
||||
difficultHelpCommonService.refreshApplyCount(difficultHelpInfo);
|
||||
if (difficultHelpCommonService.hasAppliedInYear(difficultHelpInfo.getUserId(), difficultHelpInfo.getApplyTime(), difficultHelpInfo.getId())) {
|
||||
return Result.error("该人员本年度已申请困难帮扶,不能重复申请");
|
||||
}
|
||||
dao.insertOrUpdate(difficultHelpInfo);
|
||||
return Result.success();
|
||||
}
|
||||
@@ -122,6 +129,10 @@ public class DifficultHelpApplyController {
|
||||
@SLog(tag = "困难补助申请", msg = "提交申请,填写人: ${args[0].proxyUserName}")
|
||||
public Result submit(@Param("data") DifficultHelpInfo difficultHelpInfo){
|
||||
difficultHelpInfo.setApplyTime(new Date());
|
||||
difficultHelpCommonService.refreshApplyCount(difficultHelpInfo);
|
||||
if (difficultHelpCommonService.hasAppliedInYear(difficultHelpInfo.getUserId(), difficultHelpInfo.getApplyTime(), difficultHelpInfo.getId())) {
|
||||
return Result.error("该人员本年度已申请困难帮扶,不能重复申请");
|
||||
}
|
||||
dao.insertOrUpdate(difficultHelpInfo);
|
||||
|
||||
// 开启流程实例
|
||||
@@ -146,6 +157,10 @@ public class DifficultHelpApplyController {
|
||||
@SLog(tag = "困难补助申请", msg = "重新提交申请,填写人: ${args[0].proxyUserName}")
|
||||
public Result submitAgain(@Param("data") DifficultHelpInfo difficultHelpInfo, @Param("taskId") Long taskId) {
|
||||
difficultHelpInfo.setApplyTime(ObjectUtil.defaultIfNull(difficultHelpInfo.getApplyTime(), new Date()));
|
||||
difficultHelpCommonService.refreshApplyCount(difficultHelpInfo);
|
||||
if (difficultHelpCommonService.hasAppliedInYear(difficultHelpInfo.getUserId(), difficultHelpInfo.getApplyTime(), difficultHelpInfo.getId())) {
|
||||
return Result.error("该人员本年度已申请困难帮扶,不能重复申请");
|
||||
}
|
||||
dao.insertOrUpdate(difficultHelpInfo);
|
||||
|
||||
Dict dict = Dict.create();
|
||||
|
||||
+18
@@ -7,6 +7,7 @@ import com.budwk.app.zhgh.staffbenefit.medicalMutualAid.aidFund.param.AidFundPag
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.upload.TempFile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,4 +27,21 @@ public interface DifficultHelpCommonService extends BaseService<DifficultHelpInf
|
||||
NutMap handlingMoneyImport(TempFile file, Boolean isFlag);
|
||||
|
||||
List<NutMap> getYearPayList(DifficultHelpPageParam pageForm);
|
||||
|
||||
/**
|
||||
* 校验同一受补助人同一年是否已存在申请记录。
|
||||
*
|
||||
* @param userId 受补助人id
|
||||
* @param applyTime 申请时间
|
||||
* @param excludeRecordId 排除的当前记录id,编辑/重新提交时使用
|
||||
* @return true 已存在同年申请记录
|
||||
*/
|
||||
boolean hasAppliedInYear(String userId, Date applyTime, String excludeRecordId);
|
||||
|
||||
/**
|
||||
* 新申请时按历史总申请次数重新计算申请次数字段,已有记录则保留原值。
|
||||
*
|
||||
* @param difficultHelpInfo 申请信息
|
||||
*/
|
||||
void refreshApplyCount(DifficultHelpInfo difficultHelpInfo);
|
||||
}
|
||||
|
||||
+32
@@ -50,6 +50,38 @@ public class DifficultHelpCommonServiceImpl extends BaseServiceImpl<DifficultHel
|
||||
@Inject
|
||||
private ManyAddOrRenewUtil manyAddOrRenewUtil;
|
||||
|
||||
@Override
|
||||
public boolean hasAppliedInYear(String userId, Date applyTime, String excludeRecordId) {
|
||||
if (StrUtil.isBlank(userId) || applyTime == null) {
|
||||
return false;
|
||||
}
|
||||
Cnd cnd = Cnd.where("userId", "=", userId);
|
||||
cnd.and("YEAR(applyTime)", "=", DateUtil.year(applyTime));
|
||||
if (StrUtil.isNotBlank(excludeRecordId)) {
|
||||
cnd.and("id", "<>", excludeRecordId);
|
||||
}
|
||||
// 按受补助人和申请年份校验,确保同一个人每年只能保留一条申请记录。
|
||||
return dao().count(DifficultHelpInfo.class, cnd) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshApplyCount(DifficultHelpInfo difficultHelpInfo) {
|
||||
if (difficultHelpInfo == null || StrUtil.isBlank(difficultHelpInfo.getUserId())) {
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isNotBlank(difficultHelpInfo.getId())) {
|
||||
DifficultHelpInfo dbInfo = dao().fetch(DifficultHelpInfo.class, difficultHelpInfo.getId());
|
||||
if (dbInfo != null) {
|
||||
// 已存在的申请记录沿用原申请次数,避免编辑或重新提交时重复累加。
|
||||
difficultHelpInfo.setApplyCount(dbInfo.getApplyCount());
|
||||
return;
|
||||
}
|
||||
}
|
||||
int historyApplyCount = dao().count(DifficultHelpInfo.class, Cnd.where("userId", "=", difficultHelpInfo.getUserId()));
|
||||
// 新申请记录按历史总申请次数 + 1 重新计算申请次数,不使用前端传入值。
|
||||
difficultHelpInfo.setApplyCount(historyApplyCount + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NutMap> getYearPayList(DifficultHelpPageParam pageForm) {
|
||||
// 1. 生成年份列表
|
||||
|
||||
Reference in New Issue
Block a user