This commit is contained in:
Timer
2026-04-16 01:13:03 +08:00
parent e5da30098f
commit 6738104534
10 changed files with 179 additions and 75 deletions

View File

@ -104,7 +104,7 @@ public class KpiPlanController {
if (StringUtils.isNotBlank(positonTypeList)) {
wherestr += " and j.level_type = " + positonTypeList;
}
wherestr += "and p.create_user_id ='" + id + "'";
wherestr += " and p.create_user_id ='" + id + "'";
PageHelper.startPage(page, rows);
List<KpiPlan> list = kpiPlanService.selectListByWhere(wherestr + orderstr);
@ -387,7 +387,8 @@ public class KpiPlanController {
@RequestMapping("/export.do")
public void export(HttpServletRequest request, HttpServletResponse response,
@RequestParam(value = "periodTypeName", required = false) String periodTypeList,
@RequestParam(value = "positionType", required = false) String positonTypeList) throws IOException {
@RequestParam(value = "positionType", required = false) String positonTypeList,
@RequestParam(value = "ids", required = false) String ids) throws IOException {
// 摘自列表查询接口 start
User cu = (User) request.getSession().getAttribute("cu");
String id = cu.getId();
@ -399,6 +400,10 @@ public class KpiPlanController {
if (StringUtils.isNotBlank(positonTypeList) && !"null".equals(positonTypeList)) {
wherestr += " and j.level_type = " + positonTypeList;
}
if (StringUtils.isNotBlank(ids)) {
String idstr = ids.replace("'", "").replace(",", "','");
wherestr += " and p.id in ('" + idstr + "')";
}
wherestr += "and p.create_user_id ='" + id + "'";
List<KpiPlan> list = kpiPlanService.selectListByWhere(wherestr + orderstr);

View File

@ -134,6 +134,12 @@ public class SewageController {
public String dosave(HttpServletRequest request,Model model,
@ModelAttribute Sewage sewage) {
User cu = (User) request.getSession().getAttribute("cu");
String contractNumber = sewage.getContractNumber() == null ? null : sewage.getContractNumber().trim();
sewage.setContractNumber(contractNumber);
if (this.sewageService.existsByContractNumber(contractNumber)) {
model.addAttribute("result", "{\"res\":\"合同编号已存在,不可重复\"}");
return "result";
}
sewage.setId(CommUtil.getUUID());
int result = this.sewageService.save(sewage);
String resultstr = "{\"res\":\""+result+"\",\"id\":\""+sewage.getId()+"\"}";
@ -193,6 +199,12 @@ public class SewageController {
public String doupdate(HttpServletRequest request,Model model,
@ModelAttribute Sewage sewage) {
User cu = (User) request.getSession().getAttribute("cu");
String contractNumber = sewage.getContractNumber() == null ? null : sewage.getContractNumber().trim();
sewage.setContractNumber(contractNumber);
if (this.sewageService.existsByContractNumberExcludeId(contractNumber, sewage.getId())) {
model.addAttribute("result", "{\"res\":\"合同编号已存在,不可重复\"}");
return "result";
}
int result = this.sewageService.update(sewage);
String resstr="{\"res\":\""+result+"\",\"id\":\""+sewage.getId()+"\"}";
model.addAttribute("result", resstr);
@ -348,7 +360,8 @@ public class SewageController {
@RequestMapping(value = "downloadExcelFun.do")
public ModelAndView downloadExcelFun(HttpServletRequest request,
HttpServletResponse response, Model model) throws IOException {
this.sewageService.outExcelFun(response);
String ids = request.getParameter("ids");
this.sewageService.outExcelFun(response, ids);
return null;
}

View File

@ -1252,21 +1252,14 @@ public class WorkorderDetailController {
@RequestMapping("/doExportRepair.do")
public ModelAndView doExportRepair(HttpServletRequest request,
HttpServletResponse response, Model model,
@RequestParam(value = "ids") String ids,
@RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "type") String type) throws IOException {
if (ids != null && !ids.equals("")) {
String[] id = ids.split(",");
String workorderDetailsIds = "";
for (String s : id) {
workorderDetailsIds += "'" + s + "',";
}
String whereStr = "where id in (" + workorderDetailsIds.substring(0, workorderDetailsIds.length() - 1) + ")";
try {
List<WorkorderDetail> workorderDetails = workorderDetailService.selectListByWhere(whereStr);
this.workorderDetailService.doExportRepair(response, workorderDetails, type);
} catch (Exception e) {
e.printStackTrace();
}
String whereStr = buildExportWhereByIdsAndType(ids, type);
try {
List<WorkorderDetail> workorderDetails = workorderDetailService.selectListByWhere(whereStr);
this.workorderDetailService.doExportRepair(response, workorderDetails, type);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@ -1292,21 +1285,14 @@ public class WorkorderDetailController {
@RequestMapping("/doExportRepairJS.do")
public ModelAndView doExportRepairJS(HttpServletRequest request,
HttpServletResponse response, Model model,
@RequestParam(value = "ids") String ids,
@RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "type") String type) throws IOException {
if (ids != null && !ids.equals("")) {
String[] id = ids.split(",");
String workorderDetailsIds = "";
for (String s : id) {
workorderDetailsIds += "'" + s + "',";
}
String whereStr = "where id in (" + workorderDetailsIds.substring(0, workorderDetailsIds.length() - 1) + ")";
try {
List<WorkorderDetail> workorderDetails = workorderDetailService.selectListByWhere(whereStr);
this.workorderDetailService.doExportRepairJS(response, workorderDetails, type);
} catch (Exception e) {
e.printStackTrace();
}
String whereStr = buildExportWhereByIdsAndType(ids, type);
try {
List<WorkorderDetail> workorderDetails = workorderDetailService.selectListByWhere(whereStr);
this.workorderDetailService.doExportRepairJS(response, workorderDetails, type);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@ -1332,26 +1318,47 @@ public class WorkorderDetailController {
@RequestMapping("/doExportMain.do")
public ModelAndView doExportMain(HttpServletRequest request,
HttpServletResponse response, Model model,
@RequestParam(value = "ids") String ids,
@RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "type") String type) throws IOException {
if (ids != null && !ids.equals("")) {
String[] id = ids.split(",");
String workorderDetailsIds = "";
for (String s : id) {
workorderDetailsIds += "'" + s + "',";
}
String whereStr = "where id in (" + workorderDetailsIds.substring(0, workorderDetailsIds.length() - 1) + ")";
// System.out.println(whereStr);
try {
List<WorkorderDetail> workorderDetails = workorderDetailService.selectListByWhere(whereStr);
this.workorderDetailService.doExportMain(response, workorderDetails, type);
} catch (Exception e) {
e.printStackTrace();
}
String whereStr = buildExportWhereByIdsAndType(ids, type);
try {
List<WorkorderDetail> workorderDetails = workorderDetailService.selectListByWhere(whereStr);
this.workorderDetailService.doExportMain(response, workorderDetails, type);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private String buildExportWhereByIdsAndType(String ids, String type) {
String normalizedIds = normalizeIds(ids);
if (!normalizedIds.isEmpty()) {
String[] idArr = normalizedIds.split(",");
StringBuilder idBuilder = new StringBuilder();
for (String item : idArr) {
String id = item.trim();
if (id.isEmpty()) {
continue;
}
if (idBuilder.length() > 0) {
idBuilder.append(",");
}
idBuilder.append("'").append(id).append("'");
}
if (idBuilder.length() > 0) {
return "where id in (" + idBuilder + ")";
}
}
return "where type = '" + type + "'";
}
private String normalizeIds(String ids) {
if (ids == null || ids.trim().isEmpty()) {
return "";
}
return ids.replace("'", "").replace(" ", "").replaceAll(",+$", "");
}
/**
* 日历中弹出指定日期的 维修单
*

View File

@ -5,6 +5,7 @@ import com.sipai.entity.sparepart.Sewage;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public class SewageDao extends CommDaoImpl<Sewage> {
@ -16,5 +17,13 @@ public class SewageDao extends CommDaoImpl<Sewage> {
List<Sewage> list = getSqlSession().selectList(this.getMappernamespace()+"."+Thread.currentThread().getStackTrace()[1].getMethodName(), sewage);
return list;
}
public Integer selectCountByContractNumber(String contractNumber) {
return getSqlSession().selectOne(this.getMappernamespace() + "." + Thread.currentThread().getStackTrace()[1].getMethodName(), contractNumber);
}
public Integer selectCountByContractNumberExcludeId(Map<String, String> params) {
return getSqlSession().selectOne(this.getMappernamespace() + "." + Thread.currentThread().getStackTrace()[1].getMethodName(), params);
}
}

View File

@ -312,6 +312,17 @@
delete from TB_Sewage_Source
${where}
</delete>
<select id="selectCountByContractNumber" resultType="java.lang.Integer" parameterType="java.lang.String" >
select count(1)
from TB_Sewage_Source
where contract_number = #{contractNumber,jdbcType=VARCHAR}
</select>
<select id="selectCountByContractNumberExcludeId" resultType="java.lang.Integer" parameterType="java.util.Map" >
select count(1)
from TB_Sewage_Source
where contract_number = #{contractNumber,jdbcType=VARCHAR}
and id != #{id,jdbcType=VARCHAR}
</select>
<select id="selectDistinctCityByWhere" resultMap="BaseResultMap" parameterType="java.lang.String" >
select Distinct [city] as [city]
from TB_Sewage_Source

View File

@ -26,8 +26,11 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.apache.poi.ss.usermodel.CellType.STRING;
@ -142,6 +145,28 @@ public class SewageService implements CommService<Sewage> {
return list;
}
public boolean existsByContractNumber(String contractNumber) {
if (contractNumber == null || contractNumber.trim().isEmpty()) {
return false;
}
Integer count = SewageDao.selectCountByContractNumber(contractNumber.trim());
return count != null && count > 0;
}
public boolean existsByContractNumberExcludeId(String contractNumber, String id) {
if (contractNumber == null || contractNumber.trim().isEmpty()) {
return false;
}
if (id == null || id.trim().isEmpty()) {
return existsByContractNumber(contractNumber);
}
Map<String, String> params = new HashMap<String, String>();
params.put("contractNumber", contractNumber.trim());
params.put("id", id.trim());
Integer count = SewageDao.selectCountByContractNumberExcludeId(params);
return count != null && count > 0;
}
/**
* xls文件数据转换
*
@ -298,6 +323,10 @@ public class SewageService implements CommService<Sewage> {
}
public void outExcelFun(HttpServletResponse response) throws IOException {
outExcelFun(response, null);
}
public void outExcelFun(HttpServletResponse response, String ids) throws IOException {
String fileName = "金山卫污水厂纳管企业表.xls";
String title = "纳管企业";
// 声明一个工作薄
@ -428,7 +457,7 @@ public class SewageService implements CommService<Sewage> {
// smcell.setCellStyle(tipStyle);
// smcell.setCellValue("注:日期格式(xxxx-xx-xx或xxxx/xx/xx), 班组类型,班组, 班次(根据系统配置名称填写),模式(填写巡检菜单里面的巡检模式) 排版日期,班组类型,班组,班次,模式都为必填项(集控班组可不填模式)。");
List<Sewage> list = this.selectListByWhere("where 1=1 order by contract_order asc");
List<Sewage> list = this.selectListByWhere(buildExportWhere(ids));
int n = 1;
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
@ -577,6 +606,29 @@ public class SewageService implements CommService<Sewage> {
}
}
private String buildExportWhere(String ids) {
String orderBy = " order by contract_order asc";
if (ids == null || ids.trim().isEmpty()) {
return "where 1=1" + orderBy;
}
String[] arr = ids.split(",");
List<String> idList = new ArrayList<String>();
for (String item : arr) {
if (item == null) {
continue;
}
String id = item.trim();
if (!id.isEmpty() && id.matches("[A-Za-z0-9-]+")) {
idList.add("'" + id + "'");
}
}
if (idList.isEmpty()) {
return "where 1=1" + orderBy;
}
String idstr = String.join(",", idList);
return "where id in (" + idstr + ")" + orderBy;
}
/**
* 获取树三层结构processSection为根节点sewage为子节点
*

View File

@ -296,7 +296,17 @@
function exportExcel() {
var periodTypeName = $('#periodTypeList').val();
var positionType = $('#positionTypeList').val();
window.open(ext.contextPath + "/kpi/kpiPlan/export.do?periodTypeName=" + periodTypeName + "&positionType=" + positionType);
let checkedItems = $("#table").bootstrapTable('getSelections');
let ids = "";
$.each(checkedItems, function (index, item) {
ids += item.id + ",";
});
if (ids !== "") {
ids = ids.substring(0, ids.length - 1);
window.open(ext.contextPath + "/kpi/kpiPlan/export.do?periodTypeName=" + periodTypeName + "&positionType=" + positionType + "&ids=" + encodeURIComponent(ids));
} else {
window.open(ext.contextPath + "/kpi/kpiPlan/export.do?periodTypeName=" + periodTypeName + "&positionType=" + positionType);
}
}
</script>

View File

@ -400,7 +400,17 @@
//导出
function downloadExcelFun() {
window.open(ext.contextPath + "/sparepart/sewage/downloadExcelFun.do");
var checkedItems = $("#table").bootstrapTable('getSelections');
var ids = "";
$.each(checkedItems, function(index, item){
ids += item.id + ",";
});
if(ids !== ""){
ids = ids.substring(0, ids.length - 1);
window.open(ext.contextPath + "/sparepart/sewage/downloadExcelFun.do?ids=" + encodeURIComponent(ids));
}else{
window.open(ext.contextPath + "/sparepart/sewage/downloadExcelFun.do");
}
}
</script>
</head>

View File

@ -418,17 +418,12 @@
var getExs = function () {
var datas = selectionIds.toString();
if (datas === "") {
showAlert('d', '请选中之后导出', 'mainAlertdiv');
} else {
// window.open(ext.contextPath + "/workorder/workorderDetail/doExportMain.do?ids=" + datas + "&type=maintain");
var params = {
responseType: 'blob',
ids: datas,
type: 'maintain'
};
postExcelFile(params, ext.contextPath + '/workorder/workorderDetail/doExportMain.do');
}
var params = {
responseType: 'blob',
ids: datas,
type: 'maintain'
};
postExcelFile(params, ext.contextPath + '/workorder/workorderDetail/doExportMain.do');
}
function postExcelFile(params, url) { //params是post请求需要的参数url是请求url地址

View File

@ -117,11 +117,7 @@
//金山项目导出(暂时不用)
var getExs_JS = function () {
var datas = selectionIds;
if (datas == 0) {
showAlert('d', '请选中之后导出', 'mainAlertdiv');
} else {
window.open(ext.contextPath + "/workorder/workorderDetail/doExportRepairJS.do?ids=" + datas + "&type=repair");
}
window.open(ext.contextPath + "/workorder/workorderDetail/doExportRepairJS.do?ids=" + datas + "&type=repair");
}
/**
@ -129,16 +125,12 @@
*/
var getExs = function () {
var datas = selectionIds;
if (datas == 0) {
showAlert('d', '请选中之后导出', 'mainAlertdiv');
} else {
var params = {
responseType: 'blob',
ids: datas,
type: 'repair'
};
postExcelFile(params, ext.contextPath + '/workorder/workorderDetail/doExportRepair.do');
}
var params = {
responseType: 'blob',
ids: datas,
type: 'repair'
};
postExcelFile(params, ext.contextPath + '/workorder/workorderDetail/doExportRepair.do');
}
function postExcelFile(params, url) { //params是post请求需要的参数url是请求url地址