This commit is contained in:
2026-09-03 16:08:08 +08:00
parent 921eefbc0e
commit a8b93a403d
4 changed files with 93 additions and 0 deletions
@@ -220,6 +220,23 @@ public class WelfareListController {
return null;
}
/**
* 更新福利名单中的单位信息。
*
* @param projectId 福利项目ID,前端必须传入当前选中的福利项目
* @return Integer,表示实际更新的福利名单数量
*/
@At
@ViReturn
@Aop(TransAop.READ_COMMITTED)
@RequiresPermissions("welfare.list.mange")
public Object updateWelfareListUnitInfo(@Param("projectId") String projectId) {
if (StrUtil.isBlank(projectId)) {
return Result.error("请选择福利项目");
}
return welfareListService.updateWelfareListUnitInfo(projectId);
}
@At
@ViReturn
@@ -29,5 +29,13 @@ public interface WelfareListService extends ViService<WelfareList> {
*/
void joinWelfareList(String projectId, List<String> userIds);
/**
* 将指定福利项目名单中的福利单位和二级单位,同步为用户主档案中的最新信息。
*
* @param projectId 福利项目ID
* @return 实际更新的福利名单数量
*/
int updateWelfareListUnitInfo(String projectId);
List<NutMap> getToNotWelfareUsers(String projectId);
}
@@ -120,6 +120,32 @@ public class WelfareListServiceImpl extends ViServiceImpl<WelfareList> implement
// joinWelfareList(listMap(sql), projectId);
}
/**
* 福利名单保存的是生成名单时的单位快照;人员调动后,通过用户ID关联用户主档案更新该快照。
* 用户的福利单位或二级单位为空时不参与同步,避免将名单中已有的有效信息清空。
*
* @param projectId 福利项目ID
* @return 实际更新的福利名单数量
*/
@Override
@Aop(TransAop.READ_COMMITTED)
public int updateWelfareListUnitInfo(String projectId) {
Sql sql = Sqls.create("""
UPDATE welfare_list wl
INNER JOIN sys_user u ON u.id = wl.userId
SET wl.welfareUnitId = u.$welfareUnitField,
wl.welfareSecondLevelUnitId = u.unitid
WHERE wl.projectId = @projectId
AND u.$welfareUnitField IS NOT NULL
AND u.$welfareUnitField != ''
AND u.unitid IS NOT NULL
AND u.unitid != ''
""");
sql.setVar("welfareUnitField", WelfareUnitMode.getMode().getField());
sql.setParam("projectId", projectId);
return dao().execute(sql).getUpdateCount();
}
@Override
public List<NutMap> getToNotWelfareUsers(String projectId) {
Sql sql = Sqls.create("""
@@ -280,6 +280,17 @@ layout("/layouts/platform.html"){
>
导入快递单号
</el-button>
<el-button
:disabled="!pageForm.projectId"
:loading="updateWelfareListUnitInfoLoading"
@click="updateWelfareListUnitInfo"
icon="el-icon-refresh"
size="small"
type="primary"
v-if="${@shiro.hasRole('sysadmin')}"
>
修改福利信息
</el-button>
<el-button
:disabled="!pageForm.projectId"
@click="doOneKeyReceive(pageForm.projectId)"
@@ -756,6 +767,8 @@ layout("/layouts/platform.html"){
shoppingTypeOptions: [],
updateWelfareListUnitInfoLoading: false,
/**
* 添加福利名单相关
*/
@@ -986,6 +999,35 @@ layout("/layouts/platform.html"){
this.$refs.expressExcelUpload.clearFiles()
}
},
/**
* 将当前福利项目名单中的工会和单位信息,同步为用户主档案中的最新信息。
*/
updateWelfareListUnitInfo() {
if (!this.pageForm.projectId) {
this.notifyWarning("请先选择福利项目")
return
}
this.$confirm("此操作将使用用户最新的工会和单位信息更新当前福利项目名单,是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$set(this, "updateWelfareListUnitInfoLoading", true)
$.post(loc() + "/updateWelfareListUnitInfo", {
projectId: this.pageForm.projectId
}).then((resp) => {
if (resp.code === 0) {
this.notifySuccess("福利信息修改成功,共更新" + resp.data + "条名单")
this.pageData()
} else {
this.notifyWarning(resp.msg)
}
}).always(() => {
this.$set(this, "updateWelfareListUnitInfoLoading", false)
})
}).catch(() => {
})
},
receiveAddressChange(address, optionIndex) {
this.$set(this.welfareOptions[optionIndex], "receiveAddress", address)
this.$forceUpdate()