diff --git a/src/main/java/org/energy/modules/inspection/controller/InspectionObjectController.java b/src/main/java/org/energy/modules/inspection/controller/InspectionObjectController.java new file mode 100644 index 0000000..24ea28f --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/controller/InspectionObjectController.java @@ -0,0 +1,181 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.gnu.org/licenses/lgpl.html + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.energy.modules.inspection.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +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.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 org.energy.modules.inspection.entity.InspectionRoute; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestParam; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.energy.modules.inspection.entity.InspectionObject; +import org.energy.modules.inspection.vo.InspectionObjectVO; +import org.energy.modules.inspection.service.IInspectionObjectService; +import com.dayu.daf.core.boot.ctrl.DafController; + +import java.util.ArrayList; +import java.util.List; + +/** + * 巡检对象一览 控制器 + * + * @author Daf + * @since 2024-07-11 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/inspection/inspectionobject") +@Api(value = "巡检对象一览", tags = "巡检对象一览接口") +public class InspectionObjectController extends DafController { + + private IInspectionObjectService inspectionObjectService; + + /** + * 详情 + */ + @GetMapping("/detail") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "详情", notes = "传入inspectionObject") + public R detail(InspectionObject inspectionObject) { + InspectionObject detail = inspectionObjectService.getOne(Condition.getQueryWrapper(inspectionObject)); + return R.data(detail); + } + + /** + * 分页 巡检对象一览 + */ + @GetMapping("/list") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "分页", notes = "传入inspectionObject") + public R> list(InspectionObject inspectionObject, Query query) { + QueryWrapper qw = new QueryWrapper<>(); + qw.orderByAsc("route_no"); + if (StringUtil.isNotEmpty(inspectionObject.getObjectNo())) { + qw.lambda().like(InspectionObject::getObjectNo, inspectionObject.getObjectNo()); + } + if (null != inspectionObject.getObjectName()) { + qw.lambda().eq(InspectionObject::getObjectName, inspectionObject.getObjectName()); + } + if (null != inspectionObject.getStation()) { + qw.lambda().like(InspectionObject::getStation, inspectionObject.getStation()); + } + if (StringUtil.isNotEmpty(inspectionObject.getObjectArea())){ + qw.lambda().like(InspectionObject::getObjectArea, inspectionObject.getObjectArea()); + } + if (StringUtil.isNotEmpty(inspectionObject.getKksNo())){ + qw.lambda().like(InspectionObject::getKksNo, inspectionObject.getKksNo()); + } + IPage pages = inspectionObjectService.page(Condition.getPage(query), qw); + return R.data(pages); + } + + /** + * 自定义分页 巡检对象一览 + */ + @GetMapping("/page") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "分页", notes = "传入inspectionObject") + public R> page(InspectionObjectVO inspectionObject, Query query) { + IPage pages = inspectionObjectService.selectInspectionObjectPage(Condition.getPage(query), inspectionObject); + return R.data(pages); + } + + /** + * 新增 巡检对象一览 + */ + @PostMapping("/save") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "新增", notes = "传入inspectionObject") + public R save(@Valid @RequestBody InspectionObject inspectionObject) { + return R.status(inspectionObjectService.save(inspectionObject)); + } + + /** + * 修改 巡检对象一览 + */ + @PostMapping("/update") + @ApiOperationSupport(order = 5) + @ApiOperation(value = "修改", notes = "传入inspectionObject") + public R update(@Valid @RequestBody InspectionObject inspectionObject) { + return R.status(inspectionObjectService.updateById(inspectionObject)); + } + + /** + * 新增或修改 巡检对象一览 + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 6) + @ApiOperation(value = "新增或修改", notes = "传入inspectionObject") + public R submit(@Valid @RequestBody InspectionObject inspectionObject) { + return R.status(inspectionObjectService.saveOrUpdate(inspectionObject)); + } + + + /** + * 删除 巡检对象一览 + */ + @PostMapping("/remove") + @ApiOperationSupport(order = 7) + @ApiOperation(value = "逻辑删除", notes = "传入ids") + public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return R.status(inspectionObjectService.deleteLogic(Func.toLongList(ids))); + } + /** + * 生效 + */ + @PostMapping("/takeEffect") + @ApiOperationSupport(order = 8) + @ApiOperation(value = "生效", notes = "传入ids") + public R takeEffect(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return this.updateInspectionRoute(1,ids); + } + + /** + * 失效 + */ + @PostMapping("/lapse") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "失效", notes = "传入ids") + public R lapse(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { + return this.updateInspectionRoute(0,ids); + } + + /** + * 生效OR失效 + */ + public R updateInspectionRoute(Integer status, String ids) { + List list = new ArrayList<>(); + for (String id : ids.split(",")) { + InspectionObject inspectionObject = new InspectionObject(); + inspectionObject.setId(Long.parseLong(id)); + inspectionObject.setIstatus(status); + list.add(inspectionObject); + } + return R.status(inspectionObjectService.updateBatchById(list)); + } + +} diff --git a/src/main/java/org/energy/modules/inspection/dto/InspectionObjectDTO.java b/src/main/java/org/energy/modules/inspection/dto/InspectionObjectDTO.java new file mode 100644 index 0000000..d6d0856 --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/dto/InspectionObjectDTO.java @@ -0,0 +1,18 @@ +package org.energy.modules.inspection.dto; + +import org.energy.modules.inspection.entity.InspectionObject; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 巡检对象一览数据传输对象实体类 + * + * @author Daf + * @since 2024-07-11 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class InspectionObjectDTO extends InspectionObject { + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/org/energy/modules/inspection/entity/InspectionObject.java b/src/main/java/org/energy/modules/inspection/entity/InspectionObject.java new file mode 100644 index 0000000..d258862 --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/entity/InspectionObject.java @@ -0,0 +1,72 @@ +package org.energy.modules.inspection.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.dayu.daf.core.mp.base.BaseEntity; +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * 巡检对象一览实体类 + * + * @author Daf + * @since 2024-07-11 + */ +@Data +@TableName("i_inspection_object") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "InspectionObject对象", description = "巡检对象一览") +public class InspectionObject extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @ApiModelProperty(value = "主键") + private Long id; + /** + * 对象编号 + */ + @ApiModelProperty(value = "对象编号") + private String objectNo; + /** + * 对象名称 + */ + @ApiModelProperty(value = "对象名称") + private Integer objectName; + /** + * 场站 + */ + @ApiModelProperty(value = "场站") + private Integer station; + /** + * 对象状态 + */ + @ApiModelProperty(value = "对象状态") + private Integer istatus; + /** + * 对象类型 + */ + @ApiModelProperty(value = "对象类型") + private String objectType; + /** + * 对象区域 + */ + @ApiModelProperty(value = "对象区域") + private String objectArea; + /** + * KKS编号 + */ + @ApiModelProperty(value = "KKS编号") + private String kksNo; + /** + * 取消原因 + */ + @ApiModelProperty(value = "取消原因") + private String cancelReason; + + +} diff --git a/src/main/java/org/energy/modules/inspection/mapper/InspectionObjectMapper.java b/src/main/java/org/energy/modules/inspection/mapper/InspectionObjectMapper.java new file mode 100644 index 0000000..756fd0a --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/mapper/InspectionObjectMapper.java @@ -0,0 +1,26 @@ +package org.energy.modules.inspection.mapper; + +import org.energy.modules.inspection.entity.InspectionObject; +import org.energy.modules.inspection.vo.InspectionObjectVO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import java.util.List; + +/** + * 巡检对象一览 Mapper 接口 + * + * @author Daf + * @since 2024-07-11 + */ +public interface InspectionObjectMapper extends BaseMapper { + + /** + * 自定义分页 + * + * @param page + * @param inspectionObject + * @return + */ + List selectInspectionObjectPage(IPage page, InspectionObjectVO inspectionObject); + +} diff --git a/src/main/java/org/energy/modules/inspection/mapper/InspectionObjectMapper.xml b/src/main/java/org/energy/modules/inspection/mapper/InspectionObjectMapper.xml new file mode 100644 index 0000000..f2b271c --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/mapper/InspectionObjectMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/energy/modules/inspection/service/IInspectionObjectService.java b/src/main/java/org/energy/modules/inspection/service/IInspectionObjectService.java new file mode 100644 index 0000000..c6c667b --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/service/IInspectionObjectService.java @@ -0,0 +1,25 @@ +package org.energy.modules.inspection.service; + +import org.energy.modules.inspection.entity.InspectionObject; +import org.energy.modules.inspection.vo.InspectionObjectVO; +import com.dayu.daf.core.mp.base.BaseService; +import com.baomidou.mybatisplus.core.metadata.IPage; + +/** + * 巡检对象一览 服务类 + * + * @author Daf + * @since 2024-07-11 + */ +public interface IInspectionObjectService extends BaseService { + + /** + * 自定义分页 + * + * @param page + * @param inspectionObject + * @return + */ + IPage selectInspectionObjectPage(IPage page, InspectionObjectVO inspectionObject); + +} diff --git a/src/main/java/org/energy/modules/inspection/service/impl/InspectionObjectServiceImpl.java b/src/main/java/org/energy/modules/inspection/service/impl/InspectionObjectServiceImpl.java new file mode 100644 index 0000000..4a0d3a8 --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/service/impl/InspectionObjectServiceImpl.java @@ -0,0 +1,25 @@ +package org.energy.modules.inspection.service.impl; + +import org.energy.modules.inspection.entity.InspectionObject; +import org.energy.modules.inspection.vo.InspectionObjectVO; +import org.energy.modules.inspection.mapper.InspectionObjectMapper; +import org.energy.modules.inspection.service.IInspectionObjectService; +import com.dayu.daf.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; +import com.baomidou.mybatisplus.core.metadata.IPage; + +/** + * 巡检对象一览 服务实现类 + * + * @author Daf + * @since 2024-07-11 + */ +@Service +public class InspectionObjectServiceImpl extends BaseServiceImpl implements IInspectionObjectService { + + @Override + public IPage selectInspectionObjectPage(IPage page, InspectionObjectVO inspectionObject) { + return page.setRecords(baseMapper.selectInspectionObjectPage(page, inspectionObject)); + } + +} diff --git a/src/main/java/org/energy/modules/inspection/vo/InspectionObjectVO.java b/src/main/java/org/energy/modules/inspection/vo/InspectionObjectVO.java new file mode 100644 index 0000000..280bf3e --- /dev/null +++ b/src/main/java/org/energy/modules/inspection/vo/InspectionObjectVO.java @@ -0,0 +1,20 @@ +package org.energy.modules.inspection.vo; + +import org.energy.modules.inspection.entity.InspectionObject; +import lombok.Data; +import lombok.EqualsAndHashCode; +import io.swagger.annotations.ApiModel; + +/** + * 巡检对象一览视图实体类 + * + * @author Daf + * @since 2024-07-11 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "InspectionObjectVO对象", description = "巡检对象一览") +public class InspectionObjectVO extends InspectionObject { + private static final long serialVersionUID = 1L; + +}