女职工卫生费

This commit is contained in:
=
2025-11-07 15:17:06 +08:00
parent ae86803b17
commit 42ca668f6e
8 changed files with 107 additions and 23 deletions
@@ -164,8 +164,7 @@ public class WomanSanitaryManageController {
public Result batchIssue() {
try {
// 方案1: 使用SQL直接切换所有记录的状态
Sql sql = Sqls.create("UPDATE woman_sanitary_user SET issue = !issue");
dao.execute(sql);
Sql sql = Sqls.create("UPDATE woman_sanitary_user SET issue = true WHERE issue = false"); dao.execute(sql);
return Result.success("状态切换成功");
} catch (Exception e) {
@@ -77,6 +77,16 @@ public class WomanSanitaryUser extends BaseModel implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 50)
private String mobile;
@Column
@Comment("入校时间")
@ColDefine(type = ColType.DATE)
private Date arrivalAtSchoolDate;
@Column
@Comment("离校时间")
@ColDefine(type = ColType.DATE)
private Date expectedLeaveSchoolDate;
@Column
@Comment("是否发放")
@ColDefine(type = ColType.BOOLEAN)
@@ -53,7 +53,6 @@ public class WomanSanitaryUserServiceImpl extends BaseServiceImpl<WomanSanitaryU
@Aop(TransAop.READ_COMMITTED)
@Override
public NutMap handlingMemberImport(TempFile file,String projectId ) {
// 修改1: 使用正确的VO类
List<T> ts = EasyExcelUtil.syncReadModel(file.getFile(), WomanSanitaryUserImportVo.class, 0, 1);
List<WomanSanitaryUserImportVo> list = JSONUtil.parseArray(JSONUtil.toJsonStr(ts)).toList(WomanSanitaryUserImportVo.class);
@@ -73,7 +72,9 @@ public class WomanSanitaryUserServiceImpl extends BaseServiceImpl<WomanSanitaryU
unitName,
unionName,
unionId,
unitId
unitId,
arrivalAtSchoolDate,
expectedLeaveSchoolDate
FROM
`vw_user`
""");
@@ -82,7 +83,6 @@ public class WomanSanitaryUserServiceImpl extends BaseServiceImpl<WomanSanitaryU
List<Record> vwUserList = vwUserSql.getList(Record.class);
Map<String, Record> vwUserMap = vwUserList.stream().collect(Collectors.toMap(r -> r.getString("loginname"), r -> r));
// 修改2: 使用正确的实体类
List<WomanSanitaryUser> userList = new ArrayList<>();
List<Sys_user> insertOrUpdateUserList = new ArrayList<>();
@@ -113,6 +113,7 @@ public class WomanSanitaryUserServiceImpl extends BaseServiceImpl<WomanSanitaryU
WomanSanitaryUser womanUser = new WomanSanitaryUser();
womanUser.setId(R.UU32());
// 根据工号查询vw_user视图,设置人员信息
Record vwUser = vwUserMap.get(v.getLoginName());
if (vwUser != null) {
@@ -123,6 +124,12 @@ public class WomanSanitaryUserServiceImpl extends BaseServiceImpl<WomanSanitaryU
womanUser.setSex(vwUser.getString("sex"));
womanUser.setUnionName(vwUser.getString("unionName"));
womanUser.setUnitName(vwUser.getString("unitName"));
womanUser.setMobile(vwUser.getString("mobile"));
Object arrivalDateObj = vwUser.get("arrivalAtSchoolDate");
Object leaveDateObj = vwUser.get("expectedLeaveSchoolDate");
womanUser.setArrivalAtSchoolDate(DateUtil.parse((String) arrivalDateObj));
womanUser.setExpectedLeaveSchoolDate((Date) leaveDateObj);
}
// 设置其他基本信息
@@ -130,16 +137,9 @@ public class WomanSanitaryUserServiceImpl extends BaseServiceImpl<WomanSanitaryU
womanUser.setApplyTime(new Date()); // 设置当前时间为申请时间
womanUser.setIssue(false);
womanUser.setProjectId(projectId);
if (v.getMoney() != null) {
try {
womanUser.setMoney(Double.valueOf(v.getMoney()));
} catch (NumberFormatException e) {
v.setErrorInfo("当前额度格式错误!");
errorInfos.add(v);
continue;
}
}
//设置发放金额
double calculatedMoney = calculateSanitaryFee(womanUser.getArrivalAtSchoolDate(), womanUser.getExpectedLeaveSchoolDate());
womanUser.setMoney(calculatedMoney);
userList.add(womanUser);
}
@@ -166,5 +166,65 @@ public class WomanSanitaryUserServiceImpl extends BaseServiceImpl<WomanSanitaryU
}
return null;
}
// 添加计算方法
private double calculateSanitaryFee(Date arrivalDate, Date leaveDate) {
Date now = new Date();
int currentYear = DateUtil.year(now);
int arrivalYear = DateUtil.year(arrivalDate);
// 如果没有入职时间,默认全年
if (arrivalDate == null) {
return 12 * 30.0;
}
// 如果离校时间为空
if (leaveDate == null) {
// 如果不是本年入职,全年费用
if (arrivalYear < currentYear) {
return 12 * 30.0;
} else {
// 如果是本年入职,计算从入职月份到年底的月份
// 需要包括入职当月和之后的所有月份
int arrivalMonth = DateUtil.month(arrivalDate) + 1; // month是从0开始的
return 30.0 * (12 - arrivalMonth + 1); // +1表示包括当月
}
} else {
// 如果离校时间不为空
int leaveYear = DateUtil.year(leaveDate);
// 如果离校年份小于当前年份,说明已经离校,无费用
if (leaveYear < currentYear) {
return 0.0;
}
// 如果离校年份大于当前年份,在岗时间按全年计算
if (leaveYear > currentYear) {
// 判断入职时间
if (arrivalYear < currentYear) {
return 12 * 30.0; // 全年在岗
} else {
// 本年入职
int arrivalMonth = DateUtil.month(arrivalDate) + 1;
return 30.0 * (12 - arrivalMonth + 1);
}
} else {
// 如果离校年份等于当前年份,需要计算到离校月份
if (arrivalYear < currentYear) {
// 之前年份入职,计算到离校月份
int leaveMonth = DateUtil.month(leaveDate) + 1;
return 30.0 * leaveMonth; // 包括离校当月
} else if (arrivalYear == currentYear) {
// 本年入职又本年离校
int arrivalMonth = DateUtil.month(arrivalDate) + 1;
int leaveMonth = DateUtil.month(leaveDate) + 1;
return 30.0 * (leaveMonth - arrivalMonth + 1); // 包括首尾两月
} else {
// 不可能的情况(入职时间晚于离校时间)
return 0.0;
}
}
}
}
}
@@ -40,13 +40,19 @@ public class WomanSanitaryUserExportVo {
@Excel(name = "电话", width = 20)
private String mobile;
@Excel(name = "入职时间", width = 20, format = "yyyy-MM-dd")
private String arrivalAtSchoolDate;
@Excel(name = "离职时间", width = 20, format = "yyyy-MM-dd")
private String expectedLeaveSchoolDate;
@Excel(name = "发放金额", width = 20)
private Double money;
@Excel(name = "是否发放", width = 20)
private String issueDisplay;
@Excel(name = "申请时间", width = 20, format = "yyyy-MM-dd")
@Excel(name = "导入时间", width = 20, format = "yyyy-MM-dd")
private String applyTime;
@ExcelIgnore
@@ -37,9 +37,6 @@ public class WomanSanitaryUserImportVo {
@ExcelProperty("单位")
private String unitName;
@ExcelProperty("发放金额")
private Double money;
@ExcelIgnore
private String errorInfo;
@@ -62,17 +62,23 @@ layout("/layouts/platform.html"){
<el-table-column prop="loginName" label="工号"></el-table-column>
<el-table-column prop="userName" label="姓名"></el-table-column>
<el-table-column prop="sex" label="性别"></el-table-column>
<el-table-column prop="projectName" label="所属事项"></el-table-column>
<!-- <el-table-column prop="projectName" label="所属事项"></el-table-column>-->
<el-table-column prop="unionName" label="所属工会"></el-table-column>
<el-table-column prop="unitName" label="所属单位"></el-table-column>
<el-table-column prop="mobile" label="联系方式"></el-table-column>
<el-table-column label="入职时间">
<template slot-scope="{row}">{{ row.arrivalAtSchoolDate ? $moment(row.arrivalAtSchoolDate).format('YYYY-MM-DD') : '' }}</template>
</el-table-column>
<el-table-column label="离职时间">
<template slot-scope="{row}">{{ row.expectedLeaveSchoolDate ? $moment(row.expectedLeaveSchoolDate).format('YYYY-MM-DD') : '' }}</template>
</el-table-column>
<el-table-column prop="money" label="发放金额"></el-table-column>
<el-table-column prop="issue" label="是否发放">
<template slot-scope="{row}">
<span :style="{color: row.issue ? '#67C23A' : ''}">{{ row.issue ? '已发放' : '未发放' }}</span>
</template>
</el-table-column>
<el-table-column prop="applyTime" label="录入时间"></el-table-column>
<!-- <el-table-column prop="applyTime" label="录入时间"></el-table-column>-->
<el-table-column label="操作" fixed="right" width="200px">
<template slot-scope="{row}">
<el-button
@@ -66,13 +66,19 @@ layout("/layouts/platform.html"){
<el-table-column prop="unionName" label="所属工会"></el-table-column>
<el-table-column prop="unitName" label="所属单位"></el-table-column>
<el-table-column prop="mobile" label="联系方式"></el-table-column>
<el-table-column label="入职时间">
<template slot-scope="{row}">{{ row.arrivalAtSchoolDate ? $moment(row.arrivalAtSchoolDate).format('YYYY-MM-DD') : '' }}</template>
</el-table-column>
<el-table-column label="离职时间">
<template slot-scope="{row}">{{ row.expectedLeaveSchoolDate ? $moment(row.expectedLeaveSchoolDate).format('YYYY-MM-DD') : '' }}</template>
</el-table-column>
<el-table-column prop="money" label="发放金额"></el-table-column>
<el-table-column prop="issue" label="是否发放">
<template slot-scope="{row}">
<span :style="{color: row.issue ? '#67C23A' : ''}">{{ row.issue ? '已发放' : '未发放' }}</span>
</template>
</el-table-column>
<el-table-column prop="applyTime" label="录入时间"></el-table-column>
<!-- <el-table-column prop="applyTime" label="录入时间"></el-table-column>-->
<el-table-column label="操作" fixed="right" width="200px">
<template slot-scope="{row}">
<el-button v-if="$auth.hasRole('SYSADMIN')" @click="onDelete(row.id)" size="mini" type="danger">删除</el-button>
@@ -222,7 +222,7 @@ layout("/layouts/platform.html"){
deadImmediateFamily: [{ required: true, message: "必填", trigger: ["change", "blur"] }],
remark: [{ required: true, message: "必填", trigger: ["change", "blur"] }],
files: [{ required: true, message: "必填", trigger: ["change", "blur"] }],
signature: [{ required: true, message: "必填", trigger: ["change", "blur"] }]
// signature: [{ required: true, message: "必填", trigger: ["change", "blur"] }]
},
chooseType: {},
payUserOptions: [],