|
|
|
@ -15,17 +15,29 @@ |
|
|
|
|
*/ |
|
|
|
|
package org.energy.modules.inspection.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.dayu.daf.core.log.annotation.ApiLog; |
|
|
|
|
import com.dayu.daf.core.tool.constant.DafConstant; |
|
|
|
|
import com.xkcoding.http.util.StringUtil; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import javax.validation.Valid; |
|
|
|
|
|
|
|
|
|
import com.dayu.daf.core.mp.support.Condition; |
|
|
|
|
import com.dayu.daf.core.mp.support.Query; |
|
|
|
|
import com.dayu.daf.core.tool.api.R; |
|
|
|
|
import com.dayu.daf.core.tool.utils.Func; |
|
|
|
|
import lombok.SneakyThrows; |
|
|
|
|
import org.apache.commons.codec.Charsets; |
|
|
|
|
import org.energy.modules.inspection.excel.InspectionTasksExcel; |
|
|
|
|
import org.energy.modules.leger.entity.EquipmentLedger; |
|
|
|
|
import org.energy.modules.leger.excel.EquipmentLedgerExcel; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
@ -33,6 +45,12 @@ import org.energy.modules.inspection.entity.InspectionTasks; |
|
|
|
|
import org.energy.modules.inspection.vo.InspectionTasksVO; |
|
|
|
|
import org.energy.modules.inspection.service.IInspectionTasksService; |
|
|
|
|
import com.dayu.daf.core.boot.ctrl.DafController; |
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 巡检任务 控制器 |
|
|
|
@ -66,7 +84,36 @@ public class InspectionTasksController extends DafController { |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
@ApiOperation(value = "分页", notes = "传入inspectionTasks") |
|
|
|
|
public R<IPage<InspectionTasks>> list(InspectionTasks inspectionTasks, Query query) { |
|
|
|
|
IPage<InspectionTasks> pages = inspectionTasksService.page(Condition.getPage(query), Condition.getQueryWrapper(inspectionTasks)); |
|
|
|
|
QueryWrapper<InspectionTasks> qw = new QueryWrapper<>(); |
|
|
|
|
// 场站
|
|
|
|
|
if (null != inspectionTasks.getStation()) { |
|
|
|
|
qw.lambda().eq(InspectionTasks::getStation, inspectionTasks.getStation()); |
|
|
|
|
} |
|
|
|
|
// 状态
|
|
|
|
|
if (null != inspectionTasks.getTaskStatus()) { |
|
|
|
|
qw.lambda().eq(InspectionTasks::getTaskStatus, inspectionTasks.getTaskStatus()); |
|
|
|
|
} |
|
|
|
|
// 任务编号
|
|
|
|
|
if (StringUtil.isNotEmpty(inspectionTasks.getTaskNo())) { |
|
|
|
|
qw.lambda().like(InspectionTasks::getTaskNo, inspectionTasks.getTaskNo()); |
|
|
|
|
} |
|
|
|
|
// 任务名称
|
|
|
|
|
if (StringUtil.isNotEmpty(inspectionTasks.getTaskName())) { |
|
|
|
|
qw.lambda().like(InspectionTasks::getTaskName, inspectionTasks.getTaskName()); |
|
|
|
|
} |
|
|
|
|
// 任务生成日期
|
|
|
|
|
if (StringUtil.isNotEmpty(inspectionTasks.getTaskStartDate())) { |
|
|
|
|
qw.lambda().like(InspectionTasks::getTaskStartDate, inspectionTasks.getTaskStartDate()); |
|
|
|
|
} |
|
|
|
|
// 任务完成日期
|
|
|
|
|
if (StringUtil.isNotEmpty(inspectionTasks.getTaskEndDate())) { |
|
|
|
|
qw.lambda().like(InspectionTasks::getTaskEndDate, inspectionTasks.getTaskEndDate()); |
|
|
|
|
} |
|
|
|
|
// 责任人
|
|
|
|
|
if (StringUtil.isNotEmpty(inspectionTasks.getResponsiblePerson())) { |
|
|
|
|
qw.lambda().like(InspectionTasks::getResponsiblePerson, inspectionTasks.getResponsiblePerson()); |
|
|
|
|
} |
|
|
|
|
IPage<InspectionTasks> pages = inspectionTasksService.page(Condition.getPage(query), qw); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -122,5 +169,64 @@ public class InspectionTasksController extends DafController { |
|
|
|
|
return R.status(inspectionTasksService.deleteLogic(Func.toLongList(ids))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 启动 巡检任务 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/action") |
|
|
|
|
@ApiOperationSupport(order = 8) |
|
|
|
|
@ApiOperation(value = "更新", notes = "传入ids") |
|
|
|
|
public R auditing(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
|
return this.approve("1",ids); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 停止 巡检任务 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/stop") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
|
@ApiOperation(value = "更新", notes = "传入ids") |
|
|
|
|
public R reject(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
|
return this.approve("2",ids); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 启动OR停止 巡检任务 |
|
|
|
|
*/ |
|
|
|
|
public R approve(String status, String ids) { |
|
|
|
|
List<InspectionTasks> list = new ArrayList<>(); |
|
|
|
|
for (String id : ids.split(",")) { |
|
|
|
|
InspectionTasks inspectionTasks = new InspectionTasks(); |
|
|
|
|
inspectionTasks.setId(Long.parseLong(id)); |
|
|
|
|
inspectionTasks.setTaskStatus(Long.parseLong(status)); |
|
|
|
|
list.add(inspectionTasks); |
|
|
|
|
} |
|
|
|
|
return R.status(inspectionTasksService.updateBatchById(list)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出 |
|
|
|
|
*/ |
|
|
|
|
@SneakyThrows |
|
|
|
|
@GetMapping("export") |
|
|
|
|
@ApiOperationSupport(order = 10) |
|
|
|
|
@ApiOperation(value = "导出", notes = "传入") |
|
|
|
|
@ApiLog |
|
|
|
|
public void exportUser(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) { |
|
|
|
|
if (entity.containsKey("station_equal")) { |
|
|
|
|
entity.put("station_equal", Integer.parseInt((String) entity.get("station_equal"))); |
|
|
|
|
} |
|
|
|
|
if (entity.containsKey("taskStatus_equal")) { |
|
|
|
|
entity.put("taskStatus_equal", Integer.parseInt((String) entity.get("taskStatus_equal"))); |
|
|
|
|
} |
|
|
|
|
QueryWrapper<InspectionTasks> queryWrapper = Condition.getQueryWrapper(entity, InspectionTasks.class); |
|
|
|
|
queryWrapper.lambda().eq(InspectionTasks::getIsDeleted, DafConstant.DB_NOT_DELETED); |
|
|
|
|
List<InspectionTasksExcel> list = inspectionTasksService.export(queryWrapper); |
|
|
|
|
response.setContentType("application/vnd.ms-excel"); |
|
|
|
|
response.setCharacterEncoding(Charsets.UTF_8.name()); |
|
|
|
|
String fileName = URLEncoder.encode("巡检任务数据导出", Charsets.UTF_8.name()); |
|
|
|
|
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
|
|
|
|
EasyExcel.write(response.getOutputStream(), InspectionTasksExcel.class).sheet("巡检任务").doWrite(list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|