parent
9691a27694
commit
d64f2c4422
9 changed files with 544 additions and 0 deletions
@ -0,0 +1,223 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* 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 |
||||
* <p> |
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p> |
||||
* 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.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.InspectionRouteExcel; |
||||
import org.energy.modules.leger.entity.EquipmentLedger; |
||||
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.InspectionRoute; |
||||
import org.energy.modules.inspection.vo.InspectionRouteVO; |
||||
import org.energy.modules.inspection.service.IInspectionRouteService; |
||||
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; |
||||
|
||||
/** |
||||
* 巡检路线 控制器 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/inspection/inspectionRoute") |
||||
@Api(value = "巡检路线", tags = "巡检路线接口") |
||||
public class InspectionRouteController extends DafController { |
||||
|
||||
private IInspectionRouteService inspectionRouteService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入inspectionRoute") |
||||
public R<InspectionRoute> detail(InspectionRoute inspectionRoute) { |
||||
InspectionRoute detail = inspectionRouteService.getOne(Condition.getQueryWrapper(inspectionRoute)); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 巡检路线 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionRoute") |
||||
public R<IPage<InspectionRoute>> list(InspectionRoute inspectionRoute, Query query) { |
||||
QueryWrapper<InspectionRoute> qw = new QueryWrapper<>(); |
||||
qw.orderByAsc("route_no"); |
||||
if (StringUtil.isNotEmpty(inspectionRoute.getRouteNo())) { |
||||
qw.lambda().like(InspectionRoute::getRouteNo, inspectionRoute.getRouteNo()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionRoute.getRouteName())) { |
||||
qw.lambda().like(InspectionRoute::getRouteName, inspectionRoute.getRouteName()); |
||||
} |
||||
if (null != inspectionRoute.getStations()) { |
||||
qw.lambda().eq(InspectionRoute::getStations, inspectionRoute.getStations()); |
||||
} |
||||
if (StringUtil.isNotEmpty(inspectionRoute.getType())) { |
||||
qw.lambda().like(InspectionRoute::getType, inspectionRoute.getType()); |
||||
} |
||||
if (null != inspectionRoute.getIstatus()) { |
||||
qw.lambda().eq(InspectionRoute::getIstatus, inspectionRoute.getIstatus()); |
||||
} |
||||
IPage<InspectionRoute> pages = inspectionRouteService.page(Condition.getPage(query), qw); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 巡检路线 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入inspectionRoute") |
||||
public R<IPage<InspectionRouteVO>> page(InspectionRouteVO inspectionRoute, Query query) { |
||||
IPage<InspectionRouteVO> pages = inspectionRouteService.selectInspectionRoutePage(Condition.getPage(query), inspectionRoute); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 巡检路线 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入inspectionRoute") |
||||
public R save(@Valid @RequestBody InspectionRoute inspectionRoute) { |
||||
return R.status(inspectionRouteService.save(inspectionRoute)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 巡检路线 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入inspectionRoute") |
||||
public R update(@Valid @RequestBody InspectionRoute inspectionRoute) { |
||||
return R.status(inspectionRouteService.updateById(inspectionRoute)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 巡检路线 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入inspectionRoute") |
||||
public R submit(@Valid @RequestBody InspectionRoute inspectionRoute) { |
||||
return R.status(inspectionRouteService.saveOrUpdate(inspectionRoute)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 巡检路线 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(inspectionRouteService.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<InspectionRoute> list = new ArrayList<>(); |
||||
for (String id : ids.split(",")) { |
||||
InspectionRoute inspectionRoute = new InspectionRoute(); |
||||
inspectionRoute.setId(Long.parseLong(id)); |
||||
inspectionRoute.setIstatus(status); |
||||
list.add(inspectionRoute); |
||||
} |
||||
return R.status(inspectionRouteService.updateBatchById(list)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
@SneakyThrows |
||||
@GetMapping("export") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "导出", notes = "传入") |
||||
@ApiLog |
||||
public void exportInspectionRoute(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) { |
||||
if (entity.containsKey("stations_equal")) { |
||||
entity.put("stations_equal", Integer.parseInt((String) entity.get("stations_equal"))); |
||||
} |
||||
if (entity.containsKey("istatus_equal")) { |
||||
entity.put("istatus_equal", Integer.parseInt((String) entity.get("istatus_equal"))); |
||||
} |
||||
QueryWrapper<InspectionRoute> queryWrapper = Condition.getQueryWrapper(entity, InspectionRoute.class); |
||||
queryWrapper.lambda().eq(InspectionRoute::getIsDeleted, DafConstant.DB_NOT_DELETED); |
||||
queryWrapper.orderByAsc("route_no"); |
||||
|
||||
List<InspectionRouteExcel> list = inspectionRouteService.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(), InspectionRouteExcel.class).sheet("巡检路线").doWrite(list); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package org.energy.modules.inspection.dto; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 巡检路线数据传输对象实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class InspectionRouteDTO extends InspectionRoute { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,71 @@ |
||||
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 com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
|
||||
/** |
||||
* 巡检路线实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@TableName("i_inspection_route") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "InspectionRoute对象", description = "巡检路线") |
||||
public class InspectionRoute extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
/** |
||||
* 路线编号 |
||||
*/ |
||||
@ApiModelProperty(value = "路线编号") |
||||
private String routeNo; |
||||
/** |
||||
* 路线名称 |
||||
*/ |
||||
@ApiModelProperty(value = "路线名称") |
||||
private String routeName; |
||||
/** |
||||
* 场站 |
||||
*/ |
||||
@ApiModelProperty(value = "场站") |
||||
private Integer stations; |
||||
/** |
||||
* 类型 |
||||
*/ |
||||
@ApiModelProperty(value = "类型") |
||||
private String type; |
||||
/** |
||||
* 巡检状态 |
||||
*/ |
||||
@ApiModelProperty(value = "巡检状态") |
||||
private Integer istatus; |
||||
/** |
||||
* 维护工厂 |
||||
*/ |
||||
@ApiModelProperty(value = "维护工厂") |
||||
private String factory; |
||||
/** |
||||
* 取消原因 |
||||
*/ |
||||
@ApiModelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
|
||||
} |
@ -0,0 +1,65 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* 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.excel; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth; |
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight; |
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
/** |
||||
* EquipmentLedge model export |
||||
* @author edwong |
||||
*/ |
||||
@Data |
||||
@ColumnWidth(25) |
||||
@HeadRowHeight(20) |
||||
@ContentRowHeight(16) |
||||
public class InspectionRouteExcel implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "路线编号") |
||||
private String routeNo; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "路线名称") |
||||
private String routeName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "场站") |
||||
private String stationsName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "类型") |
||||
private String type; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "巡检状态") |
||||
private String istatusName; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "维护工厂") |
||||
private String factory; |
||||
|
||||
@ColumnWidth(15) |
||||
@ExcelProperty(value = "取消原因") |
||||
private String cancelReason; |
||||
|
||||
} |
@ -0,0 +1,31 @@ |
||||
package org.energy.modules.inspection.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.vo.InspectionRouteVO; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检路线 Mapper 接口 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
public interface InspectionRouteMapper extends BaseMapper<InspectionRoute> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionRoute |
||||
* @return |
||||
*/ |
||||
List<InspectionRouteVO> selectInspectionRoutePage(IPage page, InspectionRouteVO inspectionRoute); |
||||
|
||||
List<InspectionRouteExcel> exportData(@Param("ew") Wrapper<InspectionRoute> queryWrapper); |
||||
} |
@ -0,0 +1,45 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.energy.modules.inspection.mapper.InspectionRouteMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="inspectionRouteResultMap" type="org.energy.modules.inspection.entity.InspectionRoute"> |
||||
<id column="id" property="id"/> |
||||
<result column="status" property="status"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="route_no" property="routeNo"/> |
||||
<result column="route_name" property="routeName"/> |
||||
<result column="stations" property="stations"/> |
||||
<result column="type" property="type"/> |
||||
<result column="istatus" property="istatus"/> |
||||
<result column="factory" property="factory"/> |
||||
<result column="cancel_reason" property="cancelReason"/> |
||||
</resultMap> |
||||
|
||||
|
||||
<select id="selectInspectionRoutePage" resultMap="inspectionRouteResultMap"> |
||||
select * from i_inspection_route where is_deleted = 0 |
||||
</select> |
||||
|
||||
<select id="exportData" resultType="org.energy.modules.inspection.excel.InspectionRouteExcel"> |
||||
SELECT route_no, route_name, type, factory, cancel_reason |
||||
,CASE |
||||
WHEN stations = '1' THEN '景和光伏' |
||||
WHEN stations = '2' THEN '北沙一光伏' |
||||
WHEN stations = '3' THEN '北沙二光伏' |
||||
WHEN stations = '4' THEN '达坂城风电一场' |
||||
ELSE '' |
||||
END AS stations_name |
||||
,CASE |
||||
WHEN istatus = '1' THEN '已生效' |
||||
WHEN istatus = '0' THEN '未生效' |
||||
ELSE '' |
||||
END AS istatus_name |
||||
FROM i_inspection_route ${ew.customSqlSegment} |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,36 @@ |
||||
package org.energy.modules.inspection.service; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.vo.InspectionRouteVO; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检路线 服务类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
public interface IInspectionRouteService extends BaseService<InspectionRoute> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param inspectionRoute |
||||
* @return |
||||
*/ |
||||
IPage<InspectionRouteVO> selectInspectionRoutePage(IPage<InspectionRouteVO> page, InspectionRouteVO inspectionRoute); |
||||
|
||||
/** |
||||
* 获取导出数据 |
||||
* |
||||
* @param queryWrapper |
||||
* @return |
||||
*/ |
||||
List<InspectionRouteExcel> export(Wrapper<InspectionRoute> queryWrapper); |
||||
} |
@ -0,0 +1,35 @@ |
||||
package org.energy.modules.inspection.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import org.energy.modules.inspection.excel.InspectionRouteExcel; |
||||
import org.energy.modules.inspection.vo.InspectionRouteVO; |
||||
import org.energy.modules.inspection.mapper.InspectionRouteMapper; |
||||
import org.energy.modules.inspection.service.IInspectionRouteService; |
||||
import com.dayu.daf.core.mp.base.BaseServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 巡检路线 服务实现类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Service |
||||
public class InspectionRouteServiceImpl extends BaseServiceImpl<InspectionRouteMapper, InspectionRoute> implements IInspectionRouteService { |
||||
|
||||
@Override |
||||
public IPage<InspectionRouteVO> selectInspectionRoutePage(IPage<InspectionRouteVO> page, InspectionRouteVO inspectionRoute) { |
||||
return page.setRecords(baseMapper.selectInspectionRoutePage(page, inspectionRoute)); |
||||
} |
||||
|
||||
@Override |
||||
public List<InspectionRouteExcel> export(Wrapper<InspectionRoute> queryWrapper) { |
||||
List<InspectionRouteExcel> list = baseMapper.exportData(queryWrapper); |
||||
return list; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,20 @@ |
||||
package org.energy.modules.inspection.vo; |
||||
|
||||
import org.energy.modules.inspection.entity.InspectionRoute; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import io.swagger.annotations.ApiModel; |
||||
|
||||
/** |
||||
* 巡检路线视图实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-10 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "InspectionRouteVO对象", description = "巡检路线") |
||||
public class InspectionRouteVO extends InspectionRoute { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
Loading…
Reference in new issue