parent
fddb15d308
commit
fd5d22d0dc
18 changed files with 839 additions and 2 deletions
@ -0,0 +1,189 @@ |
||||
/** |
||||
* 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.smart.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.dayu.daf.core.boot.ctrl.DafController; |
||||
import com.dayu.daf.core.log.annotation.ApiLog; |
||||
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 com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.SneakyThrows; |
||||
import org.apache.commons.codec.Charsets; |
||||
import org.energy.modules.smart.entity.WorkOrder; |
||||
import org.energy.modules.smart.excel.WorkOrderExcel; |
||||
import org.energy.modules.smart.service.IWorkOrderService; |
||||
import org.energy.modules.smart.vo.WorkOrderVO; |
||||
import org.energy.modules.system.util.DataUtils; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import javax.validation.Valid; |
||||
import java.net.URLEncoder; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/workorder") |
||||
@Api(value = "", tags = "接口") |
||||
public class WorkOrderController extends DafController { |
||||
|
||||
private IWorkOrderService workOrderService; |
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入workOrder") |
||||
public R<WorkOrderVO> detail(WorkOrder workOrder) { |
||||
WorkOrderVO detail = workOrderService.selectDetail(workOrder.getId()); |
||||
return R.data(detail); |
||||
} |
||||
|
||||
/** |
||||
* 分页 |
||||
*/ |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 2) |
||||
@ApiOperation(value = "分页", notes = "传入workOrder") |
||||
public R<IPage<WorkOrder>> list(WorkOrder workOrder, Query query) { |
||||
IPage<WorkOrder> pages = workOrderService.page(Condition.getPage(query), Condition.getQueryWrapper(workOrder)); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
*/ |
||||
@GetMapping("/page") |
||||
@ApiOperationSupport(order = 3) |
||||
@ApiOperation(value = "分页", notes = "传入workOrder") |
||||
public R<IPage<WorkOrderVO>> page(WorkOrderVO workOrderVO, Query query) { |
||||
IPage<WorkOrderVO> pages = workOrderService.selectWorkOrderPage(Condition.getPage(query), workOrderVO); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入workOrder") |
||||
public R save(@Valid @RequestBody WorkOrder workOrder) { |
||||
return R.status(workOrderService.save(workOrder)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入workOrder") |
||||
public R update(@Valid @RequestBody WorkOrder workOrder) { |
||||
return R.status(workOrderService.updateById(workOrder)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入workOrder") |
||||
public R submit(@Valid @RequestBody WorkOrder workOrder) { |
||||
return R.status(workOrderService.saveOrUpdate(workOrder)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除 |
||||
*/ |
||||
@PostMapping("/remove") |
||||
@ApiOperationSupport(order = 7) |
||||
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
||||
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return R.status(workOrderService.deleteLogic(Func.toLongList(ids))); |
||||
} |
||||
|
||||
/** |
||||
* 审核 |
||||
*/ |
||||
@PostMapping("/auditing") |
||||
@ApiOperationSupport(order = 8) |
||||
@ApiOperation(value = "更新", notes = "传入ids") |
||||
public R auditing(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return this.approve(2,ids); |
||||
} |
||||
|
||||
/** |
||||
* 驳回 |
||||
*/ |
||||
@PostMapping("/reject") |
||||
@ApiOperationSupport(order = 9) |
||||
@ApiOperation(value = "更新", notes = "传入ids") |
||||
public R reject(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
||||
return this.approve(3,ids); |
||||
} |
||||
|
||||
/** |
||||
* 驳回OR审核 |
||||
*/ |
||||
public R approve(Integer status, String ids) { |
||||
List<WorkOrder> list = new ArrayList<>(); |
||||
for (String id : ids.split(",")) { |
||||
WorkOrder workOrder = new WorkOrder(); |
||||
workOrder.setId(Long.parseLong(id)); |
||||
workOrder.setApprovalStatus(status); |
||||
list.add(workOrder); |
||||
} |
||||
return R.status(workOrderService.updateBatchById(list)); |
||||
} |
||||
|
||||
/** |
||||
* 导出 |
||||
*/ |
||||
@SneakyThrows |
||||
@GetMapping("export") |
||||
@ApiOperationSupport(order = 10) |
||||
@ApiOperation(value = "导出", notes = "传入") |
||||
@ApiLog |
||||
public void exportUser(@ApiIgnore @RequestParam Map<String, Object> entity, HttpServletResponse response) { |
||||
entity.remove("daf-auth"); |
||||
WorkOrderVO vo = DataUtils.mapToEntity(entity, WorkOrderVO::new); |
||||
List<WorkOrderExcel> list = workOrderService.export(vo); |
||||
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(), WorkOrderExcel.class).sheet("工单").doWrite(list); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,18 @@ |
||||
package org.energy.modules.smart.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.energy.modules.smart.entity.WorkOrder; |
||||
|
||||
/** |
||||
* 数据传输对象实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class WorkOrderDTO extends WorkOrder { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
} |
@ -0,0 +1,128 @@ |
||||
package org.energy.modules.smart.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.dayu.daf.core.mp.base.BaseEntity; |
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.NullSerializer; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.time.LocalDateTime; |
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@Data |
||||
@TableName("smt_work_order") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "WorkOrder对象", description = "WorkOrder对象") |
||||
public class WorkOrder extends BaseEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "主键") |
||||
private Long id; |
||||
/** |
||||
* 台账id |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "台账id") |
||||
private Long equipmentLedgerId; |
||||
/** |
||||
* 工单编号 |
||||
*/ |
||||
@ApiModelProperty(value = "工单编号") |
||||
private String workOrderNo; |
||||
/** |
||||
* 工单类型 |
||||
*/ |
||||
@ApiModelProperty(value = "工单类型") |
||||
private Integer workOrderType; |
||||
/** |
||||
* 内容描述 |
||||
*/ |
||||
@ApiModelProperty(value = "内容描述") |
||||
private String description; |
||||
/** |
||||
* 负责人 |
||||
*/ |
||||
@JsonSerialize(using = ToStringSerializer.class) |
||||
@ApiModelProperty(value = "负责人") |
||||
private Long responsibleUserId; |
||||
/** |
||||
* 责任班组 |
||||
*/ |
||||
@ApiModelProperty(value = "责任班组") |
||||
private String responsibilityTeam; |
||||
/** |
||||
* 计划工厂 |
||||
*/ |
||||
@ApiModelProperty(value = "计划工厂") |
||||
private String plannedFactory; |
||||
/** |
||||
* 维护作业类型 |
||||
*/ |
||||
@ApiModelProperty(value = "维护作业类型") |
||||
private Integer maintenanceTaskType; |
||||
/** |
||||
* 用户状态 |
||||
*/ |
||||
@ApiModelProperty(value = "用户状态") |
||||
private Integer userStatus; |
||||
/** |
||||
* 发生时间 |
||||
*/ |
||||
@ApiModelProperty(value = "发生时间") |
||||
private LocalDateTime occurrenceTime; |
||||
/** |
||||
* 执行班组 |
||||
*/ |
||||
@ApiModelProperty(value = "执行班组") |
||||
private String taskTeam; |
||||
/** |
||||
* 处理时间 |
||||
*/ |
||||
@ApiModelProperty(value = "处理时间") |
||||
private LocalDateTime processingTime; |
||||
/** |
||||
* 发生原因 |
||||
*/ |
||||
@ApiModelProperty(value = "发生原因") |
||||
private String causeIncident; |
||||
/** |
||||
* 处理过程描述 |
||||
*/ |
||||
@ApiModelProperty(value = "处理过程描述") |
||||
private String processDescription; |
||||
/** |
||||
* 结束时间 |
||||
*/ |
||||
@ApiModelProperty(value = "结束时间") |
||||
private LocalDateTime endTime; |
||||
/** |
||||
* 处理结果 |
||||
*/ |
||||
@ApiModelProperty(value = "处理结果") |
||||
private Integer handlingResult; |
||||
/** |
||||
* 审核状态 |
||||
*/ |
||||
@JsonSerialize(nullsUsing = NullSerializer.class) |
||||
@ApiModelProperty(value = "审核状态") |
||||
private Integer approvalStatus; |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,77 @@ |
||||
/** |
||||
* 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.smart.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 WorkOrderExcel implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "KKS编码") |
||||
private String kksEncoding; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "工单编号") |
||||
private String workOrderNo; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "内容描述") |
||||
private String description; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "工单类型") |
||||
private String workOrderType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "维护作业类型") |
||||
private String maintenanceTaskType; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "所属场站") |
||||
private String plannedFactory; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "负责人") |
||||
private String responsibleUserName; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "责任班组") |
||||
private String responsibilityTeam; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "工单完成") |
||||
private String handlingResult; |
||||
|
||||
@ColumnWidth(20) |
||||
@ExcelProperty(value = "审核状态") |
||||
private String approvalStatus; |
||||
|
||||
} |
@ -0,0 +1,35 @@ |
||||
package org.energy.modules.smart.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.energy.modules.leger.entity.EquipmentLedger; |
||||
import org.energy.modules.leger.excel.EquipmentLedgerExcel; |
||||
import org.energy.modules.smart.entity.WorkOrder; |
||||
import org.energy.modules.smart.excel.WorkOrderExcel; |
||||
import org.energy.modules.smart.vo.WorkOrderVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
public interface WorkOrderMapper extends BaseMapper<WorkOrder> { |
||||
|
||||
WorkOrderVO selectDetail(@Param("id") Long id); |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param workOrder |
||||
* @return |
||||
*/ |
||||
List<WorkOrderVO> selectWorkOrderPage(IPage page,@Param("vo") WorkOrderVO workOrder); |
||||
|
||||
List<WorkOrderExcel> exportData(@Param("vo") WorkOrderVO workOrder); |
||||
} |
@ -0,0 +1,127 @@ |
||||
<?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.smart.mapper.WorkOrderMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="workOrderResultMap" type="org.energy.modules.smart.vo.WorkOrderVO"> |
||||
<result column="create_user" property="createUser"/> |
||||
<result column="create_dept" property="createDept"/> |
||||
<result column="create_time" property="createTime"/> |
||||
<result column="update_user" property="updateUser"/> |
||||
<result column="update_time" property="updateTime"/> |
||||
<result column="is_deleted" property="isDeleted"/> |
||||
<result column="status" property="status"/> |
||||
<result column="id" property="id"/> |
||||
<result column="equipment_ledger_id" property="equipmentLedgerId"/> |
||||
<result column="work_order_no" property="workOrderNo"/> |
||||
<result column="work_order_type" property="workOrderType"/> |
||||
<result column="description" property="description"/> |
||||
<result column="responsible_user_id" property="responsibleUserId"/> |
||||
<result column="responsibility_team" property="responsibilityTeam"/> |
||||
<result column="planned_factory" property="plannedFactory"/> |
||||
<result column="maintenance_task_type" property="maintenanceTaskType"/> |
||||
<result column="user_status" property="userStatus"/> |
||||
<result column="occurrence_time" property="occurrenceTime"/> |
||||
<result column="task_team" property="taskTeam"/> |
||||
<result column="processing_time" property="processingTime"/> |
||||
<result column="cause_incident" property="causeIncident"/> |
||||
<result column="process_description" property="processDescription"/> |
||||
<result column="end_time" property="endTime"/> |
||||
<result column="handling_result" property="handlingResult"/> |
||||
<result column="approval_status" property="approvalStatus"/> |
||||
|
||||
<result column="kks_encoding" property="kksEncoding"/> |
||||
<result column="kks_description" property="kksDescription"/> |
||||
<result column="station" property="station"/> |
||||
<result column="responsible_user_name" property="responsibleUserName"/> |
||||
</resultMap> |
||||
|
||||
<select id="selectDetail" resultMap="workOrderResultMap"> |
||||
select a.*, b.kks_encoding, b.kks_description, b.station, c.name as responsible_user_name from smt_work_order a |
||||
left join l_equipment_ledger b on b.id = a.equipment_ledger_id and b.is_deleted = 0 |
||||
left join sys_user c on c.id = a.responsible_user_id and c.is_deleted = 0 |
||||
where a.is_deleted = 0 and a.id = #{id} |
||||
</select> |
||||
|
||||
<select id="selectWorkOrderPage" resultMap="workOrderResultMap"> |
||||
select a.*, b.kks_encoding, b.kks_description, b.station, c.name as responsible_user_name from smt_work_order a |
||||
left join l_equipment_ledger b on b.id = a.equipment_ledger_id and b.is_deleted = 0 |
||||
left join sys_user c on c.id = a.responsible_user_id and c.is_deleted = 0 |
||||
where a.is_deleted = 0 |
||||
<if test="vo.equipmentLedgerId != null and vo.equipmentLedgerId != ''"> |
||||
and a.equipment_ledger_id = #{vo.equipmentLedgerId} |
||||
</if> |
||||
<if test="vo.workOrderType != null and vo.workOrderType != ''"> |
||||
and a.work_order_type = #{vo.workOrderType} |
||||
</if> |
||||
<if test="vo.workOrderNo != null and vo.workOrderNo != ''"> |
||||
and a.work_order_no = #{vo.workOrderNo} |
||||
</if> |
||||
<if test="vo.description != null and vo.description != ''"> |
||||
and a.description = #{vo.description} |
||||
</if> |
||||
<if test="vo.maintenanceTaskType != null and vo.maintenanceTaskType != ''"> |
||||
and a.maintenance_task_type = #{vo.maintenanceTaskType} |
||||
</if> |
||||
<if test="vo.userStatus != null and vo.userStatus != ''"> |
||||
and a.user_status = #{vo.userStatus} |
||||
</if> |
||||
<if test="vo.responsibilityTeam != null and vo.responsibilityTeam != ''"> |
||||
and a.responsibility_team = #{vo.responsibilityTeam} |
||||
</if> |
||||
<if test="vo.station != null and vo.station != ''"> |
||||
and b.station = ${vo.station} |
||||
</if> |
||||
order by update_time desc |
||||
</select> |
||||
|
||||
<select id="exportData" resultType="org.energy.modules.smart.excel.WorkOrderExcel"> |
||||
select |
||||
b.kks_encoding, |
||||
a.work_order_no, |
||||
a.description, |
||||
a.planned_factory, |
||||
c.name as responsible_user_name, |
||||
a.responsibility_team, |
||||
a.work_order_type, |
||||
a.maintenance_task_type, |
||||
a.handling_result, |
||||
a.approval_status |
||||
-- d.dict_value as work_order_type, |
||||
-- d2.dict_value maintenance_task_type, |
||||
-- d3.dict_value handling_result, |
||||
-- d4.dict_value approval_status |
||||
from smt_work_order a |
||||
left join l_equipment_ledger b on b.id = a.equipment_ledger_id and b.is_deleted = 0 |
||||
left join sys_user c on c.id = a.responsible_user_id and c.is_deleted = 0 |
||||
-- left join sys_dict d on d.id = a.work_order_type and d.is_deleted = 0 |
||||
-- left join sys_dict d2 on d2.id = a.maintenance_task_type and d2.is_deleted = 0 |
||||
-- left join sys_dict d3 on d3.id = a.handling_result and d3.is_deleted = 0 |
||||
-- left join sys_dict d4 on d4.id = a.approval_status and d4.is_deleted = 0 |
||||
where a.is_deleted = 0 |
||||
<if test="vo.equipmentLedgerId != null and vo.equipmentLedgerId != ''"> |
||||
and a.equipment_ledger_id = #{vo.equipmentLedgerId} |
||||
</if> |
||||
<if test="vo.workOrderType != null and vo.workOrderType != ''"> |
||||
and a.work_order_type = #{vo.workOrderType} |
||||
</if> |
||||
<if test="vo.workOrderNo != null and vo.workOrderNo != ''"> |
||||
and a.work_order_no = #{vo.workOrderNo} |
||||
</if> |
||||
<if test="vo.description != null and vo.description != ''"> |
||||
and a.description = #{vo.description} |
||||
</if> |
||||
<if test="vo.maintenanceTaskType != null and vo.maintenanceTaskType != ''"> |
||||
and a.maintenance_task_type = #{vo.maintenanceTaskType} |
||||
</if> |
||||
<if test="vo.userStatus != null and vo.userStatus != ''"> |
||||
and a.user_status = #{vo.userStatus} |
||||
</if> |
||||
<if test="vo.responsibilityTeam != null and vo.responsibilityTeam != ''"> |
||||
and a.responsibility_team = #{vo.responsibilityTeam} |
||||
</if> |
||||
<if test="vo.station != null and vo.station != ''"> |
||||
and b.station = ${vo.station} |
||||
</if> |
||||
</select> |
||||
</mapper> |
@ -0,0 +1,39 @@ |
||||
package org.energy.modules.smart.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.dayu.daf.core.mp.base.BaseService; |
||||
import org.energy.modules.smart.entity.WorkOrder; |
||||
import org.energy.modules.smart.excel.WorkOrderExcel; |
||||
import org.energy.modules.smart.vo.WorkOrderVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
public interface IWorkOrderService extends BaseService<WorkOrder> { |
||||
|
||||
/** |
||||
* 获取详情 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
WorkOrderVO selectDetail(Long id); |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page |
||||
* @param workOrder |
||||
* @return |
||||
*/ |
||||
IPage<WorkOrderVO> selectWorkOrderPage(IPage<WorkOrderVO> page, WorkOrderVO workOrder); |
||||
|
||||
List<WorkOrderExcel> export(WorkOrderVO workOrder); |
||||
|
||||
|
||||
} |
@ -0,0 +1,56 @@ |
||||
package org.energy.modules.smart.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.dayu.daf.core.mp.base.BaseServiceImpl; |
||||
import io.micrometer.core.instrument.util.StringUtils; |
||||
import org.energy.modules.smart.entity.WorkOrder; |
||||
import org.energy.modules.smart.excel.WorkOrderExcel; |
||||
import org.energy.modules.smart.mapper.WorkOrderMapper; |
||||
import org.energy.modules.smart.service.IWorkOrderService; |
||||
import org.energy.modules.smart.vo.WorkOrderVO; |
||||
import org.energy.modules.system.service.IDictService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@Service |
||||
public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkOrder> implements IWorkOrderService { |
||||
|
||||
@Autowired |
||||
IDictService dictService; |
||||
|
||||
@Override |
||||
public WorkOrderVO selectDetail(Long id) { |
||||
return baseMapper.selectDetail(id); |
||||
} |
||||
|
||||
@Override |
||||
public IPage<WorkOrderVO> selectWorkOrderPage(IPage<WorkOrderVO> page, WorkOrderVO workOrder) { |
||||
return page.setRecords(baseMapper.selectWorkOrderPage(page, workOrder)); |
||||
} |
||||
|
||||
@Override |
||||
public List<WorkOrderExcel> export(WorkOrderVO workOrder) { |
||||
List<WorkOrderExcel> list = baseMapper.exportData(workOrder); |
||||
list.forEach(item -> { |
||||
if (StringUtils.isNotEmpty(item.getWorkOrderType())) |
||||
item.setWorkOrderType(dictService.getValue("workorder_type", Integer.parseInt(item.getWorkOrderType()))); |
||||
if (StringUtils.isNotEmpty(item.getMaintenanceTaskType())) |
||||
item.setMaintenanceTaskType(dictService.getValue("maintenance_job_type", Integer.parseInt(item.getMaintenanceTaskType()))); |
||||
if (StringUtils.isNotEmpty(item.getHandlingResult())) |
||||
item.setHandlingResult(dictService.getValue("workorder_process_res", Integer.parseInt(item.getHandlingResult()))); |
||||
if (StringUtils.isNotEmpty(item.getApprovalStatus())) |
||||
item.setApprovalStatus(dictService.getValue("check_status", Integer.parseInt(item.getApprovalStatus()))); |
||||
}); |
||||
return list; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,29 @@ |
||||
package org.energy.modules.smart.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.energy.modules.smart.entity.WorkOrder; |
||||
|
||||
/** |
||||
* 视图实体类 |
||||
* |
||||
* @author Daf |
||||
* @since 2024-07-12 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "WorkOrderVO对象", description = "WorkOrderVO对象") |
||||
public class WorkOrderVO extends WorkOrder { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
private String kksEncoding; |
||||
|
||||
private String kksDescription; |
||||
|
||||
private Integer station; |
||||
|
||||
private String responsibleUserName; |
||||
|
||||
|
||||
} |
@ -0,0 +1,22 @@ |
||||
package org.energy.modules.system.util; |
||||
|
||||
import java.util.Map; |
||||
import java.util.function.Supplier; |
||||
|
||||
public class DataUtils { |
||||
|
||||
public static <T> T mapToEntity(Map<String, Object> map, Supplier<T> supplier) { |
||||
T entity = supplier.get(); |
||||
|
||||
map.forEach((key, value) -> { |
||||
try { |
||||
entity.getClass().getDeclaredField(key).setAccessible(true); |
||||
entity.getClass().getDeclaredField(key).set(entity, value); |
||||
} catch (NoSuchFieldException | IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
}); |
||||
|
||||
return entity; |
||||
} |
||||
} |
@ -0,0 +1,43 @@ |
||||
package org.energy.modules.system.util; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.event.AnalysisEventListener; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@Slf4j |
||||
public class ExcelUtils { |
||||
|
||||
|
||||
/** |
||||
* 解析excel文件 |
||||
* |
||||
* @param fileName |
||||
* @param clazz |
||||
* @param <T> |
||||
* @return |
||||
*/ |
||||
public static <T> List<T> parseExcel(String fileName, Class<T> clazz) { |
||||
List<T> list = new ArrayList<>(); |
||||
try { |
||||
EasyExcel.read(fileName, clazz, new AnalysisEventListener<T>() { |
||||
//解析一行运行一次此方法。
|
||||
@Override |
||||
public void invoke(T t, AnalysisContext analysisContext) { |
||||
list.add(t); |
||||
} |
||||
|
||||
//解析所有数据完成,运行此方法。
|
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
||||
} |
||||
}).sheet().doRead(); |
||||
} catch (Exception e) { |
||||
log.error("解析excel异常,文件名={}", fileName, e); |
||||
} |
||||
return list; |
||||
} |
||||
} |
Loading…
Reference in new issue