|
|
@ -15,20 +15,29 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.energy.modules.inspection.controller; |
|
|
|
package org.energy.modules.inspection.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
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 com.xkcoding.http.util.StringUtil; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.validation.Valid; |
|
|
|
import javax.validation.Valid; |
|
|
|
|
|
|
|
|
|
|
|
import com.dayu.daf.core.mp.support.Condition; |
|
|
|
import com.dayu.daf.core.mp.support.Condition; |
|
|
|
import com.dayu.daf.core.mp.support.Query; |
|
|
|
import com.dayu.daf.core.mp.support.Query; |
|
|
|
import com.dayu.daf.core.tool.api.R; |
|
|
|
import com.dayu.daf.core.tool.api.R; |
|
|
|
import com.dayu.daf.core.tool.utils.Func; |
|
|
|
import com.dayu.daf.core.tool.utils.Func; |
|
|
|
|
|
|
|
import lombok.SneakyThrows; |
|
|
|
|
|
|
|
import org.apache.commons.codec.Charsets; |
|
|
|
import org.energy.modules.inspection.entity.InspectionRoute; |
|
|
|
import org.energy.modules.inspection.entity.InspectionRoute; |
|
|
|
|
|
|
|
import org.energy.modules.inspection.excel.InspectionObjectExcel; |
|
|
|
|
|
|
|
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
@ -36,9 +45,13 @@ import org.energy.modules.inspection.entity.InspectionObject; |
|
|
|
import org.energy.modules.inspection.vo.InspectionObjectVO; |
|
|
|
import org.energy.modules.inspection.vo.InspectionObjectVO; |
|
|
|
import org.energy.modules.inspection.service.IInspectionObjectService; |
|
|
|
import org.energy.modules.inspection.service.IInspectionObjectService; |
|
|
|
import com.dayu.daf.core.boot.ctrl.DafController; |
|
|
|
import com.dayu.daf.core.boot.ctrl.DafController; |
|
|
|
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 巡检对象一览 控制器 |
|
|
|
* 巡检对象一览 控制器 |
|
|
@ -73,7 +86,7 @@ public class InspectionObjectController extends DafController { |
|
|
|
@ApiOperation(value = "分页", notes = "传入inspectionObject") |
|
|
|
@ApiOperation(value = "分页", notes = "传入inspectionObject") |
|
|
|
public R<IPage<InspectionObject>> list(InspectionObject inspectionObject, Query query) { |
|
|
|
public R<IPage<InspectionObject>> list(InspectionObject inspectionObject, Query query) { |
|
|
|
QueryWrapper<InspectionObject> qw = new QueryWrapper<>(); |
|
|
|
QueryWrapper<InspectionObject> qw = new QueryWrapper<>(); |
|
|
|
qw.orderByAsc("route_no"); |
|
|
|
qw.orderByAsc("object_No"); |
|
|
|
if (StringUtil.isNotEmpty(inspectionObject.getObjectNo())) { |
|
|
|
if (StringUtil.isNotEmpty(inspectionObject.getObjectNo())) { |
|
|
|
qw.lambda().like(InspectionObject::getObjectNo, inspectionObject.getObjectNo()); |
|
|
|
qw.lambda().like(InspectionObject::getObjectNo, inspectionObject.getObjectNo()); |
|
|
|
} |
|
|
|
} |
|
|
@ -83,6 +96,9 @@ public class InspectionObjectController extends DafController { |
|
|
|
if (null != inspectionObject.getStation()) { |
|
|
|
if (null != inspectionObject.getStation()) { |
|
|
|
qw.lambda().like(InspectionObject::getStation, inspectionObject.getStation()); |
|
|
|
qw.lambda().like(InspectionObject::getStation, inspectionObject.getStation()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (null != inspectionObject.getIstatus()) { |
|
|
|
|
|
|
|
qw.lambda().like(InspectionObject::getIstatus, inspectionObject.getIstatus()); |
|
|
|
|
|
|
|
} |
|
|
|
if (StringUtil.isNotEmpty(inspectionObject.getObjectArea())){ |
|
|
|
if (StringUtil.isNotEmpty(inspectionObject.getObjectArea())){ |
|
|
|
qw.lambda().like(InspectionObject::getObjectArea, inspectionObject.getObjectArea()); |
|
|
|
qw.lambda().like(InspectionObject::getObjectArea, inspectionObject.getObjectArea()); |
|
|
|
} |
|
|
|
} |
|
|
@ -131,6 +147,19 @@ public class InspectionObjectController extends DafController { |
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入inspectionObject") |
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入inspectionObject") |
|
|
|
public R submit(@Valid @RequestBody InspectionObject inspectionObject) { |
|
|
|
public R submit(@Valid @RequestBody InspectionObject inspectionObject) { |
|
|
|
|
|
|
|
inspectionObject.setIstatus(1); |
|
|
|
|
|
|
|
String date = LocalDate.now().toString().replace("-",""); |
|
|
|
|
|
|
|
String maxNo = inspectionObjectService.getMaxNo("'%" + date + "%'"); |
|
|
|
|
|
|
|
int number; |
|
|
|
|
|
|
|
if (StringUtil.isNotEmpty(maxNo)){ |
|
|
|
|
|
|
|
number = Integer.parseInt(maxNo.substring(9)); |
|
|
|
|
|
|
|
number++; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
number = 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String numFormat = String.format("%04d", number); |
|
|
|
|
|
|
|
String no = "R" + date + numFormat; |
|
|
|
|
|
|
|
inspectionObject.setObjectNo(no); |
|
|
|
return R.status(inspectionObjectService.saveOrUpdate(inspectionObject)); |
|
|
|
return R.status(inspectionObjectService.saveOrUpdate(inspectionObject)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -151,7 +180,7 @@ public class InspectionObjectController extends DafController { |
|
|
|
@ApiOperationSupport(order = 8) |
|
|
|
@ApiOperationSupport(order = 8) |
|
|
|
@ApiOperation(value = "生效", notes = "传入ids") |
|
|
|
@ApiOperation(value = "生效", notes = "传入ids") |
|
|
|
public R takeEffect(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
public R takeEffect(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
return this.updateInspectionRoute(1,ids); |
|
|
|
return this.updateInspectionObject(1, "", ids); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -160,22 +189,74 @@ public class InspectionObjectController extends DafController { |
|
|
|
@PostMapping("/lapse") |
|
|
|
@PostMapping("/lapse") |
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
@ApiOperation(value = "失效", notes = "传入ids") |
|
|
|
@ApiOperation(value = "失效", notes = "传入ids") |
|
|
|
public R lapse(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
public R lapse(@ApiParam(value = "主键集合", required = true) @RequestParam String ids,@ApiParam(value = "取消原因", required = true) @RequestParam String reason) { |
|
|
|
return this.updateInspectionRoute(0,ids); |
|
|
|
return this.updateInspectionObject(0, reason, ids); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 生效OR失效 |
|
|
|
* 生效OR失效 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public R updateInspectionRoute(Integer status, String ids) { |
|
|
|
public R updateInspectionObject(Integer status, String reason, String ids) { |
|
|
|
List<InspectionObject> list = new ArrayList<>(); |
|
|
|
List<InspectionObject> list = new ArrayList<>(); |
|
|
|
for (String id : ids.split(",")) { |
|
|
|
for (String id : ids.split(",")) { |
|
|
|
InspectionObject inspectionObject = new InspectionObject(); |
|
|
|
InspectionObject inspectionObject = new InspectionObject(); |
|
|
|
inspectionObject.setId(Long.parseLong(id)); |
|
|
|
inspectionObject.setId(Long.parseLong(id)); |
|
|
|
|
|
|
|
inspectionObject.setCancelReason(reason); |
|
|
|
inspectionObject.setIstatus(status); |
|
|
|
inspectionObject.setIstatus(status); |
|
|
|
list.add(inspectionObject); |
|
|
|
list.add(inspectionObject); |
|
|
|
} |
|
|
|
} |
|
|
|
return R.status(inspectionObjectService.updateBatchById(list)); |
|
|
|
return R.status(inspectionObjectService.updateBatchById(list)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 导出 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@SneakyThrows |
|
|
|
|
|
|
|
@GetMapping("export") |
|
|
|
|
|
|
|
@ApiOperationSupport(order = 10) |
|
|
|
|
|
|
|
@ApiOperation(value = "导出", notes = "传入") |
|
|
|
|
|
|
|
@ApiLog |
|
|
|
|
|
|
|
public void exportInspectionObject(@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("istatus_equal")) { |
|
|
|
|
|
|
|
entity.put("istatus_equal", Integer.parseInt((String) entity.get("istatus_equal"))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (entity.containsKey("objectName_equal")) { |
|
|
|
|
|
|
|
entity.put("objectName_equal", Integer.parseInt((String) entity.get("objectName_equal"))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
QueryWrapper<InspectionObject> queryWrapper = Condition.getQueryWrapper(entity, InspectionObject.class); |
|
|
|
|
|
|
|
queryWrapper.lambda().eq(InspectionObject::getIsDeleted, DafConstant.DB_NOT_DELETED); |
|
|
|
|
|
|
|
queryWrapper.orderByAsc("object_No"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<InspectionObjectExcel> list = inspectionObjectService.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(), InspectionObjectExcel.class).sheet("巡检对象").doWrite(list); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取对象编号 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@GetMapping("/getObjectList") |
|
|
|
|
|
|
|
@ApiOperationSupport(order = 11) |
|
|
|
|
|
|
|
@ApiOperation(value = "获取对象编号", notes = "获取对象编号") |
|
|
|
|
|
|
|
public R<List<InspectionObject>> getObjectNoList() { |
|
|
|
|
|
|
|
List<InspectionObject> routeList = inspectionObjectService.getObjectList(); |
|
|
|
|
|
|
|
return R.data(routeList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取对象编号 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@GetMapping("/getDetailList") |
|
|
|
|
|
|
|
@ApiOperationSupport(order = 12) |
|
|
|
|
|
|
|
@ApiOperation(value = "获取对象信息", notes = "获取对象信息") |
|
|
|
|
|
|
|
public R<InspectionObject> getDetailList(String objectNo) { |
|
|
|
|
|
|
|
InspectionObject DetailList = inspectionObjectService.getDetailList("'" + objectNo + "'"); |
|
|
|
|
|
|
|
return R.data(DetailList); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|