This commit is contained in:
Timer
2026-04-21 23:45:48 +08:00
parent 6738104534
commit 2ca6153cda
4 changed files with 650 additions and 515 deletions

View File

@ -222,18 +222,50 @@ public class SafetyCertificateController {
@RequestMapping("/deletes.do") @RequestMapping("/deletes.do")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String delete(HttpServletRequest request, Model model, String[] ids) throws IOException { public String delete(HttpServletRequest request, Model model,
@RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "staffIds", required = false) String staffIds) throws IOException {
int result = 0; int result = 0;
for (String id : ids) {
// 兼容:支持 ids/staffIds 传 CSV也支持重复参数数组
Set<String> idSet = new LinkedHashSet<>(parseRequestIds(request, "ids", ids));
idSet.addAll(parseRequestIds(request, "staffIds", staffIds));
for (String id : idSet) {
result += service.deleteById(id); result += service.deleteById(id);
}
for (String id : ids) {
safetyFilesService.deleteByBizId(id); safetyFilesService.deleteByBizId(id);
} }
model.addAttribute("result", result); model.addAttribute("result", result);
return "result"; return "result";
} }
private List<String> parseRequestIds(HttpServletRequest request, String paramName, String rawIds) {
List<String> result = new ArrayList<>(parseIdTokens(rawIds));
String[] values = request.getParameterValues(paramName);
if (values != null) {
for (String value : values) {
result.addAll(parseIdTokens(value));
}
}
return result;
}
private List<String> parseIdTokens(String rawIds) {
List<String> result = new ArrayList<>();
if (org.apache.commons.lang3.StringUtils.isBlank(rawIds) || "null".equals(rawIds)) {
return result;
}
String[] split = rawIds.split(",");
for (String id : split) {
String value = org.apache.commons.lang3.StringUtils.trim(id);
if (org.apache.commons.lang3.StringUtils.isNotBlank(value) && value.matches("^[0-9A-Za-z_-]+$")) {
result.add(value);
}
}
return result;
}
/** /**
* 跳转导入页面 * 跳转导入页面
* *

View File

@ -339,16 +339,39 @@ public class SafetyExternalCertificateController {
@RequestMapping("/deletes.do") @RequestMapping("/deletes.do")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public String delete(HttpServletRequest request, Model model, String[] ids) throws IOException { public String delete(HttpServletRequest request, Model model,
@RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "staffIds", required = false) String staffIds) throws IOException {
int result = 0; int result = 0;
for (String id : ids) {
// 兼容:支持 ids/staffIds 传 CSV也支持重复参数数组
Set<String> certificateIdSet = new LinkedHashSet<>(parseRequestIds(request, "ids", ids));
Set<String> staffIdSet = new LinkedHashSet<>(parseRequestIds(request, "staffIds", staffIds));
for (String id : certificateIdSet) {
result += service.deleteById(id); result += service.deleteById(id);
safetyFilesService.deleteByBizId(id); safetyFilesService.deleteByBizId(id);
} }
for (String staffId : staffIdSet) {
safetyExternalStaffService.deleteById(staffId);
}
model.addAttribute("result", result); model.addAttribute("result", result);
return "result"; return "result";
} }
private List<String> parseRequestIds(HttpServletRequest request, String paramName, String rawIds) {
List<String> result = new ArrayList<>(parseExportIds(rawIds));
String[] values = request.getParameterValues(paramName);
if (values != null) {
for (String value : values) {
result.addAll(parseExportIds(value));
}
}
return result;
}
/** /**
* 跳转导入页面 * 跳转导入页面
* *
@ -536,56 +559,32 @@ public class SafetyExternalCertificateController {
public void export(HttpServletRequest request, HttpServletResponse response, public void export(HttpServletRequest request, HttpServletResponse response,
@RequestParam(value = "issueDate", required = false) String issueDate, @RequestParam(value = "issueDate", required = false) String issueDate,
@RequestParam(value = "jobType", required = false) String jobType, @RequestParam(value = "jobType", required = false) String jobType,
@RequestParam(value = "companyParam", required = false) String companyParam) throws IOException { @RequestParam(value = "companyParam", required = false) String companyParam,
// 摘自列表查询接口 start @RequestParam(value = "search_name", required = false) String searchName,
User cu = (User) request.getSession().getAttribute("cu"); @RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "staffIds", required = false) String staffIds) throws IOException {
// 与列表接口保持一致,避免“页面有数据但导出为空”
String sort = " sc.userid, sc.create_time "; String sort = " sc.userid, sc.create_time ";
String order = " desc "; String order = " desc ";
String orderstr = " order by " + sort + " " + order; String orderstr = " order by " + sort + " " + order;
String wherestr = " where flag='2' "; String wherestr = " where 1=1 ";
if (request.getParameter("search_code") != null && !request.getParameter("search_code").isEmpty()) {
List<Unit> unitlist = unitService.getUnitChildrenById(request.getParameter("search_code"));
String pidstr = "";
for (int i = 0; i < unitlist.size(); i++) {
pidstr += "'" + unitlist.get(i).getId() + "',";
}
if (pidstr != "") {
pidstr = pidstr.substring(0, pidstr.length() - 1);
wherestr += "and u.pid in (" + pidstr + ") ";
}
} else {
Company company = unitService.getCompanyByUserId(cu.getId());
String companyId = "-1";
if (company != null) {
companyId = company.getId();
}
List<User> users = unitService.getChildrenUsersById(companyId);
String userIds = "";
for (User user : users) {
if (!userIds.isEmpty()) {
userIds += "','";
}
userIds += user.getId();
}
if (!userIds.isEmpty()) {
wherestr += "and u.id in ('" + userIds + "') ";
}
}
// 搜索框筛选 // 搜索框筛选
if (request.getParameter("search_name") != null && !request.getParameter("search_name").isEmpty()) { if (StringUtils.isNotBlank(searchName)) {
wherestr += " and (sc.certificate_name like '%" + request.getParameter("search_name") + "%'" + wherestr += " and (sc.certificate_name like '%" + searchName + "%'" +
" or ses.name like '%" + request.getParameter("search_name") + "%')"; " or ses.name like '%" + searchName + "%')";
} }
// 领证时间筛选 // 领证时间筛选
if (StringUtils.isNotBlank(issueDate) && !"null".equals(issueDate)) { if (StringUtils.isNotBlank(issueDate) && !"null".equals(issueDate)) {
String[] split = issueDate.split("~"); String[] split = issueDate.split("~");
if (split.length == 2) {
String issueDate_param_start_time = split[0].trim(); String issueDate_param_start_time = split[0].trim();
String issueDate_param_end_time = split[1].trim(); String issueDate_param_end_time = split[1].trim();
wherestr += " and sc.issue_date >= '" + issueDate_param_start_time + "'" + wherestr += " and sc.issue_date >= '" + issueDate_param_start_time + "'" +
" and sc.issue_date <= '" + issueDate_param_end_time + "'"; " and sc.issue_date <= '" + issueDate_param_end_time + "'";
} }
}
// 作业类型 // 作业类型
if (StringUtils.isNotBlank(jobType) && !"null".equals(jobType)) { if (StringUtils.isNotBlank(jobType) && !"null".equals(jobType)) {
@ -597,6 +596,24 @@ public class SafetyExternalCertificateController {
wherestr += " and ses.company = '" + companyParam + "'"; wherestr += " and ses.company = '" + companyParam + "'";
} }
// 勾选导出:有勾选则仅导出勾选数据;无勾选则按筛选条件导出全部
List<String> certificateIdList = parseExportIds(ids);
List<String> staffIdList = parseExportIds(staffIds);
if (!CollectionUtils.isEmpty(certificateIdList) || !CollectionUtils.isEmpty(staffIdList)) {
StringBuilder selectedWhere = new StringBuilder(" and (");
if (!CollectionUtils.isEmpty(certificateIdList)) {
selectedWhere.append("sc.id in (").append(joinForSqlIn(certificateIdList)).append(")");
}
if (!CollectionUtils.isEmpty(staffIdList)) {
if (!CollectionUtils.isEmpty(certificateIdList)) {
selectedWhere.append(" or ");
}
selectedWhere.append("ses.id in (").append(joinForSqlIn(staffIdList)).append(")");
}
selectedWhere.append(")");
wherestr += selectedWhere;
}
List<SafetyExternalCertificateVo> list = this.service.selectListByConditionForExternal(wherestr + orderstr); List<SafetyExternalCertificateVo> list = this.service.selectListByConditionForExternal(wherestr + orderstr);
List<SafetyExternalCertificateExcel> excelList = new ArrayList<>(); List<SafetyExternalCertificateExcel> excelList = new ArrayList<>();
SafetyExternalCertificateExcel excelEntity = null; SafetyExternalCertificateExcel excelEntity = null;
@ -605,7 +622,7 @@ public class SafetyExternalCertificateController {
BeanUtils.copyProperties(vo, excelEntity); BeanUtils.copyProperties(vo, excelEntity);
excelList.add(excelEntity); excelList.add(excelEntity);
} }
// 摘自列表查询接口 end
response.setContentType("application/vnd.ms-excel"); response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf8"); response.setCharacterEncoding("utf8");
response.setHeader("Content-disposition", "attachment;filename=" + java.net.URLEncoder.encode("外部人员证书信息", "UTF-8") + ".xlsx"); response.setHeader("Content-disposition", "attachment;filename=" + java.net.URLEncoder.encode("外部人员证书信息", "UTF-8") + ".xlsx");
@ -616,4 +633,31 @@ public class SafetyExternalCertificateController {
excelWriter.finish(); excelWriter.finish();
} }
} }
private List<String> parseExportIds(String rawIds) {
List<String> result = new ArrayList<>();
if (StringUtils.isBlank(rawIds) || "null".equals(rawIds)) {
return result;
}
String[] split = rawIds.split(",");
for (String id : split) {
String value = StringUtils.trim(id);
// 仅保留安全字符,避免拼接 SQL 时引入非法字符
if (StringUtils.isNotBlank(value) && value.matches("^[0-9A-Za-z_-]+$")) {
result.add(value);
}
}
return result;
}
private String joinForSqlIn(List<String> idList) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < idList.size(); i++) {
if (i > 0) {
sb.append(",");
}
sb.append("'").append(idList.get(i)).append("'");
}
return sb.toString();
}
} }

View File

@ -55,6 +55,7 @@
.table-hover > tbody > tr:hover { .table-hover > tbody > tr:hover {
cursor: pointer; cursor: pointer;
} }
.input-clear-a { .input-clear-a {
color: white; color: white;
@ -143,11 +144,15 @@
} }
var deletesFun = function () { var deletesFun = function () {
var checkedItems = $("#table").bootstrapTable('getSelections'); var checkedItems = $("#table").bootstrapTable('getSelections');
var datas = ""; var ids = [];
var staffIds = [];
$.each(checkedItems, function (index, item) { $.each(checkedItems, function (index, item) {
datas += item.id + ","; if (item.id) {
ids.push(item.id);
staffIds.push(item.staffId || "");
}
}); });
if (datas == "") { if (ids.length === 0 && staffIds.length === 0) {
showAlert('d', '请先选择记录', 'mainAlertdiv'); showAlert('d', '请先选择记录', 'mainAlertdiv');
} else { } else {
swal({ swal({
@ -171,7 +176,10 @@
} }
}).then(function (willDelete) { }).then(function (willDelete) {
if (willDelete) { if (willDelete) {
$.post(ext.contextPath + '/safety/externalCertificate/deletes.do', {ids: datas}, function (data) { $.post(ext.contextPath + '/safety/externalCertificate/deletes.do', {
ids: ids.join(","),
staffIds: staffIds.join(",")
}, function (data) {
if (data > 0) { if (data > 0) {
$("#table").bootstrapTable('refresh'); $("#table").bootstrapTable('refresh');
// 初始化 作业类型 // 初始化 作业类型
@ -204,11 +212,24 @@
var companyParam = $('#companyParam').val(); var companyParam = $('#companyParam').val();
var issueDate = $('#reservationtimeD').val(); var issueDate = $('#reservationtimeD').val();
window.open(ext.contextPath + "/safety/externalCertificate/exportExcel.do?search_name=" + search_name var checkedItems = $("#table").bootstrapTable('getSelections');
+ "&search_code=" + search_code var ids = [];
+ "&jobType=" + jobType var staffIds = [];
+ "&issueDate=" + issueDate $.each(checkedItems, function (index, item) {
+ "&companyParam=" + companyParam if (item.id) {
ids.push(item.id);
} else if (item.staffId) {
staffIds.push(item.staffId);
}
});
window.open(ext.contextPath + "/safety/externalCertificate/exportExcel.do?search_name=" + encodeURIComponent(search_name || "")
+ "&search_code=" + encodeURIComponent(search_code || "")
+ "&jobType=" + encodeURIComponent(jobType || "")
+ "&issueDate=" + encodeURIComponent(issueDate || "")
+ "&companyParam=" + encodeURIComponent(companyParam || "")
+ "&ids=" + encodeURIComponent(ids.join(","))
+ "&staffIds=" + encodeURIComponent(staffIds.join(","))
); );
} }
@ -234,6 +255,7 @@
// 初始化 表格数据 // 初始化 表格数据
initFun(); initFun();
}); });
// 时间筛选 // 时间筛选
function initDate1() { function initDate1() {
var locale = { var locale = {
@ -288,6 +310,7 @@
} }
}); });
} }
//作业类型下拉数据 //作业类型下拉数据
function jobTypePulldown() { function jobTypePulldown() {
//选择 从事岗位 //选择 从事岗位
@ -316,6 +339,7 @@
}); });
}, 'json'); }, 'json');
} }
//施工单位下拉数据 //施工单位下拉数据
function companyPulldown() { function companyPulldown() {
$.post(ext.contextPath + "/safety/externalStaff/companyPulldown.do", {}, function (data) { $.post(ext.contextPath + "/safety/externalStaff/companyPulldown.do", {}, function (data) {
@ -343,6 +367,7 @@
}); });
}, 'json'); }, 'json');
} }
// 初始表格 // 初始表格
var nowDate = new Date(); var nowDate = new Date();
var initFun = function () { var initFun = function () {
@ -391,17 +416,17 @@
field: 'company', // 返回json数据中的name field: 'company', // 返回json数据中的name
title: '施工单位名称', // 表格表头显示文字 title: '施工单位名称', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'certificateName', // 返回json数据中的name field: 'certificateName', // 返回json数据中的name
title: '证书名称', // 表格表头显示文字 title: '证书名称', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'certificateNo', // 返回json数据中的name field: 'certificateNo', // 返回json数据中的name
title: '证书编号', // 表格表头显示文字 title: '证书编号', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'jobCode', // 返回json数据中的name field: 'jobCode', // 返回json数据中的name
title: '作业项目代码', // 表格表头显示文字 title: '作业项目代码', // 表格表头显示文字
@ -411,17 +436,17 @@
field: 'jobType', // 返回json数据中的name field: 'jobType', // 返回json数据中的name
title: '作业类型', // 表格表头显示文字 title: '作业类型', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'issuingAuthority', // 返回json数据中的name field: 'issuingAuthority', // 返回json数据中的name
title: '发证部门', // 表格表头显示文字 title: '发证部门', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'issueDate', // 返回json数据中的name field: 'issueDate', // 返回json数据中的name
title: '领证时间', // 表格表头显示文字 title: '领证时间', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'expirationDate', // 返回json数据中的name field: 'expirationDate', // 返回json数据中的name
title: '有效期至', // 表格表头显示文字 title: '有效期至', // 表格表头显示文字
@ -437,10 +462,20 @@
// 计算相差的天数 // 计算相差的天数
var days = Math.floor(usedTime / (24 * 3600 * 1000)); var days = Math.floor(usedTime / (24 * 3600 * 1000));
if (days <= 30) { if (days <= 30) {
return {css:{"background-color":"rgba(220,29,54,1)","color":"rgba(255,255,255,1)"}}; return {
css: {
"background-color": "rgba(220,29,54,1)",
"color": "rgba(255,255,255,1)"
}
};
} }
} else { } else {
return {css:{"background-color":"rgba(220,29,54,1)","color":"rgba(255,255,255,1)"}}; return {
css: {
"background-color": "rgba(220,29,54,1)",
"color": "rgba(255,255,255,1)"
}
};
} }
} }
return {css: {}}; return {css: {}};
@ -522,11 +557,22 @@
var index = 0; var index = 0;
for (var prop in sortMap) { for (var prop in sortMap) {
var count = sortMap[prop] * 1; var count = sortMap[prop] * 1;
$(target).bootstrapTable('mergeCells',{index:index, field:fieldName, colspan: colspan, rowspan: count}); $(target).bootstrapTable('mergeCells', {
$(target).bootstrapTable('mergeCells',{index:index, field:'company', colspan: colspan, rowspan: count}); index: index,
field: fieldName,
colspan: colspan,
rowspan: count
});
$(target).bootstrapTable('mergeCells', {
index: index,
field: 'company',
colspan: colspan,
rowspan: count
});
index += count; index += count;
} }
} }
var timedel = function () { var timedel = function () {
$('#reservationtimeD').val(''); $('#reservationtimeD').val('');
timeRangeEnd = null; timeRangeEnd = null;
@ -554,10 +600,12 @@
<div> <div>
<div class="form-group" style="padding:0;"> <div class="form-group" style="padding:0;">
<div class="btn-group" style="width: 300px;padding-bottom:10px;"> <div class="btn-group" style="width: 300px;padding-bottom:10px;">
<button type="button" class="btn btn-default btn-sm" onclick="addFun();" style="margin-right: 15px"><i <button type="button" class="btn btn-default btn-sm" onclick="addFun();"
style="margin-right: 15px"><i
class="fa fa-plus"></i> 新增 class="fa fa-plus"></i> 新增
</button> </button>
<button type="button" class="btn btn-default btn-sm" onclick="deletesFun();" style="margin-right: 15px"><i <button type="button" class="btn btn-default btn-sm" onclick="deletesFun();"
style="margin-right: 15px"><i
class="fa fa-trash-o"></i> 删除 class="fa fa-trash-o"></i> 删除
</button> </button>
<button type="button" class="btn btn-default btn-sm" style="margin-right: 15px" <button type="button" class="btn btn-default btn-sm" style="margin-right: 15px"
@ -575,12 +623,14 @@
<div class="form-group pull-right form-inline"> <div class="form-group pull-right form-inline">
<div class="form-group"> <div class="form-group">
<label class="form-label">施工单位名称:</label> <label class="form-label">施工单位名称:</label>
<select class="form-control select2" id="companyParam" name="companyParam" style="width: 180px;"> <select class="form-control select2" id="companyParam" name="companyParam"
style="width: 180px;">
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">作业类型:</label> <label class="form-label">作业类型:</label>
<select class="form-control select2" id="jobTypeParam" name="jobTypeParam" style="width: 180px;"> <select class="form-control select2" id="jobTypeParam" name="jobTypeParam"
style="width: 180px;">
</select> </select>
</div> </div>
<div class="input-group input-group-sm" style="width: 200px;"> <div class="input-group input-group-sm" style="width: 200px;">

View File

@ -129,11 +129,17 @@
}; };
var deletesFun = function () { var deletesFun = function () {
var checkedItems = $("#table").bootstrapTable('getSelections'); var checkedItems = $("#table").bootstrapTable('getSelections');
var datas = ""; var ids = [];
var staffIds = [];
$.each(checkedItems, function (index, item) { $.each(checkedItems, function (index, item) {
datas += item.id + ","; if (item.id) {
ids.push(item.id);
} else if (item.staffId) {
// 兼容模式若后续行模型提供备用ID批删也可工作
staffIds.push(item.staffId);
}
}); });
if (datas == "") { if (ids.length === 0 && staffIds.length === 0) {
showAlert('d', '请先选择记录', 'mainAlertdiv'); showAlert('d', '请先选择记录', 'mainAlertdiv');
} else { } else {
swal({ swal({
@ -157,7 +163,10 @@
} }
}).then(function (willDelete) { }).then(function (willDelete) {
if (willDelete) { if (willDelete) {
$.post(ext.contextPath + '/safety/internalCertificate/deletes.do', {ids: datas}, function (data) { $.post(ext.contextPath + '/safety/internalCertificate/deletes.do', {
ids: ids.join(","),
staffIds: staffIds.join(",")
}, function (data) {
if (data > 0) { if (data > 0) {
$("#table").bootstrapTable('refresh'); $("#table").bootstrapTable('refresh');
// 初始化 作业类型 // 初始化 作业类型
@ -313,17 +322,17 @@
field: 'jobType', // 返回json数据中的name field: 'jobType', // 返回json数据中的name
title: '作业类型', // 表格表头显示文字 title: '作业类型', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'issuingAuthority', // 返回json数据中的name field: 'issuingAuthority', // 返回json数据中的name
title: '发证机构', // 表格表头显示文字 title: '发证机构', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'issueDate', // 返回json数据中的name field: 'issueDate', // 返回json数据中的name
title: '领证时间', // 表格表头显示文字 title: '领证时间', // 表格表头显示文字
align: 'center', // 左右居中 align: 'center', // 左右居中
valign: 'middle', // 上下居中 valign: 'middle' // 上下居中
}, { }, {
field: 'expirationDate', // 返回json数据中的name field: 'expirationDate', // 返回json数据中的name
title: '有效期至', // 表格表头显示文字 title: '有效期至', // 表格表头显示文字